/// <summary> /// Perform an action for the player. Modifies the ITileFieldPlayer appropriately /// </summary> /// <param name="player">The player that is performing the action</param> /// <param name="action">The action to perform</param> public virtual void PerformAction(ITileFieldPlayer player, PlayerAction action) { player.LastAction = action; if (action.IsDirection()) { player.MoveSmoothly(action.ToDirection()); } }
/// <summary> /// Teleport to the other portal in case of special action. /// </summary> public override void PerformAction(ITileFieldPlayer player, PlayerAction action) { base.PerformAction(player, action); if (action == PlayerAction.SPECIAL) { player.Teleport(destination); } }
public override bool IsActionForbiddenFromHere(ITileFieldPlayer player, PlayerAction action) { if (!TileField.GetTile(Location + lastDirection.ToPoint()).StopsSliding) { return(false); } return(base.IsActionForbiddenFromHere(player, action)); }
public override bool IsActionForbiddenFromHere(ITileFieldPlayer player, PlayerAction action) { if (action == PlayerAction.SPECIAL) { // Special actions are allowed on portalTiles. return(false); } return(base.IsActionForbiddenFromHere(player, action)); }
public override void PerformAction(ITileFieldPlayer player, PlayerAction action) { if (!TileField.GetTile(Location + lastDirection.ToPoint()).StopsSliding) { player.MoveSmoothly(lastDirection); } else { base.PerformAction(player, action); } }
private bool IsComingFromAllowedDirection(ITileFieldPlayer player) { if (isHorizontal) { // A player is allowed to move onto a horizontalDoor from the tile above or below it. return(player.Location.X == Location.X); } else { // A player is allowed to move onto a verticalDoor from the Tile to the left or to the right of it. return(player.Location.Y == Location.Y); } }
public override bool IsActionForbiddenFromHere(ITileFieldPlayer player, PlayerAction action) { // only directional actions are allowed if (!action.IsDirection()) { return(true); } //A player can move only in the directions that the door allows if (isHorizontal) { //on horizontal doors only vertical actions are allowed return(!action.ToDirection().IsVertical() || base.IsActionForbiddenFromHere(player, action)); } else { //on vertical doors only horizontal actions are allowed return(!action.ToDirection().IsHorizontal() || base.IsActionForbiddenFromHere(player, action)); } }
public override bool CanPlayerMoveHere(ITileFieldPlayer player) { //A player is allowed to move onto a door tile if he comes from the correct direction and //the door is open. return(IsComingFromAllowedDirection(player) && IsDoorOpenFor(player)); }
public override void EnterTile(ITileFieldPlayer player) { player.Inventory.Items.Add(new InventoryKey(keyColor)); base.EnterTile(player); }
public virtual void EnterCenterOfTile(ITileFieldPlayer player) { }
public override void EnterTile(ITileFieldPlayer player) { base.EnterTile(player); lastDirection = player.LastAction.ToDirection(); }
public override bool CanPlayerMoveHere(ITileFieldPlayer player) { //A player is allowed to move onto floors return(true); }
public override void EnterTile(ITileFieldPlayer player) { GameEnvironment.AssetManager.PlaySound("open_door"); base.EnterTile(player); }
public bool IsDoorOpenFor(ITileFieldPlayer player) { //A player is only allowed to open a door if he has the right key. return(player.HasItem(doorColor.ToInventeryItemType())); }
/// <summary> /// Checks if the player can move to this tile when he is next to it. /// </summary> /// <param name="player"></param> /// <returns>true if the player can move here. false otherwise.</returns> public abstract bool CanPlayerMoveHere(ITileFieldPlayer player);
public override bool CanPlayerMoveHere(ITileFieldPlayer player) { return(true); }
public override bool CanPlayerMoveHere(ITileFieldPlayer player) { //A player can never walk onto a wall return false; }
public override void EnterCenterOfTile(ITileFieldPlayer player) { player.Win(); }
/// <summary> /// Checks if this tile prevents a player who is currently at this Tile from performing the specified action /// </summary> /// <param name="player">The player at this Tile that wants to perform the action</param> /// <param name="action">The action to check</param> /// <returns>true if the action is forbidden by this Tile. false otherwise.</returns> public virtual bool IsActionForbiddenFromHere(ITileFieldPlayer player, PlayerAction action) { return(action == PlayerAction.SPECIAL || !TileField.GetTile(GetLocationAfterAction(action)).CanPlayerMoveHere(player)); }