using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Slayter
{
    class Cell
    {
        public int x;
        public int y;
        public double path;
        public int time;
        public Cell father;
        Direction dir;
        public int changedDirection;
        public Cell(int x, int y, double path, int time, Cell c, Direction r)
        {
            this.x = x;
            this.y = y;
            this.path = path;
            this.time = time;
            father = c;
            dir = r;
            if (dir != Direction.Null)
            {
                changedDirection += father.changedDirection;
                if (dir != father.dir)
                {
                    this.path += 0.01;
                }
            }
        }

        public bool Activate()
        {
            time--;
            if (time == 0)
            {
                return true;
            }
            return false;
        }

        public override bool Equals(object obj)
        {
            Cell c = (Cell)obj;
            if (c == null)
            {
                if (this == null)
                {
                    return true;
                }
                return false;
            }
            return (this.x == c.x) && (this.y == c.y);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        internal bool CheckFatherForNull()
        {
            return father == null;
        }
    }
}
