Example #1
0
        public LevelScreen(PikeAndShotGame game, Level level)
            : base(game)
        {
            _levelData = level;
            playerInPlay = false;

            _formation = new Formation(this, -300, PikeAndShotGame.SCREENHEIGHT/2 - Soldier.HEIGHT*5, 20, SIDE_PLAYER);
            if (PikeAndShotGame.TEST_BOSS)
                cFormation = new ColmillosFormation(this, 800, 500);
            //_formation.addSoldier(new Colmillos(this, 200, 200, BattleScreen.SIDE_PLAYER));
            //_formation.addSoldier(new Wolf(this, 200, 200, BattleScreen.SIDE_PLAYER));

            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Pikeman(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Leader(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));
            _formation.addSoldier(new Arquebusier(this, _formation._position.X, _formation._position.Y, BattleScreen.SIDE_PLAYER));

            _coins = MAX_COINS/2;
            _doubleCoins = 0;
            _coinSprites = new ArrayList(20);
            _doppelCoinSprites = new ArrayList(20);
            coinMeterPosition = new Vector2(COIN_METER_POSITION.X, COIN_METER_POSITION.Y);

            _usedFormations = new List<int>(_levelData != null ?_levelData.formations.Count:20);
            _usedTerrain = new List<int>(_levelData != null ? _levelData.formations.Count : 20);
            _spawners = new ArrayList(2);
            _deadSpawners = new ArrayList(2);

            for (int i = 0; i < _coins; i++)
            {
                _coinSprites.Add(new Coin(this, BASE_COIN_START_POSITION, new Vector2(BASE_COIN_POSITION.X, BASE_COIN_POSITION.Y - i * 4f)));
            }
            _coinMeter = new Sprite(PikeAndShotGame.COIN_METER, new Rectangle(0, 0, 36, 94), 36, 94, false, true, 128, new Color(Color.Yellow.R, Color.Yellow.G, 100), 2);
            _coinMeterHurt = new Sprite(PikeAndShotGame.COIN_METER, new Rectangle(0, 0, 36, 94), 36, 94, false, true, 128, Color.Red,2);
            _doppelMeter = new Sprite(PikeAndShotGame.DOPPEL_METER, new Rectangle(0, 0, 36, 100), 36, 100, false, true, 80, Color.White, 0.5f);
            _doppelMeterHurt = new Sprite(PikeAndShotGame.DOPPEL_METER, new Rectangle(0, 0, 36, 100), 36, 100, false, true, 80, Color.Red, 2f);
            _coinMeterTimer = 0f;
            lootSpills = new LootSpill[4];
            for (int i = 0; i < 4; i++)
            {
                lootSpills[i] = new LootSpill(this, Vector2.Zero, 0f, Vector2.Zero);
            }

            coinsDone = new ArrayList();

            shotSounds = new ArrayList(5);
            shotSounds.Add(PikeAndShotGame.SHOT_0.CreateInstance());
            shotSounds.Add(PikeAndShotGame.SHOT_1.CreateInstance());
            shotSounds.Add(PikeAndShotGame.SHOT_2.CreateInstance());
            shotSounds.Add(PikeAndShotGame.SHOT_3.CreateInstance());
            shotSounds.Add(PikeAndShotGame.SHOT_4.CreateInstance());

            foreach (SoundEffectInstance sfx in shotSounds)
                sfx.Volume = 0.5f;

            ((SoundEffectInstance)shotSounds[3]).Volume = 0.25f;
            ((SoundEffectInstance)shotSounds[4]).Volume = 0.25f;

            pikeSounds = new ArrayList(6);
            pikeSounds.Add(PikeAndShotGame.PIKE_0.CreateInstance());
            pikeSounds.Add(PikeAndShotGame.PIKE_1.CreateInstance());
            pikeSounds.Add(PikeAndShotGame.PIKE_2.CreateInstance());
            pikeSounds.Add(PikeAndShotGame.PIKE_3.CreateInstance());
            pikeSounds.Add(PikeAndShotGame.PIKE_4.CreateInstance());
            pikeSounds.Add(PikeAndShotGame.PIKE_5.CreateInstance());

            foreach (SoundEffectInstance sfx in pikeSounds)
                sfx.Volume = 0.5f;

            meleeSounds = new ArrayList(6);
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_0.CreateInstance());
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_1.CreateInstance());
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_2.CreateInstance());
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_0.CreateInstance());
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_1.CreateInstance());
            meleeSounds.Add(PikeAndShotGame.MELEE_CLANG_2.CreateInstance());

            foreach (SoundEffectInstance sfx in meleeSounds)
                sfx.Volume = 0.25f;

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = 0.5f;
            //MediaPlayer.Play(PikeAndShotGame.THEME_1);

            spawnInitialTerrain();
            doppelType = true;
        }
Example #2
0
        public void loseCoin(int soldierType)
        {
            _coinMeterHurtTimer = COIN_METER_HURT_FLASH_TIME;
            int i = 0;
            if (_doubleCoins > 0)
            {
                _doubleCoins = 0;
                doppel = false;
                coinMeterTimer = COIN_METER_DROPTIME;
                PikeAndShotGame.DOPPEL_DOWN.Play(0.25f, 0, 0);

                LootSpill spill;
                foreach (Coin c in _doppelCoinSprites)
                {
                    c.setDone();
                    for (int j = 0; j < 3; j++)
                    {
                        spill = new LootSpill(this, Vector2.Zero, 0f, Vector2.Zero);
                        spill.reset(c._position);
                    }
                }

                foreach (Coin c in _coinSprites)
                {
                    c.finalPosition.Y = COIN_METER_POSITION.Y + 48 - i++ * 4f;
                }
                _coins--;
                ((Coin)_coinSprites[_coinSprites.Count - 1]).setDone();
                foreach (LootSpill spilly in lootSpills)
                {
                    spilly.reset(((Coin)_coinSprites[_coinSprites.Count - 1])._position);
                }
                if (soldierType != Soldier.TYPE_SWINGER)
                {
                    spawnRescue(soldierType);
                }
            }
            else if (_coins > 0)
            {
                _coins--;
                ((Coin)_coinSprites[_coinSprites.Count - 1]).setDone();
                foreach (LootSpill spill in lootSpills)
                {
                    spill.reset(((Coin)_coinSprites[_coinSprites.Count - 1])._position);
                }

                if (_coins < 1)
                {
                    retreat();
                }
                else if (soldierType != Soldier.TYPE_SWINGER/* && !PikeAndShotGame.TEST_BOSS*/)
                {
                    spawnRescue(soldierType);
                }
            }
        }