Example #1
0
        public void DespawnTopWave()
        {
            var wave  = _waveToDespawn;
            int index = wave.transform.GetSiblingIndex();

            _waveToDespawn = transform.childCount >= index + 2
                ? transform.GetChild(index + 1).gameObject.GetComponent <UiWave>()
                : null;

            wave.Despawn();
        }
Example #2
0
        public void SpawnWave(Wave wave, bool animate)
        {
            var uiWave = Instantiate(UiWavePrefab, transform);

            if (_waveToDespawn == null)
            {
                _waveToDespawn = uiWave;
            }

            foreach (var cluster in wave.WaveClusters)
            {
                var uiCluster = Instantiate(UiWaveClusterPrefab, uiWave.Layout);
                uiCluster.AmountIndicator.text  = cluster.Amount.ToString();
                uiCluster.ImageIndicator.sprite = cluster.Prefab.Sprite;
                uiCluster.ClusterIndicator.SetUp(cluster);
                uiCluster.ClusterIndicator.gameObject.SetActive(false);
            }
            if (animate)
            {
                uiWave.Spawn();
            }
        }