Files
Fishing2/Assets/Scripts/Old/InputManager.cs
2025-05-11 00:46:26 +08:00

651 lines
17 KiB
C#

// using System.Collections.Generic;
// using System.Runtime.InteropServices;
// // using Rewired;
// using UnityEngine;
// using UnityEngine.SceneManagement;
//
// public class InputManager : MonoBehaviour
// {
// public struct POINT
// {
// public int X;
//
// public int Y;
// }
//
//
// // [Tooltip("Rewired Input Manager's player used for handling player's input")]
// // private Player player;
//
// public bool IgnoreAllInput = false;
//
//
// public static bool IsMouseLeft;
// public static bool IsMouseRight;
//
//
// private bool isPaused;
//
// private float MouseX = Screen.width / 2;
//
// private float MouseY = Screen.height / 2;
//
// private float deltaMouseX;
//
// private float deltaMouseY;
//
// private float slowDownReeling;
//
// private float slowDownFloat;
//
// private bool reelUpClicked;
//
// private bool reelDownClicked;
//
//
// public static Vector2 movementAxis;
//
// public static bool isJumping;
//
// public static bool isCameraChange;
//
// public static bool isUnderwaterCamera;
//
// public static bool isUnderwaterCameraZoomUp;
//
// public static bool isUnderwaterCameraZoomDown;
//
// public static bool isUnderwaterCameraFloatZoom;
//
// public static bool LT;
//
// public static bool showUI = true;
//
//
// public static bool underwaterCameraMini;
//
// public static bool isHeadFlashLight;
//
// public static bool quickHelp;
//
// public static bool isEagleEye;
//
// public static bool isRunning;
//
// public static bool isReelReeling;
//
// public static bool isReelSpeedUp;
//
// public static bool isReelSpeedDown;
//
// public static bool isReelSpeedMax;
//
// public static bool isReelDragUp;
//
// public static bool isReelDragDown;
//
// public static bool isCastNear;
//
// public static bool isCastFar;
//
// public static bool isPullUpRod;
//
//
// public static bool isCastReset;
//
// public static bool isDeepthFloatUp;
//
// public static bool isDeepthFloatDown;
//
//
// public static bool isShowSlot0;
//
// public static bool isShowSlot1;
//
// public static bool isShowSlot2;
//
// public static bool isShowSlot3;
//
// public static bool isShowSlot4;
//
//
// public static bool RB;
//
// [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);
//
// 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(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 (IgnoreAllInput)
// {
// return;
// }
//
// if (Input.GetMouseButtonDown(0))
// {
// IsMouseLeft = true;
// }
//
// if (Input.GetMouseButtonUp(0))
// {
// IsMouseLeft = false;
// }
//
// if (Input.GetMouseButtonDown(1))
// {
// IsMouseRight = true;
// }
//
// if (Input.GetMouseButtonUp(1))
// {
// IsMouseRight = false;
// }
//
// // if (player.GetButtonDown("PressRMB"))
// // {
// // Debug.Log("PRESSEDDDDD");
// // }
//
//
// if (player.GetButtonDown("rodPullUpButton") && CanPullUpRod())
// {
// isPullUpRod = true;
// }
//
// if (player.GetButtonUp("rodPullUpButton"))
// {
// isPullUpRod = false;
// }
//
// if (player.GetButtonDown("LT"))
// {
// LT = true;
// }
//
// if (player.GetButtonUp("LT"))
// {
// LT = false;
// }
//
// if (player.GetButtonDown("RB"))
// {
// RB = true;
// }
//
// if (player.GetButtonUp("RB"))
// {
// RB = false;
// }
//
// if (player.GetButtonDown("reelSpeedMax"))
// {
// isReelSpeedMax = true;
// // isreelSpeedMaxHold = true;
// }
// else if (player.GetButtonUp("reelSpeedMax"))
// {
// isReelSpeedMax = false;
// // isreelSpeedMaxHold = false;
// }
// else if (RB)
// {
// if (reelUpClicked)
// {
// isReelSpeedMax = true;
// }
// else
// {
// isReelSpeedMax = false;
// }
// }
//
// // if (!isreelSpeedMaxHold)
// // {
// // isReelSpeedMax = false;
// // }
//
// if (player.GetButtonDown("quickHelpKey"))
// {
// quickHelp = !quickHelp;
// }
//
//
// movementAxis = Vector2.zero;
// // if (!SRDebug.Instance.IsDebugPanelVisible)
// {
// if (Application.isFocused)
// {
// 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 && FScriptsHandler.Instance.m_PlayerMain.currentRod != null &&
// // (!LT || FScriptsHandler.Instance.m_PlayerMain.currentRod.rodType != 0) && !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 (player.GetButtonDown("jumping"))
// {
// isJumping = true;
// }
// else
// {
// isJumping = false;
// }
//
//
//
// if (player.GetButtonDown("runKey"))
// {
// isRunning = true;
// }
//
// if (player.GetButtonUp("runKey"))
// {
// isRunning = false;
// }
//
// if (player.GetButtonDown("cameraTypeViewKey"))
// {
// isCameraChange = !isCameraChange;
// }
//
// if (player.GetButtonDown("showGUIKey"))
// {
// showUI = !showUI;
// }
//
//
// if (player.GetButtonDown("eagleEye"))
// {
// isEagleEye = true;
// }
//
// if (player.GetButtonUp("eagleEye"))
// {
// isEagleEye = false;
// }
//
// if (player.GetButtonDown("underwaterCameraKey"))
// {
// isUnderwaterCamera = !isUnderwaterCamera;
// }
//
// if (player.GetButtonDown("underwaterMiniCameraKey"))
// {
// underwaterCameraMini = !underwaterCameraMini;
// }
//
// if (player.GetButtonDown("underwaterZoomUpCameraKey"))
// {
// isUnderwaterCameraZoomUp = true;
// }
//
// if (player.GetButtonUp("underwaterZoomUpCameraKey"))
// {
// isUnderwaterCameraZoomUp = false;
// }
//
// if (player.GetButtonDown("underwaterZoomDownCameraKey"))
// {
// isUnderwaterCameraZoomDown = true;
// }
//
// if (player.GetButtonUp("underwaterZoomDownCameraKey"))
// {
// isUnderwaterCameraZoomDown = false;
// }
//
// if (player.GetButtonDown("underwaterZoomFloat"))
// {
// isUnderwaterCameraFloatZoom = true;
// }
// else
// {
// isUnderwaterCameraFloatZoom = false;
// }
//
// if (player.GetButtonDown("showSlot0"))
// {
// isShowSlot0 = true;
// Debug.LogError("showSlot0======");
// }
// else
// {
// isShowSlot0 = false;
// }
//
// if (player.GetButtonDown("showSlot1"))
// {
// isShowSlot1 = true;
// Debug.LogError("showSlot1======");
// }
// else
// {
// isShowSlot1 = false;
// }
//
// if (player.GetButtonDown("showSlot2"))
// {
// isShowSlot2 = true;
// Debug.LogError("showSlot2======");
// }
// else
// {
// isShowSlot2 = false;
// }
//
// if (player.GetButtonDown("showSlot3"))
// {
// isShowSlot3 = true;
// }
// else
// {
// isShowSlot3 = false;
// }
//
// if (player.GetButtonDown("showSlot4"))
// {
// isShowSlot4 = true;
// }
// else
// {
// isShowSlot4 = false;
// }
//
//
// // if (!isCastFar)
// // {
// // if (GameManager.Instance.currentLevelPopUp != null)
// // {
// // return;
// // }
// //
// // if (player.GetButtonDown("NearCastButton"))
// // {
// // isCastNear = true;
// // }
// // else if (player.GetButtonUp("NearCastButton") && isCastNear)
// // {
// // isCastNear = false;
// // }
// // }
// //
// // if (!isCastNear)
// // {
// // if (GameManager.Instance.currentLevelPopUp != null)
// // {
// // return;
// // }
// //
// // if (player.GetButtonDown("FarCastButton"))
// // {
// // isCastFar = true;
// // }
// // else if (player.GetButtonUp("FarCastButton") && isCastFar)
// // {
// // isCastFar = false;
// // }
// // }
// //
//
// if (player.GetButtonTimePressed("resetCast") >= 1.0)
// {
// isCastReset = true;
// }
// else
// {
// isCastReset = false;
// }
//
//
// if (player.GetButtonDown("reelDragUp"))
// {
// isReelDragUp = true;
// }
// else
// {
// isReelDragUp = false;
// }
//
// if (player.GetButtonDown("reelDragDown"))
// {
// isReelDragDown = true;
// }
// else
// {
// isReelDragDown = false;
// }
//
//
// if (player.GetButtonDown("headFlashLight"))
// {
// isHeadFlashLight = !isHeadFlashLight;
// }
//
//
// if (player.GetButtonDown("floatDeepthUp"))
// {
// isDeepthFloatUp = true;
// }
// else
// {
// isDeepthFloatUp = false;
// }
//
// if (player.GetButtonDown("floatDeepthDown"))
// {
// isDeepthFloatDown = true;
// }
// else
// {
// isDeepthFloatDown = false;
// }
//
// if (player.GetButtonDown("Reeling"))
// {
// isReelReeling = true;
// }
//
// if (player.GetButtonUp("Reeling"))
// {
// isReelReeling = false;
// }
//
// 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;
// }
// }
// }
//
// }
//
// 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)
// // {
// // if (FScriptsHandler.Instance.m_PlayerMain.currentRod.currentFish != null ||
// // FScriptsHandler.Instance.m_PlayerMain.currentRod.takeFish != null)
// // {
// // return true;
// // }
// //
// // return false;
// // }
//
// return true;
// }
//
// public static void ResetMouseButtonsTriggers()
// {
// isCastNear = false;
// isCastFar = false;
// isReelReeling = false;
// }
//
// private void OnApplicationFocus(bool hasFocus)
// {
// isPaused = !hasFocus;
// }
//
// private void OnApplicationPause(bool pauseStatus)
// {
// isPaused = pauseStatus;
// }
// }