private void Update() { if (endSelect) { return; } GamepadState player_state = GamePad.GetState(player_idx); if (player_state.B) { PlayerPrefs.GetInt(player_idx.ToString(), selectNumber); PlayerPrefs.Save(); endSelect = true; } else if (player_state.LeftStickAxis.x != 0 && !changed) { selectNumber += (player_state.LeftStickAxis.x > 0) ? 1 : -1; if (selectNumber < 0) { selectNumber = sprites.sprites.Length - 1; } else if (selectNumber >= sprites.sprites.Length) { selectNumber = 0; } characterImage.sprite = sprites.sprites[selectNumber]; Debug.Log(selectNumber); changed = true; return; } if (player_state.LeftStickAxis.x == 0) { changed = false; } }
public SDL2GamepadDevice() { State = new GamepadState { Thumbsticks = new GamepadThumbsticks(), Triggers = new GamePadTriggers() }; }
public async Task SendGamepadStateAsync(GamepadState state) { var message = new GamepadMessage(); message.State = state; await _transport.SendAsync(message); }
private void SetNextButton(ui_Button button, GamepadState gamepadState) { if (button != null) { button.gamepadState = gamepadState; button.IsFocused = true; this.IsFocused = false; } }
private void ComputeCharacterInputAction(GamepadState player_state) { if (player_state.RightTrigger > 0f && !has_shooted) { has_shooted = true; m_timerNeedUpdate = true; m_shootingBehavior.ShootBullet(player_state.rightStickAxis); } }
private void Update() { for (int i = 0; i < m_gamepadStateText.Length; i++) { m_gamepadStateText[i].text = GamepadState.IsConnected((GamepadIndex)i) ? "Connected" : "Not Connected"; } for (int i = 0; i < m_gamepadButtonText.Length; i++) { m_gamepadButtonText[i].text = GamepadState.GetButton((GamepadButton)i, m_selectedGamepad).ToString(); } for (int i = 0; i < m_gamepadAxisText.Length; i++) { m_gamepadAxisText[i].text = GamepadState.GetAxis((GamepadAxis)i, m_selectedGamepad).ToString(); } GenericGamepadStateAdapter adapter = GamepadState.Adapter as GenericGamepadStateAdapter; GenericGamepadProfile profile = adapter[m_selectedGamepad]; if (profile != null && profile.DPadType == GamepadDPadType.Axis) { if (GamepadState.GetButtonDown(GamepadButton.DPadUp, m_selectedGamepad)) { Debug.Log("DPadUp was pressed!"); } if (GamepadState.GetButtonDown(GamepadButton.DPadDown, m_selectedGamepad)) { Debug.Log("DPadDown was pressed!"); } if (GamepadState.GetButtonDown(GamepadButton.DPadLeft, m_selectedGamepad)) { Debug.Log("DPadLeft was pressed!"); } if (GamepadState.GetButtonDown(GamepadButton.DPadRight, m_selectedGamepad)) { Debug.Log("DPadRight was pressed!"); } if (GamepadState.GetButtonUp(GamepadButton.DPadUp, m_selectedGamepad)) { Debug.Log("DPadUp was released!"); } if (GamepadState.GetButtonUp(GamepadButton.DPadDown, m_selectedGamepad)) { Debug.Log("DPadDown was released!"); } if (GamepadState.GetButtonUp(GamepadButton.DPadLeft, m_selectedGamepad)) { Debug.Log("DPadLeft was released!"); } if (GamepadState.GetButtonUp(GamepadButton.DPadRight, m_selectedGamepad)) { Debug.Log("DPadRight was released!"); } } }
private void ControllerPreview_Load(object sender, EventArgs e) { xb = new GamepadState(0); t.Interval = 50; t.Tick += T_Tick; t.Start(); }
public void Controls_CanWriteValueIntoState() { var gamepad = InputSystem.AddDevice <Gamepad>(); var state = new GamepadState(); var value = new Vector2(0.5f, 0.5f); gamepad.leftStick.WriteValueIntoState(value, ref state); Assert.That(state.leftStick, Is.EqualTo(value)); }
void Examples() { GamePad.GetButtonDown(GamePad.Button.A, GamePad.Index.One); GamePad.GetAxis(GamePad.Axis.LeftStick, GamePad.Index.One); GamePad.GetTrigger(GamePad.Trigger.RightTrigger, GamePad.Index.One); GamepadState state = GamePad.GetState(GamePad.Index.One); print("A: " + state.A); }
protected override void UpdateInternal(SceneRelatedUpdateState updateState) { foreach (InputFrame actInputFrame in updateState.InputFrames) { GamepadState gamepadState = actInputFrame.DefaultGamepad; if (gamepadState == GamepadState.Dummy) { continue; } Vector3 moveVector = Vector3.Zero; // Handle left/right movement Vector3 moveX = new Vector3(0.1f, 0f, 0f); if (gamepadState.IsButtonDown(GamepadButton.DPadLeft)) { moveVector += -moveX; } else if (gamepadState.IsButtonDown(GamepadButton.DPadRight)) { moveVector += moveX; } else if (Math.Abs(gamepadState.LeftThumbX) > 0.5f) { moveVector += gamepadState.LeftThumbX * moveX; } else if (Math.Abs(gamepadState.RightThumbX) > 0.5f) { moveVector += gamepadState.RightThumbX * moveX; } // Handle up/down movement Vector3 moveZ = new Vector3(0f, 0f, 0.1f); if (gamepadState.IsButtonDown(GamepadButton.DPadDown)) { moveVector += -moveZ; } else if (gamepadState.IsButtonDown(GamepadButton.DPadUp)) { moveVector += moveZ; } else if (Math.Abs(gamepadState.LeftThumbY) > 0.5f) { moveVector += gamepadState.LeftThumbY * moveZ; } else if (Math.Abs(gamepadState.RightThumbY) > 0.5f) { moveVector += gamepadState.RightThumbY * moveZ; } this.Position = this.Position + moveVector; } base.UpdateInternal(updateState); }
static void ProcessGamepadButtonEvent(GamepadEventType state, GamepadKeyCode buttonIndex, double id, double value) { GamepadButton buttonToUpdate = GamepadButton.DpadUp; GamepadState gamepadState = GamepadsStates[id]; switch (buttonIndex) { case GamepadKeyCode.dpadUp: buttonToUpdate = GamepadButton.DpadUp; break; case GamepadKeyCode.dpadDown: buttonToUpdate = GamepadButton.DpadDown; break; case GamepadKeyCode.dpadLeft: buttonToUpdate = GamepadButton.DpadLeft; break; case GamepadKeyCode.dpadRight: buttonToUpdate = GamepadButton.DpadRight; break; case GamepadKeyCode.Button0: buttonToUpdate = GamepadButton.B; break; case GamepadKeyCode.Button1: buttonToUpdate = GamepadButton.A; break; case GamepadKeyCode.Button2: buttonToUpdate = GamepadButton.Y; break; case GamepadKeyCode.Button3: buttonToUpdate = GamepadButton.X; break; case GamepadKeyCode.Button6: buttonToUpdate = GamepadButton.LeftTrigger; gamepadState.leftTrigger = (float)value; break; case GamepadKeyCode.Button7: buttonToUpdate = GamepadButton.RightTrigger; gamepadState.rightTrigger = (float)value; break; default: UE.Debug.Log("Unmapped button code: " + buttonIndex); break; } GamepadsStates[id] = gamepadState.WithButton(buttonToUpdate, GamepadEventType.ButtonDown == state || GamepadEventType.ButtonPressed == state); }
private void start() { gPS = new GamepadState(SlimDX.XInput.UserIndex.One); gPS = new GamepadState(SlimDX.XInput.UserIndex.One); tSticks = new Thread(CheckControllerSticks); tSticks.Start(); tButtons = new Thread(CheckControllerButtons); tButtons.Start(); tCheckApps = new Thread(CheckAppsRunning); tCheckApps.Start(); }
//移動中の処理 private void Run() { Move(); m_state = STATE.WAIT; GamepadState keyState = GamePad.GetState(playerStatus.playerNo); if (GamePad.GetButtonDown(GamePad.Button.A, playerStatus.playerNo)) { m_state = STATE.CHARGE; } }
void Update() { if (m_timerNeedUpdate) { UpdateTimer(); } GamepadState player_state = GamePad.GetState(m_movement.player_idx); ComputeCharacterInputAction(player_state); }
void SwitchButton() { GamepadState state = GamePad.GetState(GamePad.Index.One); if (state.A || state.B || state.X || state.Y || state.LeftTrigger != 0 || state.RightTrigger != 0 || state.LeftShoulder || state.RightShoulder) { Button buttonPressed = PullButton(state); string activeButton = controllerMenuInput.GrabActiveButton().GetLevel(); loadedProfile.SwapKeys(activeButton, buttonPressed); } }
public void Events_SendingStateToDeviceWithoutBeforeRenderEnabled_DoesNothingInBeforeRenderUpdate() { var gamepad = InputSystem.AddDevice <Gamepad>(); var newState = new GamepadState { leftStick = new Vector2(0.123f, 0.456f) }; InputSystem.QueueStateEvent(gamepad, newState); InputSystem.Update(InputUpdateType.BeforeRender); Assert.That(gamepad.leftStick.ReadValue(), Is.EqualTo(default(Vector2))); }
private void ControllerPreview_Load(object sender, EventArgs e) { xb = new GamepadState(0); axisLeft.DrawAxisDot = true; axisRight.DrawAxisDot = true; t.Interval = 1; t.Tick += T_Tick; t.Start(); }
public void Events_CanUpdateStateOfDeviceWithEvent() { var gamepad = InputSystem.AddDevice <Gamepad>(); var newState = new GamepadState { leftTrigger = 0.234f }; InputSystem.QueueStateEvent(gamepad, newState); InputSystem.Update(); Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.234f).Within(0.000001)); }
public void Events_CanUpdateStateOfDeviceWithEvent() { var gamepad = InputSystem.AddDevice <Gamepad>(); var newState = new GamepadState { leftStick = new Vector2(0.123f, 0.456f) }; InputSystem.QueueStateEvent(gamepad, newState); InputSystem.Update(); Assert.That(gamepad.leftStick.x.ReadValue(), Is.EqualTo(0.123f)); Assert.That(gamepad.leftStick.y.ReadValue(), Is.EqualTo(0.456f)); }
public MainPage() { this.InitializeComponent(); Logger.LogEvent = ConsoleLog; GamepadState = new GamepadState { Connected = false }; Task.Factory.StartNew(() => Setup()); }
private void SelectPlayer() { GamepadState gamepadState1 = GamePad.GetState(GamePad.Index.One); GamepadState gamepadState2 = GamePad.GetState(GamePad.Index.Two); // プレイヤー1のキャラー選択 if (!isOkLeft) { if (Input.GetKeyDown(KeyCode.A) || gamepadState1.Left) { do { if (Time.frameCount % 8 == 0) { indexLeft--; } indexLeft = Clamp(indexLeft); } while (selectedPlayer[indexLeft]); } if (Input.GetKeyDown(KeyCode.D) || gamepadState1.Right) { do { if (Time.frameCount % 8 == 0) { indexLeft++; } indexLeft = Clamp(indexLeft); } while (selectedPlayer[indexLeft]); } while (selectedPlayer[indexLeft]) { indexLeft++; } playerImgLeft.sprite = playerImgs[indexLeft]; } // キャラーを決めた if (Input.GetKeyDown(KeyCode.LeftShift) || gamepadState1.A) { isOkLeft = true; selectedPlayer[indexLeft] = true; readyL.gameObject.SetActive(isOkLeft); } if (isOkLeft) { Invoke("StartSplitMode", 3); } }
private void UpdateByState(GamepadState state) { //NOTE: ボタンの順序はStart()で初期化してる順番と揃えてます _buttonsList[0].IsPressed = state.Start; _buttonsList[1].IsPressed = state.B; _buttonsList[2].IsPressed = state.A; _buttonsList[3].IsPressed = state.X; _buttonsList[4].IsPressed = state.Y; _buttonsList[5].IsPressed = state.R1; _buttonsList[6].IsPressed = state.L1; _buttonsList[7].IsPressed = state.Right; _buttonsList[8].IsPressed = state.Down; _buttonsList[9].IsPressed = state.Left; _buttonsList[10].IsPressed = state.Up; var right = new Vector2Int(state.RightX, state.RightY); if (Mathf.Abs(right.x - _rightStickPosition.x) + Mathf.Abs(right.y - _rightStickPosition.y) > StickPositionDiffThreshold) { _rightStickPosition = right; _rightStick.OnNext(right); } var left = new Vector2Int(state.LeftX, state.LeftY); if (Mathf.Abs(left.x - _leftStickPosition.x) + Mathf.Abs(left.y - _leftStickPosition.y) > StickPositionDiffThreshold) { _leftStickPosition = left; _leftStick.OnNext(left); } //トリガー情報はDirectInputの場合ボタンベースで取得する。 //DUAL SHOCK 4のトリガーは連続値+ボタン情報で渡ってくるのでボタン情報だけ拾って使っている、という感じ。 if (_isRightTriggerDown != state.R2) { _isRightTriggerDown = state.R2; _buttonSubject.OnNext(new GamepadKeyData(GamepadKey.RTrigger, _isRightTriggerDown)); } if (_isLeftTriggerDown != state.L2) { _isLeftTriggerDown = state.L2; _buttonSubject.OnNext(new GamepadKeyData(GamepadKey.LTrigger, _isLeftTriggerDown)); } }
//溜め中の処理 private void Charge() { ChargeMove(); GamepadState keyState = GamePad.GetState(playerStatus.playerNo, false); if (GamePad.GetButtonUp(GamePad.Button.A, playerStatus.playerNo)) { m_state = STATE.ATTACK; } if (Input.GetKeyUp(KeyCode.Space)) { m_state = STATE.ATTACK; } }
void Start() { _rb = GetComponent <Rigidbody2D>(); _rb.velocity = new Vector2(0, -1); Debug.Log(_rb.velocity.ToString()); if (team == Main.Team.Blue) { controllerNum = GamePad.Index.Two; } _groundCheck = transform.Find("groundCheck"); _lastFrameState = GamePad.GetState(GamePad.Index.One); }
void FixedUpdate() { GamepadState state = this.GetComponent <RigidbodyNetworkedPlayerController>().gamepadState; Vector3 direction = new Vector3(); if (state != null) { if (state.A) { Quaternion currentRotation = this.GetComponent <Rigidbody>().transform.rotation; this.GetComponent <Rigidbody>().transform.rotation = Quaternion.Slerp(currentRotation, Quaternion.Euler(currentRotation.x, 90, currentRotation.z), this.rotationRightingSpeed); this.GetComponent <Rigidbody>().velocity = Vector3.Lerp(this.GetComponent <Rigidbody>().velocity, Vector3.zero, this.velocityDampingSpeed); this.GetComponent <Rigidbody>().angularVelocity = Vector3.Lerp(this.GetComponent <Rigidbody>().angularVelocity, Vector3.zero, this.velocityDampingSpeed); if (debug) { Debug.Log("Player rotation " + this.transform.rotation + " angularVelocity " + this.GetComponent <Rigidbody>().angularVelocity + " velocity " + this.GetComponent <Rigidbody>().velocity); } } if (!this.alreadyThrusted || true) // temporary true { if (state.LeftShoulder) { direction = this.GetComponent <Rigidbody>().transform.up; this.alreadyThrusted = true; } else if (state.RightShoulder) { direction = this.GetComponent <Rigidbody>().transform.up * -1; this.alreadyThrusted = true; } else { return; } } else { this.alreadyThrusted = true; } } if (Network.isServer || Network.isClient) { networkView.RPC("ActivateThrusters", RPCMode.AllBuffered, direction); } else { this.ActivateThrusters(direction); } }
public GamepadDevice(IntPtr sdlHandle) { this.sdlHandle = sdlHandle; deviceName = SDL.SDL_GameControllerName(sdlHandle); statesDoubleBuffer[0] = new GamepadState() { buttonsDown = new EnumLookupTable <Button, bool>(), axisValues = new EnumLookupTable <Axis, float>() }; statesDoubleBuffer[1] = new GamepadState() { buttonsDown = new EnumLookupTable <Button, bool>(), axisValues = new EnumLookupTable <Axis, float>() }; }
void ProcessGamepadAxisEvent(double x, double y, GamepadKeyCode axisKeyCode) { GamepadState gamepadState = m_gamepadState; if (axisKeyCode == GamepadKeyCode.Axis0) { gamepadState.leftStick = new UE.Vector2((float)x, (float)y); } if (axisKeyCode == GamepadKeyCode.Axis1) { gamepadState.rightStick = new UE.Vector2((float)x, (float)y); } m_gamepadState = gamepadState; }
public void State_UpdateWithoutStateEventDoesNotAlterStateOfDevice() { var gamepad = InputSystem.AddDevice <Gamepad>(); var state = new GamepadState { leftTrigger = 0.25f }; InputSystem.QueueStateEvent(gamepad, state); InputSystem.Update(); InputSystem.Update(); Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.25f).Within(0.000001)); }
public void State_CanUpdateButtonState() { var gamepad = InputSystem.AddDevice <Gamepad>(); Assert.That(gamepad.buttonEast.isPressed, Is.False); var newState = new GamepadState { buttons = 1 << (int)GamepadButton.B }; InputSystem.QueueStateEvent(gamepad, newState); InputSystem.Update(); Assert.That(gamepad.buttonEast.isPressed, Is.True); }
void Update() { GamepadState player_state = GamePad.GetState(player_idx); GamepadState player_statetwo = GamePad.GetState(player_idxtwo); if (player_state.A || player_state.B || player_state.X || player_state.Y || player_statetwo.A || player_statetwo.B || player_statetwo.X || player_statetwo.Y || Input.GetKeyDown("space")) { if (!loadingStart) { loadings.LoadingScene(scene_name); loadingStart = true; } } }
private void connectButton_Click(object sender, EventArgs e) { if (connectButton.Text == "Connect") { controller = new GamepadState(SlimDX.XInput.UserIndex.One); if (controller.Connected) { connectedTextBox.Text = "Connected"; } else { connectedTextBox.Text = "Disconnected"; } } if (controllerUpdateTimer == null) { controllerUpdateTimer = new System.Windows.Threading.DispatcherTimer(); controllerUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, delay); controllerUpdateTimer.Tick += new EventHandler(updateControllerState); controllerUpdateTimer.Start(); } }
Button PullButton( GamepadState aState ) { if( aState.A ) return Button.A; if( aState.B ) return Button.B; if( aState.X ) return Button.X; if( aState.Y ) return Button.Y; if( aState.LeftShoulder ) return Button.LeftShoulder; if( aState.RightShoulder ) return Button.RightShoulder; if( aState.LeftTrigger != 0 ) return Button.LeftTrigger; if( aState.RightTrigger != 0 ) return Button.RightTrigger; if( aState.Start ) return Button.Start; else { return Button.None; } }
public void OnImportsSatisfied() { for (int i = 0; i < 4; i++) { var gamepad = new GamepadState((UserIndex)i); FAllGamepads.Add(gamepad); } CheckConnectedDevices(); }
public GamepadEventArgs(int DeviceID, GamepadState State) { this.DeviceID = DeviceID; this.State = State; }
public override IEnumerator<bool> Execute() { Manager.Add(sum, 1); Manager.AddRangeTo(uvs, 1); Manager.AddRangeTo(seluvs, 1); Manager.AddRangeTo(udc, 2); foreach (var i in udc) i.AddSubOperation(SpritePatterns.Blink(30, 0.8, Easing.Linear)); Manager.Add(mc, 2); Manager.AddRangeTo(selopts, 1); Manager.OffsetX = 640; Manager.OffsetY = 240; //突入 for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 640, -640); yield return true; } Manager.OffsetX = 0; prevstate = Gamepad.GetState(); while (true) { state = Gamepad.GetState(); tstate = state.GetTriggerStateWith(prevstate); switch (cstate) { case 0: if (tstate.Buttons[1]) { Parent.SendChildMessage("ReturnToOptionEdit"); CommonObjects.SoundMenuCancel.Play(); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, 640); yield return true; } goto EXIT; } if (tstate.Buttons[0]) { CommonObjects.SoundMenuOK.Play(); if (usel == selopts.Count - 1) { var ol = new OptionInformation[5]; for (int i = 0; i < avu; i++) { ol[i] = new OptionInformation(opts[i]); ol[i].TargetOperation = OptionOperations.SelectionInformation[osi[i]].Operation; ol[i].InitializationInformation = oii[i]; } Parent.SendChildMessage("ApplyOptionInformation", ol); Parent.SendChildMessage("StartGame"); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, -640); yield return true; } goto EXIT; } else { GoToEditingMode(); } } if ((tstate.Direction & GamepadDirection.Up) != 0) { selopts[usel].AddSubOperation(SpritePatterns.Alpha(15, 0, Easing.Linear)); selopts[usel].AddSubOperation(SpritePatterns.Move(15, selopts[usel].X, selopts[usel].Y - 96, Easing.OutQuad)); usel = (usel + (selopts.Count - 1)) % selopts.Count; selopts[usel].Y = 128 + 96; selopts[usel].AddSubOperation(SpritePatterns.Alpha(15, 1, Easing.Linear)); selopts[usel].AddSubOperation(SpritePatterns.Move(15, selopts[usel].X, selopts[usel].Y - 96, Easing.OutQuad)); if (usel < avu) RefreshOptionInformation(false); smsel = 0; mc.AddSubOperation(SpritePatterns.VerticalMove(10, uvsmal[smsel].Y, Easing.OutQuad)); CommonObjects.SoundMenuSelect.Play(); } if ((tstate.Direction & GamepadDirection.Down) != 0) { selopts[usel].AddSubOperation(SpritePatterns.Alpha(15, 0, Easing.Linear)); selopts[usel].AddSubOperation(SpritePatterns.Move(15, selopts[usel].X, selopts[usel].Y + 96, Easing.OutQuad)); usel = (usel + 1) % selopts.Count; selopts[usel].Y = 128 - 96; selopts[usel].AddSubOperation(SpritePatterns.Alpha(15, 1, Easing.Linear)); selopts[usel].AddSubOperation(SpritePatterns.Move(15, selopts[usel].X, selopts[usel].Y + 96, Easing.OutQuad)); if (usel < avu) RefreshOptionInformation(false); smsel = 0; mc.AddSubOperation(SpritePatterns.VerticalMove(10, uvsmal[smsel].Y, Easing.OutQuad)); CommonObjects.SoundMenuSelect.Play(); } break; case 1: SubMenuOperation(); break; case 2: if (!UserValueInputOperation()) { var ivs = new StringSprite(CommonObjects.FontSystemMedium, CommonObjects.Colors.Red) { Value = "入力値が不正です!", X = seluvs[smsel].X, Y = seluvs[smsel].Y }; ivs.AddSubOperation(SpritePatterns.VerticalFadeOut(60, -64, Easing.OutQuad, Easing.Linear)); Manager.Add(ivs, 3); } break; } prevstate = state; yield return true; } EXIT: ; }
void Update() { var elapsed = Time.deltaTime; gamepadStates[PlayerIndex.One].Update(elapsed); gamepadStates[PlayerIndex.Two].Update(elapsed); gamepadStates[PlayerIndex.Three].Update(elapsed); gamepadStates[PlayerIndex.Four].Update(elapsed); First = gamepadStates[PlayerIndex.One].Connected ? gamepadStates[PlayerIndex.One] : gamepadStates[PlayerIndex.Two].Connected ? gamepadStates[PlayerIndex.Two] : gamepadStates[PlayerIndex.Three].Connected ? gamepadStates[PlayerIndex.Three] : gamepadStates[PlayerIndex.Four].Connected ? gamepadStates[PlayerIndex.Four] : null; any.Update(gamepadStates[PlayerIndex.One], gamepadStates[PlayerIndex.Two], gamepadStates[PlayerIndex.Three], gamepadStates[PlayerIndex.Four]); }
// Update as fast as possible void Update () { //Keyboard Input if (Input.GetKey (KeyCode.A)) moveLR = -1; else if (Input.GetKey (KeyCode.D)) moveLR = 1; else moveLR = 0; if (Input.GetKey (KeyCode.S)) moveUD = -1; else if (Input.GetKey (KeyCode.W)) moveUD = 1; else moveUD = 0; if (Input.GetKey (KeyCode.UpArrow)) fireUD = 1; else if (Input.GetKey (KeyCode.DownArrow)) fireUD = -1; else fireUD = 0; if (Input.GetKey (KeyCode.LeftArrow)) fireLR = -1; else if (Input.GetKey (KeyCode.RightArrow)) fireLR = 1; else fireLR = 0; //get the state of the gamepad state = GamePad.GetState((GamePad.Index)conNum); //head direction///////////////////////////////////////////////// if (state.rightStickAxis[0] > 0.5f || fireLR > 0f ) { attGo = true; attdir = Vector3.right; dirHeadX = 1f; dirHeadY = 0f; } else if (state.rightStickAxis[0] < -0.5f || fireLR < 0f) { attGo = true; attdir = Vector3.left; dirHeadX = -1f; dirHeadY = 0f; } else if (state.rightStickAxis [1] > 0.5f || fireUD > 0f) { attGo = true; attdir = Vector3.up; dirHeadY = 1f; dirHeadX = 0f; } else if (state.rightStickAxis [1] < -0.5f || fireUD < 0f) { attGo = true; attdir = Vector3.down; dirHeadY = -1f; dirHeadX = 0f; } else { attGo = false; } //set head sprite///////////////////////////////////////////////// if (dirHeadX == 1f) { Head.sprite = hRight; } else if (dirHeadY == 1f) { Head.sprite = hUp; } else if (dirHeadX == -1f) { Head.sprite = hLeft; } else if (dirHeadY == -1f) { Head.sprite = hDown; } //direction detirminer for body/////////////////////////////////////////// if (state.LeftStickAxis[0] > 0.5f || moveLR > 0) { if(dirHeadX == -1f) dirBodyX = -1f; else dirBodyX = 1f; dirBodyY = 0; } else if (state.LeftStickAxis[0] < -0.5f || moveLR < 0) { if(dirHeadX == 1f) dirBodyX = 1f; else dirBodyX = -1f; dirBodyY = 0; } if (state.LeftStickAxis[1] > 0.5f || moveUD > 0) { if(dirHeadY == -1f) dirBodyY = -1f; else dirBodyY = 1f; dirBodyX = 0; } else if (state.LeftStickAxis[1] < -0.5f || moveUD < 0) { if(dirHeadY == 1) dirBodyY = 1f; else dirBodyY = -1f; dirBodyX = 0; } //set body sprite///////////////////////////////////////////////////////// if (dirBodyX == 1f) { Body.sprite = bRight; } else if (dirBodyY == 1f) { Body.sprite = bUp; } else if (dirBodyX == -1f) { Body.sprite = bLeft; } else if (dirBodyY == -1f) { Body.sprite = bDown; } }
public override IEnumerator<bool> Execute() { Manager.OffsetX = 640; Manager.OffsetY = 240; Manager.Add(new StringSprite(CommonObjects.FontSystemMedium, CommonObjects.Colors.Black) { Value = "オプションユーザー選択", X = 210, Y = 8 }, 0); Manager.AddRangeTo(opod, 0); Manager.AddRangeTo(opsn, 0); Manager.Add(opop, 0); Manager.Add(next, 0); Manager.Add(new StringSprite(CommonObjects.FontSystemMedium, CommonObjects.Colors.Black) { X = 320, Y = 64 - 8, Value = "検索:" }, 1); Manager.Add(valid, 0); mc.AddSubOperation(SpritePatterns.Blink(30, 0.5, Easing.Linear)); Manager.Add(mc, 1); mc.X = mal[msel].X; mc.Y = mal[msel].Y; Manager.AddRangeTo(okcancel, 1); Manager.Add(ouip, 1); //突入 for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, b ? -640 : 640, b ? 640 : -640); yield return true; } Manager.OffsetX = 0; prevstate = Gamepad.GetState(); while (true) { state = Gamepad.GetState(); tstate = state.GetTriggerStateWith(prevstate); switch (cs) { case 0: if (tstate.Buttons[1]) { Parent.SendChildMessage("ReturnToAccountSelect"); CommonObjects.SoundMenuCancel.Play(); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, 640); yield return true; } goto EXIT; } if (tstate.Buttons[0]) { CommonObjects.SoundMenuOK.Play(); if (msel < 5) { GoToOptionOperationSelect(); } else { Parent.SendChildMessage("GoToOptionSetting"); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, -640); yield return true; } goto EXIT; } } OptionUserOrderSelectionOperation(); break; case 1: OptionScreenNameInputOperation(); break; case 2: OptionDecisionOperation(); break; case 3: //本当はScreenNameInputの前だけどゆるして OptionOperationSelectionOperation(); break; } prevstate = state; yield return true; } EXIT: ; }
public override IEnumerator<bool> Tick() { prevstate = Gamepad.GetState(); while (true) { state = Gamepad.GetState(); tstate = state.GetTriggerStateWith(prevstate); Operation.MoveNext(); Manager.TickAll(); Children.TickAll(); prevstate = state; yield return true; } }
// Update is called once per frame void Update() { if (isDead || isLocked) return; animator.SetBool("LyingDown", isLyingDown); animator.SetBool("IsUp", isUp); aimLine.enabled = isUp; if (isLyingDown) { Collider[] hits = Physics.OverlapSphere(transform.position, 4); foreach (Collider c in hits) { Painting paint = c.GetComponent<Painting>(); if (paint != null) { drainGroup = paint.splatGroup; } } if (drainGroup != null) { player.Drain(0.025f * Time.deltaTime); drainGroup.Drain(1f * Time.deltaTime); isReviving = true; } if (isReviving && drainGroup == null) { isLyingDown = false; } } else { if (animator.GetCurrentAnimatorStateInfo(3).IsName("Disabled")) { isUp = true; animator.SetBool("IsUp", isUp); } } if (!isUp) return; padState = GamepadInput.GamePad.GetState(GamepadInput.GamePad.Index.One); leftStickInUse = (padState.LeftStickAxis.magnitude > leftStickDeadzone); rightStickInUse = (padState.rightStickAxis.magnitude > rightStickDeadzone && canShoot); if (useRemaining > 0 && canShoot) useRemaining -= Time.deltaTime; aimLine.enabled = ((rightStickInUse && canShoot) || currentShotCharge > 0); if (sonarDelayRemaining > 0 ) { sonarDelayRemaining -= Time.deltaTime; } else if (sonarDelayRemaining <= 0 && haveSonar) { haveSonar = false; particleSystemSonar.Play(); audioSource_misc.Stop(); audioSource_misc.volume = 0.05F; audioSource_misc.PlayOneShot(onSonar); Collider[] hitColliders = Physics.OverlapSphere(transform.position, sonarRange); List<Vector3> blips = new List<Vector3>(); foreach (Collider c in hitColliders) { bool isVisible = false; foreach (MeshRenderer m in c.gameObject.GetComponentsInChildren<MeshRenderer>()) { if (m.enabled) { isVisible = true; break; } } if (isVisible) { Activator_OnSonar activator = c.gameObject.GetComponent<Activator_OnSonar>(); Activator_GroundButton activatorGb = c.gameObject.GetComponent<Activator_GroundButton>(); if (activator != null) { activator.Activate(); } else if (activatorGb != null) { activatorGb.Activate(); } } else { if (c.gameObject.layer != LayerMask.NameToLayer("Hidden KeyObjects")) continue; blips.Add(c.transform.position); } } Sonar(blips.ToArray()); hitColliders = Physics.OverlapSphere(transform.position, pushRange); List<EnemyInfo> hitEnemies = new List<EnemyInfo>(); foreach (Collider c in hitColliders) { EnemyInfo hitEnemy = c.GetComponent<EnemyInfo>(); if (Vector3.Distance(transform.position, c.transform.position) < pushRange && hitEnemy != null) { hitEnemies.Add(hitEnemy); } } Push(hitEnemies.ToArray(), pushForce); } //Rotates player to face in the direction of the right stick, if right stick not applied, faces same direction as before float aimAngle = 0; if (currentShotCharge <= 0) { if (canShoot) { slingshotLineRenderer.SetVertexCount(2); slingshotLineRenderer.SetPosition(0, slingshotEnds[0].position); slingshotLineRenderer.SetPosition(1, slingshotEnds[1].position); } } if (rightStickInUse || currentShotCharge > 0) { if (!rightStickInUse && currentShotCharge > 0) { aimAngle = Mathf.Atan2(lastRightStickPosition.x, lastRightStickPosition.y) * Mathf.Rad2Deg; } else if (rightStickInUse) { aimAngle = Mathf.Atan2(padState.rightStickAxis.x, padState.rightStickAxis.y) * Mathf.Rad2Deg; } if (canShoot) { slingshotLineRenderer.SetVertexCount(3); slingshotLineRenderer.SetPosition(0, slingshotEnds[0].position); slingshotLineRenderer.SetPosition(1, leftHand.position); slingshotLineRenderer.SetPosition(2, slingshotEnds[1].position); } } barrelEnd.rotation = Quaternion.AngleAxis(aimAngle, barrelEnd.up); //Animations if (leftStickInUse) lastLeftStickPosition = padState.LeftStickAxis; if (rightStickInUse) lastRightStickPosition = padState.rightStickAxis; Vector2 tempLeftStickAxis = padState.LeftStickAxis; Vector2 tempRightStickAxis = padState.rightStickAxis; if (tempRightStickAxis == Vector2.zero && currentShotCharge > 0) tempRightStickAxis = lastRightStickPosition; if (tempLeftStickAxis == Vector2.zero) tempLeftStickAxis = lastLeftStickPosition; float vertical = tempLeftStickAxis.magnitude; if (Vector2.Angle(tempLeftStickAxis, tempRightStickAxis) > 91) { vertical = -vertical; } if (!leftStickInUse) vertical = 0; float horizontal = 0; float leftAngle = Vector2.Angle(new Vector2(0, 1), tempLeftStickAxis); if (tempLeftStickAxis.x < 0) leftAngle = 360 - leftAngle; if (tempRightStickAxis == Vector2.zero || !canShoot) { horizontal = 0; } else { float rightAngle = Vector2.Angle(tempLeftStickAxis, tempRightStickAxis); Vector2 refVec = new Vector2(Mathf.Sin((leftAngle + 90) * Mathf.Deg2Rad), Mathf.Cos((leftAngle + 90) * Mathf.Deg2Rad)); float relativeAngle = (rightAngle / 90); if (Vector2.Angle(refVec, tempRightStickAxis) < 90) { if (vertical > 0) { horizontal = relativeAngle; } else if (vertical < 0) { horizontal = 1 - (relativeAngle - 1); horizontal = -horizontal; } else if (vertical == 0) { horizontal = relativeAngle; if (oppositeRotation) horizontal = relativeAngle - 2; } } else { if (vertical > 0) { horizontal = -relativeAngle; } else if (vertical < 0) { horizontal = 1 - (relativeAngle - 1); } else if (vertical == 0) { horizontal = -relativeAngle; if (oppositeRotation) { horizontal = 1 - (relativeAngle - 1); } } } } animator.SetBool("RightStickInUse", ((rightStickInUse || currentShotCharge > 0) && canShoot)); animator.SetFloat("Vertical", vertical); animator.SetFloat("Horizontal", horizontal); //Shoot if right trigger is pulled enough if (canShoot && player.canShoot) { if (padState.RightTrigger > rightTriggerDeadzone && (rightStickInUse || currentShotCharge > 0)) { //XInputDotNetPure.GamePad.SetVibration(PlayerIndex.One, (currentShotCharge / maxShotChargeTime) * rumbleSensivity, (currentShotCharge / maxShotChargeTime) * rumbleSensivity); if (!shotChargeSoundIsPlaying) { audioSource_shooting.PlayOneShot(isChargingShot, soundVolume); shotChargeSoundIsPlaying = true; } if (shotChargeSoundIsPlaying && !audioSource_shooting.isPlaying) shotChargeSoundIsPlaying = false; currentShotCharge += Time.deltaTime; if (currentShotCharge > maxShotChargeTime) { if (!speedIndicSling.isPlaying) speedIndicSling.Play(); currentShotCharge = maxShotChargeTime; audioSource_shooting.Stop(); shotChargeSoundIsPlaying = false; } else { if (speedIndicSling.isPlaying) { speedIndicSling.Clear(); speedIndicSling.Stop(); } } } else if (currentShotCharge > 0) { if (currentShotCharge > minShotChargeTime) { shotChargeSoundIsPlaying = false; audioSource_shooting.Stop(); audioSource_shooting.PlayOneShot(onShotRelease, soundVolume); GameData.ShotType shotType; if (currentShotCharge == maxShotChargeTime) { shotType = GameData.ShotType.Charged; } else shotType = GameData.ShotType.Normal; Shoot(shotType); currentShotCharge = 0; } else { currentShotCharge = 0; } //XInputDotNetPure.GamePad.SetVibration(PlayerIndex.One, 0, 0); if (shotChargeSoundIsPlaying) audioSource_shooting.Stop(); if (speedIndicSling.isPlaying) { speedIndicSling.Clear(); speedIndicSling.Stop(); } } animator.SetFloat("ShotCharge", currentShotCharge); } else { if (speedIndicSling.isPlaying) { speedIndicSling.Clear(); speedIndicSling.Stop(); } } //Use closest item to the player that is within use range if (padState.B && useRemaining <= 0) { Collider[] hitColliders = Physics.OverlapSphere(transform.position, useRadius); InteractableObject closestObj = null; float distance = float.MaxValue; foreach (Collider c in hitColliders) { float magnitude = (transform.position - c.transform.position).sqrMagnitude; InteractableObject io = c.GetComponent<InteractableObject>(); if (magnitude < distance && io != null) { distance = magnitude; closestObj = io; } } if (closestObj != null) { Use(closestObj); } useRemaining = useCooldown; } //Sonar if (padState.LeftTrigger > leftTriggerDeadzone && player.canSonar) { haveSonar = true; sonarDelayRemaining = sonarDelay; player.Sonar(); animator.SetTrigger("Sonar"); } //Try to absorb color from underneath you, if you are not doing anything else, and you have capacity to absorb if (padState.A && padState.LeftTrigger < leftTriggerDeadzone && padState.RightTrigger < rightTriggerDeadzone && drainGroup != null) { currentDrainAccel += drainSpeedAccel * Time.deltaTime; if (currentDrainAccel > maxDrainSpeed) currentDrainAccel = maxDrainSpeed; actualDrainSpeed = Mathf.Lerp(actualDrainSpeed, maxDrainSpeed, currentDrainAccel); if (player.Drain(drainGroup.splats.Count * actualDrainSpeed * Time.deltaTime)) { if (!particleDrain.isPlaying) particleDrain.Play(); drainGroup.Drain(actualDrainSpeed); if (!audioSource_draining.isPlaying) { audioSource_draining.volume = 0.05F; audioSource_draining.PlayOneShot(isDraining); } } else { if(audioSource_draining.volume <= 0) { if (audioSource_draining.isPlaying) audioSource_draining.Stop(); } else { audioSource_draining.volume -= 0.02F; } if (particleDrain.isPlaying) particleDrain.Stop(); } } else { if (audioSource_draining.volume <= 0) { if (audioSource_draining.isPlaying) audioSource_draining.Stop(); } else { audioSource_draining.volume -= 0.02F; } actualDrainSpeed = 0; player.StopDraining(); if (particleDrain.isPlaying) particleDrain.Stop(); } if (padState.Start) { gameController.PauseGame(); } }
void FixedUpdate() { CanShoot = canShoot; if (!isUp || isDead || isLocked) return; padState = GamepadInput.GamePad.GetState(GamepadInput.GamePad.Index.One); GetComponent<Rigidbody>().AddForce(new Vector3(padState.LeftStickAxis.x * leftStickSensivity, 0, padState.LeftStickAxis.y * leftStickSensivity) * moveSpeed); if (leftStickInUse) { rotationAngleGoal = Mathf.Atan2(padState.LeftStickAxis.x, padState.LeftStickAxis.y) * Mathf.Rad2Deg; } if (leftStickInUse && stepIntervalRemaining > 0) { stepIntervalRemaining -= Time.deltaTime * stepSoundIntervalMultiplier * padState.LeftStickAxis.magnitude; } if (stepIntervalRemaining <= 0) { audioSource_walking.Stop(); if (footsteps.Length > 0) audioSource_walking.PlayOneShot(footsteps[Random.Range(0, footsteps.Length - 1)]); stepIntervalRemaining = 1; } Vector2 tempLeftStickAxis = padState.LeftStickAxis; Vector2 tempRightStickAxis = padState.rightStickAxis; if (!leftStickInUse) { tempLeftStickAxis = lastLeftStickPosition; } if (!rightStickInUse && currentShotCharge > 0) { tempRightStickAxis = lastRightStickPosition; } if (Vector2.Angle(tempLeftStickAxis, tempRightStickAxis) > 91) { oppositeRotation = true; } else { oppositeRotation = false; } //Rotates the player at a given Max speed float rotMod = 0; if (oppositeRotation) rotMod += 180; if (rightStickInUse || currentShotCharge > 0) rotMod += 90; transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0, rotationAngleGoal + rotMod, 0), playerRotationSpeed * Time.deltaTime); }
public void Update(GamepadState first, GamepadState second, GamepadState third, GamepadState fourth) { Connected = first.Connected || second.Connected || third.Connected || fourth.Connected; if (!Connected) return; // Shoulders LeftShoulder = ArrayHelper.Coalesce(first.LeftShoulder, second.LeftShoulder, third.LeftShoulder, fourth.LeftShoulder); RightShoulder = ArrayHelper.Coalesce(first.RightShoulder, second.RightShoulder, third.RightShoulder, fourth.RightShoulder); // Triggers LeftTrigger = ArrayHelper.Coalesce(first.LeftTrigger, second.LeftTrigger, third.LeftTrigger, fourth.LeftTrigger); RightTrigger = ArrayHelper.Coalesce(first.RightTrigger, second.RightTrigger, third.RightTrigger, fourth.RightTrigger); // Buttons Start = ArrayHelper.Coalesce(ComplexButtonStateComparer.Default, first.Start, second.Start, third.Start, fourth.Start); Back = ArrayHelper.Coalesce(ComplexButtonStateComparer.Default, first.Back, second.Back, third.Back, fourth.Back); A = ArrayHelper.Coalesce(first.A, second.A, third.A, fourth.A); B = ArrayHelper.Coalesce(first.B, second.B, third.B, fourth.B); X = ArrayHelper.Coalesce(first.X, second.X, third.X, fourth.X); Y = ArrayHelper.Coalesce(first.Y, second.Y, third.Y, fourth.Y); // D-Pad DPad = ArrayHelper.Coalesce(first.DPad, second.DPad, third.DPad, fourth.DPad); // Thumbsticks LeftStick = ArrayHelper.Coalesce(first.LeftStick, second.LeftStick, third.LeftStick, fourth.LeftStick); RightStick = ArrayHelper.Coalesce(first.RightStick, second.RightStick, third.RightStick, fourth.RightStick); }
//called on an interval void FixedUpdate() { state = GamePad.GetState((GamePad.Index)conNum); fullBodyPosition = new Vector3 ((speed * (state.LeftStickAxis [0] + moveLR)) + gameObject.GetComponent<Transform> ().position.x, (speed * (state.LeftStickAxis [1] + moveUD)) + gameObject.GetComponent<Transform> ().position.y, 0); //wepon/////////////////////////////////////////////////////////////////// if (fireType == 1) { if (gunCool < 0 && attGo) { gunCool = gunCycle; GameObject tempLaser = GameObject.Find ("PoolLasers").GetComponent<ObjectPoolScript> ().FetchObject (); tempLaser.GetComponent<Transform> ().position = fullBodyPosition; tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); } } else if (fireType == 2) { if (gunCool < 0 && attGo) { gunCool = gunCycle; if(attdir.x == 1 || attdir.x == -1) { GameObject tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y+.3f,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y-.3f,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); } else { GameObject tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x +.3f,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x -.3f ,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); } } } else if (fireType == 3) { if (gunCool < 0 && attGo) { gunCool = gunCycle; if(attdir.x == 1 || attdir.x == -1) { GameObject tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y+.1f,0); tempLaser.GetComponent<lazer> ().dir (new Vector3(attdir.x,attdir.y + .2f,0),range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y-.1f,0); tempLaser.GetComponent<lazer> ().dir (new Vector3(attdir.x,attdir.y - .2f,0),range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); } else { GameObject tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x +.1f,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (new Vector3(attdir.x + .2f,attdir.y ,0),range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x -.1f ,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (new Vector3(attdir.x - .2f,attdir.y,0 ),range,pir); tempLaser = Laser.FetchObject (); tempLaser.GetComponent<Transform>().position = new Vector3(fullBodyPosition.x ,fullBodyPosition.y,0); tempLaser.GetComponent<lazer> ().dir (attdir,range,pir); } } } gunCool --; if (dmgon){ dmgCool --; if(dmgCool < 0) { dmgCool = 50; health --; } } dmgCool --; full.position = fullBodyPosition; }
private void UpdateGame (GamepadState state) { // No action if not your turn if (Game.instance.currentPlayer.canAction == false) { return; } // Do you press a button ? if(isTriggered == false) { /****** Actions ******/ /* Button A */ if (GamePad.GetButtonDown(GamePad.Button.A, Game.instance.currentPlayer.controllerIndex) == true && Game.instance.currentPlayer.GetCountMinions(MinionColor.GREEN) > 0) { buttonTriggered = GamePad.Button.A; isTriggered = true; _isKeyStroke = false; currentMode = Mode.Action; return; } else if (Input.GetButton("Button_A") == true && Game.instance.currentPlayer.GetCountMinions(MinionColor.GREEN) > 0) { buttonTriggered = GamePad.Button.A; isTriggered = true; _isKeyStroke = true; currentMode = Mode.Action; return; } /* Button B */ if (GamePad.GetButtonDown(GamePad.Button.B, Game.instance.currentPlayer.controllerIndex) == true && Game.instance.currentPlayer.GetCountMinions (MinionColor.RED) > 0) { buttonTriggered = GamePad.Button.B; isTriggered = true; _isKeyStroke = false; currentMode = Mode.Action; return; } else if (Input.GetButton("Button_B") == true && Game.instance.currentPlayer.GetCountMinions(MinionColor.RED) > 0) { buttonTriggered = GamePad.Button.B; isTriggered = true; _isKeyStroke = true; currentMode = Mode.Action; return; } /* Button X */ if (GamePad.GetButtonDown(GamePad.Button.X, Game.instance.currentPlayer.controllerIndex) == true && Game.instance.currentPlayer.GetCountMinions (MinionColor.BLUE) > 0) { buttonTriggered = GamePad.Button.X; isTriggered = true; _isKeyStroke = false; currentMode = Mode.Action; return; } else if (Input.GetButton("Button_X") == true && Game.instance.currentPlayer.GetCountMinions(MinionColor.BLUE) > 0) { buttonTriggered = GamePad.Button.X; isTriggered = true; _isKeyStroke = true; currentMode = Mode.Action; return; } /* Button Y */ if (GamePad.GetButtonDown(GamePad.Button.Y, Game.instance.currentPlayer.controllerIndex) == true && Game.instance.currentPlayer.GetCountMinions (MinionColor.YELLOW) > 0) { buttonTriggered = GamePad.Button.Y; isTriggered = true; _isKeyStroke = false; currentMode = Mode.Action; return; } else if (Input.GetButton("Button_Y") == true && Game.instance.currentPlayer.GetCountMinions(MinionColor.YELLOW) > 0) { buttonTriggered = GamePad.Button.Y; isTriggered = true; _isKeyStroke = true; currentMode = Mode.Action; return; } /* Moves */ if (Input.GetButton("Up") == true || state.Up == true) { int tmpTileIndex = Game.instance.currentPlayer.tileIndex - (1 * Game.instance.currentPlayer.speed * Game.instance.mapManager.map.columns); if (Game.instance.currentPlayer.CanMove(tmpTileIndex) == true) { buttonTriggered = GamePad.Button.Up; isTriggered = true; _isKeyStroke = Input.GetButton("Up") == true; currentMode = Mode.Move; _newTileIndex = tmpTileIndex; return; } } if (Input.GetButton("Right") == true || state.Right == true) { int tmpTileIndex = Game.instance.currentPlayer.tileIndex + (1 * Game.instance.currentPlayer.speed); if (Game.instance.currentPlayer.CanMove(tmpTileIndex) == true) { buttonTriggered = GamePad.Button.Right; isTriggered = true; _isKeyStroke = Input.GetButton("Right") == true; currentMode = Mode.Move; _newTileIndex = tmpTileIndex; return; } } if (Input.GetButton("Down") == true || state.Down == true) { int tmpTileIndex = Game.instance.currentPlayer.tileIndex + (1 * Game.instance.currentPlayer.speed * Game.instance.mapManager.map.columns); if (Game.instance.currentPlayer.CanMove(tmpTileIndex) == true) { buttonTriggered = GamePad.Button.Down; isTriggered = true; _isKeyStroke = Input.GetButton("Down") == true; currentMode = Mode.Move; _newTileIndex = tmpTileIndex; return; } } if (Input.GetButton("Left") == true || state.Left == true) { int tmpTileIndex = Game.instance.currentPlayer.tileIndex - (1 * Game.instance.currentPlayer.speed); if (Game.instance.currentPlayer.CanMove(tmpTileIndex) == true) { buttonTriggered = GamePad.Button.Left; isTriggered = true; _isKeyStroke = Input.GetButton("Left") == true; currentMode = Mode.Move; _newTileIndex = tmpTileIndex; return; } } } // Do you release a button ? else { if (buttonTriggered == GamePad.Button.A && ((GamePad.GetButtonUp(GamePad.Button.A, Game.instance.currentPlayer.controllerIndex) == true && _isKeyStroke == false) || (Input.GetButton("Button_A") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; return; } if (buttonTriggered == GamePad.Button.B && ((GamePad.GetButtonUp(GamePad.Button.B, Game.instance.currentPlayer.controllerIndex) == true && _isKeyStroke == false) || (Input.GetButton("Button_B") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; return; } if (buttonTriggered == GamePad.Button.X && ((GamePad.GetButtonUp(GamePad.Button.X, Game.instance.currentPlayer.controllerIndex) == true && _isKeyStroke == false) || (Input.GetButton("Button_X") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; return; } if (buttonTriggered == GamePad.Button.Y && ((GamePad.GetButtonUp(GamePad.Button.Y, Game.instance.currentPlayer.controllerIndex) == true && _isKeyStroke == false) || (Input.GetButton("Button_Y") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; return; } if (buttonTriggered == GamePad.Button.Up && ((state.Up == false && _isKeyStroke == false) || (Input.GetButton("Up") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; ActionLoader.instance.CleanHighlight(_newTileIndex); return; } if (buttonTriggered == GamePad.Button.Right && ((state.Right == false && _isKeyStroke == false) || (Input.GetButton("Right") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; ActionLoader.instance.CleanHighlight(_newTileIndex); return; } if (buttonTriggered == GamePad.Button.Down && ((state.Down == false && _isKeyStroke == false) || (Input.GetButton("Down") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; ActionLoader.instance.CleanHighlight(_newTileIndex); return; } if (buttonTriggered == GamePad.Button.Left && ((state.Left == false && _isKeyStroke == false) || (Input.GetButton("Left") == false && _isKeyStroke == true)) ) { buttonTriggered = GamePad.Button.None; isTriggered = false; _isKeyStroke = false; currentMode = Mode.None; ActionLoader.instance.CleanHighlight(_newTileIndex); return; } } }
public override IEnumerator<bool> Execute() { Manager.OffsetX = backing ? -640 : 640; Manager.OffsetY = 240; if (ainfo.Accounts.Length == 0) { Manager.Add(new StringSprite(CommonObjects.FontSystemSmall, CommonObjects.Colors.Red) { X = 16, Y = 120, Value = "アカウントがありません。Kbtter4で登録してください。" }, 2); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 640, -640); yield return true; } Manager.OffsetX = 0; while (true) yield return true; } LoadUsers(); var sel = 0; Manager.AddRangeTo(uips, 1); for (int i = 0; i < uips.Length; i++) { uips[i].Y = 240 * i; if (i != sel) uips[i].Alpha = 0; } Manager.Add(new StringSprite(CommonObjects.FontSystemMedium, CommonObjects.Colors.Black) { Value = "アカウント選択", X = 250, Y = 8 }, 0); udc = new[] { new MultiAdditionalCoroutineSprite(){HomeX=64,HomeY=64,ScaleX=0.8,ScaleY=0.4,Image=CommonObjects.ImageCursor128[2],X=64,Y=48}, new MultiAdditionalCoroutineSprite(){HomeX=64,HomeY=64,ScaleX=0.8,ScaleY=0.4,Image=CommonObjects.ImageCursor128[3],X=64,Y=208}, }; Manager.AddRangeTo(udc, 2); foreach (var i in udc) i.AddSubOperation(SpritePatterns.Blink(30, 0.8, Easing.Linear)); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, backing ? -640 : 640, backing ? 640 : -640); yield return true; } Manager.OffsetX = 0; prevstate = Gamepad.GetState(); while (true) { state = Gamepad.GetState(); tstate = state.GetTriggerStateWith(prevstate); if (tstate.Buttons[1]) { Parent.SendChildMessage("ReturnToMenuSelect"); CommonObjects.SoundMenuCancel.Play(); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, 640); yield return true; } break; } if (tstate.Buttons[0] && uinfo[sel] != null) { Parent.SendChildMessage("GoToOptionEdit:" + sel.ToString()); CommonObjects.SoundMenuOK.Play(); for (int i = 0; i < 40; i++) { Manager.OffsetX = Easing.OutQuad(i, 40, 0, -640); yield return true; } break; } if ((tstate.Direction & GamepadDirection.Up) != 0) { uips[sel].AddSubOperation(SpritePatterns.Move(15, 0, -120, Easing.OutQuad)); uips[sel].AddSubOperation(SpritePatterns.Alpha(15, 0, Easing.OutQuad)); sel = (sel + uips.Length - 1) % uips.Length; uips[sel].Y = 120; uips[sel].AddSubOperation(SpritePatterns.Move(15, 0, 0, Easing.OutQuad)); uips[sel].AddSubOperation(SpritePatterns.Alpha(15, 1, Easing.OutQuad)); CommonObjects.SoundMenuSelect.Play(); } if ((tstate.Direction & GamepadDirection.Down) != 0) { uips[sel].AddSubOperation(SpritePatterns.Move(15, 0, 120, Easing.OutQuad)); uips[sel].AddSubOperation(SpritePatterns.Alpha(15, 0, Easing.OutQuad)); sel = (sel + 1) % uips.Length; uips[sel].Y = -120; uips[sel].AddSubOperation(SpritePatterns.Move(15, 0, 0, Easing.OutQuad)); uips[sel].AddSubOperation(SpritePatterns.Alpha(15, 1, Easing.OutQuad)); CommonObjects.SoundMenuSelect.Play(); } prevstate = state; yield return true; } }