// private Vector3 pursue() { // Vector3 desired_velocity = target.position - self.transform.position; // float distance = Vector3.Distance(target.position, self.transform.position); // float centerDistance = Vector3.Distance(self.centerPoint.transform.position, self.transform.position); // desired_velocity = Vector3.Normalize(desired_velocity) * self.maxAttackVelocity - selfRigidbody.velocity; // // if (checkAttackDelegate(distance, self.hp, self.anim, transform)) { // desired_velocity = Vector3.zero; // float addtime = (self.anim.GetCurrentAnimatorStateInfo(0).length < 1) ? self.anim.GetCurrentAnimatorStateInfo(0).length : 1; // attackPeriod = Time.time + addtime; // // //When outside territory range, back to search mode // } else if (centerDistance >= self.centerPoint.territoryRange && distance > 6) { // self.changeState(gameObject.AddComponent<EnemyFSM.Search>()); // } else { // if (Time.time > attackPeriod) { // transform.Translate(Vector3.forward * self.maxAttackVelocity * Time.deltaTime); // } // self.anim.SetBool("Attack", false); // } // // self.anim.SetFloat("Speed", desired_velocity.magnitude); // return desired_velocity; // } //Check if attack is available private void attackHandler(string type) { Debug.Log(type); switch (type) { case "Monkey": EnemyFSM.AttackMode.Both both = new EnemyFSM.AttackMode.Both(); //both.mParticleEffect = gameObject.GetComponentsInChildren<ParticleSystem>(); checkAttackDelegate = both.checkCanAttack; break; case "Triangle": EnemyFSM.AttackMode.TriangleHead triangle = new EnemyFSM.AttackMode.TriangleHead(); checkAttackDelegate = triangle.checkCanAttack; break; default : checkAttackDelegate = new EnemyFSM.AttackMode.Melee().checkCanAttack; break; } }
// private Vector3 pursue() { // Vector3 desired_velocity = target.position - self.transform.position; // float distance = Vector3.Distance(target.position, self.transform.position); // float centerDistance = Vector3.Distance(self.centerPoint.transform.position, self.transform.position); // desired_velocity = Vector3.Normalize(desired_velocity) * self.maxAttackVelocity - selfRigidbody.velocity; // // if (checkAttackDelegate(distance, self.hp, self.anim, transform)) { // desired_velocity = Vector3.zero; // float addtime = (self.anim.GetCurrentAnimatorStateInfo(0).length < 1) ? self.anim.GetCurrentAnimatorStateInfo(0).length : 1; // attackPeriod = Time.time + addtime; // // //When outside territory range, back to search mode // } else if (centerDistance >= self.centerPoint.territoryRange && distance > 6) { // self.changeState(gameObject.AddComponent<EnemyFSM.Search>()); // } else { // if (Time.time > attackPeriod) { // transform.Translate(Vector3.forward * self.maxAttackVelocity * Time.deltaTime); // } // self.anim.SetBool("Attack", false); // } // // self.anim.SetFloat("Speed", desired_velocity.magnitude); // return desired_velocity; // } //Check if attack is available private void attackHandler(string type) { Debug.Log(type); switch (type) { case "Monkey": EnemyFSM.AttackMode.Both both = new EnemyFSM.AttackMode.Both(); //both.mParticleEffect = gameObject.GetComponentsInChildren<ParticleSystem>(); checkAttackDelegate = both.checkCanAttack; break; case "Triangle": EnemyFSM.AttackMode.TriangleHead triangle = new EnemyFSM.AttackMode.TriangleHead(); checkAttackDelegate = triangle.checkCanAttack; break; default: checkAttackDelegate = new EnemyFSM.AttackMode.Melee().checkCanAttack; break; } }