877 lines
26 KiB
C#
877 lines
26 KiB
C#
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using Rewired;
|
|
using UFS2.Gameplay;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class InputManager : Singleton<InputManager>
|
|
{
|
|
public struct POINT
|
|
{
|
|
public int X;
|
|
|
|
public int Y;
|
|
}
|
|
|
|
public class Keys
|
|
{
|
|
public string DesciptionLangKey;
|
|
|
|
public KeyCode key;
|
|
|
|
public KeyCode defaultkey;
|
|
}
|
|
|
|
[SerializeField]
|
|
private GameObject gamepadPopup;
|
|
|
|
public List<Keys> keysbind;
|
|
|
|
[Tooltip("Rewired Input Manager's player used for handling player's input")]
|
|
private Player player;
|
|
|
|
private bool isPaused;
|
|
|
|
private float MouseX = Screen.width / 2;
|
|
|
|
private float MouseY = Screen.height / 2;
|
|
|
|
private float deltaMouseX;
|
|
|
|
private float deltaMouseY;
|
|
|
|
private const float GamepadReelingSensitivity = 100f;
|
|
|
|
private const float GamepadDepthFloatSensitivity = 10f;
|
|
|
|
private float slowDownReeling;
|
|
|
|
private float slowDownFloat;
|
|
|
|
private const float minReelingSpeed = 1f;
|
|
|
|
private bool reelUpClicked;
|
|
|
|
private bool reelDownClicked;
|
|
|
|
public static bool isQClicked = false;
|
|
|
|
private KeyCode moveForward = KeyCode.W;
|
|
|
|
private KeyCode moveBackward = KeyCode.S;
|
|
|
|
private KeyCode moveLeft = KeyCode.A;
|
|
|
|
private KeyCode moveRight = KeyCode.D;
|
|
|
|
private KeyCode jumping = KeyCode.Space;
|
|
|
|
private KeyCode exitKey = KeyCode.Escape;
|
|
|
|
private KeyCode equipmentScene = KeyCode.I;
|
|
|
|
private KeyCode shopScene = KeyCode.F3;
|
|
|
|
private KeyCode mapScene = KeyCode.M;
|
|
|
|
private KeyCode settingsScene = KeyCode.F2;
|
|
|
|
private KeyCode helpPanel = KeyCode.F1;
|
|
|
|
private KeyCode quickHelpKey = KeyCode.Tab;
|
|
|
|
private KeyCode runKey = KeyCode.LeftShift;
|
|
|
|
private KeyCode cameraTypeViewKey = KeyCode.C;
|
|
|
|
private KeyCode cameraThirdPersonChangeSide = KeyCode.V;
|
|
|
|
private KeyCode cameraThirdPersonChangeZoomUp = KeyCode.KeypadPlus;
|
|
|
|
private KeyCode cameraThirdPersonChangeZoomDown = KeyCode.KeypadMinus;
|
|
|
|
private KeyCode showGUIKey = KeyCode.G;
|
|
|
|
private KeyCode freeCameraKey = KeyCode.F6;
|
|
|
|
private KeyCode eagleEye = KeyCode.V;
|
|
|
|
private KeyCode underwaterCameraKey = KeyCode.U;
|
|
|
|
private KeyCode underwaterMiniCameraKey = KeyCode.Y;
|
|
|
|
private KeyCode underwaterZoomUpCameraKey = KeyCode.UpArrow;
|
|
|
|
private KeyCode underwaterZoomDownCameraKey = KeyCode.DownArrow;
|
|
|
|
private KeyCode underwaterZoomFloat = KeyCode.Z;
|
|
|
|
private KeyCode showSlot0 = KeyCode.Alpha1;
|
|
|
|
private KeyCode showSlot1 = KeyCode.Alpha2;
|
|
|
|
private KeyCode showSlot2 = KeyCode.Alpha3;
|
|
|
|
private KeyCode showSlot3 = KeyCode.Alpha4;
|
|
|
|
private KeyCode showSlot4 = KeyCode.Alpha5;
|
|
|
|
private KeyCode TargetingCastButton = KeyCode.Mouse1;
|
|
|
|
private KeyCode NearCastButton = KeyCode.Mouse1;
|
|
|
|
private KeyCode FarCastButton = KeyCode.Mouse0;
|
|
|
|
private KeyCode catchButton = KeyCode.Mouse1;
|
|
|
|
private KeyCode rodPullUpButton = KeyCode.Mouse1;
|
|
|
|
private KeyCode resetCast = KeyCode.Q;
|
|
|
|
private KeyCode fingerBlockLineButton = KeyCode.Mouse0;
|
|
|
|
private KeyCode UnlockLockReelButton = KeyCode.Mouse2;
|
|
|
|
private KeyCode reelSpeedUp = KeyCode.PageUp;
|
|
|
|
private KeyCode reelSpeedDown = KeyCode.PageDown;
|
|
|
|
private KeyCode reelDragUp = KeyCode.Equals;
|
|
|
|
private KeyCode reelDragDown = KeyCode.Minus;
|
|
|
|
private KeyCode reelDragUpKeyPad = KeyCode.KeypadPlus;
|
|
|
|
private KeyCode reelDragDownKeyPad = KeyCode.KeypadMinus;
|
|
|
|
private KeyCode reelSpeedMax = KeyCode.LeftControl;
|
|
|
|
private bool isreelSpeedMaxHold;
|
|
|
|
private KeyCode getUpRod = KeyCode.E;
|
|
|
|
private KeyCode headFlashLight = KeyCode.F;
|
|
|
|
private KeyCode dropGetSupportButton = KeyCode.Mouse0;
|
|
|
|
private KeyCode cancelSupportButton = KeyCode.Mouse1;
|
|
|
|
private KeyCode floatDeepthUp = KeyCode.RightBracket;
|
|
|
|
private KeyCode floatDeepthDown = KeyCode.LeftBracket;
|
|
|
|
public static Vector2 movementAxis;
|
|
|
|
public static bool isJumping;
|
|
|
|
public static bool isCameraChange = false;
|
|
|
|
public static bool isCameraChangeViewSide = false;
|
|
|
|
public static bool isCameraChangeZoomUp = false;
|
|
|
|
public static bool isCameraChangeZoomDown = false;
|
|
|
|
public static bool isFreeCamera = false;
|
|
|
|
public static bool isUnderwaterCamera = false;
|
|
|
|
public static bool isUnderwaterCameraZoomUp = false;
|
|
|
|
public static bool isUnderwaterCameraZoomDown = false;
|
|
|
|
public static bool isUnderwaterCameraFloatZoom = false;
|
|
|
|
public static bool LT = false;
|
|
|
|
public static bool showUI = true;
|
|
|
|
public static int floatDistanceScale = 5;
|
|
|
|
public static bool underwaterCameraMini = false;
|
|
|
|
public static bool isHeadFlashLight = false;
|
|
|
|
public static bool quickHelp = false;
|
|
|
|
public static bool isEagleEye = false;
|
|
|
|
public static bool isRunning = false;
|
|
|
|
public static bool isReelReeling = false;
|
|
|
|
public static bool isReelSpeedUp = false;
|
|
|
|
public static bool isReelSpeedDown = false;
|
|
|
|
public static bool isReelSpeedMax = false;
|
|
|
|
public static bool isReelDragUp = false;
|
|
|
|
public static bool isReelDragDown = false;
|
|
|
|
public static bool isCatch = false;
|
|
|
|
public static bool isCastTargeting = false;
|
|
|
|
public static bool isCastNear = false;
|
|
|
|
public static bool isCastFar = false;
|
|
|
|
public static bool isPullUpRod = false;
|
|
|
|
public static bool isGetUpRod = false;
|
|
|
|
public static bool isCastReset = false;
|
|
|
|
public static bool isDeepthFloatUp = false;
|
|
|
|
public static bool isDeepthFloatDown = false;
|
|
|
|
public static bool isBlockLineFinger = false;
|
|
|
|
public static bool isReelUnlockLock = false;
|
|
|
|
public static bool isShowSlot0 = false;
|
|
|
|
public static bool isShowSlot1 = false;
|
|
|
|
public static bool isShowSlot2 = false;
|
|
|
|
public static bool isShowSlot3 = false;
|
|
|
|
public static bool isShowSlot4 = false;
|
|
|
|
public static bool dropGetSupport = false;
|
|
|
|
public static bool cancelSupport = false;
|
|
|
|
public static bool isEnterLeaveBoat = false;
|
|
|
|
public static bool isStartStopSteringBoat = false;
|
|
|
|
public static bool isRestartPositionBoat = false;
|
|
|
|
public static bool isOpenEquipmentScene = false;
|
|
|
|
public static bool isOpenShopScene = false;
|
|
|
|
public static bool isOpenLocationMapScene = false;
|
|
|
|
public static bool isOpenSettingsScene = false;
|
|
|
|
public static bool isOpenHelpPanel = false;
|
|
|
|
public static bool isOpenEquipmentSceneByMenu = false;
|
|
|
|
public static bool isOpenShopSceneByMenu = false;
|
|
|
|
public static bool isOpenLocationMapSceneByMenu = false;
|
|
|
|
public static bool isOpenSettingsSceneByMenu = false;
|
|
|
|
public static bool isOpenHelpPanelByMenu = false;
|
|
|
|
public static bool isExit = false;
|
|
|
|
public static bool isExitByMenu = false;
|
|
|
|
public static bool isBPressed = false;
|
|
|
|
public static bool RB = false;
|
|
|
|
private GameObject currentGamepadPopup;
|
|
|
|
public bool IsInputEnabled = true;
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern bool SetCursorPos(int X, int Y);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool GetCursorPos(out POINT lpPoint);
|
|
|
|
public void StartControllerPopUpWork()
|
|
{
|
|
ReInput.ControllerConnectedEvent += OnControllerConnected;
|
|
ReInput.ControllerDisconnectedEvent += OnControllerDisconnected;
|
|
if (player.controllers.Joysticks.Count > 0)
|
|
{
|
|
_ = player.controllers.Joysticks[0];
|
|
string message = "Gamepad connected!";
|
|
ShowGamePadPopUp(message);
|
|
}
|
|
}
|
|
|
|
private void OnControllerDisconnected(ControllerStatusChangedEventArgs args)
|
|
{
|
|
if (args.controllerType == ControllerType.Joystick)
|
|
{
|
|
string message = "Gamepad disconnected!";
|
|
ShowGamePadPopUp(message);
|
|
}
|
|
}
|
|
|
|
private void OnControllerConnected(ControllerStatusChangedEventArgs args)
|
|
{
|
|
if (args.controllerType == ControllerType.Joystick)
|
|
{
|
|
string message = "Gamepad connected!";
|
|
ShowGamePadPopUp(message);
|
|
}
|
|
}
|
|
|
|
private void ShowGamePadPopUp(string message)
|
|
{
|
|
Object.DestroyImmediate(currentGamepadPopup);
|
|
currentGamepadPopup = Object.Instantiate(gamepadPopup, (!(Object.FindObjectOfType<MainGameScene>() != null)) ? FScriptsHandler.Instance?.m_Canvas?.transform : Object.FindObjectOfType<MainGameScene>()?.transform);
|
|
currentGamepadPopup.GetComponent<GamepadPopup>().ShowGamepadPopup(message);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
player = ReInput.players.GetPlayer(0);
|
|
MouseMap mouseMapInstance = ReInput.mapping.GetMouseMapInstance(0, 0);
|
|
MouseMap mouseMapInstanceSavedOrDefault = ReInput.mapping.GetMouseMapInstanceSavedOrDefault(0, 0, 0);
|
|
KeyboardMap keyboardMapInstance = ReInput.mapping.GetKeyboardMapInstance(0, 0);
|
|
KeyboardMap keyboardMapInstanceSavedOrDefault = ReInput.mapping.GetKeyboardMapInstanceSavedOrDefault(0, 0, 0);
|
|
int num = mouseMapInstance.ButtonMaps.Count - mouseMapInstanceSavedOrDefault.ButtonMaps.Count;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
Debug.Log("Added new map: " + mouseMapInstance.ButtonMaps[mouseMapInstance.ButtonMaps.Count - 1 - i].actionDescriptiveName);
|
|
mouseMapInstanceSavedOrDefault.ButtonMaps.Add(mouseMapInstance.ButtonMaps[mouseMapInstance.ButtonMaps.Count - 1 - i]);
|
|
}
|
|
num = keyboardMapInstance.ButtonMaps.Count - keyboardMapInstanceSavedOrDefault.ButtonMaps.Count;
|
|
for (int j = 0; j < num; j++)
|
|
{
|
|
Debug.Log("Added new map: " + keyboardMapInstance.ButtonMaps[keyboardMapInstance.ButtonMaps.Count - 1 - j].actionDescriptiveName);
|
|
keyboardMapInstanceSavedOrDefault.ButtonMaps.Add(keyboardMapInstance.ButtonMaps[keyboardMapInstance.ButtonMaps.Count - 1 - j]);
|
|
}
|
|
num = mouseMapInstance.AxisMaps.Count - mouseMapInstanceSavedOrDefault.AxisMaps.Count;
|
|
for (int k = 0; k < num; k++)
|
|
{
|
|
Debug.Log("New action added: " + mouseMapInstance.AxisMaps[mouseMapInstance.AxisMaps.Count - 1 - k].actionDescriptiveName);
|
|
mouseMapInstanceSavedOrDefault.AxisMaps.Add(mouseMapInstance.ButtonMaps[mouseMapInstance.ButtonMaps.Count - 1 - k]);
|
|
}
|
|
ReInput.userDataStore.Save();
|
|
ReInput.userDataStore.SavePlayerData(0);
|
|
ReInput.userDataStore.Load();
|
|
}
|
|
|
|
private void recheckMouseDeltaPosition()
|
|
{
|
|
GetCursorPos(out var lpPoint);
|
|
deltaMouseX = Mathf.Abs((float)lpPoint.X - Input.mousePosition.x);
|
|
deltaMouseY = Mathf.Abs((float)lpPoint.Y + (Input.mousePosition.y - (float)Screen.height));
|
|
}
|
|
|
|
public void SetCursorPositionToScreenCenter()
|
|
{
|
|
recheckMouseDeltaPosition();
|
|
MouseX = Screen.width / 2;
|
|
MouseY = Screen.height / 2;
|
|
SetCursorPos((int)(deltaMouseX + (float)(Screen.width / 2)), (int)(deltaMouseY + (float)(Screen.height / 2)));
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!IsInputEnabled)
|
|
{
|
|
return;
|
|
}
|
|
if (GameManager.Instance.CurrentlyScrollable != null)
|
|
{
|
|
if (player.GetButtonDown("ToDeleteUp"))
|
|
{
|
|
GameManager.Instance.CurrentlyScrollable.gameObject.transform.position = new Vector3(GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.x, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.y - 100f, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.z);
|
|
}
|
|
if (player.GetButtonDown("ToDeleteDown"))
|
|
{
|
|
GameManager.Instance.CurrentlyScrollable.gameObject.transform.position = new Vector3(GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.x, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.y + 100f, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.z);
|
|
}
|
|
GameManager.Instance.CurrentlyScrollable.gameObject.transform.position = new Vector3(GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.x, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.y + player.GetAxis("CameraVerticalGamepad") * -200f * Time.unscaledDeltaTime, GameManager.Instance.CurrentlyScrollable.gameObject.transform.position.z);
|
|
}
|
|
if (player.GetAxis("cameraVerticalGamepad") != 0f || player.GetAxis("cameraHorizontalGamepad") != 0f || player.GetAxis("CameraHorizontalGamepadUI") != 0f || player.GetAxis("CameraVerticalGamepadUI") != 0f)
|
|
{
|
|
GameManager.Instance.controllerType = GameManager.ControllerType.GamePad;
|
|
recheckMouseDeltaPosition();
|
|
}
|
|
if (player.GetAxis("cameraVertical") != 0f || player.GetAxis("cameraHorizontal") != 0f)
|
|
{
|
|
GameManager.Instance.controllerType = GameManager.ControllerType.KeyboardMouse;
|
|
MouseX = Input.mousePosition.x;
|
|
MouseY = Mathf.Abs(Input.mousePosition.y - (float)Screen.height);
|
|
}
|
|
float gamepadCursorSensitivityValue = Singleton<SaveDataManager>.Instance.SettingsData.GamepadCursorSensitivityValue;
|
|
if (!isPaused && GameManager.Instance.controllerType == GameManager.ControllerType.GamePad)
|
|
{
|
|
MouseX += player.GetAxis("CameraHorizontalGamepadUI") * Time.unscaledDeltaTime * 500f * gamepadCursorSensitivityValue;
|
|
MouseY -= player.GetAxis("CameraVerticalGamepadUI") * Time.unscaledDeltaTime * 500f * gamepadCursorSensitivityValue;
|
|
MouseX = Mathf.Clamp(MouseX, 0f, Screen.width - 1);
|
|
MouseY = Mathf.Clamp(MouseY, 0f, Screen.height - 1);
|
|
SetCursorPos((int)(MouseX + deltaMouseX), (int)(MouseY + deltaMouseY));
|
|
if (player.GetButtonDown("MouseClick"))
|
|
{
|
|
mouse_event(2, 0, 0, 0, 0);
|
|
}
|
|
if (player.GetButtonUp("MouseClick"))
|
|
{
|
|
mouse_event(4, 0, 0, 0, 0);
|
|
}
|
|
}
|
|
if (SRDebug.Instance.IsDebugPanelVisible || GameManager.Instance.addectiveSceneLoaded != "none")
|
|
{
|
|
movementAxis.x = 0f;
|
|
movementAxis.y = 0f;
|
|
return;
|
|
}
|
|
isExit = player.GetButtonDown("exitKey");
|
|
isBPressed = player.GetButtonDown("B");
|
|
if (GameManager.Instance.currentMessageView != null)
|
|
{
|
|
return;
|
|
}
|
|
UpdateButtonState(ref isPullUpRod, "rodPullUpButton");
|
|
UpdateButtonState(ref LT, "LT");
|
|
UpdateButtonState(ref RB, "RB");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
UpdateButtonState(ref isreelSpeedMaxHold, "reelSpeedMax");
|
|
if (RB)
|
|
{
|
|
isReelSpeedMax = reelUpClicked;
|
|
}
|
|
if (!isreelSpeedMaxHold)
|
|
{
|
|
isReelSpeedMax = false;
|
|
}
|
|
if (player.GetButtonDown("quickHelpKey"))
|
|
{
|
|
quickHelp = !quickHelp;
|
|
}
|
|
if (GameManager.Instance.ChechIfPlayerShouldBeStoppedFromDoingAnything())
|
|
{
|
|
if (player.GetButtonDown("cameraTypeViewKey"))
|
|
{
|
|
isCameraChange = !isCameraChange;
|
|
}
|
|
if (player.GetButtonDown("showGUIKey"))
|
|
{
|
|
showUI = !showUI;
|
|
}
|
|
if (player.GetButtonDown("headFlashLight"))
|
|
{
|
|
isHeadFlashLight = !isHeadFlashLight;
|
|
}
|
|
return;
|
|
}
|
|
movementAxis = Vector2.zero;
|
|
if (!SRDebug.Instance.IsDebugPanelVisible)
|
|
{
|
|
if (Singleton<ChatManager>.Instance != null && Singleton<ChatManager>.Instance.IsChatOpen && Time.timeScale > 0f)
|
|
{
|
|
return;
|
|
}
|
|
movementAxis.x = player.GetAxis("moveHorizontal") * Time.deltaTime * 500f;
|
|
movementAxis.y = player.GetAxis("moveVertical") * Time.deltaTime * 500f;
|
|
}
|
|
if (player.GetButtonDown("reelSpeedUp"))
|
|
{
|
|
reelUpClicked = true;
|
|
}
|
|
if (player.GetButtonUp("reelSpeedUp"))
|
|
{
|
|
isReelSpeedUp = false;
|
|
reelUpClicked = false;
|
|
}
|
|
if (player.GetButtonDown("reelSpeedDown"))
|
|
{
|
|
reelDownClicked = true;
|
|
}
|
|
if (player.GetButtonUp("reelSpeedDown"))
|
|
{
|
|
isReelSpeedDown = false;
|
|
reelDownClicked = false;
|
|
}
|
|
if (FScriptsHandler.Instance != null && (bool)FScriptsHandler.Instance && (bool)FScriptsHandler.Instance.m_PlayerMain && (bool)FScriptsHandler.Instance.m_PlayerMain.currentRod && (!LT || FScriptsHandler.Instance.m_PlayerMain.currentRod.rodType != FRod.RodType.Float) && !RB)
|
|
{
|
|
if (reelUpClicked)
|
|
{
|
|
if (slowDownReeling >= 1f)
|
|
{
|
|
isReelSpeedUp = true;
|
|
slowDownReeling = 0f;
|
|
}
|
|
else
|
|
{
|
|
isReelSpeedUp = false;
|
|
slowDownReeling += Time.deltaTime * 100f;
|
|
}
|
|
}
|
|
if (reelDownClicked)
|
|
{
|
|
if (slowDownReeling >= 1f)
|
|
{
|
|
isReelSpeedDown = true;
|
|
slowDownReeling = 0f;
|
|
}
|
|
else
|
|
{
|
|
isReelSpeedDown = false;
|
|
slowDownReeling += Time.deltaTime * 100f;
|
|
}
|
|
}
|
|
}
|
|
if (TutorialKeys() || !FScriptsHandler.Instance)
|
|
{
|
|
return;
|
|
}
|
|
isJumping = player.GetButtonDown("jumping");
|
|
isOpenEquipmentScene = player.GetButtonDown("equipmentScene");
|
|
if (player.GetButtonDown("mapScene"))
|
|
{
|
|
if (SceneManager.GetActiveScene().name != "Residence")
|
|
{
|
|
isOpenLocationMapScene = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
isOpenLocationMapScene = false;
|
|
}
|
|
isOpenShopScene = player.GetButtonDown("shopScene");
|
|
UpdateButtonState(ref isRunning, "runKey");
|
|
if (player.GetButtonDown("cameraTypeViewKey"))
|
|
{
|
|
isCameraChange = !isCameraChange;
|
|
}
|
|
if (player.GetButtonDown("showGUIKey"))
|
|
{
|
|
showUI = !showUI;
|
|
}
|
|
isFreeCamera = player.GetButtonDown("freeCameraKey");
|
|
UpdateButtonState(ref isEagleEye, "eagleEye");
|
|
if (player.GetButtonDown("underwaterCameraKey"))
|
|
{
|
|
isUnderwaterCamera = !isUnderwaterCamera;
|
|
}
|
|
if (player.GetButtonDown("underwaterMiniCameraKey"))
|
|
{
|
|
underwaterCameraMini = !underwaterCameraMini;
|
|
}
|
|
UpdateButtonState(ref isUnderwaterCameraZoomUp, "underwaterZoomUpCameraKey");
|
|
UpdateButtonState(ref isUnderwaterCameraZoomDown, "underwaterZoomDownCameraKey");
|
|
isUnderwaterCameraFloatZoom = player.GetButtonDown("underwaterZoomFloat");
|
|
isShowSlot0 = player.GetButtonDown("showSlot0");
|
|
isShowSlot1 = player.GetButtonDown("showSlot1");
|
|
isShowSlot2 = player.GetButtonDown("showSlot2");
|
|
isShowSlot3 = player.GetButtonDown("showSlot3");
|
|
isShowSlot4 = player.GetButtonDown("showSlot4");
|
|
UpdateButtonState(ref isCastTargeting, "TargetingCastButton");
|
|
if (!isCastFar)
|
|
{
|
|
if (GameManager.Instance.currentLevelPopUp != null)
|
|
{
|
|
return;
|
|
}
|
|
UpdateButtonState(ref isCastNear, "NearCastButton");
|
|
}
|
|
if (!isCastNear)
|
|
{
|
|
if (GameManager.Instance.currentLevelPopUp != null)
|
|
{
|
|
return;
|
|
}
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
UpdateButtonState(ref isCatch, "catchButton");
|
|
isCastReset = player.GetButtonTimePressed("resetCast") >= 1.0 && CanResetCast();
|
|
UpdateButtonState(ref isQClicked, "resetCast");
|
|
UpdateButtonState(ref isBlockLineFinger, "fingerBlockLineButton");
|
|
UpdateButtonState(ref isReelUnlockLock, "UnlockLockReelButton");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
isGetUpRod = player.GetButtonDown("getUpRod");
|
|
if (player.GetButtonDown("headFlashLight"))
|
|
{
|
|
isHeadFlashLight = !isHeadFlashLight;
|
|
}
|
|
dropGetSupport = player.GetButtonDown("dropGetSupportButton");
|
|
cancelSupport = player.GetButtonDown("cancelSupportButton");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
if (LT && !RB)
|
|
{
|
|
if (reelUpClicked)
|
|
{
|
|
if (slowDownFloat >= 1f)
|
|
{
|
|
isDeepthFloatUp = true;
|
|
slowDownFloat = 0f;
|
|
}
|
|
else
|
|
{
|
|
isDeepthFloatUp = false;
|
|
slowDownFloat += Time.deltaTime * 10f;
|
|
}
|
|
}
|
|
if (reelDownClicked)
|
|
{
|
|
if (slowDownFloat >= 1f)
|
|
{
|
|
isDeepthFloatDown = true;
|
|
slowDownFloat = 0f;
|
|
}
|
|
else
|
|
{
|
|
isDeepthFloatDown = false;
|
|
slowDownFloat += Time.deltaTime * 10f;
|
|
}
|
|
}
|
|
}
|
|
isEnterLeaveBoat = player.GetButtonDown("isEnterLeaveBoat");
|
|
isStartStopSteringBoat = player.GetButtonDown("isStartStopSteringBoat");
|
|
isRestartPositionBoat = player.GetButtonDown("isRestartPositionBoat");
|
|
}
|
|
|
|
private bool TutorialKeys()
|
|
{
|
|
if (!TutorialManager.Instance)
|
|
{
|
|
return false;
|
|
}
|
|
if (GameManager.Instance.isDevModeAllowed)
|
|
{
|
|
return false;
|
|
}
|
|
switch (TutorialManager.Instance.acctualLessonIndex)
|
|
{
|
|
case 1:
|
|
isShowSlot1 = player.GetButtonDown("showSlot1");
|
|
break;
|
|
case 2:
|
|
isShowSlot1 = player.GetButtonDown("showSlot1");
|
|
if (!isCastFar)
|
|
{
|
|
UpdateButtonState(ref isCastNear, "NearCastButton");
|
|
}
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
break;
|
|
case 3:
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
break;
|
|
case 4:
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
break;
|
|
case 5:
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
UnderwaterCameraButtons();
|
|
break;
|
|
case 6:
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
UnderwaterCameraButtons();
|
|
UpdateButtonState(ref isCatch, "catchButton");
|
|
UpdateButtonState(ref isPullUpRod, "rodPullUpButton");
|
|
break;
|
|
case 7:
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
UnderwaterCameraButtons();
|
|
UpdateButtonState(ref isCatch, "catchButton");
|
|
UpdateButtonState(ref isPullUpRod, "rodPullUpButton");
|
|
break;
|
|
case 8:
|
|
isCastReset = player.GetButtonDown("resetCast") && CanResetCast();
|
|
isShowSlot0 = player.GetButtonDown("showSlot0");
|
|
break;
|
|
case 9:
|
|
if (!isCastFar)
|
|
{
|
|
UpdateButtonState(ref isCastNear, "NearCastButton");
|
|
}
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
UnderwaterCameraButtons();
|
|
UpdateButtonState(ref isCatch, "catchButton");
|
|
UpdateButtonState(ref isPullUpRod, "rodPullUpButton");
|
|
break;
|
|
case 10:
|
|
if (!isCastFar)
|
|
{
|
|
UpdateButtonState(ref isCastNear, "NearCastButton");
|
|
}
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
UpdateButtonState(ref isReelReeling, "Reeling");
|
|
isDeepthFloatUp = player.GetButtonDown("floatDeepthUp");
|
|
isDeepthFloatDown = player.GetButtonDown("floatDeepthDown");
|
|
UpdateButtonState(ref isReelSpeedMax, "reelSpeedMax");
|
|
isReelDragUp = player.GetButtonDown("reelDragUp");
|
|
isReelDragDown = player.GetButtonDown("reelDragDown");
|
|
UnderwaterCameraButtons();
|
|
UpdateButtonState(ref isCatch, "catchButton");
|
|
UpdateButtonState(ref isPullUpRod, "rodPullUpButton");
|
|
break;
|
|
case 11:
|
|
isOpenLocationMapScene = player.GetButtonDown("mapScene");
|
|
if (!isCastFar)
|
|
{
|
|
UpdateButtonState(ref isCastNear, "NearCastButton");
|
|
}
|
|
if (!isCastNear)
|
|
{
|
|
UpdateButtonState(ref isCastFar, "FarCastButton");
|
|
}
|
|
break;
|
|
case 12:
|
|
isOpenLocationMapScene = player.GetButtonDown("mapScene");
|
|
break;
|
|
}
|
|
return true;
|
|
void UnderwaterCameraButtons()
|
|
{
|
|
if (player.GetButtonDown("underwaterCameraKey"))
|
|
{
|
|
isUnderwaterCamera = !isUnderwaterCamera;
|
|
}
|
|
if (player.GetButtonDown("underwaterMiniCameraKey"))
|
|
{
|
|
underwaterCameraMini = !underwaterCameraMini;
|
|
}
|
|
UpdateButtonState(ref isUnderwaterCameraZoomUp, "underwaterZoomUpCameraKey");
|
|
UpdateButtonState(ref isUnderwaterCameraZoomDown, "underwaterZoomDownCameraKey");
|
|
isUnderwaterCameraFloatZoom = player.GetButtonDown("underwaterZoomFloat");
|
|
}
|
|
}
|
|
|
|
private bool CanPullUpRod()
|
|
{
|
|
if (FScriptsHandler.Instance == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (FScriptsHandler.Instance.m_PlayerMain == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (FScriptsHandler.Instance.m_PlayerMain.currentRod == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (FScriptsHandler.Instance.m_PlayerMain.currentRod.fishingLine == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!(FScriptsHandler.Instance.m_PlayerMain.currentRod.fishingLine.ropeToHookDistance <= 1f))
|
|
{
|
|
return true;
|
|
}
|
|
if (!(FScriptsHandler.Instance.m_PlayerMain.currentRod.currentFish != null))
|
|
{
|
|
return FScriptsHandler.Instance.m_PlayerMain.currentRod.takeFish != null;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool CanResetCast()
|
|
{
|
|
bool result = false;
|
|
if ((bool)FScriptsHandler.Instance && (bool)FScriptsHandler.Instance.m_PlayerMain && (bool)FScriptsHandler.Instance.m_PlayerMain.currentRod && !FScriptsHandler.Instance.m_PlayerMain.currentRod.isThrowing && FScriptsHandler.Instance.m_PlayerMain.currentRod.fishingLine.currentLineHandler.PhisicsLineOut > 0f && (!FishEntity.CurrentFishInFight || !FishEntity.CurrentFishInFight.IsCatched))
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static void ResetMouseButtonsTriggers()
|
|
{
|
|
isCastNear = false;
|
|
isCastFar = false;
|
|
isReelReeling = false;
|
|
}
|
|
|
|
private void UpdateButtonState(ref bool buttonState, string actionName)
|
|
{
|
|
if (player.GetButtonDown(actionName))
|
|
{
|
|
buttonState = true;
|
|
return;
|
|
}
|
|
if (player.GetButtonUp(actionName))
|
|
{
|
|
buttonState = false;
|
|
}
|
|
if (buttonState && !player.GetButton(actionName))
|
|
{
|
|
buttonState = false;
|
|
}
|
|
}
|
|
|
|
private void OnApplicationFocus(bool hasFocus)
|
|
{
|
|
isPaused = !hasFocus;
|
|
}
|
|
|
|
private void OnApplicationPause(bool pauseStatus)
|
|
{
|
|
isPaused = pauseStatus;
|
|
}
|
|
}
|