Esempio n. 1
0
        public void NewWave()
        {
            if (Waves.Count > 0)
            {
                currentEnemyInWave = 0;
                CurrentWaveNumber++;

                CurrentWave   = Waves.Dequeue();
                QueuedEnemies = CurrentWave.Enemies;

                FlashingLabel warningLabel = new FlashingLabel("Enemies Detected!", new Vector2(ScreenManager.ScreenCentre.X, ScreenManager.ScreenCentre.Y * 0.25f), Color.Red, null, 4.8f);
                UnderSiegeGameplayScreen.HUD.AddUIObject(warningLabel, "New Wave Label");

                int spawnCounter = 0;
                foreach (Vector2 spawnPoint in CurrentWave.WaveData.SpawnPoints)
                {
                    UnderSiegeGameplayScreen.HUD.AddUIObject(new Marker(new Vector2(-CurrentWave.WaveData.SpawnPoints.Count * 0.5f * 32 + spawnCounter * 32, 32), Camera.GameToScreenCoords(spawnPoint), "Sprites\\UI\\Markers\\DirectionMarker", warningLabel), spawnPoint.ToString() + "Marker");
                    spawnCounter++;
                }

                currentTimeBetweenWaves       = 0;
                currentTimeBetweenEnemySpawns = CurrentWave.WaveData.TimeBetweenEnemySpawns;

                // If our time between enemy spawns is zero, add them all at once
                if (CurrentWave.WaveData.TimeBetweenEnemySpawns == 0)
                {
                    while (QueuedEnemies.Count > 0)
                    {
                        currentEnemyInWave++;
                        GameplayScreen.AddEnemyShip(QueuedEnemies.Dequeue(), "Wave " + CurrentWaveNumber + " Enemy " + currentEnemyInWave);
                    }
                }
            }
            else
            {
                CurrentWave = null;
            }

            if (Continuous)
            {
                if (Waves.Count == 1)
                {
                    //Waves.Enqueue(Waves.Peek().Clone());
                    Wave <T> wave = new Wave <T>(GameplayScreen.GameplayScreenData.WaveNames[GameplayScreen.GameplayScreenData.WaveNames.Count - 1]);
                    wave.LoadContent();
                    wave.Initialize();
                    Waves.Enqueue(wave);
                }
            }
        }
Esempio n. 2
0
        private void AddUI()
        {
            float padding = 5;

            UIManager.Clear();

            Image shipImage = new Image(new Vector2(0, -Size.Y * 0.25f), PlayerShipData.TextureAsset, this);

            AddUIObject(shipImage, "Ship Image", true);

            HardPointUI = new HardPointUIManager(shipImage);
            HardPointUI.Initialize(PlayerShipData);
            HardPointUI.DrawEngineHardPointUI = true;
            HardPointUI.DrawOtherHardPointUI  = true;

            Label shipName = new Label("Name: " + PlayerShipData.DisplayName, new Vector2(0, shipImage.Size.Y * 0.5f + SpriteFont.LineSpacing + padding), Color.White, shipImage);

            AddUIObject(shipName, "Ship Name", true);

            Label shipHull = new Label("Hull Strength: " + PlayerShipData.Health.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, shipName);

            AddUIObject(shipHull, "Ship Hull Health", true);

            ImageAndLabel money = new ImageAndLabel("Sprites\\UI\\Icons\\MoneyIcon", PlayerShipData.Price.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), shipHull);

            AddUIObject(money, "Ship Price", true);

            if (Session.Money >= PlayerShipData.Price)
            {
                Button buyButton = new Button(new Vector2(0, SpriteFont.LineSpacing + Button.defaultTexture.Height * 0.5f + padding), "Buy", money);
                buyButton.OnSelect += BuyShipEvent;
                AddUIObject(buyButton, "Buy Ship Button", true);
            }
            else
            {
                FlashingLabel insufficientMoney = new FlashingLabel("Insufficient Money", new Vector2(0, 2 * SpriteFont.LineSpacing + padding), Color.Red, money);
                AddUIObject(insufficientMoney, "Insufficient Money Flashing Label");
            }
        }