コード例 #1
0
        public void LoadLevel(string levelName)
        {
            LoadContent();

            Tile = new LevelTiler();

            levelData = Engine.Instance.Content.Load <LevelData>(levelName);
            Tile.LoadContent(levelData);

            collisionInfoSolid = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tilesSolid         = new LevelTilesSolid(collisionInfoSolid);
            this.Add(tilesSolid);

            spawnPoints = LevelTiler.TileConverison(Tile.CollisionLayer, 3);
            SpawnPointAssignment();

            collisionInfoEmpty = LevelTiler.TileConverison(Tile.CollisionLayer, 0);
            tilesEmpty         = new LevelTilesEmpty(collisionInfoEmpty);
            this.Add(tilesEmpty);

            playerOne = new Player(Tile.PlayerPosition[0], PlayerIndex.One);
            this.Add(playerOne);
            playerOne.Added(this);

            playerTwo = new Player(Tile.PlayerPosition[1], PlayerIndex.Two);
            this.Add(playerTwo);
            playerTwo.Added(this);

            Camera = new GraveCamera();
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: Kinaetron/HHRPG
        public override void LoadContent()
        {
            base.LoadContent();

            Tile = new LevelTiler();

            levelData = LevelData.Load("Content/testMap.json");
            Tile.LoadContent(levelData);

            collisionInfo = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tiles         = new LevelTilesSolid(collisionInfo);
            this.Add(tiles);

            player = new Player(Tile.PlayerPosition[0]);
            this.Add(player);
            player.Added(this);
        }
コード例 #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            levelData = Engine.Instance.Content.Load <LevelData>("TestMap");
            tile.LoadContent(levelData);

            bool[,] collisionInfo = LevelTiler.TileConverison(tile.CollisionLayer, 513);
            tiles = new LevelTiles(collisionInfo);
            this.Add(tiles);

            player = new Player(tile.PlayerPosition[0]);
            this.Add(player);
            player.Added(this);

            initalizeMusic();
        }
コード例 #4
0
ファイル: Level.cs プロジェクト: Kinaetron/WallJumpPhysics
        public override void LoadContent()
        {
            base.LoadContent();

            Tile = new LevelTiler();

            levelData = Engine.Instance.Content.Load <LevelData>("Map");
            Tile.LoadContent(levelData);

            collisionInfo = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tiles         = new LevelTilesSolid(collisionInfo);
            this.Add(tiles);

            player = new Player(new Vector2(200, 200));
            this.Add(player);
            player.Added(this);
        }
コード例 #5
0
ファイル: Level.cs プロジェクト: Kinaetron/Runner2
        public void LoadLevel(string levelName)
        {
            LoadContent();

            Tile = new LevelTiler();

            levelData = Engine.Instance.Content.Load <LevelData>(levelName);
            Tile.LoadContent(levelData);

            collisionInfoSolid = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tilesSolid         = new LevelTilesSolid(collisionInfoSolid);
            this.Add(tilesSolid);

            collisionInfoEmpty = LevelTiler.TileConverison(Tile.CollisionLayer, 0);
            tilesEmpty         = new LevelTilesEmpty(collisionInfoEmpty);
            this.Add(tilesEmpty);

            player = new Player(Tile.PlayerPosition[0]);
            this.Add(player);
            player.Added(this);
        }
コード例 #6
0
        public override void LoadContent()
        {
            base.LoadContent();

            Tile = new LevelTiler();

            hitboxData = Engine.Instance.Content.Load <HitboxData>("SOMETHING");

            levelData = Engine.Instance.Content.Load <LevelData>("level");
            Tile.LoadContent(levelData);

            collisionInfoSolid = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tilesSolid         = new LevelTilesSolid(collisionInfoSolid);
            this.Add(tilesSolid);

            collisionInfoEmpty = LevelTiler.TileConverison(Tile.CollisionLayer, 0);
            tilesEmpty         = new LevelTilesEmpty(collisionInfoEmpty);
            this.Add(tilesEmpty);

            player = new Player(new Vector2(100, 100));
            this.Add(player);
            player.Added(this);
        }
コード例 #7
0
        public override void LoadContent()
        {
            base.LoadContent();

            levelData = Engine.Instance.Content.Load <LevelData>("Arena");
            tile.LoadContent(levelData);

            bool[,] collisionInfo = LevelTiler.TileConverison(tile.CollisionLayer, 65);
            tiles = new LevelTiles(collisionInfo);
            this.Add(tiles);

            for (int i = 0; i < tile.PlayerPosition.Count; i++)
            {
                if (i == 0)
                {
                    players.Add(new Player1(tile.PlayerPosition[i], i, Color.Blue, GameTags.Player1,
                                            new Vector2(tile.MapWidthInPixels, tile.MapHeightInPixels)));
                }

                if (i == 1)
                {
                    players.Add(new Player2(tile.PlayerPosition[i], i, Color.Green, GameTags.Player2,
                                            new Vector2(tile.MapWidthInPixels, tile.MapHeightInPixels)));
                }
            }

            this.HelperEntity.Add(counters);
            this.Add(players);

            foreach (var player in players)
            {
                player.Added(this);
            }

            initalizeMusic();
        }
