public virtual void TriggerActionInput() { if (triggerAction == null || !triggerAction.gameObject.activeInHierarchy) { return; } // AutoAction if (triggerAction.inputType == vTriggerGenericAction.InputType.AutoAction && actionConditions) { TriggerActionEvents(); TriggerAnimation(); } // GetButtonDown else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonDown && actionConditions) { if (triggerAction.actionInput.GetButtonDown()) { TriggerActionEvents(); TriggerAnimation(); } } // GetDoubleButton else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetDoubleButton && actionConditions) { if (triggerAction.actionInput.GetDoubleButtonDown(triggerAction.doubleButtomTime)) { TriggerActionEvents(); TriggerAnimation(); } } // GetButtonTimer (Hold Button) else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonTimer) { if (_currentInputDelay <= 0) { var up = false; var t = 0f; // this mode will play the animation while you're holding the button if (triggerAction.playAnimationWhileHoldingButton) { TriggerActionEventsInput(); // call the OnFinishActionInput after the buttomTimer is concluded and reset player settings if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer)) { if (debugMode) { Debug.Log($"<b>GenericAction: </b>Finish Action Input "); } triggerAction.UpdateButtonTimer(0); triggerAction.OnFinishActionInput.Invoke(); ResetActionState(); ResetTriggerSettings(); } // trigger the Animation and the ActionEvents while your hold the button if (triggerAction && triggerAction.actionInput.inButtomTimer) { if (debugMode) { Debug.Log($"<b>GenericAction: </b><color=blue>Holding Input</color> "); } triggerAction.UpdateButtonTimer(t); TriggerAnimation(); } // call OnCancelActionInput if the button is released before ending the buttonTimer if (up && triggerAction) { CancelButtonTimer(); } } // this mode will play the animation after you finish holding the button else /*if (!doingAction)*/ { TriggerActionEventsInput(); // call the OnFinishActionInput after the buttomTimer is concluded and reset player settings if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer)) { if (debugMode) { Debug.Log($"<b>GenericAction: </b>Finish Action Input "); } triggerAction.UpdateButtonTimer(0); triggerAction.OnFinishActionInput.Invoke(); // destroy the triggerAction if checked with destroyAfter TriggerAnimation(); } // trigger the ActionEvents while your hold the button if (triggerAction && triggerAction.actionInput.inButtomTimer) { if (debugMode) { Debug.Log($"<b>GenericAction: </b><color=blue>Holding Input</color>"); } triggerAction.UpdateButtonTimer(t); } // call OnCancelActionInput if the button is released before ending the buttonTimer if (up && triggerAction) { CancelButtonTimer(); } } } else { _currentInputDelay -= Time.deltaTime; } } }
public virtual void TriggerActionInput() { if (triggerAction == null || !triggerAction.gameObject.activeInHierarchy) { return; } // if (canTriggerAction) { if (triggerAction.inputType == vTriggerGenericAction.InputType.AutoAction && actionConditions) { TriggerAnimation(); } else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonDown && actionConditions) { if (triggerAction.actionInput.GetButtonDown()) { TriggerAnimation(); } } else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetDoubleButton && actionConditions) { if (triggerAction.actionInput.GetDoubleButtonDown(triggerAction.doubleButtomTime)) { TriggerAnimation(); } } else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonTimer) { if (_currentInputDelay <= 0) { // this mode will animate while you press the button and call the OnEndAction once you finish pressing the button if (triggerAction.doActionWhilePressingButton) { var up = false; var t = 0f; // call the OnEndAction after the buttomTimer if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer)) { triggerAction.OnFinishActionInput.Invoke(); ResetActionState(); ResetTriggerSettings(); } // trigger the animation when you start pressing the action button if (triggerAction && triggerAction.actionInput.inButtomTimer) { triggerAction.UpdateButtonTimer(t); TriggerAnimation(); } // call OnCancelActionInput if the button is released if (up && triggerAction) { if (debugMode) { Debug.Log("Cancel Action"); } triggerAction.OnCancelActionInput.Invoke(); _currentInputDelay = triggerAction.inputDelay; triggerAction.UpdateButtonTimer(0); ResetActionState(); ResetTriggerSettings(); } } // this mode will call the animation and event only when the buttonTimer finished else { if (triggerAction.actionInput.GetButtonTimer(triggerAction.buttonTimer)) { TriggerAnimation(); if (playingAnimation) { if (debugMode) { Debug.Log("call OnFinishInput Event"); } triggerAction.OnFinishActionInput.Invoke(); } } } } else { _currentInputDelay -= Time.deltaTime; } } } }