public PredictEntity(Ghosts.Ghost ghost, GameState gs)
 {
     if (ghost.Entered)
     {
         this.Node      = ghost.Node;
         this.Direction = ghost.Direction;
     }
     else
     {
         this.Node      = gs.Map.Nodes[13, 11];
         this.Direction = Direction.Up;
     }
 }
 public PredictGhost(Ghosts.Ghost ghost, GameState gs)
     : base(ghost.Node, ghost.Direction)
 {
     if (ghost.Entered)
     {
         this.Chasing = (ghost.Chasing || ghost.RemainingFlee < 200);
     }
     else
     {
         this.Chasing   = true;
         this.Node      = gs.Map.Nodes[13, 11];
         this.Direction = Direction.Up;
     }
 }
            public PredictGhost(Ghosts.Ghost ghost, GameState gs)
                : base(ghost.Node, ghost.Direction)
            {
                if (ghost.Entered)
                {
                    this.Chasing = (ghost.Chasing || ghost.RemainingFlee < 200);
                }
                else
                {
                    this.Chasing   = false;
                    this.Node      = gs.Map.Nodes[13, 11];
                    this.Direction = Direction.Up;
                }
                switch (ghost.Name)
                {
                case "Red": Danger = GhostDanger.Red; break;

                case "Blue": Danger = GhostDanger.Blue; break;

                case "Pink": Danger = GhostDanger.Pink; break;

                case "Brown": Danger = GhostDanger.Brown; break;
                }
            }
        public virtual void Move()
        {
            float curSpeed = Speed;

            Ghosts.Ghost ghost = this as Ghosts.Ghost;
            if (ghost != null)
            {
                if (!ghost.Entered)
                {
                    // going back speed
                }
                else if (gameState.Map.Tunnels[node.Y] && (node.X <= 1 || node.X >= Map.Width - 2))
                {
                    curSpeed = Ghosts.Ghost.TunnelSpeed;
                }
                else if (!ghost.Chasing)
                {
                    curSpeed = Ghosts.Ghost.FleeSpeed;
                }
            }

            //Console.WriteLine(direction + " << going " + node.X + "," + node.Y + ", " + node.Type + " ::: " + X + "," + Y + " : " + node.CenterX + "," + node.CenterY);
            switch (direction)
            {
            case Direction.Up:
                if (this.y > node.CenterY)                            // move towards target node if we haven't reached it yet
                {
                    this.y -= curSpeed;
                }
                if (this.y <= node.CenterY)
                {
                    ProcessNode();
                    if (!setNextDirection())                                // try to change direction
                    {
                        if (node.Up.Type == Node.NodeType.Wall)
                        {
                            this.y = node.CenterY;
                        }
                        else
                        {
                            node = node.Up;
                        }
                    }
                    ;
                }
                break;

            case Direction.Down:
                if (this.y < node.CenterY)
                {
                    this.y += curSpeed;
                }
                if (this.y >= node.CenterY)
                {
                    ProcessNode();
                    if (!setNextDirection())
                    {
                        if (node.Down.Type == Node.NodeType.Wall)
                        {
                            this.y = node.CenterY;
                        }
                        else
                        {
                            node = node.Down;
                        }
                    }
                    ;
                }
                break;

            case Direction.Left:
                if (node.X == Map.Width - 1 && this.x < 10)                            // check wrapping round // buggy on map 3
                {
                    this.x -= curSpeed;
                    if (this.x < 0)
                    {
                        this.x = gameState.Map.PixelWidth + this.x;
                    }
                }
                else
                {
                    if (this.x > node.CenterX)
                    {
                        this.x -= curSpeed;
                    }
                    if (this.x <= node.CenterX)
                    {
                        ProcessNode();
                        if (!setNextDirection())
                        {
                            if (node.Left.Type == Node.NodeType.Wall)
                            {
                                this.x = node.CenterX;
                            }
                            else
                            {
                                node = node.Left;
                            }
                        }
                        ;
                    }
                }
                break;

            case Direction.Right:
                if (node.X == 0 && this.x > gameState.Map.PixelWidth - 10)                            // check wrapping round // buggy on map 3
                {
                    this.x += curSpeed;
                    if (this.x > gameState.Map.PixelWidth)
                    {
                        this.x = this.x - gameState.Map.PixelWidth;
                    }
                }
                else
                {
                    if (this.x < node.CenterX)
                    {
                        this.x += curSpeed;
                    }
                    if (this.x >= node.CenterX)
                    {
                        ProcessNode();
                        if (!setNextDirection())
                        {
                            if (node.Right.Type == Node.NodeType.Wall)
                            {
                                this.x = node.CenterX;
                            }
                            else
                            {
                                node = node.Right;
                            }
                        }
                        ;
                    }
                }
                break;

            case Direction.None:
                setNextDirection();
                break;
            }
        }