public void PlayerInputs(float a_camVertical, float a_camHorizontal, float a_triggerAxis, bool a_faceDown, bool a_leftBumper, bool a_rightBumper, bool a_leftClick, bool a_rightClick, bool a_select)
{
// Zero input if not enabled
if (!this.isActiveAndEnabled)
{
ResetCamRotation(true);
}
else
{
// Reset camera facing
if (a_leftClick)
{
ResetCamRotation(true);
}
// Reset on accelerate only a few seconds after the last input
m_lastCamLookTime -= Time.deltaTime;
if (a_triggerAxis > 0 && m_lastCamLookTime < 0)
{
// Check for direct cam input first
ResetCamRotation(false);
}
// Record last camera movement time for when to reset the looking
if (!Mathf.Approximately(a_camHorizontal, 0) || !Mathf.Approximately(a_camVertical, 0))
{
m_lastCamLookTime = movingCamResetTime;
}
// Sample look input
m_totalVert += a_camVertical * camTurnSpeed * Time.deltaTime;
m_totalHoriz += a_camHorizontal * camTurnSpeed * Time.deltaTime;
// Clamp the total rotation values
m_totalHoriz = Mathf.Clamp(m_totalHoriz, -1.0f, 1.0f);
m_totalVert = Mathf.Clamp(m_totalVert, -1.0f, 1.0f);
// Map input to desired tilt angle
m_tiltAroundX = m_totalVert * 90.0f * horizontalTiltAnglePerc;
m_tiltAroundY = m_totalHoriz * 90.0f * verticalTiltAnglePerc;
if (invertUpDown)
{
m_tiltAroundX = -m_tiltAroundX;
}
if (invertLeftRight)
{
m_tiltAroundY = -m_tiltAroundY;
}
bool shouldFlip = a_rightClick;
// Construct the local target rotation
Vector3 playerRot = m_shipTrans.rotation.eulerAngles;
Quaternion target = Quaternion.Euler(playerRot.x + m_tiltAroundX, playerRot.y + m_tiltAroundY, 0);
EPlayerState currState = m_referenceStateManager.GetPlayerState();
if (currState == EPlayerState.Control || currState == EPlayerState.Suicide)
{
// If the view was flipped last tick, just snap
if (m_flippedViewLast && !shouldFlip)
{
m_camRotTrans.rotation = target;
}
// Smooth the camera's rotation out on control and suicide
m_camRotTrans.rotation = Quaternion.Slerp(m_camRotTrans.rotation, target, Time.deltaTime * smooth);
}
// Look behind self on right stick click
m_flippedViewLast = false;
if (shouldFlip)
{
m_camRotTrans.localRotation = Quaternion.Euler(0, -180, 0);
m_flippedViewLast = true;
}
//Invert cam on select button press
if (!a_select && a_lastSelect)
{
invertUpDown = !invertUpDown;
//a_select = !a_select;
if (announcerController != null)
{
string me = gameObject.GetComponent<FactionIndentifier>().factionName;
string myTag = gameObject.GetComponent<FactionIndentifier>().gameObject.tag;
if (invertUpDown)
{
announcerController.InvertYCam(me, myTag);
}
else
if (!invertUpDown)
{
announcerController.NormalYCam(me, myTag);
}
}
}
a_lastSelect = a_select;
}
}