public override InputEvents ReadInput(InputReferences inputReference) { if (inputReference != null){ string buttonName = inputReference.inputButtonName; string joystickAxisName = inputReference.joystickAxisName; if( inputReference.inputType == InputType.HorizontalAxis || inputReference.inputType == InputType.VerticalAxis ){ float axis = this.getAxis(buttonName); float axisRaw = this.getAxisRaw(buttonName); if (this.inputManager && !string.IsNullOrEmpty(joystickAxisName)){ axis += this.getAxis(joystickAxisName); } if (this.inputManager && !string.IsNullOrEmpty(joystickAxisName)){ axisRaw += this.getAxisRaw(joystickAxisName); } // If we try to read the axis value as if it were a button, // it will return count as pressed if the value of the axis is not zero return new InputEvents(axis, axisRaw); }else{ return new InputEvents(this.getButton(buttonName)); } }else{ return InputEvents.Default; } }
public void AssembliesUpdated(IEnumerable <Exports.IAssembly> assemblyPaths) { var items = new List <ITaskItem>(); var excludedAssemblies = ExcludeAssemblies != null?ExcludeAssemblies.Select(x => x.ItemSpec).ToList() : new List <string>(0); var assemblies = assemblyPaths.Distinct(new PathComparer()).ToList(); foreach (var assemblyRef in assemblies) { if (excludedAssemblies.Contains(assemblyRef.AssemblyName.Name, StringComparer.OrdinalIgnoreCase)) { Log.LogMessage("Ignoring OpenWrap reference to '{0}'", assemblyRef.File.Path.FullPath); continue; } if (InputReferences.Any(x => string.Equals(x.ItemSpec, assemblyRef.AssemblyName.Name, StringComparison.OrdinalIgnoreCase))) { Log.LogMessage("OpenWrap reference to '{0}' already added", assemblyRef.File.Path.FullPath); continue; } Log.LogMessage("Adding OpenWrap reference to '{0}'", assemblyRef.File.Path.FullPath); var item = new TaskItem(assemblyRef.AssemblyName.FullName); item.SetMetadata("HintPath", assemblyRef.File.Path.FullPath); item.SetMetadata("Private", CopyLocal ? "True" : "False"); item.SetMetadata("FromOpenWrap", "True"); items.Add(item); } OutputReferences = items.ToArray(); }
public override InputEvents ReadInput(InputReferences inputReference) { if (inputReference != null) { string buttonName = inputReference.inputButtonName; string axisName = inputReference.joystickAxisName; if ( inputReference.inputType == InputType.HorizontalAxis || inputReference.inputType == InputType.VerticalAxis ) { return(new InputEvents( inputSource.GetAxisRaw(rewiredPlayerId, axisName) )); } else { return(new InputEvents( inputSource.GetButton(rewiredPlayerId, buttonName) )); } } else { return(InputEvents.Default); } }
public override InputEvents ReadInput(InputReferences inputReference) { if (inputReference != null) { string buttonName = inputReference.inputButtonName; string joystickAxisName = inputReference.joystickAxisName; if ( inputReference.inputType == InputType.HorizontalAxis || inputReference.inputType == InputType.VerticalAxis ) { float axisRaw = this.getAxisRaw(buttonName); if (this.inputManager && !string.IsNullOrEmpty(joystickAxisName)) { axisRaw += this.getAxisRaw(joystickAxisName); } // If we try to read the axis value as if it were a button, // it will return count as pressed if the value of the axis is not zero return(new InputEvents(axisRaw)); } else { return(new InputEvents(this.getButton(buttonName))); } } else { return(InputEvents.Default); } }
protected virtual void SendNetworkPackage() { int count = this.inputBuffer.Count; FrameInput[] buffer = new FrameInput[count]; for (int i = 0; i < count; ++i) { float horizontalAxis = 0f; float horizontalAxisRaw = 0f; float verticalAxis = 0f; float verticalAxisRaw = 0f; NetworkButtonPress buttons = NetworkButtonPress.None; foreach (KeyValuePair <InputReferences, InputEvents> pair in this.inputBuffer[i]) { InputReferences inputReference = pair.Key; InputEvents inputEvent = pair.Value; if (inputReference.inputType == InputType.HorizontalAxis) { horizontalAxis = inputEvent.axis; horizontalAxisRaw = inputEvent.axisRaw; } else if (inputReference.inputType == InputType.VerticalAxis) { verticalAxis = inputEvent.axis; verticalAxisRaw = inputEvent.axisRaw; } else if (inputReference.inputType == InputType.Button && inputEvent.button) { buttons |= inputReference.engineRelatedButton.ToNetworkButtonPress(); } } buffer[i] = new FrameInput( horizontalAxis, horizontalAxisRaw, verticalAxis, verticalAxisRaw, buttons, this.optionSelections[i] == null ? -2 : this.optionSelections[i].Value ); } InputBufferMessage msg = new InputBufferMessage(this.player, this.currentFrame, buffer); if (UFE.config.networkOptions.fakeNetwork) { RemotePlayerController remoteController = UFE.GetController(UFE.GetRemotePlayer()) as RemotePlayerController; remoteController.OnMessageReceived(msg.Serialize(), new NetworkMessageInfo()); } else { UFE.multiplayerAPI.SendNetworkMessage(msg); } }
public static FrameInput ToFrameInput(this Dictionary <InputReferences, InputEvents> inputs, sbyte?selectedOption) { Fix64 horizontalAxisRaw = 0; Fix64 verticalAxisRaw = 0; NetworkButtonPress buttons = NetworkButtonPress.None; foreach (KeyValuePair <InputReferences, InputEvents> pair in inputs) { InputReferences inputReference = pair.Key; InputEvents inputEvent = pair.Value; if (inputReference.inputType == InputType.HorizontalAxis) { horizontalAxisRaw = inputEvent.axisRaw; } else if (inputReference.inputType == InputType.VerticalAxis) { verticalAxisRaw = inputEvent.axisRaw; } else if (inputReference.inputType == InputType.Button && inputEvent.button) { NetworkButtonPress buttonPress = inputReference.engineRelatedButton.ToNetworkButtonPress(); if (UFE.config.networkOptions.networkMessageSize == NetworkMessageSize.Size8Bits) { buttonPress &= (NetworkButtonPress)((sbyte)(-1)); } else if (UFE.config.networkOptions.networkMessageSize == NetworkMessageSize.Size16Bits) { buttonPress &= (NetworkButtonPress)((short)(-1)); } buttons |= buttonPress; //buttons |= inputReference.engineRelatedButton.ToNetworkButtonPress(); } } if (UFE.config.inputOptions.forceDigitalInput) { return(new FrameInput( FPMath.Sign(horizontalAxisRaw), FPMath.Sign(verticalAxisRaw), buttons, selectedOption == null ? FrameInput.NullSelectedOption : selectedOption.Value )); } else { return(new FrameInput( horizontalAxisRaw, verticalAxisRaw, buttons, selectedOption == null ? FrameInput.NullSelectedOption : selectedOption.Value )); } }
public InputEvents GetInput(InputReferences inputReference) { InputEvents currentEvent = null; if (inputReference != null && this.inputs.TryGetValue(inputReference, out currentEvent)) { return(currentEvent); } return(null); }
public InputEvents GetPreviousInput(InputReferences inputReference) { InputEvents previousEvent = null; if (inputReference != null && this.previousInputs.TryGetValue(inputReference, out previousEvent)) { return(previousEvent); } return(null); }
public override InputEvents ReadInput(InputReferences inputReference) { InputEvents ev = base.ReadInput(inputReference); if (this.useControlFreak && inputReference.inputType != InputType.Button && Mathf.Abs(ev.axis) < this.deadZone){ return new InputEvents(0f); } return ev; }
protected InputTouchControllerBridge touchControllerBridge = null; // [DGT] #endregion #region public overriden methods public override InputEvents ReadInput(InputReferences inputReference) { InputEvents ev = base.ReadInput(inputReference); if (this.useControlFreak && inputReference.inputType != InputType.Button && Mathf.Abs((float)ev.axisRaw) < this.deadZone) { return(new InputEvents(0f)); } return(ev); }
public float GetAxisRaw(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); if (currentEvent != null) { return(currentEvent.axisRaw); } return(0f); }
public bool GetButton(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); if (currentEvent != null) { return(currentEvent.button); } return(false); }
public bool GetButtonDown(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); InputEvents previousEvent = this.GetPreviousInput(inputReference); if (currentEvent != null && previousEvent != null) { return(currentEvent.button && !previousEvent.button); } return(false); }
public override InputEvents ReadInput(InputReferences inputReference) { if ( this.behaviour != null && this.inputReferences != null && this.inputBuffer != null && this.inputBuffer.Count >= 2 ) { return(this.inputs[inputReference]); } return(InputEvents.Default); }
protected bool UseHumanController(InputReferences inputReference) { return (this.humanController != null && ( !(this.isCPU && UFE.gameRunning) || UFE.isPaused() || // Even if the character is being controlled by the CPU, // we want to listen "Start" button events from the player controller inputReference.inputType == InputType.Button && inputReference.engineRelatedButton == ButtonPress.Start )); }
// Override ReadInput so it can send the information back to UFE public override InputEvents ReadInput(InputReferences inputReference) { if (inputReference != null) { if (inputReference.inputType == InputType.HorizontalAxis) // Sends hAxis value as a Horizontal Axis Input Event { return(new InputEvents(hAxis)); } else if (inputReference.inputType == InputType.VerticalAxis) // Sends vAxis value as a Vertical Axis Input Event { return(new InputEvents(vAxis)); } else if (inputReference.inputType == InputType.Button && inputReference.engineRelatedButton == ButtonPress.Button1) // Sends Button 1 Input Event { return(new InputEvents(b1)); } else if (inputReference.inputType == InputType.Button && inputReference.engineRelatedButton == ButtonPress.Button2) // Sends Button 2 Input Event { return(new InputEvents(b2)); } } return(InputEvents.Default); }
public static string GetInputReference(InputType inputType, InputReferences[] inputReferences) { foreach(InputReferences inputReference in inputReferences){ if (inputReference.inputType == inputType) return inputReference.inputButtonName; } return null; }
public static string GetInputReference(ButtonPress button, InputReferences[] inputReferences) { foreach(InputReferences inputReference in inputReferences){ if (inputReference.engineRelatedButton == button) return inputReference.inputButtonName; } return null; }
public bool GetButton(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); if (currentEvent != null){ return currentEvent.button; } return false; }
public float GetAxisRaw(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); if (currentEvent != null){ return currentEvent.axisRaw; } return 0f; }
protected virtual void OnInput(InputReferences[] inputReferences, int player) { }
public bool GetButtonUp(InputReferences inputReference) { InputEvents currentEvent = this.GetCurrentInput(inputReference); InputEvents previousEvent = this.GetPreviousInput(inputReference); if (currentEvent != null && previousEvent != null){ return !currentEvent.button && previousEvent.button; } return false; }
public virtual void SetInput(InputReferences inputReference, InputEvents ev) { this.inputs[inputReference] = ev; }
public override InputEvents ReadInput(InputReferences inputReference) { ControlsScript self = UFE.GetControlsScript(this.player); if (self != null){ ControlsScript opponent = self.opControlsScript; if (opponent != null){ bool isOpponentDown = opponent.currentState == PossibleStates.Down; float dx = opponent.transform.position.x - self.transform.position.x; int distance = Mathf.RoundToInt(100f * Mathf.Clamp01(self.normalizedDistance)); float maxDistance = float.NegativeInfinity; AIDistanceBehaviour behaviour = null; // Try to find the correct "Distance Behaviour" // If there are several overlapping "Distance Behaviour", we choose the first in the list. foreach(AIDistanceBehaviour thisBehaviour in UFE.config.aiOptions.distanceBehaviour){ if (thisBehaviour != null){ if (distance >= thisBehaviour.proximityRangeBegins && distance <= thisBehaviour.proximityRangeEnds){ behaviour = thisBehaviour; break; } if (thisBehaviour.proximityRangeEnds > maxDistance){ maxDistance = thisBehaviour.proximityRangeEnds; } } } // If we don't find the correct "Distance Behaviour", make our best effort... if (behaviour == null){ foreach(AIDistanceBehaviour thisBehaviour in UFE.config.aiOptions.distanceBehaviour){ if (thisBehaviour != null && thisBehaviour.proximityRangeEnds == maxDistance){ behaviour = thisBehaviour; } } } if (behaviour == null){ return InputEvents.Default; }else if (inputReference.inputType == InputType.HorizontalAxis) { float axis = 0f; if (UFE.config.aiOptions.moveWhenEnemyIsDown || !isOpponentDown){ axis = Mathf.Sign(dx) * ( (Random.Range (0f, 1f) < behaviour.movingForwardProbability ? 1f : 0f) - (Random.Range (0f, 1f) < behaviour.movingBackProbability ? 1f : 0f) ); } return new InputEvents (axis); } else if (inputReference.inputType == InputType.VerticalAxis) { float axis = 0f; if (UFE.config.aiOptions.moveWhenEnemyIsDown || !isOpponentDown){ axis = (Random.Range (0f, 1f) < behaviour.jumpingProbability ? 1f : 0f) - (Random.Range (0f, 1f) < behaviour.movingBackProbability ? 1f : 0f); } return new InputEvents (axis); }else{ if (!UFE.config.aiOptions.attackWhenEnemyIsDown && isOpponentDown){ return InputEvents.Default; } else if (inputReference.engineRelatedButton == ButtonPress.Button1) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button2) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button3) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button4) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button5) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button6) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button7) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button8) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button9) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button10) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button11) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); } else if (inputReference.engineRelatedButton == ButtonPress.Button12) { return new InputEvents (Random.Range (0f, 1f) < behaviour.attackProbability); }else{ return InputEvents.Default; } } } } return InputEvents.Default; }
public static void CastInput(InputReferences[] inputReferences, int player) { if (UFE.OnInput != null) OnInput(inputReferences, player); }
public InputEvents GetCurrentInput(InputReferences inputReference) { InputEvents currentEvent = null; if (inputReference != null && this.inputs.TryGetValue(inputReference, out currentEvent)){ return currentEvent; } return null; }
protected bool UseHumanController(InputReferences inputReference) { return this.humanController != null && ( !(this.isCPU && UFE.gameRunning) || UFE.isPaused() || // Even if the character is being controlled by the CPU, // we want to listen "Start" button events from the player controller inputReference.inputType == InputType.Button && inputReference.engineRelatedButton == ButtonPress.Start ); }
public override InputEvents ReadInput(InputReferences inputReference) { ControlsScript self = UFE.GetControlsScript(this.player); if (self != null) { ControlsScript opponent = self.opControlsScript; if (opponent != null) { bool isOpponentDown = opponent.currentState == PossibleStates.Down; float dx = opponent.transform.position.x - self.transform.position.x; int distance = Mathf.RoundToInt(100f * Mathf.Clamp01((float)self.normalizedDistance)); float maxDistance = float.NegativeInfinity; AIDistanceBehaviour behaviour = null; // Try to find the correct "Distance Behaviour" // If there are several overlapping "Distance Behaviour", we choose the first in the list. foreach (AIDistanceBehaviour thisBehaviour in UFE.config.aiOptions.distanceBehaviour) { if (thisBehaviour != null) { if (distance >= thisBehaviour.proximityRangeBegins && distance <= thisBehaviour.proximityRangeEnds) { behaviour = thisBehaviour; break; } if (thisBehaviour.proximityRangeEnds > maxDistance) { maxDistance = thisBehaviour.proximityRangeEnds; } } } // If we don't find the correct "Distance Behaviour", make our best effort... if (behaviour == null) { foreach (AIDistanceBehaviour thisBehaviour in UFE.config.aiOptions.distanceBehaviour) { if (thisBehaviour != null && thisBehaviour.proximityRangeEnds == maxDistance) { behaviour = thisBehaviour; } } } if (behaviour == null) { return(InputEvents.Default); } else if (inputReference.inputType == InputType.HorizontalAxis) { float axis = 0f; if (UFE.config.aiOptions.moveWhenEnemyIsDown || !isOpponentDown) { axis = Mathf.Sign(dx) * ( (Random.Range(0f, 1f) < behaviour.movingForwardProbability ? 1f : 0f) - (Random.Range(0f, 1f) < behaviour.movingBackProbability ? 1f : 0f) ); } return(new InputEvents(axis)); } else if (inputReference.inputType == InputType.VerticalAxis) { float axis = 0f; if (UFE.config.aiOptions.moveWhenEnemyIsDown || !isOpponentDown) { axis = (Random.Range(0f, 1f) < behaviour.jumpingProbability ? 1f : 0f) - (Random.Range(0f, 1f) < behaviour.movingBackProbability ? 1f : 0f); } return(new InputEvents(axis)); } else { if (!UFE.config.aiOptions.attackWhenEnemyIsDown && isOpponentDown) { return(InputEvents.Default); } else if (inputReference.engineRelatedButton == ButtonPress.Button1) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button2) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button3) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button4) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button5) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button6) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button7) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button8) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button9) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button10) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button11) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else if (inputReference.engineRelatedButton == ButtonPress.Button12) { return(new InputEvents(Random.Range(0f, 1f) < behaviour.attackProbability)); } else { return(InputEvents.Default); } } } } return(InputEvents.Default); }
int CharacterMenuSelection(int selectedIndex, AbstractInputController controller, InputReferences horizontalAxis, InputReferences verticalAxis) { if (controller.GetAxisRaw(horizontalAxis) > 0){ UFE.PlaySound(moveCursorSound); if (selectedIndex == UFE.config.characters.Length - 1){ selectedIndex = 0; }else{ selectedIndex += 1; } }else if (controller.GetAxisRaw(horizontalAxis) < 0){ UFE.PlaySound(moveCursorSound); if (selectedIndex == 0){ selectedIndex = UFE.config.characters.Length - 1; }else{ selectedIndex -= 1; } } if (controller.GetAxisRaw(verticalAxis) < 0){ UFE.PlaySound(moveCursorSound); if (selectedIndex <= 3 && UFE.config.characters.Length > 4){ selectedIndex += 4; } }else if (controller.GetAxisRaw(verticalAxis) > 0){ UFE.PlaySound(moveCursorSound); if (selectedIndex > 3){ selectedIndex -= 4; } } return selectedIndex; }
void OnInput(InputReferences[] inputReferences, int player) { // Fires whenever a player presses a button if (!isRunning) return; if (inputReferences == null || inputReferences.Length == 0) return; List<Texture2D> activeIconList = new List<Texture2D>(); foreach(InputReferences inputRef in inputReferences) if (inputRef.activeIcon != null) activeIconList.Add(inputRef.activeIcon); if (player == 1){ if (activeIconList.Count > 0) player1ButtonPresses.Add(activeIconList.ToArray()); if (player1ButtonPresses.Count >= 13) player1ButtonPresses.RemoveAt(0); }else{ if (activeIconList.Count > 0) player2ButtonPresses.Add(activeIconList.ToArray()); if (player2ButtonPresses.Count >= 13) player2ButtonPresses.RemoveAt(0); } }
public override InputEvents ReadInput(InputReferences inputReference) { return InputEvents.Default; }
public InputEvents GetPreviousInput(InputReferences inputReference) { InputEvents previousEvent = null; if (inputReference != null && this.previousInputs.TryGetValue(inputReference, out previousEvent)){ return previousEvent; } return null; }
protected override void OnInput(InputReferences[] inputReferences, int player) { base.OnInput (inputReferences, player); // Fires whenever a player presses a button if( this.isRunning && inputReferences != null && inputReferences.Length > 0 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.inputInfo ){ List<Sprite> activeIconList = new List<Sprite>(); foreach(InputReferences inputRef in inputReferences){ if (inputRef != null && inputRef.activeIcon != null){ Sprite sprite = Sprite.Create( inputRef.activeIcon, new Rect(0f, 0f, inputRef.activeIcon.width, inputRef.activeIcon.height), new Vector2(0.5f * inputRef.activeIcon.width, 0.5f * inputRef.activeIcon.height) ); activeIconList.Add(sprite); } } List<List<Image>> playerButtonPresses = null; if (player == 1){ playerButtonPresses = this.player1ButtonPresses; }else if (player == 2){ playerButtonPresses = this.player2ButtonPresses; } // If we have at least one icon, show those icons if (activeIconList.Count > 0){ List<Image> images = new List<Image>(); foreach (Sprite sprite in activeIconList){ GameObject go = new GameObject("Player " + player + " - Button Press"); go.transform.parent = UFE.canvas != null ? UFE.canvas.transform : null; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; Image image = go.AddComponent<Image>(); image.sprite = sprite; images.Add(image); } playerButtonPresses.Add(images); } // If we have too many lines, remove the exceeding lines while (playerButtonPresses.Count >= 11){ foreach(Image image in playerButtonPresses[0]){ if (image != null){ GameObject.Destroy(image.gameObject); } } playerButtonPresses.RemoveAt(0); } for(int i = 0; i < playerButtonPresses.Count; ++i){ int distance = 0; foreach(Image image in playerButtonPresses[i]){ if (image != null && image.rectTransform){ float x = player == 1 ? 0f : 1f; float y = Mathf.Lerp(0.8f, 0.05f, (float)(i) / 11f); image.rectTransform.anchorMin = new Vector2(x, y); image.rectTransform.anchorMax = image.rectTransform.anchorMin; image.rectTransform.anchoredPosition = Vector2.zero; image.rectTransform.offsetMax = Vector2.zero; image.rectTransform.offsetMin = Vector2.zero; image.rectTransform.sizeDelta = new Vector2(image.preferredWidth * 200, image.preferredHeight * 200); if (player == 1){ image.rectTransform.pivot = new Vector2(0f, 0.5f); image.rectTransform.anchoredPosition = new Vector2(image.rectTransform.sizeDelta.x * distance, 0f); }else{ image.rectTransform.pivot = new Vector2(1f, 0.5f); image.rectTransform.anchoredPosition = new Vector2(-image.rectTransform.sizeDelta.x * distance, 0f); } ++distance; } } } } }
public abstract InputEvents ReadInput(InputReferences inputReference);
public virtual void Initialize(IEnumerable<InputReferences> inputs, int bufferSize) { List<InputReferences> buttonList = new List<InputReferences>(); List<InputReferences> inputList = new List<InputReferences>(); //------------------------------------------------- // We need at least a buffer of 2 positions: // + buffer[0] -------> previous Input // + buffer[1] -------> current Input // + buffer[i > 1] ---> future Inputs //------------------------------------------------- bufferSize = Mathf.Max(bufferSize, 2); this.inputBuffer = new List<Dictionary<InputReferences, InputEvents>>(); for (int i = 0; i < bufferSize; ++i){ this.inputBuffer.Add(new Dictionary<InputReferences, InputEvents>()); } if (inputs != null){ foreach (InputReferences input in inputs){ input.heldDown = 0; if (input != null){ for (int i = 0; i < bufferSize; ++i){ this.inputBuffer[i][input] = InputEvents.Default; } inputList.Add(input); if (input.inputType == InputType.HorizontalAxis){ this.horizontalAxis = input; }else if (input.inputType == InputType.VerticalAxis){ this.verticalAxis = input; }else{ buttonList.Add(input); } } } } this.inputReferences = new ReadOnlyCollection<InputReferences>(inputList); this.buttons = new ReadOnlyCollection<InputReferences>(buttonList); }
public override InputEvents ReadInput(InputReferences inputReference) { return(InputEvents.Default); }
public abstract InputEvents ReadInput(InputReferences inputReference);
public override InputEvents ReadInput(InputReferences inputReference) { if (UFE.config.aiOptions.engine == AIEngine.FuzzyAI){ if (this.inputReferences != null && this.inputBuffer != null && this.inputBuffer.Count >= 2){ return this.inputs[inputReference]; } return InputEvents.Default; }else{ return base.ReadInput(inputReference); } }
public InputEvents DoBestMove(InputReferences inputReference, string bestMove) { //Debug.Log("Trying to fire " + bestMove); //StartCoroutine(Wait(Random.Range(0,1))); ControlsScript self = UFE.GetControlsScript(this.player); if (self != null) { ControlsScript opponent = self.opControlsScript; if (opponent != null) { bool isOpponentDown = opponent.currentState == PossibleStates.Down; float dx = opponent.transform.position.x - self.transform.position.x; float axis = 0f; int distance = Mathf.RoundToInt(100f * Mathf.Clamp01(self.normalizedDistance)); if (bestMove == "Foward") { //Debug.Log("Trying to move forward"); axis = Mathf.Sign(dx) * 1f; //StartCoroutine(HoldButton(0.5f, 1.0f)); return(new InputEvents(axis)); } if (bestMove == "Backward") { axis = Mathf.Sign(dx) * 0f; return(new InputEvents(axis)); } if (bestMove == "Down") { return(new InputEvents(axis)); } if (bestMove == "Up") { axis = 1f; return(new InputEvents(axis)); } switch (inputReference.engineRelatedButton) { case ButtonPress.Button1: if (bestMove == "Button1") { //StartCoroutine(Wait(0.05F)); //Debug.Log("Waiting to fire Button1"); return(new InputEvents(true)); } break; case ButtonPress.Button2: if (bestMove == "Button2") { //StartCoroutine(Wait(0.05F)); //Debug.Log("Waiting to fire Button2"); return(new InputEvents(true)); } break; case ButtonPress.Button3: if (bestMove == "Button3") { //StartCoroutine(Wait(0.05F)); //Debug.Log("Waiting to fire Button3"); return(new InputEvents(true)); } break; case ButtonPress.Button4: if (bestMove == "Button4") { //StartCoroutine(Wait(0.05F)); //Debug.Log("Waiting to fire Button4"); return(new InputEvents(true)); } break; default: //Debug.Log("Waiting to fire Button ERR"); return(new InputEvents(true)); } } } return(InputEvents.Default); }