Example #1
0
        public IEnumerator EachEnemyWave(EnemyBornMsg bornMsg, int bornPointID, int bornPathID)
        {
            if (bornMsg.enemys.Count < 1)
            {
                yield break;
            }
            if (bornMsg.enemys.Count == 1)
            {
                GameObject enemy     = AssestManager.Instance.LoadEnemy(bornMsg.enemys[0].type);
                BaseEnemy  baseEnemy = enemy.GetComponent <BaseEnemy>();
                baseEnemy.PathID = bornPathID;
                for (int i = 0; i < bornMsg.enemys[0].num; i++)
                {
                    InstantiateEnemy(bornMsg.enemys[0].type, bornPointID, bornPathID);

                    Debug.Log($"1  intervalTime {bornMsg.intervalTime}");
                    yield return(new WaitForSeconds(bornMsg.intervalTime));
                }
            }
            else
            {
                for (int i = 0; i < bornMsg.enemys.Count; i++)
                {
                    EnemyDetail enemy = bornMsg.enemys[i];
                    StartCoroutine(YieldInstantiateEnemy(enemy.type, enemy.num, bornPointID, bornPathID));
                    Debug.Log($"2  intervalTime {bornMsg.intervalTime}");
                    yield return(new WaitForSeconds(bornMsg.intervalTime));
                }
            }
        }
Example #2
0
        public IEnumerator EachBornPoint(SingleWavePointMsg bornPoint)
        {
            for (int j = 0; j < bornPoint.EnemyBornMsgs.Count; j++)
            {
                if (isRest)
                {
                    yield break;
                }

                EnemyBornMsg bornMsg = bornPoint.EnemyBornMsgs[j];
                Debug.Log($"{j}  watiTime {bornMsg.waitTime}");
                EnemyMgr.Instance.EnemyBorn(bornMsg, bornPoint.pathId);
                yield return(new WaitForSeconds(bornMsg.waitTime));

//                StartCoroutine(EachEnemyWave(bornMsg, bornPoint.pointId, bornPoint.pathId));
//
//                int bornPathID = ;
//                int bornPointID = bornPoint.pointId;
//                if(bornMsg.enemys.Count < 1)
//                    yield break;
//                if (bornMsg.enemys.Count == 1)
//                {
//                    GameObject enemy = AssestMgr.Instance.LoadEnemy(bornMsg.enemys[0].type);
//                    BaseEnemy baseEnemy = enemy.GetComponent<BaseEnemy>();
//                    baseEnemy.PathID = bornPathID;
//                    for (int i = 0; i < bornMsg.enemys[0].num; i++)
//                    {
//                        InstantiateEnemy(bornMsg.enemys[0].type, bornPointID, bornPathID);
//
//                        Debug.Log($"1  intervalTime {bornMsg.intervalTime}");
//                        yield return new WaitForSeconds(bornMsg.intervalTime);
//                    }
//                }
//                else
//                {
//                    for (int i = 0; i < bornMsg.enemys.Count; i++)
//                    {
//                        EnemyDetail enemy = bornMsg.enemys[i];
//                        StartCoroutine(YieldInstantiateEnemy(enemy.type,enemy.num, bornPointID, bornPathID));
//                        Debug.Log($"2  intervalTime {bornMsg.intervalTime}");
//                        yield return new WaitForSeconds(bornMsg.intervalTime);
//                    }
//                }
            }
        }