Ejemplo n.º 1
0
        public void GetEnemysTypeTest()
        {
            EnemysType enemysType = TileManager.GetEnemysType(TileType.EnemyA);

            Assert.That(EnemysType.EnemyA, Is.EqualTo(enemysType));
        }
Ejemplo n.º 2
0
        public void LoadLevel(Byte levelNo)
        {
            String file = String.Format("{0}/{1}.txt", levelRoot, levelNo);

            LevelDataLines = MyGame.Manager.FileManager.LoadTxt(file);

            LevelWide = (Byte)LevelDataLines[0].Length;
            LevelHigh = (Byte)LevelDataLines.Count;

            LevelMap1D  = new Byte[LevelHigh * LevelWide];
            TileType1D  = new Byte[LevelHigh * LevelWide];
            Collision1D = new Byte[LevelHigh * LevelWide];
            //Position1D = new Vector2[LevelHigh * LevelWide];

            LevelMap2D  = new Byte[LevelHigh][];
            TileType2D  = new Byte[LevelHigh][];
            Collision2D = new Byte[LevelHigh][];
            //Position2D = new Vector2[LevelHigh][];

            PlayerSpot = 0;
            EnemysSpots.Clear();
            EnemysTypes.Clear();

            for (Byte high = 0; high < LevelHigh; high++)
            {
                String line = LevelDataLines[high];
                LevelMap2D[high]  = new Byte[LevelWide];
                TileType2D[high]  = new Byte[LevelWide];
                Collision2D[high] = new Byte[LevelWide];
                //Position2D[high] = new Vector2[LevelWide];

                for (Byte wide = 0; wide < LevelWide; wide++)
                {
                    UInt16 index = (UInt16)(high * LevelHigh + wide);

                    Char     tile     = line[wide];
                    TileType tileType = MyGame.Manager.TileManager.GetTileType(tile);
                    TileType1D[index]      = (Byte)tileType;
                    TileType2D[high][wide] = (Byte)tileType;

                    if (tileType == TileType.Player)
                    {
                        PlayerSpot = (UInt16)(high * LevelHigh + wide);
                    }
                    if (tileType == TileType.EnemyA || tileType == TileType.EnemyB || tileType == TileType.EnemyC || tileType == TileType.EnemyD)
                    {
                        EnemysType enemysType = MyGame.Manager.TileManager.GetEnemysType(tileType);
                        UInt16     enemysSpot = (UInt16)(high * LevelHigh + wide);
                        EnemysTypes.Add(enemysType);
                        EnemysSpots.Add(enemysSpot);
                    }

                    CollisionType collisionType = MyGame.Manager.CollisionManager.GetCollisionType(tile);
                    Collision1D[index]      = (Byte)collisionType;
                    Collision2D[high][wide] = (Byte)collisionType;

                    BlockType blockType = MyGame.Manager.TileManager.GetBlockType(tileType);
                    LevelMap1D[index]      = (Byte)blockType;
                    LevelMap2D[high][wide] = (Byte)blockType;
                }
            }
        }