コード例 #8
0
ファイル: Level.cs プロジェクト: Kinaetron/Issho
        public void LoadLevel(string levelName)
        {
            LoadContent();

            levelData = Engine.Instance.Content.Load <LevelData>(levelName);
            tile.LoadContent(levelData);

            collisionInfoSolid = LevelTiler.TileConverison(tile.CollisionLayer, 73);
            tilesSolid         = new LevelTilesSolid(collisionInfoSolid);
            this.Add(tilesSolid);

            collisionInfoEmpty = LevelTiler.TileConverison(tile.CollisionLayer, 0);
            tilesEmpty         = new LevelTilesEmpty(collisionInfoEmpty);
            this.Add(tilesEmpty);

            foreach (var entity in tile.Entites)
            {
                if (entity.Type == "GravityBox")
                {
                    GravityBox = new GravityBoxMediumCombo(entity.Position);
                    GravityItemList.Add(GravityBox);
                    this.Add(GravityBox);
                    GravityBox.Added(this);
                }

                if (entity.Type == "GravityBoxLeftRight")
                {
                    GravityBoxLeftRight = new GravityBoxMediumLeftRight(entity.Position);
                    GravityItemList.Add(GravityBoxLeftRight);
                    this.Add(GravityBoxLeftRight);
                    GravityBoxLeftRight.Added(this);
                }

                if (entity.Type == "GravityBoxUpDown")
                {
                    GravityBoxUpDown = new GravityBoxMediumUpDown(entity.Position);
                    GravityItemList.Add(GravityBoxUpDown);
                    this.Add(GravityBoxUpDown);
                    GravityBoxUpDown.Added(this);
                }

                if (entity.Type == "GravityBoxSmall")
                {
                    GravityBoxSmall = new GravityBoxSmallCombo(entity.Position);
                    GravityItemList.Add(GravityBoxSmall);
                    this.Add(GravityBoxSmall);
                    GravityBoxSmall.Added(this);
                }

                if (entity.Type == "GravityBoxSmallLeftRight")
                {
                    GravityBoxSmallLeftRight = new GravityBoxSmallLeftRight(entity.Position);
                    GravityItemList.Add(GravityBoxSmallLeftRight);
                    this.Add(GravityBoxSmallLeftRight);
                    GravityBoxSmallLeftRight.Added(this);
                }

                if (entity.Type == "GravityBoxSmallUpDown")
                {
                    GravityBoxSmallUpDown = new GravityBoxSmallUpDown(entity.Position);
                    GravityItemList.Add(GravityBoxSmallUpDown);
                    this.Add(GravityBoxSmallUpDown);
                    GravityBoxSmallUpDown.Added(this);
                }

                if (entity.Type == "Enemy")
                {
                    if (entity.Properties.Count > 0)
                    {
                        EnemyMoveDirection direction = EnemyMoveDirection.Right;
                        int distance = 100;

                        foreach (var item in entity.Properties)
                        {
                            if (item.Key == "Direction")
                            {
                                if (item.Value == "Right")
                                {
                                    direction = EnemyMoveDirection.Right;
                                }
                                else if (item.Value == "Left")
                                {
                                    direction = EnemyMoveDirection.Left;
                                }
                            }
                            else if (item.Key == "Distance")
                            {
                                distance = int.Parse(item.Value);
                            }
                        }

                        Enemy = new EnemyCombo(entity.Position, distance, direction);
                        GravityItemList.Add(Enemy);
                        this.Add(Enemy);
                        Enemy.Added(this);
                    }
                    else
                    {
                        Enemy = new EnemyCombo(entity.Position);
                        GravityItemList.Add(Enemy);
                        this.Add(Enemy);
                        Enemy.Added(this);
                    }
                }

                if (entity.Type == "EnemyUpDown")
                {
                    if (entity.Properties.Count > 0)
                    {
                        EnemyMoveDirection direction = EnemyMoveDirection.Right;
                        int distance = 100;

                        foreach (var item in entity.Properties)
                        {
                            if (item.Key == "Direction")
                            {
                                if (item.Value == "Right")
                                {
                                    direction = EnemyMoveDirection.Right;
                                }
                                else if (item.Value == "Left")
                                {
                                    direction = EnemyMoveDirection.Left;
                                }
                            }
                            else if (item.Key == "Distance")
                            {
                                distance = int.Parse(item.Value);
                            }
                        }

                        EnemyUpDown = new EnemyUpDown(entity.Position, distance, direction);
                        GravityItemList.Add(EnemyUpDown);
                        this.Add(EnemyUpDown);
                        EnemyUpDown.Added(this);
                    }
                    else
                    {
                        EnemyUpDown = new EnemyUpDown(entity.Position);
                        GravityItemList.Add(EnemyUpDown);
                        this.Add(EnemyUpDown);
                        EnemyUpDown.Added(this);
                    }
                }

                if (entity.Type == "EnemyLeftRight")
                {
                    if (entity.Properties.Count > 0)
                    {
                        EnemyMoveDirection direction = EnemyMoveDirection.Right;
                        int distance = 100;

                        foreach (var item in entity.Properties)
                        {
                            if (item.Key == "Direction")
                            {
                                if (item.Value == "Right")
                                {
                                    direction = EnemyMoveDirection.Right;
                                }
                                else if (item.Value == "Left")
                                {
                                    direction = EnemyMoveDirection.Left;
                                }
                            }
                            else if (item.Key == "Distance")
                            {
                                distance = int.Parse(item.Value);
                            }
                        }

                        EnemyLeftRight = new EnemyLeftRight(entity.Position, distance, direction);
                        GravityItemList.Add(EnemyLeftRight);
                        this.Add(EnemyLeftRight);
                        EnemyLeftRight.Added(this);
                    }
                    else
                    {
                        EnemyLeftRight = new EnemyLeftRight(entity.Position);
                        GravityItemList.Add(EnemyLeftRight);
                        this.Add(EnemyLeftRight);
                        EnemyLeftRight.Added(this);
                    }
                }

                if (entity.Type == "Checkpoint")
                {
                    Checkpoint checkpoint = new Checkpoint(entity.Position);
                    this.Add(checkpoint);
                    checkpoint.Added(this);

                    Checkpoints.Add(checkpoint);
                }

                if (entity.Type == "Exit")
                {
                    Exit = new Exit(entity.Position);
                    this.Add(Exit);
                    Exit.Added(this);
                }

                if (entity.Type == "NextLevel")
                {
                    NextLevel = entity.Name;
                }
            }

            if (CurrentPlayerPosition == Vector2.Zero)
            {
                player = new Player(tile.PlayerPosition[0]);
            }
            else
            {
                player = new Player(CurrentPlayerPosition);
            }

            this.Add(player);
            player.Added(this);
        }
