/// <summary> /// 创建怪物编队 /// </summary> /// <param name="position">怪物出现的位置</param> /// <param name="speed">怪物的速度</param> /// <param name="size">怪物的数量</param> /// <param name="type">怪物模式</param> private void CreateOniGroup(Vector3 position, float speed, int level, GROUPTYPE type) { position.y = 1.0f; GameObject group = Instantiate(OniGroupPrefab, position, Quaternion.identity); if (group == null) { return; } int size = 1; if (level < 3) { size = level + 1; } else { size = Random.Range(6, 10); } _OniGroupControl groupControl = group.GetComponent <_OniGroupControl>(); if (groupControl == null) { return; } groupControl.CreateOnis(size, position); groupControl.runSpeed = speed; if (type == GROUPTYPE.DECELERATE) { groupControl.isDecelerate = true; } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "OniGroup") { _OniGroupControl oniGroup = collision.gameObject.GetComponent <_OniGroupControl>(); if (oniGroup.isAlive) { runSpeed = 0.0f; gameControl.OnPlayerMissed(); missAudioScource.Play(); charaAnimation.Play("P_yarare"); charaAnimation.CrossFadeQueued("P_run"); } } }
private void OnTriggerStay(Collider other) { if (!isAttacking) { return; } if (other.gameObject.tag == "OniGroup") { _OniGroupControl oniGroup = other.GetComponent <_OniGroupControl>(); if (oniGroup.isAlive) { float attackTime = Player.GetComponent <_PlayerControl>().GetAttackTimer(); // 攻击时机 int count = oniGroup.GetCount(); // 怪物数量 _GameControl.EVALUATION evaluation = gameControl.Scored(count, attackTime); // 评估得分 Player.GetComponent <_PlayerControl>().AttackTheTarget(oniGroup.transform.position); // 角色击中目标 oniGroup.OnAttackedFromPlayer(evaluation); // 怪物被击飞 } } }