コード例 #1
0
ファイル: Level.cs プロジェクト: Ahmed310/SpaceFighter
        public Level()
        {
            for (int i = 0; i < dimension.X; i++)
            {
                for (int j = 0; j < dimension.Y; j++)
                {
                    block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), id, false, Color.White, SpriteEffects.None, false);
                }
            }

        }
コード例 #2
0
ファイル: Level.cs プロジェクト: Ahmed310/SpaceFighter
        private void generateLevel()
        {

            for (int i = 0; i < dimension.X; i++)           //nested loop row wise
            {
                for (int j = 0; j < dimension.Y; j++)
                {
                    if (levels[i, j] == Global.airBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], true, Color.White, SpriteEffects.None, false);
                        
                    }
                    else if (levels[i, j] == Global.speedUpBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], true, Color.White,SpriteEffects.None, true);
                        block[i, j].speedUp();
                        block[i, j].time = 75d;
                        
                    }

                    else if (levels[i, j] == Global.speedDownBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], true,Color.White, SpriteEffects.FlipHorizontally, true);
                        block[i, j].speedUp();
                        block[i, j].time = 75d;
                    }
                    else if (levels[i, j] == Global.lightGrayTileId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], false, Color.White, SpriteEffects.None, true);
                        block[i, j].verylightGrayTile();
                        
                    }
                    else if (levels[i, j] == Global.grayTileId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], false, Color.White, SpriteEffects.None, true);
                        block[i, j].lightGrayTile();

                    }
                    else if (levels[i, j] == Global.rockTileId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], false, Color.White, SpriteEffects.None, true);
                        block[i, j].rockTile();

                    }
                    else if (levels[i, j] == Global.playerId)
                    {
                        Manager.manager.player = new Player(new Vector2(j * Manager.tileSize, i * Manager.tileSize));
                    }
                    else if (levels[i, j] == Global.fuelId)
                    {
                        Manager.manager.meat.fuel = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.fuel.Width, Manager.manager.meat.fuel.Height);
                    }
                    else if (levels[i, j] == Global.spacerDownBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], true, Color.White, SpriteEffects.FlipVertically, false);
                        block[i, j].spearUp();
                        block[i, j].time = 175d;
                    }
                    else if (levels[i, j] == Global.dirtBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], false,Color.White, SpriteEffects.None, true);
                        block[i, j].dirtBlock();
                    }
                    else if (levels[i, j] == Global.spacerUpBlockId)
                    {
                        block[i, j] = new Block(new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.tileSize, Manager.tileSize), levels[i, j], true,Color.BurlyWood, SpriteEffects.None, false);
                        block[i, j].spearUp();
                        block[i, j].time = 175d;
                    }
                    else if (levels[i, j] == Global.healthId)
                    {
                        Manager.manager.meat.health = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.health.Width, Manager.manager.meat.health.Height);
                    }
                    else if (levels[i, j] == Global.terminalId)
                    {
                        Manager.manager.meat.casel = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.casel.Width, Manager.manager.meat.casel.Height);
                    }

                    else if (levels[i, j] == Global.fireGunId)
                    {
                        Manager.manager.meat.fireGun = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.fireGun.Width, Manager.manager.meat.fireGun.Height);
                    }
                    else if (levels[i, j] == Global.threeBulletGunId)
                    {
                        Manager.manager.meat.threeBulletGun = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.threeBulletGun.Width, Manager.manager.meat.threeBulletGun.Height);
                    }
                    else if (levels[i, j] == Global.layserGunId)
                    {
                        Manager.manager.meat.layserGun = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.layserGun.Width, Manager.manager.meat.layserGun.Height);
                    }
                    else if (levels[i, j] == Global.simpleGunId)
                    {
                        Manager.manager.meat.simpleGun = new Rectangle(j * Manager.tileSize, i * Manager.tileSize,
                        Manager.manager.meat.simpleGun.Width, Manager.manager.meat.simpleGun.Height);
                    }
                    else if (levels[i, j] == Global.zombieId)
                    {
                        foreach (Obj o in Manager.manager.enemyItem)
                        {
                            if (o.GetType() == typeof(Enemy) && !o.alive)
                            {
                                o.position.X = j * Manager.tileSize;
                                o.position.Y =  i * Manager.tileSize ;
                                o.alive = true;
                                Enemy e = (Enemy)o;
                                e.zombieEnemy();
                                break;
                            }
                        }
                    }


                    else if (levels[i, j] == Global.alienShipId)
                    {
                        foreach (Obj o in Manager.manager.enemyItem)
                        {
                            if (o.GetType() == typeof(Enemy) && !o.alive)
                            {
                                o.position.X = j * Manager.tileSize;
                                o.position.Y = i * Manager.tileSize;
                                o.alive = true;
                                Enemy e = (Enemy)o;
                                e.alienShip();
                                break;
                            }
                        }
                    }



                    else if (levels[i, j] == Global.lionId)
                    {
                        foreach (Obj o in Manager.manager.enemyItem)
                        {
                            if (o.GetType() == typeof(Enemy) && !o.alive)
                            {
                                
                                o.position.X = j * Manager.tileSize;
                                o.position.Y = i * Manager.tileSize;
                      
                                o.alive = true;
                                
                                Enemy e = (Enemy)o;
                                e.lionEneny();
                                break;
                            }
                        }
                    }

                    else if (levels[i, j] == Global.soliderId)
                    {
                        foreach (Obj o in Manager.manager.enemyItem)
                        {
                            if (o.GetType() == typeof(Enemy) && !o.alive)
                            {
                                o.alive = true;
                                o.position.X = j * Manager.tileSize;
                                o.position.Y = i * Manager.tileSize;
                                Enemy e = (Enemy)o;
                                e.soliderEnemy();
                                break;
                            }
                        }
                    }



                }
            }
        }