void OnTriggerExit2D(Collider2D col) { if (col.gameObject.GetComponent <AttackableTarget>()) { state = State.Moving; } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.GetComponent <AttackableTarget>() != null && state != State.Attacking) { attackTarget = col.gameObject.GetComponent <AttackableTarget>(); state = State.Attacking; } }
private void hitTarget() { if (attackTarget != null) { if (timeLeftBeforeHit <= 0) { attackTarget.hitTarget(attackPower); timeLeftBeforeHit = timeBetweenHits; if (!attackTarget.alive) { state = State.Idle; attackTarget = null; } } else { timeLeftBeforeHit -= Time.deltaTime; } } }
//public bool reachedDestination; // Start is called before the first frame update void Start() { timeLeftBeforeHit = timeBetweenHits; state = Creature.State.Idle; }