/// <summary> /// Swaps value of <see cref="PlayerHasFire"/> and transitions to <see cref="AlphaFleeState"/> /// </summary> /// <param name="eventInfo"> Contains information from <see cref="EventInfo"/></param> private void TorchIsLit(EventInfo eventInfo) { PlayerHasFire = !PlayerHasFire; TorchEventInfo torchInfo = (TorchEventInfo)eventInfo; if (Vector3.Distance(torchInfo.playerPosition, transform.position) < 30f && PlayerHasFire) { TransitionTo <AlphaFleeState>(); } }
/// <summary> /// Activates the torch. /// </summary> private void ToggleTorch() { if (Input.GetButton("Activate torch") && NrOfTorches > 0 && torchIsActive == false) { torchIsActive = !torchIsActive; owner.transform.GetChild(0).gameObject.SetActive(torchIsActive); TorchEventInfo tei = new TorchEventInfo { playerPosition = Position.position }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.TorchActivation, tei); } }
/// <summary> /// Depletes the torch over a set amount of time and triggers events once the timer has reached 0 or less. /// </summary> private void TorchDepletionTimer() { if (torchIsActive) { CurrentTorchDuration -= Time.deltaTime; if (CurrentTorchDuration <= 0) { NrOfTorches--; TorchDepleted td = new TorchDepleted { }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.TorchDepleted, td); torchIsActive = !torchIsActive; owner.transform.GetChild(0).gameObject.SetActive(torchIsActive); CurrentTorchDuration = TimerLifetime; TorchEventInfo tei = new TorchEventInfo { playerPosition = Position.position }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.TorchActivation, tei); } } }