Beispiel #1
0
        void SpawnSubCreep(UnitCreep prefab, float orHP = -1, float orSH = -1, float orSpd = -1, int orRscExp = -1, List <int> orRsc = null)
        {
            Vector3 dir      = (subPath[subWpIdx] - GetPos()).normalized;
            Vector3 spawnPos = GetPos() + dir * Random.Range(-.5f, .5f);

            //~ GameObject unitObj=(GameObject)Instantiate(prefab.gameObject, spawnPos, thisT.rotation);
            GameObject unitObj      = ObjectPoolManager.Spawn(prefab.gameObject, spawnPos, thisT.rotation);
            UnitCreep  unitInstance = unitObj.GetComponent <UnitCreep>();

            unitInstance.SetHP(orHP);
            unitInstance.SetSH(orSH);
            unitInstance.SetSpeed(orSpd);
            if (orRsc != null)
            {
                unitInstance.rscGainOnDestroyed = orRsc;
            }

            //~ if(orHP>0) unitInstance.SetHP(orHP);
            //~ if(orSH>0) unitInstance.SetSH(orSH);
            //~ if(orSpd>0) unitInstance.SetSpeed(orSpd);
            //~ if(orRsc!=null) unitInstance.rscGainOnDestroyed=orRsc;

            unitInstance.Init(waveIdx, path, wpIdx, subWpIdx, false, reverse, new List <Path>(prevPathList), subPath);

            SpawnManager.SubUnitSpawned(unitInstance);
            //SpawnManager.SubUnitSpawned(unitInstance, waveIdx);
        }