/// <summary> /// Finds an appropriate target /// </summary> private void LookForTarget() { PlayerDriver player = PlayerDriver.Party.GetLeader(); if (player != null && this.CanSee(player.gameObject)) { this.targetPlayer = player; } }
/// <summary> /// Started as a coroutine to update the target /// </summary> /// <returns>An iterator</returns> private IEnumerator UpdateTarget() { do { if (this.targetPlayer == null) { if (Random.value < 0.2f) { this.spriteManager.FlipToDirection(!this.spriteManager.IsFacingRight); } this.LookForTarget(); } else if (!this.CanSee(this.targetPlayer.gameObject)) { this.targetPlayer = null; } yield return(new WaitForSeconds(TargetUpdateDelay)); }while (!this.defeated); }
/// <summary> /// Called by Unity to initialize the <seealso cref="RecruitablePlayer"/> whether it is active or not /// </summary> private void Awake() { this.playerDriver = this.GetComponent <PlayerDriver>(); }