Beispiel #1
0
        public override void Destroyed(bool spawnEffDestroyed = true)
        {
            path.OnCreepExit(this);

            if (spawnEffDestroyed)
            {
                effectDestroyed.Spawn(GetPos(), Quaternion.identity);
                AudioManager.PlaySound(soundDestroyed);
            }

            if (IsSupport())
            {
                SupportClearAllTarget();
            }

            if (spawnOnDestroyed != null && sodCount > 0)
            {
                float      oHP  = sodOverride.GetHP(this);
                float      oSH  = sodOverride.GetSH(this);
                float      oSpd = sodOverride.GetSpd(this);
                int        oExp = sodOverride.GetExp(this);
                List <int> oRsc = sodOverride.GetRsc(this, rscGainOnDestroyed);

                for (int i = 0; i < sodCount; i++)
                {
                    SpawnSubCreep(spawnOnDestroyed, oHP, oSH, oSpd, oExp, oRsc);
                }
            }

            ClearAllEffect();

            if (Random.value < lifeGainedOnDestroyedChance)
            {
                GameControl.GainLife(lifeGainedOnDestroyed);
            }
            RscManager.GainRsc(rscGainOnDestroyed, RscManager._GainType.CreepKilled);

            float animDuration = AnimPlayDestroyed();

            SpawnManager.CreepDestroyed(this);
            ObjectPoolManager.Unspawn(thisObj, animDuration);
            //Destroy(thisObj);
        }
Beispiel #2
0
        private void ReachDestination()
        {
            effectDestination.Spawn(GetPos(), Quaternion.identity);
            AudioManager.PlaySound(soundDestination);

            GameControl.LostLife(lifeLostOnDestination);

            if (path.loop)
            {
                wpIdx = 0;        subWpIdx = 0;
                SpawnManager.ClearCleanWaveFlag(waveIdx);

                ResetPathOffset();

                if (path.warpToStart)
                {
                    thisT.position = path.GetWP(0)[0] + pathOffsetV;
                    if (faceTravelingDir)
                    {
                        thisT.rotation = Quaternion.LookRotation(path.GetWP(1)[0] + pathOffsetV - GetPos());
                    }
                }
            }
            else
            {
                path.OnCreepExit(this);
                path = null;

                AnimPlayMove(0);
                float animDuration = AnimPlayDestination();

                SpawnManager.CreepDestroyed(this, true);
                ObjectPoolManager.Unspawn(thisObj, animDuration);
            }


            //Destroy(thisObj);
        }