Exemple #1
0
        public IEnumerator ClearMonsterSpawnCells(int fightId)
        {
            MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition;

            if (null == monsterSpawnCellDefinition)
            {
                yield break;
            }
            FightMapDefinition       definition = m_definition;
            FightMapRegionDefinition obj        = definition.regions[fightId];
            Vector2Int sizeMin         = obj.sizeMin;
            Vector2Int sizeMax         = obj.sizeMax;
            List <int> indicesToRemove = ListPool <int> .Get();

            foreach (KeyValuePair <int, GameObject> item in m_monsterSpawnCellDictionary)
            {
                int        key        = item.Key;
                Vector2Int cellCoords = definition.GetCellCoords(key);
                if (cellCoords.get_x() >= sizeMin.get_x() && cellCoords.get_y() >= sizeMin.get_y() && cellCoords.get_x() < sizeMax.get_x() && cellCoords.get_y() < sizeMax.get_y())
                {
                    Transform transform = item.Value.get_transform();
                    if (AudioManager.isReady)
                    {
                        AudioReference disappearanceSound = monsterSpawnCellDefinition.disappearanceSound;
                        if (disappearanceSound.get_isValid())
                        {
                            AudioManager.PlayOneShot(disappearanceSound, transform);
                        }
                    }
                    VisualEffect disappearanceEffect = monsterSpawnCellDefinition.disappearanceEffect;
                    if (null != disappearanceEffect)
                    {
                        Object.Instantiate <VisualEffect>(disappearanceEffect, transform.get_position(), transform.get_rotation(), transform.get_parent());
                    }
                    indicesToRemove.Add(key);
                }
            }
            int indicesToRemoveCount = indicesToRemove.Count;

            if (indicesToRemoveCount > 0)
            {
                float disappearanceDelay = monsterSpawnCellDefinition.disappearanceDelay;
                if (disappearanceDelay > 0f)
                {
                    yield return((object)new WaitForTime(disappearanceDelay));
                }
                for (int i = 0; i < indicesToRemoveCount; i++)
                {
                    int key2 = indicesToRemove[i];
                    if (m_monsterSpawnCellDictionary.TryGetValue(key2, out GameObject value))
                    {
                        monsterSpawnCellDefinition.DestroyInstance(value);
                    }
                }
            }
            ListPool <int> .Release(indicesToRemove);
        }
        protected override IEnumerator Load()
        {
            if (m_concurrentFightsCount == 1)
            {
                RuntimeData.currentKeywordContext = KeywordContext.FightSolo;
            }
            else
            {
                RuntimeData.currentKeywordContext = KeywordContext.FightMulti;
            }
            instance = this;
            int fightCount = m_concurrentFightsCount;

            if (!RuntimeData.fightDefinitions.TryGetValue(m_fightDefId, out m_fightDefinition))
            {
                Log.Error(string.Format("Could not find {0} with id {1}.", "FightDefinition", m_fightDefId), 78, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            yield return(RuntimeData.LoadTextCollectionAsync("Fight"));

            yield return(LoadSceneAndBundleRequest("FightMapWrapper", "core/scenes/maps/fight_maps"));

            Scene sceneByName = SceneManager.GetSceneByName("FightMapWrapper");

            if (!sceneByName.get_isLoaded())
            {
                Log.Error("Could not load scene named 'FightMapWrapper' from bundle 'core/scenes/maps/fight_maps'.", 93, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            yield return(LoadFightMap());

            FightMap current = FightMap.current;

            if (null == current)
            {
                Log.Error("Failed to load fight map.", 104, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            FightLogicExecutor.Initialize(fightCount);
            FightMapDefinition definition = current.definition;

            FightStatus[] array = new FightStatus[fightCount];
            for (int i = 0; i < fightCount; i++)
            {
                FightMapStatus mapStatus   = definition.CreateFightMapStatus(i);
                FightStatus    fightStatus = new FightStatus(i, mapStatus);
                if (fightStatus.fightId == m_ownFightId)
                {
                    FightStatus.local = fightStatus;
                }
                FightLogicExecutor.AddFightStatus(fightStatus);
                array[i] = fightStatus;
            }
            GameStatus.Initialize((FightType)m_fightInfo.FightType, m_fightDefinition, array);
            yield return(current.Initialize());

            VisualEffectFactory.Initialize();
            yield return(FightObjectFactory.Load());

            if (!FightObjectFactory.isReady)
            {
                yield break;
            }
            yield return(FightSpellEffectFactory.Load(fightCount));

            if (!FightSpellEffectFactory.isReady)
            {
                yield break;
            }
            yield return(FightUIFactory.Load());

            if (!FightUIFactory.isReady)
            {
                yield break;
            }
            UILoader <FightUIRework> loaderRework = new UILoader <FightUIRework>(this, "FightUIRework", "core/scenes/ui/fight");

            yield return(loaderRework.Load());

            m_uiRework = loaderRework.ui;
            m_uiRework.Init(GameStatus.fightType, m_fightDefinition);
            frame = new FightFrame
            {
                onOtherPlayerLeftFight = OnOtherPlayerLeftFight
            };
            if (m_hardResumed)
            {
                FightSnapshot snapshot = null;
                frame.onFightSnapshot = delegate(FightSnapshot fightSnapshot)
                {
                    snapshot = fightSnapshot;
                };
                frame.SendFightSnapshotRequest();
                while (snapshot == null)
                {
                    yield return(null);
                }
                frame.onFightSnapshot = null;
                yield return(ApplyFightSnapshot(snapshot));
            }
            frame.SendPlayerReady();
            while (!FightLogicExecutor.fightInitialized)
            {
                yield return(null);
            }
            yield return(uiRework.Load());
        }