using UnityEngine;
using System.Collections;
namespace Opsive.ThirdPersonController.Input
{
///
/// Acts as a common base class for Control Freak input.
///
public class ControlFreakInput : PlayerInput
{
// Internal variables
private bool m_AllowGameplayInput = true;
///
/// Assign the static variables and initialize the default values.
///
private void OnEnable()
{
s_PlayerInput = this;
}
///
/// Register for any events that the handler should be aware of.
///
private void Start()
{
EventHandler.RegisterEvent(gameObject, "OnAllowGameplayInput", AllowGameplayInput);
}
///
/// Internal method to determine if the disabled button is down.
///
/// Should the primary input be checked?
/// True if the disabled button is down.
protected override bool IsDisabledButtonDownInternal(bool primaryInput)
{
return GetButton(primaryInput ? Constants.PrimaryDisableButtonName : Constants.SecondaryDisableButtonName, true);
}
///
/// Internal method to return true if the button is being pressed.
///
/// The name of the button.
/// True of the button is being pressed.
protected override bool GetButtonInternal(string name, bool positiveAxis)
{
if (!m_AllowGameplayInput) {
return false;
}
return CFInput.GetButton(name);
}
///
/// Internal method to return true if the button was pressed this frame. Will use the joystick axis if a joystick is connected.
///
/// The name of the button.
/// If using a joystick, is the joystick axis positive?
/// True if the button is pressed this frame.
protected override bool GetButtonDownInternal(string name, bool positiveAxis)
{
if (!m_AllowGameplayInput) {
return false;
}
return CFInput.GetButtonDown(name);
}
///
/// Internal method to return true if the button was pressed this frame.
///
/// The name of the button.
/// True if the button is pressed this frame.
protected override bool GetButtonDownInternal(string name)
{
return CFInput.GetButtonDown(name);
}
///
/// Internal method to return true if the button is up.
///
/// The name of the button.
/// Should the input be using the joystick if connected?
/// True if the button is up.
protected override bool GetButtonUpInternal(string name, bool useJoystickAxis)
{
return CFInput.GetButtonUp(name);
}
///
/// Internal method to return true if a double tap occurred.
///
/// True if a double tap occurred.
protected override bool GetDoublePressInternal()
{
if (UnityEngine.Input.touchCount == 0) {
return false;
}
var touch = UnityEngine.Input.touches[0];
return touch.tapCount == 2;
}
///
/// Internal method to return the value of the axis with the specified name.
///
/// The name of the axis.
/// The value of the axis.
protected override float GetAxisInternal(string name)
{
return CFInput.GetAxis(name);
}
///
/// Internal method to return the value of the raw axis with the specified name.
///
/// The name of the axis.
/// The value of the raw axis.
protected override float GetAxisRawInternal(string name)
{
return CFInput.GetAxisRaw(name);
}
///
/// Should the mouse be used?
///
/// True if the mouse should be used.
protected bool UseMouseInternal()
{
return false;
}
///
/// Internal method to return the position of the mouse.
///
/// The mouse position.
protected override Vector2 GetMousePositionInternal()
{
return CFInput.mousePosition;
}
///
/// Is gameplay input allowed? An example of when it will not be allowed is when there is a fullscreen UI over the main camera.
///
/// True if gameplay is allowed.
private void AllowGameplayInput(bool allow)
{
m_AllowGameplayInput = allow;
}
}
}
I corrected one of the errors but I don't understand this one.
↧