Exemplo n.º 1
0
        public override int Update(GameTime gameTime)
        {
            var mousePosition  = Screen.GetMousePosition();
            var mouseWorldPos  = Camera.ScreenToWorldPosition(mousePosition);
            var centerWorldPos = Camera.ScreenToWorldPosition(WorldManager.ScreenCenter);

            if (_lockCamera)
            {
                Camera.CenterPosition(WorldManager.PlayerEntity.Position);
            }

            _menu.GetWidget <PUIWLabel>("lblDebug").Text =
                Camera.GetViewRect().ToString() + " : " + Camera.Zoom + "\n" +
                "Asteroids: " + (WorldManager.Asteroids.LastActiveIndex + 1) + "\n" +
                mouseWorldPos.ToString() + "\n" +
                centerWorldPos.ToString();

            var inventoryString = new StringBuilder();

            foreach (var kvp in WorldManager.PlayerEntity.Inventory.Resources)
            {
                inventoryString.Append(kvp.Key.ToString() + ": " + kvp.Value.ToString() + "\n");
            }

            _menu.GetWidget <PUIWLabel>("lblInventory").Text = inventoryString.ToString();

            _menu.Update(gameTime);
            WorldManager.Update(gameTime);
            UnitManager.Update(gameTime);

            return(_nextGameState);
        }
Exemplo n.º 2
0
        } // Load

        public override int Update(GameTime gameTime)
        {
            if (GameOver || GameWon)
            {
                return((int)GameStateType.GameOver);
            }

            var mousePosition  = MouseManager.GetMousePosition();
            var mouseWorldPos  = Camera.ScreenToWorldPosition(mousePosition);
            var centerWorldPos = Camera.ScreenToWorldPosition(WorldManager.ScreenCenter);

            if (_lockCamera)
            {
                Camera.CenterPosition(WorldManager.PlayerEntity.Position);
            }

            Menu.GetWidget <PUIWLabel>("lblDebug").Text =
                Camera.GetViewRect().ToString() + " : " + Camera.Zoom + "\n" +
                "Asteroids: " + (WorldManager.Asteroids.LastActiveIndex + 1) + "\n" +
                mouseWorldPos.ToString() + "\n" +
                centerWorldPos.ToString() + "\n" +
                WorldManager.PlayerShips.Count.ToString() + " / " + WorldManager.EnemyShips.Count.ToString();

            _sbGeneral.Clear();
            _sbGeneral.Append("Queue: ");
            var queueListedCount = 0;

            for (var i = 0; i < WorldManager.PlayerEntity.BuildQueue.Count && queueListedCount < 3; i++)
            {
                var nextShip = WorldManager.PlayerEntity.BuildQueue[i];
                _sbGeneral.Append(nextShip.ShipType.ToString() + "(" + (nextShip.Duration / 1000.0f).ToString("0.0") + "s), ");
                queueListedCount += 1;
            }

            if (WorldManager.PlayerEntity.BuildQueue.Count > 0)
            {
                _sbGeneral.Remove(_sbGeneral.Length - 2, 2);
            }

            if (queueListedCount < WorldManager.PlayerEntity.BuildQueue.Count)
            {
                _sbGeneral.Append(" +" + (WorldManager.PlayerEntity.BuildQueue.Count - queueListedCount).ToString() + "");
            }

            _lblProductionQueue.Text = _sbGeneral.ToString();

            Menu.Update(gameTime);
            WorldManager.Update(gameTime);
            UnitManager.Update(gameTime);
            ProjectileManager.Update(gameTime);
            EffectsManager.Update(gameTime);
            EnemyWaveManager.Update(gameTime);

            Menu.GetWidget <PUIWLabel>("lblNextEnemyWaveTimer").Text    = "Next Enemy Wave: " + (EnemyWaveManager.NextWaveTimer / 1000.0f).ToString("0");
            Menu.GetWidget <PUIWLabel>("lblNextEnemyWavePosition").Text = "Next Wave Spawn: " + EnemyWaveManager.NextWavePosition.Name;
            Menu.GetWidget <PUIWLabel>("lblEnemyCount").Text            = "Enemies Alive: " + WorldManager.EnemyShips.Count.ToString();
            Menu.GetWidget <PUIWLabel>("lblMinerCount").Text            = "Miners: " + WorldManager.Miners.Count.ToString() + " / " + (Config.BaseMinerLimit + UpgradeManager.BonusMaxMiners).ToString();

            var idleMiners = 0;

            foreach (var type in WorldData.ResourceTypes)
            {
                MinerResourceCounts[type] = 0;
            }

            foreach (var m in WorldManager.Miners)
            {
                var miner = (Miner)m;

                if (miner.CurrentMiningTarget == null)
                {
                    idleMiners += 1;
                }
                else
                {
                    MinerResourceCounts[miner.CurrentMiningTarget.ResourceType] += 1;
                }
            }

            _btnIdleMiners.ButtonText = "Idle Miners (" + idleMiners.ToString() + ")";

            if (idleMiners == 0)
            {
                _btnIdleMiners.Visible = false;
                _btnIdleMiners.Active  = false;
            }
            else
            {
                _btnIdleMiners.Visible = true;
                _btnIdleMiners.Active  = true;
            }

            _lblMetal.Text   = WorldManager.PlayerEntity.Inventory.Resources[ResourceType.Metal].ToString() + " (" + MinerResourceCounts[ResourceType.Metal].ToString() + ")";
            _lblGas.Text     = WorldManager.PlayerEntity.Inventory.Resources[ResourceType.Gas].ToString() + " (" + MinerResourceCounts[ResourceType.Gas].ToString() + ")";
            _lblWater.Text   = WorldManager.PlayerEntity.Inventory.Resources[ResourceType.Water].ToString() + " (" + MinerResourceCounts[ResourceType.Water].ToString() + ")";
            _lblCrystal.Text = WorldManager.PlayerEntity.Inventory.Resources[ResourceType.Crystal].ToString() + " (" + MinerResourceCounts[ResourceType.Crystal].ToString() + ")";
            _lblUranium.Text = WorldManager.PlayerEntity.Inventory.Resources[ResourceType.Uranium].ToString() + " (" + MinerResourceCounts[ResourceType.Uranium].ToString() + ")";

            _btnUpgrades.ButtonText = "Upgrades (" + UpgradeManager.UpgradePoints.ToString() + ")";
            _lblUpgradesTitle.Text  = "Upgrades (" + UpgradeManager.UpgradePoints.ToString() + " points)";

            return(_nextGameState);
        }