Example #1
0
        protected override IEnumerator SpawnRoutine(Vector3 startPos, Vector3 endPos)
        {
            m_IsSpawning = true;

            while (m_SpawnQueue.Count > 0)
            {
                m_CurrentTimeOnSpawn = 0f;

                var unitType = m_SpawnQueue.Dequeue();
                m_CurrentUnitToSpawn = unitType;

                float timeToSpawn = m_CurrentUnitTimeSpawn = GetUnitSpawnTime(m_CurrentUnitToSpawn);

                while (m_CurrentTimeOnSpawn < timeToSpawn)
                {
                    m_CurrentTimeOnSpawn += Time.deltaTime;
                    yield return(null);
                }

                SpawnManager.Instance.SpawnUnit(unitType, Barracks.m_UnitSpawnPoint.position,
                                                Barracks.FlagPoint);

                RemoveImageInQueue();
            }

            m_IsSpawning = false;
        }
Example #2
0
        public void SpawnUnit(TextureAssetType type, Vector3 startPos, Vector3 endPos)
        {
            var unit = PoolManager.Instance.GetPooledUnit(type, true);

            unit.transform.position = startPos;
            unit.TryGetComponent(out IUnit u);
            u.Move(endPos);
        }
Example #3
0
 public Texture this[TextureAssetType type]
 {
     get
     {
         Init();
         return(m_Dictionary[type]);
     }
 }
Example #4
0
        protected static float GetUnitSpawnTime(TextureAssetType type)
        {
            var unitTime = type switch
            {
                TextureAssetType.Builder => DataManager.Instance.SpawnData.BuilderSpawnTime,
                TextureAssetType.Solider => DataManager.Instance.SpawnData.SoldierSpawnTime,
                TextureAssetType.Horse => DataManager.Instance.SpawnData.HorseSpawnTime,
                _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
            };

            return(unitTime);
        }
    }
Example #5
0
        protected override void Spawn(TextureAssetType type)
        {
            if (i >= m_ImageQueue.Length)
            {
                Log.Message("CastleTimer.cs", "Queue is full!");
                return;
            }

            m_SpawnQueue.Enqueue(type);
            m_ImageQueue[i].texture = AllTextures.Instance.GetTexture(type);
            i++;

            if (!m_IsSpawning)
            {
                StartCoroutine(SpawnRoutine(Castle.m_UnitSpawnPoint.position, Castle.FlagPoint));
            }
        }
Example #6
0
        public Texture GetTexture(TextureAssetType type)
        {
            var tex = type switch
            {
                TextureAssetType.Builder => m_Textures[TextureAssetType.Builder],
                TextureAssetType.Solider => m_Textures[TextureAssetType.Solider],
                TextureAssetType.Horse => m_Textures[TextureAssetType.Horse],
                TextureAssetType.Castle => m_Textures[TextureAssetType.Castle],
                TextureAssetType.Barracks => m_Textures[TextureAssetType.Barracks],
                TextureAssetType.Flag => m_Textures[TextureAssetType.Flag],
                TextureAssetType.Build => m_Textures[TextureAssetType.Build],
                TextureAssetType.Back => m_Textures[TextureAssetType.Back],
                _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
            };

            return(tex);
        }
    }
Example #7
0
 protected virtual void Spawn(TextureAssetType type)
 {
 }