Beispiel #1
0
 /// <summary>
 /// If its bloked position - dont move.
 ///     If player wants to move to an item - take it
 ///     If player wants to move to an enemy - hit it
 ///
 ///     If enemy wants to move to a player - hit it
 ///
 /// Both move if position is free.
 /// </summary>
 /// <param name="actor">Player or enemy</param>
 /// <param name="newLocation">The position we/he wants to move</param>
 public void MoveUnit(IGameUnit actor, Point newLocation)
 {
     if (CheckTile(newLocation))
     {
         if (actor is IPlayer)
         {
             (actor as Player).Turns++;
             if (this.Tiles[newLocation.X, newLocation.Y].Actor != null)
             {
                 actor.Hit(this.Tiles[newLocation.X, newLocation.Y].Actor as IGameUnit);
                 (this.Tiles[newLocation.X, newLocation.Y].Actor as Enemy).InBattle = true;
                 (this.Tiles[newLocation.X, newLocation.Y].Actor as Enemy).Player   = actor as Player;
             }
             else
             {
                 this[actor.Position].Actor = null;
                 actor.Position             = newLocation;
                 this[newLocation].Actor    = actor;
             }
         }
         else if (actor is IEnemy)
         {
             if (this.Tiles[newLocation.X, newLocation.Y].Actor is IPlayer)
             {
                 actor.Hit(this.Tiles[newLocation.X, newLocation.Y].Actor as IGameUnit);
                 (actor as Enemy).InBattle = true;
                 (actor as Enemy).Player   = this.Tiles[newLocation.X, newLocation.Y].Actor as Player;
             }
             else if (this.Tiles[newLocation.X, newLocation.Y].Actor is IEnemy)
             {
                 // Will they help each other ?
             }
             else if (this.Tiles[newLocation.X, newLocation.Y].Item != null)
             {
                 // Will they take items ?
             }
             else
             {
                 this[actor.Position].Actor = null;
                 actor.Position             = newLocation;
                 this[newLocation].Actor    = actor;
             }
         }
     }
 }