public void Refresh(CommandSequences parent) { float hor = Input.GetAxisRaw(parent.config.DigitalHorizontal + parent.config.PlayerSlotPrefix); float ver = Input.GetAxisRaw(parent.config.DigitalVertical + parent.config.PlayerSlotPrefix); if (hor > DeadZone) { if (ver > DeadZone) { SetDirection("↗"); } else if (ver < -DeadZone) { SetDirection("↘"); } else { SetDirection("→"); } } else if (hor < -DeadZone) { if (ver > DeadZone) { SetDirection("↖"); } else if (ver < -DeadZone) { SetDirection("↙"); } else { SetDirection("←"); } } else { if (ver > DeadZone) { SetDirection("↑"); } else if (ver < -DeadZone) { SetDirection("↓"); } else { SetDirection(""); } } //Debug.Log("Dir: " + Direction); }
public void DrawMoveOrderingOptions <T>(int i, CommandSequences comboMaster, ref T[] MovesAndTechniques, T currentMove, float XOffset = 0f, float YOffset = 0f) { //ORDERING Rect optionsRect = EditorGUILayout.GetControlRect(false, 1f); optionsRect.x += optionsRect.width - 35f + XOffset; optionsRect.y -= 42f - YOffset; optionsRect.height = 12f; optionsRect.width = 22f; if (i == 0f) { GUI.enabled = false; } else { GUI.enabled = true; } if (GUI.Button(optionsRect, "▲")) { MovesAndTechniques = LeoLuz.Utilities.ArrayUtility.Remove(MovesAndTechniques, currentMove); MovesAndTechniques = LeoLuz.Utilities.ArrayUtility.Insert(MovesAndTechniques, currentMove, i - 1); // comboMaster.Autofit(); ReloadSerializedProperties(); } optionsRect.y += 12f; if (i > MovesAndTechniques.Length - 2) { GUI.enabled = false; } else { GUI.enabled = true; } if (GUI.Button(optionsRect, "▼")) { LeoLuz.Utilities.ArrayUtility.Remove(ref MovesAndTechniques, currentMove); MovesAndTechniques = LeoLuz.Utilities.ArrayUtility.Insert(MovesAndTechniques, currentMove, i + 1); // comboMaster.Autofit(); ReloadSerializedProperties(); } GUI.enabled = true; optionsRect.x += 22f; optionsRect.y -= 12f; optionsRect.height = 24f; optionsRect.width = 22f; if (GUI.Button(optionsRect, "X")) { LeoLuz.Utilities.ArrayUtility.Remove(ref MovesAndTechniques, currentMove); // comboMaster.Autofit(); ReloadSerializedProperties(); } }
void VerifyAntecipations(CommandSequences root) { for (int i = 0; i < CommandStepsToAntecipate.Length; i++) { if (commandList[CommandStepsToAntecipate[i]].commandWerePerformedCMInput(root)) { if (commandStep.debug) { Debug.Log("<color=blue>" + commandList[CommandStepsToAntecipate[i]].RealAxisButtonName + "</color> antecipation register" + " frame:" + Time.frameCount + " time:" + Time.time.ToString("0.00")); } commandList[CommandStepsToAntecipate[i]].LastVerifiedAnticipation = Time.time; } } }
void CalculateGUILog() { GuiStr = ""; if (CompletedSequenceOnGui != -1) { GuiStr += "\n<color=#ffdd00><b>" + InputSequences[CompletedSequenceOnGui].Name + "</b>\n"; for (int ib = 0; ib < InputSequences[CompletedSequenceOnGui].commandList.Length; ib++) { GuiStr += InputSequences[CompletedSequenceOnGui].commandList[ib].RealAxisButtonName + (ib < InputSequences[CompletedSequenceOnGui].commandList.Length - 1 ? (InputSequences[CompletedSequenceOnGui].commandList[ib]._Operator == InputSequence.commandStep.Operator.Next ? " + " : InputSequences[CompletedSequenceOnGui].commandList[ib]._Operator == InputSequence.commandStep.Operator.And ? " and " : " or ") : ""); } GuiStr += "</color>"; } int mostLongSequeceCompleted = -1; for (int i = 0; i < InputSequences.Length; i++) { if (CommandSequences.SequenceIsCompleted(InputSequences[i].Name, config.Player)) { if (mostLongSequeceCompleted == -1 || InputSequences[i].commandList.Length >= InputSequences[mostLongSequeceCompleted].commandList.Length) { mostLongSequeceCompleted = i; } } if (InputSequences[i].CurrentSequenceIndex > 0) { GuiStr += "\n" + InputSequences[i].Name + "\n"; for (int ib = 0; ib < InputSequences[i].commandList.Length; ib++) { if (InputSequences[i].CurrentSequenceIndex > ib) { GuiStr += InputSequences[i].commandList[ib].RealAxisButtonName + (InputSequences[i].commandList[ib]._Operator == InputSequence.commandStep.Operator.Next? " + ": InputSequences[i].commandList[ib]._Operator == InputSequence.commandStep.Operator.And?" and ": " or "); } else { GuiStr += "<color=grey>" + InputSequences[i].commandList[ib].RealAxisButtonName + (ib < InputSequences[i].commandList.Length - 1 ? (InputSequences[i].commandList[ib]._Operator == InputSequence.commandStep.Operator.Next ? " + " : InputSequences[i].commandList[ib]._Operator == InputSequence.commandStep.Operator.And ? " and " : " or ") : "") + "</color>"; } } } } if (mostLongSequeceCompleted != -1) { CompletedSequenceOnGui = mostLongSequeceCompleted; StopAllCoroutines(); StartCoroutine(CompletedSequencesOnGUIExpireTime()); } }
public bool CheckInversions(CommandSequences root) { float Axis = axisInversion == AxisInversion.NoInvert || (axisInversion == AxisInversion.InvertRelativeToHorizontalFacing && root.FacingRight) || (axisInversion == AxisInversion.InvertRelativeToVerticalFacing && root.FacingUp) ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : -Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix); if (axisDirection == AxisDirection.PositiveOrNegative) { return(true); } else if (axisDirection == AxisDirection.Positive && Axis > 0f) { return(true); } else if (axisDirection == AxisDirection.Negative && Axis < 0f) { return(true); } return(false); }
/// <summary> /// inside this method even if it returns false it is registering and annotating the sequences so that when executing the last sequence it returns true, and then the move begins. /// </summary> public bool CommandSequenceToStartWerePerformed(CommandSequences root) { if (commandList.Length == 0) { return(true); } //Jump to first commandstep of this horizontal list //If dead line expires, reset index if (CurrentSequenceIndex > 0 && TimeOfTheLastSequencePerformed + commandList[CurrentSequenceIndex].deadline < Time.time) { CurrentSequenceIndex = 0; } ///Check if command is performed if (commandList[CurrentSequenceIndex].commandChainWerePerformedCMInput(root, commandList)) { TimeOfTheLastSequencePerformed = Time.time; if (commandList[CurrentSequenceIndex].next == -1) { CurrentSequenceIndex = 0; return(true); } else { CurrentSequenceIndex = commandList[CurrentSequenceIndex].next; VerifyAntecipations(root); return(false); } } if (CurrentSequenceIndex > 0) { VerifyAntecipations(root); } return(false); }
//Navigation variables public override void OnInspectorGUI() { comboMaster = (CommandSequences)target; Draw(); }
void DrawMoveElement(SerializedProperty currentMoveProp, CommandSequences.InputSequence currentMove, CommandSequences comboMaster) { //FIRST 4 PROPERTYS currentMoveProp.DrawChildrenLight("", "StartupType"); }
public bool commandChainWerePerformedCMInput(CommandSequences root, commandStep[] commandSteps) { if (Antecipation < 0f && Time.time < LastVerifiedAnticipation - Antecipation && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { if (debug) { Debug.Log("<color=green>ANTECIPATED " + RealAxisButtonName + " " + inputEvent + "</color>"); } LastVerifiedAnticipation = -9999f; return(true); } if (IsAbstractedDiretional) { string abstractedAxisButton = axisInversion == AxisInversion.NoInvert ? this.RealAxisButtonName : axisInversion == AxisInversion.InvertRelativeToHorizontalFacing ? root.FacingRight ? this.RealAxisButtonName : NegativeRealAxisButtonName : root.FacingUp ? this.RealAxisButtonName : NegativeRealAxisButtonName; // Debug.Log("AxisNameVerified: " + AxisName); switch (inputEvent) { case InputEvent.ButtonDown: if (root.AbstractedDirectionalInput.GetDirectionalDown(abstractedAxisButton) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonHold: if (root.AbstractedDirectionalInput.GetDirectionalHold(abstractedAxisButton) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonUp: if (root.AbstractedDirectionalInput.GetDirectionalUp(abstractedAxisButton) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonReleased: if (root.AbstractedDirectionalInput.GetDirectionalReleased(abstractedAxisButton) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; default: break; } } else { if (!IsAxis) { switch (inputEvent) { case InputEvent.ButtonDown: if (Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonHold: if (Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonUp: if (Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case InputEvent.ButtonReleased: if (!(Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix) || Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix) || Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix)) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; default: break; } } else { switch (inputEvent) { case InputEvent.Axis: float Axis = axisInversion == AxisInversion.NoInvert ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : axisInversion == AxisInversion.InvertRelativeToHorizontalFacing ? root.FacingRight ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : -Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : root.FacingUp ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : -Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix); switch (Statement) { case GreaterEqualLower.greater: if (value < Axis && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; case GreaterEqualLower.Equal: if (value == Axis && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; default: if (value > Axis && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { return(true); } break; } break; case InputEvent.ButtonDown: if (Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonHold: if (Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonUp: if (Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix) && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonReleased: float ThisAxis = Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix); if (ThisAxis < 0.5f && ThisAxis > -0.5f && (And == -1 || commandSteps[And].commandChainWerePerformedCMInput(root, commandSteps))) { if (CheckInversions(root)) { return(true); } } break; default: break; } } } if (Or == -1) { return(false); } else if (commandSteps[Or].commandChainWerePerformedCMInput(root, commandSteps)) { return(true); } return(false); }
public bool commandWerePerformedCMInput(CommandSequences root) { if (IsAbstractedDiretional) { string abstractedAxisButton = axisInversion == AxisInversion.NoInvert ? this.RealAxisButtonName : axisInversion == AxisInversion.InvertRelativeToHorizontalFacing ? root.FacingRight ? this.RealAxisButtonName : NegativeRealAxisButtonName : root.FacingUp ? this.RealAxisButtonName : NegativeRealAxisButtonName; // Debug.Log("AxisNameVerified: " + AxisName); switch (inputEvent) { case InputEvent.ButtonDown: if (root.AbstractedDirectionalInput.GetDirectionalDown(abstractedAxisButton)) { return(true); } break; case InputEvent.ButtonHold: if (root.AbstractedDirectionalInput.GetDirectionalHold(abstractedAxisButton)) { return(true); } break; case InputEvent.ButtonUp: if (root.AbstractedDirectionalInput.GetDirectionalUp(abstractedAxisButton)) { return(true); } break; case InputEvent.ButtonReleased: if (root.AbstractedDirectionalInput.GetDirectionalReleased(abstractedAxisButton)) { return(true); } break; default: break; } } else { if (!IsAxis) { switch (inputEvent) { case InputEvent.ButtonDown: if (Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix)) { return(true); } break; case InputEvent.ButtonHold: if (Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix)) { return(true); } break; case InputEvent.ButtonUp: if (Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix)) { return(true); } break; case InputEvent.ButtonReleased: if (!(Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix) || Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix) || Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix))) { return(true); } break; default: break; } } else { switch (inputEvent) { case InputEvent.Axis: float Axis = axisInversion == AxisInversion.NoInvert ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : axisInversion == AxisInversion.InvertRelativeToHorizontalFacing ? root.FacingRight ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : -Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : root.FacingUp ? Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix) : -Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix); switch (Statement) { case GreaterEqualLower.greater: if (value < Axis) { return(true); } break; case GreaterEqualLower.Equal: if (value == Axis) { return(true); } break; default: if (value > Axis) { return(true); } break; } break; case InputEvent.ButtonDown: if (Input.GetButtonDown(RealAxisButtonName + root.config.PlayerSlotPrefix)) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonHold: if (Input.GetButton(RealAxisButtonName + root.config.PlayerSlotPrefix)) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonUp: if (Input.GetButtonUp(RealAxisButtonName + root.config.PlayerSlotPrefix)) { if (CheckInversions(root)) { return(true); } } break; case InputEvent.ButtonReleased: float ThisAxis = Input.GetAxis(RealAxisButtonName + root.config.PlayerSlotPrefix); if (ThisAxis < 0.5f && ThisAxis > -0.5f) { if (CheckInversions(root)) { return(true); } } break; default: break; } } } return(false); }