コード例 #1
0
ファイル: Game.cs プロジェクト: dhav211/SimpleRouge
 public void SetPlayerFromStairs(Stairs.StairDirection _comingFromDirection)
 {
     if (_comingFromDirection == Stairs.StairDirection.Up)
     {
         // Find the stairs with direction down and spawn player there
     }
     else if (_comingFromDirection == Stairs.StairDirection.Down)
     {
         // Find the stairs with direction up and spawn player there
     }
 }
コード例 #2
0
    private void CreateStair(int _floor, List <Room> _rooms, Stairs.StairDirection _direction)
    {
        // Here the stairs will actually be placed. It will determine it's position by the direction it's going. If it's going down then find a place in the last
        // room. Once that is determined it will be added to the floors set of stairs.

        Vector2 stairGridPosition = new Vector2();

        if (_direction == Stairs.StairDirection.Down)
        {
            stairGridPosition = GetGridPositionForStair(_rooms[_rooms.Count - 1]);
        }
        else if (_direction == Stairs.StairDirection.Up)
        {
            stairGridPosition = GetGridPositionForStair(_rooms[0]);
        }

        Vector2 stairPosition = new Vector2(stairGridPosition.x * 16, stairGridPosition.y * 16);
        Stairs  stair         = stairScene.Instance() as Stairs;

        stair.InitializeStair(grid, stairPosition, _direction);

        grid.Stairs.Add(stair);
    }
コード例 #3
0
        public void Handle()
        {
            if (block is Stairs)
            {
                if (block.Hitbox.Contains(player.Center))
                {
                    Stairs.StairDirection direction = (block as Stairs).Direction;
                    if (direction == Stairs.StairDirection.Down)
                    {
                        game.state = new ChangeRoomState("stairdown", player, game);
                    }
                    else
                    {
                        game.state = new ChangeRoomState("stairup", player, game);
                    }
                }
                return;
            }

            // computing this here so that link doesn't get double corrected if he runs
            // into two blocks at the same time
            Rectangle collision = Rectangle.Intersect(player.Footbox, block.Hitbox);

            IMoveableBlock moveableBlock;

            if (block is IMoveableBlock)
            {
                moveableBlock = block as IMoveableBlock;
            }

            else
            {
                moveableBlock = new MoveableBlock(doors);
            }

            if (collision.Width > collision.Height)
            {
                if (collision.Y == player.Footbox.Y)
                {
                    player.Y += collision.Height;
                    moveableBlock.MoveOnceUp();
                }
                else
                {
                    player.Y -= collision.Height;
                    moveableBlock.MoveOnceDown();
                }
            }
            else
            {
                if (collision.X == player.Footbox.X)
                {
                    player.X += collision.Width;
                    moveableBlock.MoveOnceLeft();
                }
                else
                {
                    player.X -= collision.Width;
                    moveableBlock.MoveOnceRight();
                }
            }
        }