IEnumerator Diswave4()//第四关 { yield return(new WaitForSeconds(4)); obj_Enemy = new Enemy_Object[10]; for (int i = 0; i < 10; i++) { obj_Enemy[i] = new Enemy_Object(); } Enemy_Dis = new NumDis[1]; Enemy_Dis[0].prefabindex = 0; Enemy_Dis[0].EnemyAmount = 10; InitialEnemy(Enemy_Dis);//生成对应敌军,即10个0号预制体 for (int i = 9; i >= 0; i--) { obj_Enemy[i].m_obj.transform.position = new Vector3(tb_Boundary.xMax - i * (tb_Boundary.xLength / 9), 0, tb_Boundary.zMax); obj_Enemy[i].m_obj.GetComponent <Done_Mover>().speed *= 1 + 0.3f * i;//第二波 把敌人速依次增加 } #region 等待进入下个波次 weave_StartFlag = 0; log("waitnext"); yield return(new WaitUntil(() => weave_StartFlag == 1)); //判断波次是否结束 log("startnext"); #endregion obj_Enemy = new Enemy_Object[12]; for (int i = 0; i < 12; i++) { obj_Enemy[i] = new Enemy_Object(); } Enemy_Dis = new NumDis[1]; Enemy_Dis[0].prefabindex = 0; Enemy_Dis[0].EnemyAmount = 11; InitialEnemy(Enemy_Dis);//生成对应敌军,即11个0号预制体 1个1号预制体 for (int i = 9; i >= 0; i--) { obj_Enemy[i].m_obj.transform.position = new Vector3(tb_Boundary.xMax - i * (tb_Boundary.xLength / 9), 0, tb_Boundary.zMax); obj_Enemy[i].m_obj.GetComponent <Done_Mover>().speed *= 3f;//第二波 11个加速陨石 } GameObject gm = Enemy_Prefab[1]; EnemyMoveControl em = gm.GetComponent <EnemyMoveControl>(); em.MovePart_LeftTop = EnemyBoundary.bd_L1; em.MovePart_RightBottom = EnemyBoundary.bd_R2; em.Movelevel = 0; em.moveSpeed = -8f; obj_Enemy[11].m_obj = Instantiate(gm, new Vector3(tb_Boundary.xMin + tb_Boundary.xLength / 2, 0, tb_Boundary.zMax), Quaternion.Euler(new Vector3(0, 0, 0))); obj_Enemy[11].Alive = 1; #region 等待进入下个波次 weave_StartFlag = 0; log("waitnext"); yield return(new WaitUntil(() => weave_StartFlag == 1)); //判断波次是否结束 log("startnext"); #endregion //显示通关面板 m_control.DisEnd(obj_config.int_NowMapLevel);//0失败 >1成功 表示通过的关卡等级 }
protected override void InitAwake() { base.InitAwake(); enemyStatus = GetComponentInChildren <EnemyController>(); gameObject.name = transform.GetInstanceID() + "-" + gameObject.name; moveControl = GetComponentInChildren <EnemyMoveControl>(); boxCol = GetComponentInChildren <BoxCollider>(); villagePoint = GameObject.Find("VillagePoint").GetComponent <Transform>(); GetComponentAniControl(); }
IEnumerator Diswave15() { int int_wave = 1; yield return(new WaitForSeconds(4)); while (true) { Debug.Log("start 15 wave"); m_control.PostNewTopMessage("第 " + int_wave + " 波"); int_wave++; int t_num = Random.Range(5, 10); obj_Enemy = new Enemy_Object[t_num]; for (int i = 0; i < t_num; i++) { obj_Enemy[i] = new Enemy_Object(); } for (int i = 0; i < t_num; i++) { GameObject gm = Enemy_Prefab[Random.Range(1, Enemy_Prefab.Length)]; EnemyMoveControl em = gm.GetComponent <EnemyMoveControl>(); EnemyBoundary.RandomBd(out em.MovePart_LeftTop, out em.MovePart_RightBottom); if (i % 2 == 0) { em.Movelevel = 0; } else { em.Movelevel = 5; } em.moveSpeed = Random.Range(-0.5f, -1f); if (i % 3 == 0) { gm.GetComponent <Done_WeaponController>().CircleNum = Random.Range(5, 10); gm.GetComponent <Done_WeaponController>().HowtoCreate = 8; } gm.GetComponent <prefabAttribute>().Setlife(80 + 20 * int_wave); gm.GetComponent <prefabAttribute>().SetAttack(10 + 5 * int_wave); em.moveSpeed = Random.Range(-4f, -2f); obj_Enemy[i].m_obj = Instantiate(gm, new Vector3(Random.Range(tb_Boundary.xMin, tb_Boundary.xMax), 0, tb_Boundary.zMax), Quaternion.Euler(new Vector3(0, 0, 0))); obj_Enemy[i].Alive = 1; } #region 等待进入下个波次 weave_StartFlag = 0; log("waitnextwave"); yield return(new WaitUntil(() => weave_StartFlag == 1)); //判断波次是否结束 log("startnextwave"); #endregion } }
protected override void InitAwake() { base.InitAwake(); prevStopPoint = transform; //enemyStatus = GetComponent<EnemyController>(); gameObject.name = transform.GetInstanceID() + "-" + gameObject.name; aniControl = GetComponentInChildren <NPCAnimationControl>(); moveControl = GetComponentInChildren <EnemyMoveControl>(); //boxCol = GetComponentInChildren<BoxCollider>(); if (aniControl != null) { aniControl.Weapon = Weapon; } else { Debug.Log("[EnemyStateControl][InitAwake]: EnemyAnimationControl is null!"); } }