//bool gamepadConnected = false; // Use this for initialization private void Start() { _gamepadInput = target.GetComponent <GamepadInputHandler>(); _gamepadInput.OnGamepadConnected += OnGamepadConnected; canMove = true; Vector3 angles = transform.eulerAngles; x = angles.y; y = angles.x; //rigidbody = GetComponent<Rigidbody>(); // Make the rigid body not change rotation /*if (rigidbody != null) * { * rigidbody.freezeRotation = true; * }*/ //string [] names = Input.GetJoystickNames(); for (int i = 0; i < 4; i++) { PlayerIndex index = (PlayerIndex)i; GamePadState state = GamePad.GetState(index); if (state.IsConnected) { _playerIndex = index; //gamepadConnected = true; break; } } }
private void Run(string[] args) { using (new AgateWinForms(args) .Initialize()) using (new DisplayWindowBuilder(args) .BackbufferSize(1280, 720) .QuitOnClose() .Build()) { inputHandler = new GamepadInputHandler(); playerOne = inputHandler.Gamepads.First(); Input.Handlers.Add(inputHandler); font = new Font(Font.AgateSans, 12); while (AgateApp.IsAlive) { Update(AgateApp.GameClock.Elapsed); RenderScreen(); AgateApp.KeepAlive(); } // Dispose of the input handler inputHandler.Dispose(); } }
private void Start() { _gamepadInput = player.GetComponent <GamepadInputHandler>(); _gamepadInput.OnGamepadConnected += OnGamepadConnected; canMove = true; Vector3 angles = transform.eulerAngles; x = angles.y; y = angles.x; transform.position = camRef.transform.position; // gunCam = GetComponent<Camera>(); for (int i = 0; i < 4; i++) { PlayerIndex index = (PlayerIndex)i; GamePadState state = GamePad.GetState(index); if (state.IsConnected) { _playerIndex = index; //gamepadConnected = true; break; } } }
private void Start() { _gamepadInput = GetComponent <GamepadInputHandler>(); _gamepadInput.OnMovement += HandleGamepadSelection; _gamepadInput.OnAPressed += OnSelect; PlayerIndex _playerIndex = 0; for (int i = 0; i < 4; i++) { PlayerIndex index = (PlayerIndex)i; GamePadState state = GamePad.GetState(index); if (state.IsConnected) { _playerIndex = index; break; } } if (!GamePad.GetState(_playerIndex).IsConnected) { enabled = false; } /*for(int i=0; i< buttons.Length;i++) * buttons[i].rectTransform.parent.GetComponent<Button>().onClick.AddListener();*/ }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D> (); gamepad = gameObject.GetComponent(typeof(Doodle.InputSystem.InputHandler)) as GamepadInputHandler; sprite = gameObject.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer; isFacingRight = true; colliderList = new List <Collider2D> (); }
private void Start() { _gamepadInput = GetComponentInParent <GamepadInputHandler>(); _gamepadInput.OnAttack += OnAttack; _keyboardInput = GetComponentInParent <KeyboardInputHandler>(); _keyboardInput.OnAttack += OnAttack; _playerMovement = GetComponentInParent <PlayerMovement>(); anim = GetComponentInParent <Animator>(); }
private void Start() { canMove = true; rb = GetComponent <Rigidbody>(); anim = GetComponent <Animator>(); gamepadInput = GetComponent <GamepadInputHandler>(); gamepadInput.OnMovement += OnMove; gamepadInput.OnStopMoving += OnStopMoving; keyboardInput = GetComponent <KeyboardInputHandler>(); keyboardInput.OnMovement += OnMove; keyboardInput.OnStopMoving += OnStopMoving; }
private static GamepadInputHandler NewInputHandler() { var result = new GamepadInputHandler(); result.KeyMap.Add(KeyCode.Left, KeyMapItem.ToLeftStick(result.Gamepads.First(), Axis.X, -1)); result.KeyMap.Add(KeyCode.Right, KeyMapItem.ToLeftStick(result.Gamepads.First(), Axis.X, 1)); result.KeyMap.Add(KeyCode.Up, KeyMapItem.ToLeftStick(result.Gamepads.First(), Axis.Y, -1)); result.KeyMap.Add(KeyCode.Down, KeyMapItem.ToLeftStick(result.Gamepads.First(), Axis.Y, 1)); result.KeyMap.Add(KeyCode.Enter, KeyMapItem.ToButton(result.Gamepads.First(), GamepadButton.Start)); result.KeyMap.Add(KeyCode.Escape, KeyMapItem.ToButton(result.Gamepads.First(), GamepadButton.Back)); return(result); }
static void Main(string[] args) { using (new AgateWinForms(args) .Initialize()) using (new DisplayWindowBuilder(args) .Title("Event Driven Scene Example") .BackbufferSize(1280, 720) .AutoResizeBackBuffer() .QuitOnClose() .Build()) { // Create a Scene object for the title screen. When the enter key or // the start button on the first gamepad is pressed, that will // begin a new scene. GamepadInputHandler titleInputHandler = NewInputHandler(); Scene titleScene = new Scene { InputHandler = titleInputHandler }; titleInputHandler.Gamepads.First().ButtonPressed += (sender, e) => { if (e.Button == GamepadButton.Start) { CreateGameScene(titleScene.SceneStack); } else if (e.Button == GamepadButton.Back) { titleScene.IsFinished = true; } }; var font = new Font(Font.AgateSans) { Size = 22, Style = FontStyles.Bold }; titleScene.Redraw += (sender, eventArgs) => { Display.Clear(Color.Maroon); font.DrawText(0, 0, "Press enter to begin game, escape to quit."); }; var stack = new SceneStack(); stack.Start(titleScene); } }
private void Start() { _inputHandler = GetComponent <GamepadInputHandler>(); _inputHandler.OnAPressed += Skip; _keyboardInput = GetComponent <KeyboardInputHandler>(); _keyboardInput.OnSkip += Skip; alphaValue = 0; text.GetComponent <CanvasRenderer>().SetAlpha(alphaValue); sentencesCounter = 0; fadeInOutDuration *= 60; text.text = sentences[sentencesCounter]; //textRyhtm = (sentences[sentencesCounter].Length)*2; //text.CrossFadeAlpha(1, fadeInOutDuration, false); nextSentence = (sentences[sentencesCounter].Length); }
private void Start() { _gamepadInput = GetComponentInParent <GamepadInputHandler>(); _gamepadInput.OnAttack += OnAttack; _gamepadInput.OnEnterFirstPerson += EnterFP; _gamepadInput.OnExitFirstPerson += ExitFP; _gamepadInput.OnTakeAim += TakeAim; _gamepadInput.OnReleaseArrow += Shoot; _keyboardInput = GetComponentInParent <KeyboardInputHandler>(); _keyboardInput.OnAttack += OnAttack; _keyboardInput.OnEnterFirstPerson += EnterFP; _keyboardInput.OnExitFirstPerson += ExitFP; _playerMovement = GetComponentInParent <PlayerMovement>(); anim = GetComponentInParent <Animator>(); }
void directionFacing(GamepadInputHandler g) { float direction = g.GetAxis(InputAxis.MotionX); //Debug.Log ("Direction: " + direction); if (direction > 0) { isFacingRight = true; //sprite.flipX = true; transform.localScale = new Vector3(1, 1, 1); //wallCheckPoint.localScale = new Vector2 (wallCheckPoint.localScale.x * 1, wallCheckPoint.localScale.y); } else if (direction < 0) { isFacingRight = false; //sprite.flipX = false; transform.localScale = new Vector3(-1, 1, 1); //wallCheckPoint.localScale = new Vector2 (wallCheckPoint.localScale.x * -1, wallCheckPoint.localScale.y); } else { //just keep the last known variables } }
private void Start() { _playerInput = GameObject.FindGameObjectWithTag("Player").GetComponent <GamepadInputHandler>(); _playerKeyboardInput = GameObject.FindGameObjectWithTag("Player").GetComponent <KeyboardInputHandler>(); _playerInput.OnPause += OpenCloseMenu; }