void Awake()
        {
            instance=this;

            spawner=gameObject.GetComponent<CollectibleSpawner>();
            spawner.spawnUponStart=false;	//disable the spawner spawnUponStart so that it only spawned when called
        }
Exemple #2
0
        void Awake()
        {
            instance = this;

            spawner = gameObject.GetComponent <CollectibleSpawner>();
            spawner.spawnUponStart = false;             //disable the spawner spawnUponStart so that it only spawned when called
        }
 void OnEnable()
 {
     dropManager=instance.gameObject.GetComponent<CollectibleDropManager>();
 }
 void OnEnable()
 {
     dropManager = instance.gameObject.GetComponent <CollectibleDropManager>();
 }
Exemple #5
0
        //for when the unit is destroy by game mechanic
        public void Destroyed(UnitPlayer player = null)
        {
            if (destroyed)
            {
                return;
            }

            //if(player==null) Debug.LogWarning("unit destroyed by not source player has been detected", null);

            destroyed = true;

            //spawn a unit if spawnUponDestroy is assigned
            if (spawnUponDestroy != null)
            {
                //loop as many as required
                for (int i = 0; i < spawnUponDestroyCount; i++)
                {
                    //instantiate the unit
                    //GameObject unitObj=(GameObject)Instantiate(spawnUponDestroy.gameObject, thisT.position, thisT.rotation);
                    GameObject unitObj = ObjectPoolManager.Spawn(spawnUponDestroy.gameObject, thisT.position, thisT.rotation);
                    unitObj.layer = thisObj.layer;

                    //pass on the wave info
                    Unit unitInstance = unitObj.GetComponent <Unit>();
                    if (waveID >= 0)
                    {
                        unitInstance.SetWaveID(spawner, waveID);
                        spawner.AddUnitToWave(unitInstance);
                    }
                    else if (spawner != null)
                    {
                        spawner.AddUnit(unitInstance);
                    }
                }
            }

            //check if the unit is going to drop any collectible
            if (useDropManager)                 //if useDropManager is enabled, inform CollectibleDropManager
            {
                CollectibleDropManager.UnitDestroyed(thisT.position);
            }
            else
            {
                //check chance and spawn the item
                if (dropObject != null && Random.value < dropChance)
                {
                    ObjectPoolManager.Spawn(dropObject.gameObject, thisT.position, Quaternion.identity);
                }
            }


            if (player != null)
            {
                //applies the bonus value for when the unit is destroyed.
                //if(valueCredits>0) GameControl.GainCredits(valueCredits);
                if (valueScore > 0)
                {
                    GameControl.GainScore(valueScore);
                }

                if (valuePerkC > 0)
                {
                    player.GainPerkCurrency(valuePerkC);
                }
                if (valueExp > 0)
                {
                    player.GainExp(valueExp);
                }
                if (valueHitPoint > 0)
                {
                    player.GainHitPoint(valueHitPoint);
                }
                if (valueEnergy > 0)
                {
                    player.GainEnergy(valueEnergy);
                }
            }

            //if(isPlayer) GetUnitPlayer().DeleteSave();

            //shake camera
            TDS.CameraShake(destroyCamShake);

            float delay = uAnimation != null?uAnimation.Destroyed() : 0;

            ClearUnit(true, delay);
        }
Exemple #6
0
 void Awake()
 {
     instance = (CollectibleDropManager)target;
     LoadDB();
 }
 void Awake()
 {
     instance = (CollectibleDropManager)target;
     LoadDB();
 }