protected virtual void Start() { curHealth = maxHealth; myStatusIndicator.gameObject.SetActive(false); collectibles = GameObject.Find("Collectibles"); myCollider = GetComponent <BoxCollider2D>(); myAnimator = GetComponent <Animator>(); myPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); myBoundaryScript = transform.Find("Boundary").GetComponent <EnemyBoundary>(); }
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 } }
new private void Awake() { base.Awake(); //Organizers collectibles = GameObject.Find("Collectibles"); myPlayer = GameObject.Find("Player"); //Find the player if (myPlayer != null) { playerTarget = myPlayer.transform.Find("Target"); } myBoundary = transform.parent.Find("Boundary").GetComponent <EnemyBoundary>(); myBoundaryCollider = transform.parent.Find("Boundary").GetComponent <BoxCollider2D>(); //X and Y boundaries xBoundary.x = myBoundaryCollider.bounds.center.x - myBoundaryCollider.bounds.extents.x; xBoundary.y = myBoundaryCollider.bounds.center.x + myBoundaryCollider.bounds.extents.x; yBoundary.x = myBoundaryCollider.bounds.center.y - myBoundaryCollider.bounds.extents.y; yBoundary.y = myBoundaryCollider.bounds.center.y + myBoundaryCollider.bounds.extents.y; //Status Indicator myStatusIndicator = transform.parent.transform.Find("StatusIndicator"); statusIndicatorScript = myStatusIndicator.GetComponent <StatusIndicator>(); statusIndicatorScript.offset = myStatusIndicator.position - transform.position; statusIndicatorScript.offset.x = 0; myStatusIndicator.gameObject.SetActive(false); //Spawn Particle Vector3 spawnPos = myCollider.bounds.center; Transform something = Instantiate(mySpawnParticle, spawnPos, mySpawnParticle.rotation); ParticleSystem.MainModule settings = something.GetComponent <ParticleSystem>().main; settings.startColor = deathParticleColor; }