Beispiel #1
0
 public IEnumerator Initialize()
 {
     if (null == m_prefab)
     {
         yield break;
     }
     m_prefabPool = new GameObjectPool(m_prefab, 8);
     if (!m_appearanceSound.get_isValid() || !AudioManager.isReady)
     {
         yield break;
     }
     if (AudioManager.TryGetDefaultBankName(m_appearanceSound, out string bankName))
     {
         AudioBankLoadRequest bankLoadRequest = AudioManager.LoadBankAsync(bankName);
         while (!bankLoadRequest.isDone)
         {
             yield return(null);
         }
         if (AssetManagerError.op_Implicit(bankLoadRequest.error) != 0)
         {
             Log.Error($"Failed to load bank named '{bankName}': {bankLoadRequest.error}", 105, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Maps\\MonsterSpawnCellDefinition.cs");
         }
         else
         {
             m_loadedAudioBank = true;
         }
     }
     else
     {
         Log.Warning($"Could not find a bank to load for event '{m_appearanceSound}'.", 113, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Maps\\MonsterSpawnCellDefinition.cs");
     }
 }
Beispiel #2
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);
        }
Beispiel #3
0
        public unsafe IEnumerator AddMonsterSpawnCell(int x, int y, Direction direction)
        {
            MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition;

            if (null == monsterSpawnCellDefinition)
            {
                yield break;
            }
            IMapDefinition mapDefinition = m_mapDefinition;
            Vector2        val           = Vector2Int.op_Implicit(mapDefinition.sizeMin);

            if ((float)x < ((IntPtr)(void *)val).x || (float)y < ((IntPtr)(void *)val).y)
            {
                yield break;
            }
            Vector2 val2 = Vector2Int.op_Implicit(mapDefinition.sizeMax);

            if ((float)x >= ((IntPtr)(void *)val2).x || (float)y >= ((IntPtr)(void *)val2).y)
            {
                yield break;
            }
            int        index      = mapDefinition.GetCellIndex(x, y);
            CellObject cellObject = m_cellObjectsByIndex[index];
            Transform  transform  = cellObject.get_transform();
            Vector3    position   = transform.get_position() + 0.5f * Vector3.get_up();
            Quaternion rotation   = Quaternion.get_identity();

            if (AudioManager.isReady)
            {
                AudioReference appearanceSound = monsterSpawnCellDefinition.appearanceSound;
                if (appearanceSound.get_isValid())
                {
                    AudioManager.PlayOneShot(appearanceSound, transform);
                }
            }
            VisualEffect appearanceEffect = monsterSpawnCellDefinition.appearanceEffect;

            if (null != appearanceEffect)
            {
                Object.Instantiate <VisualEffect>(appearanceEffect, position, rotation, transform);
                float appearanceDelay = monsterSpawnCellDefinition.appearanceDelay;
                if (appearanceDelay > 0f)
                {
                    yield return((object)new WaitForTime(appearanceDelay));
                }
            }
            GameObject val3 = monsterSpawnCellDefinition.Instantiate(position, rotation, cellObject.get_transform());

            if (!(null == val3))
            {
                val3.GetComponent <SpawnCellObject>().SetDirection(direction);
                m_monsterSpawnCellDictionary.Add(index, val3);
            }
        }
Beispiel #4
0
        public IEnumerator RemoveMonsterSpawnCell(int x, int y)
        {
            MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition;

            if (null == monsterSpawnCellDefinition)
            {
                yield break;
            }
            int cellIndex = m_mapDefinition.GetCellIndex(x, y);

            if (!m_monsterSpawnCellDictionary.TryGetValue(cellIndex, out GameObject instance))
            {
                yield break;
            }
            m_monsterSpawnCellDictionary.Remove(cellIndex);
            Transform transform = instance.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());
                float disappearanceDelay = monsterSpawnCellDefinition.disappearanceDelay;
                if (disappearanceDelay > 0f)
                {
                    yield return((object)new WaitForTime(disappearanceDelay));
                }
            }
            monsterSpawnCellDefinition.DestroyInstance(instance);
        }