void InitInputConfigurations() { int playerNumber = InputMng.GetJoystickNames().Length; if (playerNumber > 4) { playerNumber = 4; } string confNamePrefix = "Win"; if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor) { confNamePrefix = "OS_X"; } for (int i = 0; i < playerNumber; i++) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i); InputMng.SetInputConfiguration(confNamePrefix + "_gamepad_" + (i + 1), playerId); } if (playerNumber < 4) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(playerNumber); InputMng.SetInputConfiguration("keyboard", playerId); playersConnected = playerNumber + 1; } else { playersConnected = 4; } }
void Update() { if (InputMng.GetButtonDown("Back", playerId)) { EventManager.Fire(new Event_Paused()); } GameState state = FindObjectOfType <GameState> (); if (state && state.PauseEnabled) { if (_pauseMenuActionLockedFrameNumber == 0) { var offst = GetPauseMenuDirection(); EventManager.Fire(new Event_ChangeSelectedPauseMenuItem() { offset = offst }); _pauseMenuActionLockedFrameNumber = PAUSE_MENU_FRAME_LOCK; } else { _pauseMenuActionLockedFrameNumber -= 1; } if (InputMng.GetButtonDown("Button A", playerId)) { EventManager.Fire(new Event_SelectPauseMenuItem()); } } }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); IsOpen = true; _tryedToFindInputManagerInScene = false; if (_inputManager == null) { _inputManager = UnityEngine.Object.FindObjectOfType(typeof(_InputManager)) as _InputManager; } if (_selectionPath == null) { _selectionPath = new List <int>(); } if (_searchResults == null) { _searchResults = new List <SearchResult>(); } if (_highlightTexture == null) { CreateHighlightTexture(); } EditorApplication.playmodeStateChanged += HandlePlayModeChanged; }
public Vector2 GetDirectionVector() { return(new Vector2( InputMng.GetAxis("Left Stick Horizontal", playerId), InputMng.GetAxis("Left Stick Vertical", playerId) )); }
public static void OpenWindow(_InputManager target) { if (!IsOpen) { var window = EditorWindow.GetWindow <AdvancedInputEditor>("Input Editor"); window._inputManager = target; } }
public float GetMoveAcceleration() { if (InputMng.GetButton("Right Trigger", playerId) || InputMng.GetAxis("Right Trigger", playerId) > 0.5f) { return(1f); } return(0f); }
public static void CreateSnapshot(TeamUtility.IO.InputManager inputManager) { if (_snapshotFile == null) { _snapshotFile = Path.Combine(Application.temporaryCachePath, "input_config.xml"); } InputSaverXML inputSaver = new InputSaverXML(_snapshotFile); inputSaver.Save(inputManager.inputConfigurations, inputManager.defaultConfiguration); }
public override void OnInspectorGUI() { _InputManager inputManager = target as _InputManager; serializedObject.Update(); GUILayout.Space(5.0f); GUILayout.BeginHorizontal(); GUI.enabled = !AdvancedInputEditor.IsOpen; if (GUILayout.Button("Input\nEditor", GUILayout.Height(40.0f))) { AdvancedInputEditor.OpenWindow(inputManager); } GUI.enabled = true; if (GUILayout.Button(_createSnapshotIngo, GUILayout.Height(40.0f))) { EditorToolbox.CreateSnapshot(inputManager); } GUI.enabled = EditorToolbox.CanLoadSnapshot(); if (GUILayout.Button("Restore\nSnapshot", GUILayout.Height(40.0f))) { EditorToolbox.LoadSnapshot(inputManager); } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.Space(5.0f); EditorGUILayout.PropertyField(_playerOneDefault); EditorGUILayout.PropertyField(_playerTwoDefault); EditorGUILayout.PropertyField(_playerThreeDefault); EditorGUILayout.PropertyField(_playerFourDefault); EditorGUILayout.PropertyField(_dontDestroyOnLoad); EditorGUILayout.PropertyField(_ignoreTimescale); EditorGUILayout.PropertyField(_intputConfigurations); if (_intputConfigurations.isExpanded) { EditorGUI.indentLevel++; int arraySize = EditorGUILayout.DelayedIntField("Size", _intputConfigurations.arraySize); if (arraySize != _intputConfigurations.arraySize) { _intputConfigurations.arraySize = arraySize; } for (int i = 0; i < _intputConfigurations.arraySize; i++) { DisplayInputConfigurations(_intputConfigurations.GetArrayElementAtIndex(i)); } EditorGUI.indentLevel--; } GUILayout.Space(5.0f); serializedObject.ApplyModifiedProperties(); }
public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager) { if (!CanLoadSnapshot()) { return; } InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile); inputLoader.Load(out inputManager.inputConfigurations, out inputManager.defaultConfiguration); }
public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager) { if (!CanLoadSnapshot()) { return; } InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile); inputManager.Load(inputLoader.Load()); }
public bool GetLaunchTrigger(int typeOfLaunchedMine) { switch (typeOfLaunchedMine) { case (int)Mine.MineTypes.Simple: return(InputMng.GetButtonDown("Button A", playerId)); case (int)Mine.MineTypes.Dash: return(InputMng.GetButtonDown("Button B", playerId)); case (int)Mine.MineTypes.Speed: return(InputMng.GetButtonDown("Button X", playerId)); default: throw new System.Exception("Unknown type of launched mine: " + typeOfLaunchedMine); } }
// Update is called once per frame void Update() { // Eu: The input is inverted because I'm stupid float h = -Input.GetAxisRaw("Horizontal", GetPlayerID()); float v = -Input.GetAxisRaw("Vertical", GetPlayerID()); Vector2 walkDir = new Vector2(h, v); if (walkDir.SqrMagnitude() > 0.1f * 0.1f) { this.walkDirection = walkDir; } else { this.walkDirection = new Vector2(0, 0); } this.jump = Input.GetButton("Jump", GetPlayerID()); //this.run = Input.GetButton("Run", GetPlayerID()); if (this.attack == false && Input.GetButton("Attack", GetPlayerID()) == true) { timeAttackDown = Time.time; this.attackDown = true; this.attackUp = false; } else if (this.attack == true && Input.GetButton("Attack", GetPlayerID()) == false) { this.attackUp = true; this.attackDown = false; } else { this.attackUp = false; this.attackDown = false; } this.attack = Input.GetButton("Attack", GetPlayerID()); }
private void Awake() { if (_instance != null) { UnityEngine.Object.Destroy (this); } else { if (dontDestroyOnLoad) { UnityEngine.Object.DontDestroyOnLoad (this); } _instance = this; _keys = (KeyCode[])Enum.GetValues (typeof(KeyCode)); _configurationTable = new Dictionary<string, InputConfiguration> (); _axesTable = new Dictionary<string, Dictionary<string, AxisConfiguration>> (); SetRawAxisNames (); Initialize (); } }
void Update() { if (_lockFlag) { return; } if (Input.GetKeyDown(KeyCode.Return) && JoinObjects.Count > 0) { GoToGame(); } int i = 0; while (i < playersConnected) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i); if (InputMng.GetButtonDown("Button A", playerId)) { PlayerInfo info = _holder.playersInfos.Find(infs => infs.playerNumber == i); if (info != null) { _holder.RemovePlayerInfo(info); GameObject hideGO = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[i]); if (hideGO) { hideGO.SetActive(false); } } else { //Color col = UnityEngine.Random.ColorHSV(0, 1, 1, 1, 1, 1); Color col = PlayerColors[i]; _holder.AddPlayerInfo(new PlayerInfo(col, i)); GameObject showGO = JoinObjects.Find(objs => objs.activeSelf == false); if (showGO) { showGO.SetActive(true); showGO.name = joinKeysPrefixes[i]; ColorSetter.UpdateModelColor(showGO, col); } } PlayMenuClick(); } i++; } foreach (var player in _holder.playersInfos) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)) .GetValue(player.playerNumber); if (InputMng.GetButtonDown("Start", playerId)) { player.ready = !player.ready; GameObject readyGOParent = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[player.playerNumber]); readyGOParent.transform.Find("ReadyFlag").gameObject.SetActive(player.ready); PlayMenuClick(); } } bool _allReady = true; if (_holder.playersInfos.Count > 1) { foreach (var player in _holder.playersInfos) { if (!player.ready) { _allReady = false; } } } else { _allReady = false; } if (_allReady) { _lockFlag = true; Invoke("GoToGame", 0.5f); } }
private void TryToFindInputManagerInScene() { _inputManager = UnityEngine.Object.FindObjectOfType(typeof(_InputManager)) as _InputManager; _tryedToFindInputManagerInScene = true; }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); IsOpen = true; _tryedToFindInputManagerInScene = false; if(_inputManager == null) _inputManager = UnityEngine.Object.FindObjectOfType(typeof(_InputManager)) as _InputManager; if(_selectionPath == null) _selectionPath = new List<int>(); if(_searchResults == null) _searchResults = new List<SearchResult>(); if(_highlightTexture == null) CreateHighlightTexture(); EditorApplication.playmodeStateChanged += HandlePlayModeChanged; }
public bool GetDashTrigger() { bool flag = InputMng.GetButton("Left Bumper", playerId); return(flag); }
public static void OpenWindow(InputManager target) { if(!IsOpen) { var window = EditorWindow.GetWindow<AdvancedInputEditor>("Input"); window._inputManager = target; } }
private void OnEnable() { EditorToolbox.ShowStartupWarning(); CreateGUIStyles(); IsOpen = true; if(_inputManager == null) _inputManager = UnityEngine.Object.FindObjectOfType(typeof(InputManager)) as InputManager; if(_selectionPath == null) _selectionPath = new List<int>(); if(_searchResults == null) _searchResults = new List<SearchResult>(); if(_highlightTexture == null) CreateHighlightTexture(); }
int GetPauseMenuDirection() { int verticalAxisVal = (int)InputMng.GetAxis("Left Stick Vertical", playerId); return(verticalAxisVal * -1); }