예제 #1
0
 public override void Load(ContentManager Content, GraphicsDevice graphics)
 {
     _menu.AddMethod(StartNewGame);
     _menu.AddMethod(Settings);
     _menu.AddMethod(Exit);
     _menu.Load(graphics, "MainMenuDefinition", "UITemplates");
 }
예제 #2
0
 public override void Load(ContentManager Content, GraphicsDevice graphics)
 {
     _menu.AddMethod(UpdateMusicVolume);
     _menu.AddMethod(UpdateSFXVolume);
     _menu.AddMethod(UpdateUIVolume);
     _menu.AddMethod(BackToMenu);
     _menu.Load(graphics, "SettingsMenuDefinition", "UITemplates");
 }
예제 #3
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            _menu.AddMethod(StartNewGame);
            _menu.AddMethod(Settings);
            _menu.AddMethod(Exit);
            _menu.Load(graphics, "MainMenuDefinition", "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);
        }
예제 #4
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();
        }
예제 #5
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            _menu.AddMethod(UpdateMusicVolume);
            _menu.AddMethod(UpdateSFXVolume);
            _menu.AddMethod(UpdateUIVolume);
            _menu.AddMethod(BackToMenu);
            _menu.Load(graphics, "SettingsMenuDefinition", "UITemplates");

            ModManager.Instance.SoundManager.PlaySound("MusicMenu", (int)SoundType.Music, true);

            var musicVolume = SettingsManager.Instance.GetSetting <float>("sound", "musicvolume");
            var sfxVolume   = SettingsManager.Instance.GetSetting <float>("sound", "sfxvolume");
            var uiVolume    = SettingsManager.Instance.GetSetting <float>("sound", "uivolume");

            _menu.GetWidget <PUIWHScrollBar>("scrlMusicVolume").FValue = musicVolume;
            _menu.GetWidget <PUIWHScrollBar>("scrlSFXVolume").FValue   = sfxVolume;
            _menu.GetWidget <PUIWHScrollBar>("scrlUIVolume").FValue    = uiVolume;
        }
예제 #6
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            _menu.AddMethod(updateDifficulty);
            _menu.AddMethod(updateMusicVolume);
            _menu.AddMethod(updateSFXVolume);
            _menu.AddMethod(updateUIVolume);
            _menu.AddMethod(backToMenu);
            _menu.Load(graphics, "SettingsMenuDefinition", "UITemplates");

            var musicVolume = SettingsManager.Instance.GetSetting <float>("sound", "musicvolume");
            var sfxVolume   = SettingsManager.Instance.GetSetting <float>("sound", "sfxvolume");
            var uiVolume    = SettingsManager.Instance.GetSetting <float>("sound", "uivolume");

            _menu.GetWidget <PUIWHScrollBar>("scrlMusicVolume").FValue = musicVolume;
            _menu.GetWidget <PUIWHScrollBar>("scrlSFXVolume").FValue   = sfxVolume;
            _menu.GetWidget <PUIWHScrollBar>("scrlUIVolume").FValue    = uiVolume;

            _menu.GetWidget <PUIWHScrollBar>("scrlDifficulty").Value = Config.Difficulty;

            _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);
        }
예제 #7
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