Exemplo n.º 1
0
        public float CreepDestroyed()
        {
            List <int> rscGain = new List <int>();

            for (int i = 0; i < valueRscMin.Count; i++)
            {
                rscGain.Add(Random.Range(valueRscMin[i], valueRscMax[i]));
            }
            ResourceManager.GainResource(rscGain, PerkManager.GetRscCreepKilled());

            AbilityManager.GainEnergy(valueEnergyGain + (int)PerkManager.GetEnergyWaveClearedModifier());

            if (spawnUponDestroyed != null && spawnUponDestroyedCount > 0)
            {
                for (int i = 0; i < spawnUponDestroyedCount; i++)
                {
                    Vector3    posOffset = new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f));
                    GameObject obj       = ObjectPoolManager.Spawn(spawnUponDestroyed, thisT.position + posOffset, thisT.rotation);
                    UnitCreep  unit      = obj.GetComponent <UnitCreep>();

                    unit.waveID = waveID;
                    int ID = SpawnManager.AddDestroyedSpawn(unit);
                    unit.Init(path, ID, waveID, this);
                }
            }

            if (aniInstance != null)
            {
                return(aniInstance.PlayDead());
            }

            return(0);
        }
Exemplo n.º 2
0
        public override void Destroyed(float delay = 0)
        {
            if (destroyed)
            {
                return;
            }

            destroyed = true;

            List <int> rscGain = new List <int>();

            for (int i = 0; i < valueRscMin.Count; i++)
            {
                rscGain.Add(Random.Range(valueRscMin[i], valueRscMax[i]));
            }
            ResourceManager.GainResource(rscGain, PerkManager.GetRscCreepKilled());

            AbilityManager.GainEnergy(valueEnergyGain + (int)PerkManager.GetEnergyWaveClearedModifier());
            if (lifeValue > 0)
            {
                GameControl.GainLife(lifeValue);
            }

            if (spawnUponDestroyed != null && spawnUponDestroyedCount > 0)
            {
                for (int i = 0; i < spawnUponDestroyedCount; i++)
                {
                    Vector3    posOffset = new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f));
                    GameObject obj       = ObjectPoolManager.Spawn(spawnUponDestroyed.gameObject, thisT.position + posOffset, thisT.rotation);
                    UnitCreep  unit      = obj.GetComponent <UnitCreep>();

                    unit.waveID = waveID;
                    int ID = SpawnManager.AddDestroyedSpawn(unit);
                    unit.Init(path, ID, waveID, this);
                }
            }

            SpawnManager.OnUnitDestroyed(this);
            TDTK.OnUnitCreepDestroyed(this);

            base.Destroyed(PlayAnimDestroyed());
        }