コード例 #1
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            _menu = new PUIMenu();
            _menu.AddMethod(Exit);
            _menu.Load(graphics, "GameOverMenuDefinition", "UITemplates");

            _menuBG          = new Sprite(ModManager.Instance.AssetManager.LoadTexture2D(graphics, "MenuBG"));
            _menuBG.Position = Vector2.Zero;
            _menuBG.Center   = Vector2.Zero; // otherwise scaling is weird
            _menuBG.Scale    = ((float)graphics.PresentationParameters.BackBufferWidth / (float)_menuBG.Texture.Width);

            if (GameplayState.GameWon)
            {
                _menu.GetWidget <PUIWLabel>("lblTitle").Text = "You Won!";
            }
            else
            {
                _menu.GetWidget <PUIWLabel>("lblTitle").Text = "You Lost!";
            }

            var lblLeft  = _menu.GetWidget <PUIWLabel>("lblStatsLeft");
            var lblRight = _menu.GetWidget <PUIWLabel>("lblStatsRight");

            var sbLeft  = new StringBuilder("Ship Type\n\n");
            var sbRight = new StringBuilder("Killed / Lost\n\n");

            foreach (var kvp in GameplayState.ShipsKilled)
            {
                sbLeft.AppendLine(kvp.Key.ToString());
                sbRight.AppendLine(kvp.Value.ToString() + " / " + GameplayState.ShipsLost[kvp.Key].ToString());
            }

            lblLeft.Text  = sbLeft.ToString();
            lblRight.Text = sbRight.ToString();
        }
コード例 #2
0
        public void Setup(GraphicsDevice graphics, PUIMenu menu)
        {
            Graphics = graphics;
            Menu     = menu;

            SelectedShips     = new List <Ship>();
            SelectedShipTypes = new Dictionary <ShipType, List <Ship> >();
            SelectHomeShip();

            DragSelectTexture = new RenderTarget2D(graphics, graphics.PresentationParameters.BackBufferWidth, graphics.PresentationParameters.BackBufferHeight);

            graphics.SetRenderTarget((RenderTarget2D)DragSelectTexture);
            graphics.Clear(new Color(120, 120, 120, 120));
            graphics.SetRenderTarget(null);
        }
