コード例 #1
0
        public void CleanUp()
        {
            LightMap?.Dispose();
            LightMap = null;

            ScreenCopy?.Dispose();
            ScreenCopy = null;

            LightingShader = null;
            LightMask      = null;

            BattleDarkness = null;

            Initialized = false;
        }
コード例 #2
0
        /// <summary>
        /// Initializes the LightingManager.
        /// </summary>
        /// <param name="battleDarkness">The battle darkness object.</param>
        /// <param name="lightingShader">The shader to use for the lighting.</param>
        /// <param name="lightMask">A Texture2D representing the light.</param>
        public void Initialize(BattleDarknessObj battleDarkness, Effect lightingShader, Texture2D lightMask)
        {
            if (Initialized == true)
            {
                Debug.LogError($"The {nameof(LightingManager)} has already been initialized! To reset it, clean it up first");
                return;
            }

            BattleDarkness = battleDarkness;
            LightMap       = new RenderTarget2D(SpriteRenderer.Instance.graphicsDeviceManager.GraphicsDevice, RenderingGlobals.BaseResolutionWidth, RenderingGlobals.BaseResolutionHeight);
            ScreenCopy     = new RenderTarget2D(SpriteRenderer.Instance.graphicsDeviceManager.GraphicsDevice, RenderingGlobals.BaseResolutionWidth, RenderingGlobals.BaseResolutionHeight);

            LightingShader = lightingShader;
            LightMask      = lightMask;

            Initialized = true;
        }
コード例 #3
0
 public LightingManager(BattleDarknessObj battleDarkness, Effect lightingShader, Texture2D lightMask)
 {
     Initialize(battleDarkness, lightingShader, lightMask);
 }
コード例 #4
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();
        }