Пример #1
0
 float CalculateWaveSpawnDuration(SubWave[] subWaveList)
 {
     float duration=0;
     foreach(SubWave subWave in subWaveList){
         float tempDuration=subWave.count*subWave.interval+subWave.delay;
         if(tempDuration>duration){
             duration=tempDuration;
         }
     }
     return duration;
 }
Пример #2
0
    SubWave CopySubWaveInfo(SubWave srcSubWave)
    {
        SubWave tempSubWave=new SubWave();

        tempSubWave.unit=srcSubWave.unit;
        tempSubWave.count=srcSubWave.count;
        tempSubWave.interval=srcSubWave.interval;
        tempSubWave.delay=srcSubWave.delay;
        tempSubWave.path=srcSubWave.path;
        tempSubWave.overrideHP=srcSubWave.overrideHP;
        tempSubWave.overrideMoveSpd=srcSubWave.overrideMoveSpd;

        return tempSubWave;
    }
Пример #3
0
    void UpdateUnit(int ID, int length)
    {
        Wave wave=spawnManager.waves[ID];

        if(length!=wave.subWaves.Length){
            if(length>wave.subWaves.Length){
                SubWave[] tempSubWaveList=new SubWave[length];

                for(int i=0; i<tempSubWaveList.Length; i++){

                    if(i<wave.subWaves.Length){
                        tempSubWaveList[i]=wave.subWaves[i];
                    }
                    else{
                        if(wave.subWaves.Length!=0)
                            tempSubWaveList[i]=CopySubWaveInfo(wave.subWaves[wave.subWaves.Length-1]);
                        else tempSubWaveList[i]=new SubWave();
                    }
                }

                spawnManager.waves[ID].subWaves=tempSubWaveList;
            }
            else{
                SubWave[] tempSubWaveList=new SubWave[length];
                //bool[] tempwaveFoldList=new bool[waveLength];

                for(int i=0; i<tempSubWaveList.Length; i++){
                    tempSubWaveList[i]=wave.subWaves[i];
                    //tempwaveFoldList[i]=waveFoldList[i];
                }

                spawnManager.waves[ID].subWaves=tempSubWaveList;
                //waveFoldList=tempwaveFoldList;
            }
        }
    }
Пример #4
0
    //actual spawning routine, responsible for spawning one type of creep only
    IEnumerator SpawnSubwave(SubWave subWave, Wave parentWave, int waveID)
    {
        yield return new WaitForSeconds(subWave.delay);
        int spawnCount=0;
        while(spawnCount<subWave.count){

            Vector3 pos;
            Quaternion rot;

            PathTD tempPath;
            if(subWave.path==null) tempPath=defaultPath;
            else tempPath=subWave.path;

            pos=tempPath.waypoints[0].position;
            rot=tempPath.waypoints[0].rotation;

            GameObject obj=ObjectPoolManager.Spawn(subWave.unit, pos, rot);
            //Unit unit=obj.GetComponent<Unit>();
            UnitCreep unit=obj.GetComponent<UnitCreep>();
            if(subWave.overrideHP>0) unit.SetFullHP(subWave.overrideHP);
            if(subWave.overrideMoveSpd>0) unit.SetMoveSpeed(subWave.overrideMoveSpd);
            unit.Init(tempPath, totalSpawnCount, waveID);

            totalSpawnCount+=1;

            parentWave.activeUnitCount+=1;

            spawnCount+=1;
            if(spawnCount==subWave.count) break;

            yield return new WaitForSeconds(subWave.interval);
        }

        subWave.spawned=true;
    }
Пример #5
0
    SubWave CopySubWaveInfo(SubWave srcSubWave)
    {
        SubWave tempSubWave=new SubWave();

        tempSubWave.unit=srcSubWave.unit;
        tempSubWave.count=srcSubWave.count;
        tempSubWave.interval=srcSubWave.interval;
        tempSubWave.delay=srcSubWave.delay;
        tempSubWave.path=srcSubWave.path;

        return tempSubWave;
    }