コード例 #3
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            GameWon  = false;
            GameOver = false;

            Graphics = graphics;

            UpgradeManager = new UpgradeManager();
            Menu           = new PUIMenu();

            Menu.AddMethod(BuildMiner);
            Menu.AddMethod(BuildFighter);
            Menu.AddMethod(BuildBomber);
            Menu.AddMethod(BuildRepairShip);
            Menu.AddMethod(BuildMissileFrigate);
            Menu.AddMethod(BuildBeamFrigate);
            Menu.AddMethod(BuildSupportCruiser);
            Menu.AddMethod(BuildHeavyCruiser);
            Menu.AddMethod(BuildBattleship);
            Menu.AddMethod(BuildCarrier);
            Menu.AddMethod(IdleMiners);
            Menu.AddMethod(Upgrades);
            Menu.AddMethod(Help);
            Menu.AddMethod(ExitToMenu);
            Menu.AddMethod(Build);

            Menu.AddMethod(UpgradeManager.UpgradeMinerCap1);
            Menu.AddMethod(UpgradeManager.UpgradeMinerCap2);
            Menu.AddMethod(UpgradeManager.UpgradeMiningRate1);
            Menu.AddMethod(UpgradeManager.UpgradeMiningRate2);
            Menu.AddMethod(UpgradeManager.UpgradeRepairRate);
            Menu.AddMethod(UpgradeManager.UpgradeShieldRegen1);
            Menu.AddMethod(UpgradeManager.UpgradeShieldRegen2);
            Menu.AddMethod(UpgradeManager.UpgradeWarmachine1);
            Menu.AddMethod(UpgradeManager.UpgradeWarmachine2);
            Menu.AddMethod(UpgradeManager.UpgradeHyperdrive);

            Menu.Load(graphics, "GameplayMenuDefinition", "UITemplates");

            MinimapFrame = Menu.GetFrame("frmMinimap");

            GameOver = false;

            Config.Load();
            EntityData.Load();
            WorldData.Load();

            if (Config.HelpSeen)
            {
                var helpFrame = Menu.GetFrame("frmHelp");

                helpFrame.Visible = false;
                helpFrame.Active  = false;
            }

            Config.HelpSeen = true;
            SettingsManager.Instance.UpdateSetting("general", "helpseen", "true");

            _lblProductionQueue = Menu.GetWidget <PUIWLabel>("lblProductionQueue");
            _lblMetal           = Menu.GetWidget <PUIWLabel>("lblMetal");
            _lblGas             = Menu.GetWidget <PUIWLabel>("lblGas");
            _lblWater           = Menu.GetWidget <PUIWLabel>("lblWater");
            _lblCrystal         = Menu.GetWidget <PUIWLabel>("lblCrystal");
            _lblUranium         = Menu.GetWidget <PUIWLabel>("lblUranium");
            _lblUpgradesTitle   = Menu.GetWidget <PUIWLabel>("lblUpgradesTitle");

            _btnIdleMiners = Menu.GetWidget <PUIWBasicButton>("btnIdleMiners");
            _btnUpgrades   = Menu.GetWidget <PUIWBasicButton>("btnUpgrades");

            ShipsKilled = new Dictionary <ShipType, int>();
            ShipsLost   = new Dictionary <ShipType, int>();

            foreach (var kvp in EntityData.ShipTypes)
            {
                ShipsKilled.Add(kvp.Key, 0);
                ShipsLost.Add(kvp.Key, 0);
            }

            // create build menu tooltips
            foreach (var kvp in EntityData.ShipTypes)
            {
                if (!kvp.Value.CanBuild)
                {
                    continue;
                }

                var button = Menu.GetWidget <PUIWBasicButton>("btnBuild" + kvp.Value.ShipType.ToString());

                _sbGeneral.Clear();

                _sbGeneral.Append("\n\n").Append(kvp.Value.Description.Replace("\\n", "\n"));

                foreach (var kvpBuild in kvp.Value.BuildCost)
                {
                    var sprite = TexturePacker.GetSprite("ResourcesAtlas", kvpBuild.Key.ToString());

                    _sbGeneral
                    .Append("[")
                    .Append("ResourcesTexture-")
                    .Append(sprite.SourceRect.X).Append(",")
                    .Append(sprite.SourceRect.Y).Append(",")
                    .Append(sprite.SourceRect.Width).Append(",")
                    .Append(sprite.SourceRect.Height)
                    .Append("] ")
                    .Append(kvpBuild.Value)
                    .Append("  ");
                }

                _sbGeneral.Remove(_sbGeneral.Length - 2, 2);

                button.SetTooltip(_sbGeneral.ToString(), _sbGeneral.ToString(), true);
            }

            _sbGeneral.Clear();

            Camera = new BasicCamera2D(
                new Rectangle(0, 0, graphics.PresentationParameters.BackBufferWidth, graphics.PresentationParameters.BackBufferHeight),
                new Rectangle(0, 0, Config.WorldWidth, Config.WorldHeight));

            _currentZoomLevel = _zoomLevels.IndexOf(0.5f);
            Camera.Zoom       = _zoomLevels[_currentZoomLevel];

            EffectsManager    = new EffectsManager();
            UnitManager       = new UnitManager();
            WorldManager      = new WorldManager();
            ProjectileManager = new ProjectileManager();
            EnemyWaveManager  = new EnemyWaveManager();

            UpgradeManager.Load();

            UnitManager.Setup(graphics, Menu);
            WorldManager.Setup(graphics);
            EnemyWaveManager.Start();

            Camera.CenterPosition(WorldManager.PlayerEntity.Position);

            MinerResourceCounts = new Dictionary <ResourceType, int>();

            foreach (var type in WorldData.ResourceTypes)
            {
                MinerResourceCounts.Add(type, 0);
            }
        } // Load