public virtual void AILogicHardcode() { switch (currentState) { case AI_STATE.IDLE_STATE: break; case AI_STATE.CHASE_STATE: attackDelay -= Time.deltaTime; chaseState.Update(Time.deltaTime); if (chaseState.target == null || !chaseState.target.GetComponent <BaseAI>().isAlive) { chaseState.target = AIData.Instance.GetNearestTarget(this.gameObject); } if (attackState.currArm == null) { attackState.Attack(); } attackState.animator.speed = chaseState.movementSpeed; if (chaseState.target == null || attackState.currArm == null) { break; } if (chaseState.target.transform.position.x - chaseState.attachedObject.transform.position.x > 0.0f) { chaseState.attachedObject.transform.root.localEulerAngles = new Vector3(0, 180, 0); } else { chaseState.attachedObject.transform.root.localEulerAngles = new Vector3(0, 0, 0); } if (Vector2.Distance(this.transform.root.position, chaseState.target.transform.root.position) < 2.5f) { SetState(AI_STATE.ATTACK_STATE); // Start the attack { attackState.Attack(); attackDelay = attackState.currArm.attackDelay; } } break; case AI_STATE.ATTACK_STATE: break; } }
public override void Attack() { base.Attack(); currentState = new AttackState(details); currentState.Attack(); }