コード例 #1
0
    public void SpawnAutomatic(int index = -1)
    {
        AISpawnAutomaticData auto = AISpawnAutomaticData.CreateAutomaticData(mDelay, mID);

        if (auto != null)
        {
            StartCoroutine(SpawnCoroutine(auto, index));
        }
        else
        {
            Debug.LogError("Can't fin automatic data!");
        }
    }
コード例 #2
0
    public void StopAutomatic()
    {
        mStartTime = 0.0f;
        mDelayTime = 0.0f;
        //mWaveIndex = -1;
        mSpawning         = false;
        mCurrentWave      = null;
        mCurrentAutomatic = null;

        HideAutomaticGUI();

        StopAllCoroutines();
    }
コード例 #3
0
 void FixWaveIndex()
 {
     if (mCurrentTimer != null)
     {
         AISpawnAutomaticData auto = AISpawnAutomaticData.CreateAutomaticData(0.0f, mCurrentTimer.spawnId);
         if (auto != null)
         {
             if (mCurrentTimer.currentWave == auto.data.data.Count - 1)
             {
                 if (GetComponentsInChildren <SPPointSimulate>().Length == 0)
                 {
                     mCurrentTimer.currentWave = auto.data.data.Count;
                 }
             }
         }
     }
 }
コード例 #4
0
    IEnumerator SpawnCoroutine(AISpawnAutomaticData auto, int index)
    {
        mStartTime = Time.time;
        //mWaveIndex = -1;
        mSpawning         = true;
        mCurrentWave      = null;
        mCurrentAutomatic = auto;

        mTotalCount = 0;

        ShowAutomaticGUI();

        //if (GameConfig.IsMultiMode && IsController)
        //    RPC("RPC_C2S_Start");

        OnSpawnStart();

        if (index <= -1)
        {
            mDelayTime = auto.delayTime;

            if (GameConfig.IsMultiMode && IsController)
            {
                RPCServer(EPacketType.PT_TD_Wave, mDelayTime, -1);
            }

            yield return(new WaitForSeconds(auto.delayTime));
        }

        foreach (AISpawnWaveData wave in auto.data.data)
        {
            Debug.LogWarning("wave index = " + wave.index + " : " + "index = " + index);
            if (wave.index < index)
            {
                continue;
            }

            mDelayTime = wave.delayTime;

            if (index > -1 && wave.index == index)
            {
                mDelayTime = 0.0f;
            }

            if (GameConfig.IsMultiMode && IsController)
            {
                RPCServer(EPacketType.PT_TD_Wave, mDelayTime, wave.index);
            }

            mStartTime   = Time.time;
            mCurrentWave = wave;
            //mWaveIndex = wave.index;

            yield return(new WaitForSeconds(mDelayTime));

            SpawnWave(wave);

            foreach (AISpawnData sp in wave.data.data)
            {
                int number = Random.Range(sp.minCount, sp.maxCount + 1);

                mTotalCount += number;

                for (int i = 0; i < number; i++)
                {
                    SPTerrainEvent.instance.RegisterSPPoint(Spawn(sp));

                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }

        mStartTime = 0.0f;
        mDelayTime = 0.0f;
        //mWaveIndex = -1;
        mSpawning         = false;
        mCurrentWave      = null;
        mCurrentAutomatic = null;

        HideAutomaticGUI();

        OnSpawnComplete();

        if (IsController)
        {
            RPCServer(EPacketType.PT_TD_End);
        }
    }