예제 #1
0
        public override void Load(ContentManager Content, GraphicsDevice graphics)
        {
            _menu.Load(graphics, "GameplayMenuDefinition", "UITemplates");

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

            _currentZLevel = _zLevels.IndexOf(2.0f);
            Camera.Z       = _zLevels[_currentZLevel];

            UnitManager  = new UnitManager();
            WorldManager = new WorldManager();

            UnitManager.Setup(graphics, Camera, _menu);
            WorldManager.Setup(graphics, Camera, UnitManager);
            WorldManager.PlayerEntity.UnitManager = UnitManager;

            Camera.CenterPosition(WorldManager.PlayerEntity.Position);
        }
예제 #2
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