Gruppe22.Backend.Map.MoveActor C# (CSharp) Метод

MoveActor() публичный Метод

Move an actor on the map in a specified direction (does not check for walls - use CanMove)
public MoveActor ( Actor actor, Direction dir ) : void
actor Actor The actor object to move
dir Direction Direction to move to
Результат void
        public void MoveActor(Actor actor, Direction dir)
        {
            if ((actor.tile != null) && (actor.tile.enabled))
            {
                Backend.Coords source = actor.tile.coords;
                Backend.Coords target = DirectionTile(actor.tile.coords, dir);
                if (this[target].coords.x > -1)
                {
                    // Remove ActorTile from current tile
                    ((FloorTile)actor.tile.parent).Remove(actor.tile);
                    // Add ActorTile to new Tile
                    _tiles[target.y][target.x].Add(actor.tile);
                    actor.tile.parent = _tiles[target.y][target.x];
                    // Remove old tile from updatelist (if no other actor or trap)
                    if (!((_tiles[source.y][source.x].hasEnemy)
                        || (_tiles[source.y][source.x].hasPlayer)
                        || (_tiles[source.y][source.x].hasTrap)))
                        _updateTiles.Remove(source);
                    // Add new tile to updatelist
                    _updateTiles.Add(target);
                }
            }
        }