Esempio n. 1
0
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// game-specific content.
        /// </summary>
        protected override void UnloadContent()
        {
            graphics.PreparingDeviceSettings -= OnPreparingDeviceSettings;

            lightingManager?.CleanUp();
            lightingManager = null;

            battleManager.CleanUp();
            battleManager = null;

            if (Inventory.HasInstance == true)
            {
                Inventory.Instance.CleanUp();
            }

            if (DialogueManager.HasInstance == true)
            {
                DialogueManager.Instance.CleanUp();
            }

            AssetManager.Instance.CleanUp();
            SoundManager.Instance.CleanUp();
            SpriteRenderer.Instance.CleanUp();

            crashHandler.CleanUp();

            LostFocusEvent     = null;
            RegainedFocusEvent = null;
        }
Esempio n. 2
0
        private void LoadBattle()
        {
            //Initialize core battle properties
            BattleGlobals.BattleProperties battleProperties = new BattleGlobals.BattleProperties(BattleGlobals.BattleSettings.Normal, true);

            BattleMario mario = new BattleMario(new MarioStats(1, 10, 5, 0, 0,
                                                               EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));

            List <BattleEntity> enemyList = new List <BattleEntity>();

            //Clean up any previous references we may have
            lightingManager?.CleanUp();
            lightingManager = null;

            battleManager?.CleanUp();
            battleManager = null;

            if (Inventory.HasInstance == true)
            {
                Inventory.Instance.CleanUp();
            }

            if (DialogueManager.HasInstance == true)
            {
                DialogueManager.Instance.CleanUp();
            }

            //Read from the config
            //First check if the config is in the same folder as the executable
            if (ConfigLoader.LoadConfig($"{ContentGlobals.ConfigName}", ref battleProperties, mario, enemyList) == false)
            {
                //If it's not here, check in the root of the Content folder
                if (ConfigLoader.LoadConfig($"{ContentGlobals.ContentRoot}/{ContentGlobals.ConfigName}", ref battleProperties, mario, enemyList) == false)
                {
                    //If we failed to read from the config, initialize a default battle
                    InitDefaultBattle(mario, enemyList);
                }
            }

            //Initialize the BattleManager
            battleManager = new BattleManager();

            //Send out the first Partner to battle, provided it exists
            int           partnerCount = Inventory.Instance.partnerInventory.GetPartnerCount();
            BattlePartner partner      = (partnerCount == 0) ? null : Inventory.Instance.partnerInventory.GetAllPartners()[0];

            battleManager.Initialize(battleProperties, mario, partner, enemyList);

            //Initialize helper objects
            //Check for the battle setting and add darkness if so
            if (battleManager.Properties.BattleSetting == BattleGlobals.BattleSettings.Dark)
            {
                BattleDarknessObj battleDarkness = new BattleDarknessObj(battleManager);

                //Initialize the lighting manager for dark battles
                lightingManager = new LightingManager(battleDarkness,
                                                      AssetManager.Instance.LoadAsset <Effect>($"{ContentGlobals.ShaderRoot}Lighting"),
                                                      AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.ShaderTextureRoot}LightMask.png"));

                battleManager.battleObjManager.AddBattleObject(battleDarkness);
            }

            //Add the HP bar manager
            battleManager.battleObjManager.AddBattleObject(new HPBarManagerObj(battleManager));

            //If you can't run from battle, show a message at the start saying so
            if (battleManager.Properties.Runnable == false)
            {
                battleManager.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Message,
                                                                  new BattleGlobals.BattleState[] { BattleGlobals.BattleState.Turn },
                                                                  new MessageBattleEvent(battleManager.battleUIManager, BattleGlobals.NoRunMessage, MessageBattleEvent.DefaultWaitDuration));
            }

            //Start the battle
            battleManager.StartBattle();
        }