IEnumerator PlayDead(BaseDuckling DuckBody) { DuckBody.myAnimator.SetBool("IsShot", true); yield return(new WaitForSeconds(time)); DuckBody.myAnimator.SetBool("IsShot", false); DuckBody.StopCoroutine(PlayDead(DuckBody)); DuckBody.currentHealth = 1; DuckBody.speed = 2; DuckBody.ChangeState("fly"); DuckBody.transform.gameObject.SetActive(false); }
public override void OnUpdate(BaseDuckling duckling) { if (duckling.currentHealth <= 0) { duckling.ChangeState("dead"); } //Check if you are at target position if (duckling.transform.position.x == duckling.targets[myTarget].transform.position.x) { if (duckling.transform.position.y == duckling.targets[myTarget].transform.position.y) { //if so then go to new target posiiton myTarget = Random.Range(0, duckling.targets.Count); } } //move towards your current target if you are not dead currentTarget = new Vector2(duckling.targets[myTarget].transform.position.x, duckling.targets[myTarget].transform.position.y); duckling.transform.position = Vector2.MoveTowards(duckling.transform.position, currentTarget, mySpeed * Time.deltaTime); }
public override void OnEnter(BaseDuckling duckling) { duckling.StartCoroutine(PlayDead(duckling)); }
public override void OnUpdate(BaseDuckling duckling) { }
public override void OnExit(BaseDuckling duckling) { }
public override void OnExit(BaseDuckling duckling) { mySpeed = 0; }
public override void OnEnter(BaseDuckling duckling) { myTarget = Random.Range(0, duckling.targets.Count); mySpeed = duckling.speed; }
public abstract void OnExit(BaseDuckling duckling);
public abstract void OnUpdate(BaseDuckling duckling);
public abstract void OnEnter(BaseDuckling duckling);