// ------------------------------------------------------------------ // 偕同程序 IEnumerator Creater() { while (SysMain.pthis.bIsGaming) { // 計算要出的敵人佇列. List <int> ListEnemy = new List <int>(); ListEnemyCreater(ListEnemy); // 計算等待間隔. yield return(new WaitForSeconds(Random.Range(GameDefine.iMinWaitSec, GameDefine.iMaxWaitSec))); for (int i = 0; i < ListEnemy.Count; i++) { DBFMonster DBFData = GameDBF.GetMonster(ListEnemy[i]) as DBFMonster; // 如果是擋路怪要生在路上. if ((ENUM_ModeMonster)DBFData.Mode == ENUM_ModeMonster.NoMove) { CreateByRoad(ListEnemy[i]); } // 魅惑怪需要生在路附近. else if ((ENUM_ModeMonster)DBFData.Mode == ENUM_ModeMonster.Bewitch) { CreateByStandOutRoad(ListEnemy[i], 7, 15); } else { CreateByNormal(ListEnemy[i]); } yield return(new WaitForSeconds(0.05f)); } } }
// ------------------------------------------------------------------ void Start() { DBFData = GameDBF.GetMonster(iMonster) as DBFMonster; SysMain.pthis.Enemy.Add(gameObject, DBFData.Threat); if (DBFData == null) { Debug.Log("DBFMonster(" + iMonster + ") null"); return; } //if if (iHP <= 0) { iHP = DBFData.HP; } if ((ENUM_ModeMonster)DBFData.Mode == ENUM_ModeMonster.Boss) { iHP = Rule.BossHP(iHP); } PosStart = transform.position; EnemyCreater.pthis.SetAI(gameObject, (ENUM_ModeMonster)DBFData.Mode); }
// ------------------------------------------------------------------ // 敵人佇列產生函式. public void ListEnemyCreater(List <int> EnemyList) { // 先清理List. EnemyList.Clear(); if (SysMain.pthis.bIsGaming == false) { return; } // 取得可使用的怪物列表. List <int> pEnemy = Rule.MonsterList(); int iTempEnegry = iEnegry; bool bRoadblock = false; bool bSuccubus = false; while (iTempEnegry > 0) { int iEnemy = LibCSNStandard.Tool.RandomPick(pEnemy); DBFMonster DBFData = GameDBF.GetMonster(iEnemy) as DBFMonster; if (DBFData == null) { Debug.Log("DBFMonster(" + iEnemy + ") null"); return; } //if // 只產生一隻擋路怪 if ((ENUM_ModeMonster)DBFData.Mode == ENUM_ModeMonster.NoMove) { if (bRoadblock == false) { bRoadblock = true; } else { continue; } } //if // 只產生一隻魅魔 if ((ENUM_ModeMonster)DBFData.Mode == ENUM_ModeMonster.Bewitch) { if (bSuccubus == false) { bSuccubus = true; } else { continue; } } //if if (iTempEnegry > 0 && iTempEnegry <= 1) { iTempEnegry -= 1; EnemyList.Add(1); } if (iTempEnegry > 0 && iTempEnegry >= DBFData.Enegry) { iTempEnegry -= DBFData.Enegry; EnemyList.Add(iEnemy); } } }