IEnumerator WaitBeforeCatchUp() { yield return(new WaitForSeconds(timeBeforeCharge)); currentUpdate = CatchUpToPlayerUpdate; // determine destination if (Mathf.Abs(this.transform.position.x - player.position.x) < Mathf.Abs(this.transform.position.y - player.position.y)) { float xDistance = this.transform.position.x - player.position.x; targetDirectionFromPlayer = xDistance == 0 ? Vector3.right : Vector3.right * (this.transform.position.x - player.position.x); targetDirectionFromPlayer = targetDirectionFromPlayer.normalized; } else { float yDistance = this.transform.position.y - player.position.y; targetDirectionFromPlayer = yDistance == 0 ? Vector3.up : Vector3.up * (this.transform.position.y - player.position.y); targetDirectionFromPlayer = targetDirectionFromPlayer.normalized; } }
void BeginCatchUpToPlayer() { currentUpdate = DoNothing; StartCoroutine(WaitBeforeCatchUp()); }
void BeginShadowPlayer() { currentUpdate = ShadowPlayerUpdate; }
protected override void Init() { player = Player.Instance.transform; currentUpdate = DoNothing; BeginShadowPlayer(); }
protected override void Init() { target = Player.Instance.transform; currentUpdate = FollowPlayer; }