コード例 #9
0
ファイル: Level.cs プロジェクト: Kinaetron/MegaSword
        public override void LoadContent()
        {
            base.LoadContent();

            Tile = new LevelTiler();

            levelData = Engine.Instance.Content.Load <LevelData>("TestLevel");
            Tile.LoadContent(levelData);

            collisionInfo = LevelTiler.TileConverison(Tile.CollisionLayer, 2);
            tiles         = new LevelTilesSolid(collisionInfo);
            this.Add(tiles);

            stopPointsInfo = LevelTiler.TileConverison(Tile.CollisionLayer, 4);
            stopPoints     = new LevelTilesStopPoints(stopPointsInfo);
            this.Add(stopPoints);

            Player = new Player(Tile.PlayerPosition[0]);
            this.Add(Player);
            Player.Added(this);

            onewayInfo = LevelTiler.TileConverison(Tile.CollisionLayer, 3);

            for (int i = 0; i < onewayInfo.GetLength(0); i++)
            {
                for (int j = 0; j < onewayInfo.GetLength(1); j++)
                {
                    bool tile = onewayInfo[i, j];
                    if (tile == false)
                    {
                        continue;
                    }

                    Vector2 position = new Vector2(i * TileInformation.TileWidth, j * TileInformation.TileHeight);
                    Oneway  platform = new Oneway(position);
                    this.Add(platform);
                    platform.Added(this);
                }
            }

            foreach (Entity entity in Tile.Entites)
            {
                if (entity.Type == "Enemy")
                {
                    BasicEnemy enemy = new BasicEnemy(entity.Position);
                    this.Add(enemy);
                    enemy.Added(this);
                }

                if (entity.Type == "FallingPlatform")
                {
                    FallingPlatform fallingPlatform = new FallingPlatform(entity.Position);
                    this.Add(fallingPlatform);
                    fallingPlatform.Added(this);
                }

                if (entity.Type == "MovingPlatform")
                {
                    MovingPlatform movingPlatform = new MovingPlatform(entity.Position);
                    this.Add(movingPlatform);
                    movingPlatform.Added(this);
                }

                if (entity.Type == "MovingPlatformVert")
                {
                    MovingPlatformVert movingPlatform = new MovingPlatformVert(entity.Position);
                    this.Add(movingPlatform);
                    movingPlatform.Added(this);
                }
            }
        }