/// <summary> /// Makes cows return to their normal move state. /// </summary> /// <param name="eventInfo"> contains infomation brought from <see cref="EventInfo"/></param> public void CalmTheCow(EventInfo eventInfo) { if (CurrentState.GetType() == typeof(CowFleeState)) { CalmCowEvent calmCowEventInfo = (CalmCowEvent)eventInfo; if (Vector3.Distance(calmCowEventInfo.playerPosition, transform.position) < hearingRange) { TransitionTo <CowMoveState>(); } } }
/// <summary> /// Uses different runes depending on the <see cref="CurrentRune"/> value. And enables the selection of rune. /// </summary> private void RuneKeys() { if (Input.GetButtonDown("Rune activation key") || (Input.GetAxisRaw("Rune activation axis") > 0 && XboxInputLeftTriggerNotOnCooldown == true)) { XboxInputLeftTriggerNotOnCooldown = false; owner.StartCoroutine(owner.XboxCooldown()); if (CurrentRune != null && CurrentRune.ReadyToUse() && !Source.isPlaying) { CurrentRune.Used(); switch (CurrentRune.GetRuneValue()) { case 1: AudioClip clip = StunGiantSound; Source.PlayOneShot(clip); StunGiantEventInfo sgei = new StunGiantEventInfo { playerPosition = Position.position, stunDistance = StunRange }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.StunGiant, sgei); MadeANoise(clip.length); break; case 2: CalmCowEvent cce = new CalmCowEvent { playerPosition = Position.position }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.CalmCow, cce); MadeANoise(1); break; case 3: LocateCowEventInfo lcei = new LocateCowEventInfo { playerPosition = Position.position }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.LocateCow, lcei); MadeANoise(1); break; default: break; } } } if (Input.GetButton("Change rune key") || (Input.GetAxisRaw("Change rune axis") < 0 && XboxInputDownNotOnCooldown == true)) { if (CurrentRune != null) { XboxInputDownNotOnCooldown = false; owner.StartCoroutine(owner.XboxCooldown()); int temp = CurrentRune.Index; temp++; if (temp >= RuneNumber) { temp = 0; } CurrentRune = Runes[temp]; Debug.Log("Sending change rune event with value " + CurrentRune.GetRuneValue()); ChangeRuneEventInfo crei = new ChangeRuneEventInfo { newRune = CurrentRune }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.ChangeRune, crei); } } }