コード例 #1
0
ファイル: Tile.cs プロジェクト: jensj12/MeesGame
 /// <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());
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
        public override bool IsActionForbiddenFromHere(ITileFieldPlayer player, PlayerAction action)
        {
            if (!TileField.GetTile(Location + lastDirection.ToPoint()).StopsSliding)
            {
                return(false);
            }

            return(base.IsActionForbiddenFromHere(player, action));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 public override void PerformAction(ITileFieldPlayer player, PlayerAction action)
 {
     if (!TileField.GetTile(Location + lastDirection.ToPoint()).StopsSliding)
     {
         player.MoveSmoothly(lastDirection);
     }
     else
     {
         base.PerformAction(player, action);
     }
 }
コード例 #6
0
ファイル: DoorTile.cs プロジェクト: jensj12/MeesGame
 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);
     }
 }
コード例 #7
0
ファイル: DoorTile.cs プロジェクト: jensj12/MeesGame
        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));
            }
        }
コード例 #8
0
ファイル: DoorTile.cs プロジェクト: jensj12/MeesGame
 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));
 }
コード例 #9
0
 public override void EnterTile(ITileFieldPlayer player)
 {
     player.Inventory.Items.Add(new InventoryKey(keyColor));
     base.EnterTile(player);
 }
コード例 #10
0
ファイル: Tile.cs プロジェクト: jensj12/MeesGame
 public virtual void EnterCenterOfTile(ITileFieldPlayer player)
 {
 }
コード例 #11
0
 public override void EnterTile(ITileFieldPlayer player)
 {
     base.EnterTile(player);
     lastDirection = player.LastAction.ToDirection();
 }
コード例 #12
0
ファイル: FloorTile.cs プロジェクト: jensj12/MeesGame
 public override bool CanPlayerMoveHere(ITileFieldPlayer player)
 {
     //A player is allowed to move onto floors
     return(true);
 }
コード例 #13
0
ファイル: DoorTile.cs プロジェクト: jensj12/MeesGame
 public override void EnterTile(ITileFieldPlayer player)
 {
     GameEnvironment.AssetManager.PlaySound("open_door");
     base.EnterTile(player);
 }
コード例 #14
0
ファイル: DoorTile.cs プロジェクト: jensj12/MeesGame
 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()));
 }
コード例 #15
0
ファイル: Tile.cs プロジェクト: jensj12/MeesGame
 /// <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);
コード例 #16
0
 public override bool CanPlayerMoveHere(ITileFieldPlayer player)
 {
     return(true);
 }
コード例 #17
0
 public override bool CanPlayerMoveHere(ITileFieldPlayer player)
 {
     //A player can never walk onto a wall
     return false;
 }
コード例 #18
0
 public override void EnterCenterOfTile(ITileFieldPlayer player)
 {
     player.Win();
 }
コード例 #19
0
ファイル: Tile.cs プロジェクト: jensj12/MeesGame
 /// <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));
 }