Ejemplo n.º 1
0
        public UnitCreep SpawnUnit(UnitCreep creep, int waveIdx, Path path, SubWave subWave = null)
        {
            //~ GameObject unitObj=(GameObject)Instantiate(creep.gameObject, path.GetSpawnPoint(), Quaternion.identity);
            GameObject unitObj      = ObjectPoolManager.Spawn(creep.gameObject, path.GetSpawnPoint(), Quaternion.identity);
            UnitCreep  unitInstance = unitObj.GetComponent <UnitCreep>();

            unitInstance.ResetHP();
            unitInstance.ResetSH();
            unitInstance.ResetSpeed();
            unitInstance.ResetRscGainOnDestroy();

            if (subWave != null)
            {
                //if(subWave.HP>0) unitInstance.SetHP(subWave.HP);
                //if(subWave.SH>0) unitInstance.SetSH(subWave.SH);
                //if(subWave.speed>0) unitInstance.SetSpeed(subWave.speed);
                //if(subWave.overrideRscGain) unitInstance.rscGainOnDestroyed=subWave.rscGain;
                unitInstance.SetHP(subWave.HP > 0 ? subWave.HP : -1);
                unitInstance.SetSH(subWave.SH > 0 ? subWave.SH : -1);
                unitInstance.SetSpeed(subWave.speed > 0 ? subWave.speed : -1);
                unitInstance.SetRscGainOnDestroy(subWave.overrideRscGain ? subWave.rscGain : null);
            }
            else                //reset the unit value to default value
            {
                unitInstance.SetHP();
                unitInstance.SetSH();
                unitInstance.SetSpeed();
                unitInstance.SetRscGainOnDestroy(null);
            }

            unitInstance.Init(waveIdx, path);

            totalCreepCount += 1;     unitInstance.instanceID = totalCreepCount;

            return(unitInstance);
        }