/// <summary> /// Displays the next action /// </summary> /// <param name="action">The action to display</param> /// <param name="device">The device the player is using</param> public void SetAction(MarshLandInputAction action, InputDevice device) { ActionInput.color = new Color(1, 1, 1, 1); // display the relevant image if ((int)action < ControllerImages.Length) { ActionInput.sprite = device is Gamepad ? ControllerImages[(int)action] : KeyboardImages[(int)action]; } else { // null if not enough images ActionInput.sprite = UnknownIconImage; } _currentImage = ActionInput.sprite; }
/// <summary> /// A button has been pressed. Handle it /// </summary> /// <param name="action">The entered action</param> void InputReceived_(MarshLandInputAction action) { // if not playing yet/finished, just stop if (!_active) { return; } // if in the game, not frozen if (!_inWater) { if (_jumpScript.OnGround()) { // check for a match if (MatchesTargetAction_(action)) { Jump_(); } else { Fall_(); } } } else { // try to recover if (action == RECOVERY_ACTION) { _recoveryPressesRemaining--; if (_recoveryPressesRemaining == 0) { StartCoroutine(Recover()); } } } }
/// <summary> /// Checks if the specified input matches the first one in the list /// </summary> /// <param name="action">The entered action</param> /// <returns>Whether it is a match</returns> bool MatchesTargetAction_(MarshLandInputAction action) { return(action == _actions.First()); }
/// <summary> /// Displays the action for a player /// </summary> /// <param name="index">The player index</param> /// <param name="action">The action to display</param> public void SetAction(int index, MarshLandInputAction action) { InputDisplays[index].SetAction(action, PlayerManagerScript.Instance.GetPlayers()[index].PlayerInput.devices.FirstOrDefault()); }