IEnumerator spawnMobPerCore(RefMobSpawn mobSpawn) { float stage = Mathf.Min(SpawnMobLevel()-1, 100)*0.01f; int mobSpawnRepeatCount = (int)(mobSpawn.repeatCount[0] * (1f-stage) + mobSpawn.repeatCount[1] * stage); for(int r = 0; r < mobSpawnRepeatCount; ++r) { yield return new WaitForSeconds (mobSpawn.interval); if (m_champ == null) { break; } SpawnMobDescResult spawnMobDescResult = new SpawnMobDescResult(); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.melee, RefData.Instance.RefMeleeMobs, true, false); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.range, RefData.Instance.RefRangeMobs, true, false); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.boss, RefData.Instance.RefBossMobs, true, true); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.itemPandora, RefData.Instance.RefItemPandoraMobs, false, false); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.itemDummy, RefData.Instance.RefItemDummyMobs, false, false); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.miniBoss, RefData.Instance.RefMiniBossMobs, true, false); buildSpawnMob(spawnMobDescResult, mobSpawn.refMobIds.skilled, RefData.Instance.RefSkilledMobs, false, false); Vector3 cp = m_champ.transform.position; for(int ii = 0; ii < spawnMobDescResult.spawnMobs.Count; ++ii) { for(int i = 0; i < spawnMobDescResult.spawnMobCount[ii]; ++i) { RefMob refMob = spawnMobDescResult.spawnMobs[ii]; Vector3 enemyPos = cp; float[] angles = {0f, 3.14f}; float angle = 0f; float length = 8f; /* switch(m_goalPointIndex) { case 0: angle = 0f; length = 12; if (m_champ != null) m_champ.m_creatureProperty.AttackRange=2; break; case 5: angle = 3.14f; length = 12; if (m_champ != null) m_champ.m_creatureProperty.AttackRange=2; break; default: angle = angles[Random.Range(0, angles.Length)]; if (m_champ != null) m_champ.m_creatureProperty.AttackRange=0; break; } */ if (isLeftToRight()) { angle = 0f; length = 12; if (m_champ != null) m_champ.m_creatureProperty.AttackRange=2; } else { angle = 3.14f; length = 12; if (m_champ != null) m_champ.m_creatureProperty.AttackRange=2; } if (refMob.baseCreatureProperty.moveSpeed > 0f && refMob.nearByChampOnSpawn == false) { enemyPos.x += Mathf.Cos(angle) * length; enemyPos.z += Mathf.Sin(angle) * length; } else { enemyPos.x += Mathf.Cos(angle) * 4f; enemyPos.z += Mathf.Sin(angle) * 4f; } yield return new WaitForSeconds (0.1f); Creature cre = SpawnMob(refMob, SpawnMobLevel(), enemyPos, spawnMobDescResult.spawnMobBoss[ii], spawnMobDescResult.spawnMobMonitored[ii]); cre.gameObject.SetActive(false); switch(spawnMobDescResult.spawnEffectType[ii]) { case MobSpawnEffectType.Falling: StartCoroutine( EffectSpawnMob1(cre.transform.position, cre) ); break; default: StartCoroutine( EffectSpawnMob(cre.transform.position, cre) ); break; } } } } }
void buildSpawnMob(SpawnMobDescResult result, RefMobSpawnRatio.Desc spawnRatioDesc, RefMob[] mobs, bool monitoredDeath, bool boss) { if (spawnRatioDesc == null) return; if (spawnRatioDesc.chance < Random.Range(0f, 1f)) return; float progress = ProgressStage(); int minIndex = 0; int maxIndex = Mathf.Min((int)progress, mobs.Length-1); //Debug.Log("min:" + minIndex + ", max:" + maxIndex + ", progress:" + progress); minIndex = Mathf.Clamp(minIndex, 0, mobs.Length-1); int mobCount = (int)(spawnRatioDesc.count[0]); int mobLength = spawnRatioDesc.count[1]-spawnRatioDesc.count[0]; int stage = GetStage()-1; if (boss == true) { if (stage < RefData.Instance.RefBossMobs.Length) { result.spawnMobs.Add(mobs[maxIndex]); } else { result.spawnMobs.Add(mobs[Random.Range(minIndex, maxIndex+1)]); mobCount += Mathf.Min(mobLength, stage/(m_refWorldMap.waves.Length*RefData.Instance.RefBossMobs.Length)); } } else { result.spawnMobs.Add(mobs[Random.Range(minIndex, maxIndex+1)]); mobCount += Mathf.Min(mobLength, stage/(m_refWorldMap.waves.Length*RefData.Instance.RefBossMobs.Length)); } result.spawnMobCount.Add(mobCount); result.spawnMobMonitored.Add(monitoredDeath); result.spawnMobBoss.Add(boss); result.spawnEffectType.Add(spawnRatioDesc.spawnEffectType); }