void OnEnable() { m_EventSystem.SetSelectedGameObject(GameObject.Find("KeyboardOrXbox")); m_Player1 = InputManager.Instance.m_InputStrings[(int)PlayerNumber.One]; m_Player2 = InputManager.Instance.m_InputStrings[(int)PlayerNumber.Two]; RefreshButtonText(); }
private static InputStrings LoadInputFile(string fileName) { InputStrings input = null; if (fileName.Contains(kbFileName)) { TextAsset file = Resources.Load(fileName) as TextAsset; if (file != null && file.text != "") { XmlSerializer serializer = new XmlSerializer(typeof(KeyboardInputStrings)); StringReader reader = new StringReader(file.text); input = serializer.Deserialize(reader) as KeyboardInputStrings; reader.Close(); } } else { TextAsset file = Resources.Load(fileName) as TextAsset; if (file != null && file.text != "") { XmlSerializer serializer = new XmlSerializer(typeof(GamepadInputStrings)); StringReader reader = new StringReader(file.text); input = serializer.Deserialize(reader) as GamepadInputStrings; reader.Close(); } } return(input); }
private static void SaveInputFile(string fileName, InputStrings inputStrings) { string filepath = realFilePath + fileName + ".xml"; if (File.Exists(filepath)) { File.Delete(filepath); } StreamWriter writer; FileInfo t = new FileInfo(filepath); if (!t.Exists) { writer = t.CreateText(); } else { t.Delete(); writer = t.CreateText(); } writer.Write(XMLFileHandler.ObjectToXml(inputStrings)); writer.Close(); }
void OnEnable() { m_EventSystem.SetSelectedGameObject(GameObject.Find("KeyboardOrXbox")); m_Player = InputManager.Instance.m_InputStrings[(int)m_PlayerNumber]; // Set the player string to be = to the playerString of the player who invoked pause... RefreshButtonText(); }
public void SetInputType(ref InputStrings aInputStrings, InputType aInputType) // InputManager.Instance.m_InputStrings[PlayerNumber.One], InputType.XBOX; { aInputStrings.InputType = aInputType; }
public void ReInitializeInputStrings(ref InputStrings aInputStrings) { if (aInputStrings.InputType == InputType.Joystick) { aInputStrings.MoveXInput = InputXBOXControlsArray[(int)InputXBOXControls.LeftStickX]; aInputStrings.MoveYInput = InputXBOXControlsArray[(int)InputXBOXControls.LeftStickY]; aInputStrings.CameraXInput = InputXBOXControlsArray[(int)InputXBOXControls.RightStickX]; aInputStrings.CameraYInput = InputXBOXControlsArray[(int)InputXBOXControls.RightStickY]; aInputStrings.InteractInput = InputXBOXControlsArray[(int)InputXBOXControls.X]; aInputStrings.JumpInput = InputXBOXControlsArray[(int)InputXBOXControls.A]; aInputStrings.SprintInput = InputXBOXControlsArray[(int)InputXBOXControls.LeftTrigger]; aInputStrings.CarryInput = InputXBOXControlsArray[(int)InputXBOXControls.Y]; aInputStrings.PauseInput = InputXBOXControlsArray[(int)InputXBOXControls.Start]; aInputStrings.HelpInput = InputXBOXControlsArray[(int)InputXBOXControls.Back]; } else if (aInputStrings.InputType == InputType.Keyboard) { aInputStrings.MoveXInput = InputPCControlsArray[(int)InputPCControls.MoveX]; aInputStrings.MoveYInput = InputPCControlsArray[(int)InputPCControls.MoveY]; aInputStrings.CameraXInput = InputPCControlsArray[(int)InputPCControls.MouseX]; aInputStrings.CameraYInput = InputPCControlsArray[(int)InputPCControls.MouseY]; aInputStrings.InteractInput = InputPCControlsArray[(int)InputPCControls.MouseLeftClick]; aInputStrings.JumpInput = InputPCControlsArray[(int)InputPCControls.Space]; aInputStrings.SprintInput = InputPCControlsArray[(int)InputPCControls.LeftShift]; aInputStrings.CarryInput = InputPCControlsArray[(int)InputPCControls.MouseRightClick]; aInputStrings.PauseInput = InputPCControlsArray[(int)InputPCControls.Escape]; aInputStrings.HelpInput = InputPCControlsArray[(int)InputPCControls.Tab]; } }
private InputManager() { m_State = new InputState(); m_InputStrings = new InputStrings[9]; // There is a maximum of 8 player support, 0 is God element m_ControllersConnected = GetNumControllersConnected(); InitializeInputArrays(); InitializeDictionaries(); InitializePlayerNumbers(); if (m_ControllersConnected == 0) /////////////TEMPORARY PLEASE DELETE ME!!!!!!!!! { m_InputStrings[0].InputType = InputType.Keyboard; m_InputStrings[1].InputType = InputType.Keyboard; } for (int i = 0; i < m_InputStrings.Length; i++) { ReInitializeInputStrings(ref m_InputStrings[i]); } SetPlayerControllerNumbers(); }
/** * Sets up all of the player information * @param num The index of the player * @param input How the player should be controlling their pointer * @return True if successful */ public bool SetupPlayer(int num, LevelManager.InputType input) { // Bounds check if (num < 0 || num > 4) { return(false); } // Set the player's index playerNum = num; // Set the sprite's position and sets the starting angle and color of the pointer Color playerColor = Color.white; Vector3 spritePos = new Vector3(3f, 1f); switch (playerNum) { case 1: angle = 225; playerColor = Color.red; break; case 2: angle = 135; spritePos.x *= -1; playerColor = Color.blue; break; case 3: angle = 315; spritePos.y *= -1; playerColor = Color.yellow; break; case 4: angle = 45; spritePos.x *= -1; spritePos.y *= -1; playerColor = Color.green; break; } trueLastAngle = angle; GameObject pSprite = Instantiate(playerSprite, gameObject.transform.position + spritePos, Quaternion.identity, gameObject.transform.parent); pSprite.GetComponent <SpriteRenderer>().color = playerColor; transform.Find("Pointer").GetComponent <SpriteRenderer>().color = playerColor; // Sets the pointer's input strings (this is how we will receive input) inputStrings = new InputStrings(); string suffix = ""; switch (input) { case LevelManager.InputType.TRY_HARDS: suffix = "MainJoy" + playerNum; break; case LevelManager.InputType.TWO_FOR_PRICE_OF_ONE: suffix = (playerNum % 2 != 0 ? "MainJoy" : "SndJoy") + ((playerNum + 1) / 2); break; case LevelManager.InputType.ALL_TOGETHER_NOW: switch (playerNum) { case 1: suffix = "MainJoy1"; break; case 2: suffix = "Btns1"; break; case 3: suffix = "DPad1"; break; case 4: suffix = "SndJoy1"; break; } break; case LevelManager.InputType.KEYBOARD: default: Debug.Log("You are in debug mode"); suffix = "Keyboard"; break; } inputStrings.x = "Horiz" + suffix; inputStrings.y = "Vert" + suffix; return(true); }