Exemplo n.º 1
0
        /// <summary>
        /// Place the Ghost in a new grid position. After checking if there is
        /// anything to fight.
        /// </summary>
        /// <param name="newPosition"> The Ghost's new grid position</param>
        public virtual void Move(Vector newPosition)
        {
            IBoardObject[] gridSpace;
            GameBoard.Board.TryGetValue(newPosition, out gridSpace);

            IInstantInteractable possibleGhost = gridSpace[1] as GhostObject;
            IInstantInteractable possiblePortal
                = gridSpace[2] as PortalDummyGhost;

            possibleGhost?.OnInstantInteraction(this);

            if (possibleGhost != null)
            {
                OnInstantInteraction(possibleGhost);
            }

            possiblePortal?.OnInstantInteraction(this);

            // Since Ghosts go to 0,0 when sent to dungeon
            // we can check their status like this.
            if (!InDungeon)
            {
                Position = newPosition;
            }
            GameController.GBoard.UpdateGhostOnBoard(this);
        }
Exemplo n.º 2
0
 /// <summary>
 /// This Ghost has found another one to fight with!
 /// </summary>
 /// <param name="other"> The other Ghost </param>
 public void OnInstantInteraction(IInstantInteractable other)
 {
     enemy = (other as GhostObject);
     if (enemy.MyColor == BeatColor)
     {
         WinFight();
     }
     else if (enemy.MyColor == LoseToColor)
     {
         LoseFight();
     }
 }