private void _endTouch() { if (!СGameController.IsInputState()) { return; } _isDragged = false; if (_state == GameInputState.MOVING) { if (_currentCell && _currentCell.Piece) { _currentCell.Piece.zIndex = _beforeDragZIndex; if (GameEngine.GameController != null) { Debug.Log("End drag piece"); GameEngine.GameController.OnPlayerEndDragBoard(_currentCell); _currentCell = null; } } _state = GameInputState.WAIT_MOVE; } else if (_state == GameInputState.FIGHT_CELL) { if (_currentCell && _currentCell.HasFight) { _gameEngine.FightUi.DisplayFightInput(_currentCell); SetUiInput(true); } } }
void SendInput(BaseEventData e, GameInputState state) { var pe = (PointerEventData)e; var pos = _cameraView.ScreenToWorldPoint(pe.position); //前回がUpだったか、押されたタイミング if (_model.State == GameInputState.PointerUp || state == GameInputState.PointerDown) { Debug.Log("Reset"); _before = pe.position; _model.DownPos = pe.position; _model.WorldDownPos = pos; } if (state == GameInputState.PointerDown) { //downの時のみ判定 var mode = InputMode.MoveCamera; if (_mapPlaceUseCase.SelectedTile != null) { mode = InputMode.PlaceTile; } _model.InputMode = mode; } _model.Delta = pe.delta; _model.WorldDelta = pos - _cameraView.ScreenToWorldPoint(_before); _model.CurrentPos = pe.position; _model.WorldCurrentPos = pos; _model.State = state; _inputManager.InputOnGame(_model); _before = pe.position; }
public override void Begin() { base.Begin(); this.player = PlayerNetworkController.playerNumber; this.adapter = this.gameObject.GetComponent <NetworkAdapter>(); GameInputState input = new GameInputState(this.listenerId, 1); input.SetInputMapping(GameInputState.LEFT_STICK_LEFT_RIGHT, "moveStick"); input.SetInputMapping(GameInputState.A, "chargeButton"); input.SetInputMapping(GameInputState.B, "specialButton"); input.SetInputMapping(GameInputState.START, "start"); this.AddCurrentState(input); PlayerNetworkController.playerNumber++; }
public override void Begin() { base.Begin(); this.focusChangeTimer = this.focusChangeTimerDefault = 0.2; SettingsMenuInputState settingsInput = new SettingsMenuInputState(this.listenerId); GameInputState input = new GameInputState(this.listenerId, 1); input.SetInputMapping(GameInputState.LEFT_STICK_UP_DOWN, "leftStickUpDown"); input.SetInputMapping(GameInputState.LEFT_STICK_LEFT_RIGHT, "leftStickLeftRight"); input.SetInputMapping(GameInputState.A, "select"); input.SetInputMapping(GameInputState.B, "close"); this.AddCurrentState(settingsInput); this.AddCurrentState(input); }
private void _beginTouch(Vector2 touchPosition) { if (!СGameController.IsInputState()) { return; } if (_state != GameInputState.WAIT_MOVE) { return; } _mouseBeginDragPos = Camera.main.ScreenToWorldPoint(touchPosition); _mouseBeginDragPos = new Vector3(_mouseBeginDragPos.x * GameEngine.TO_PIXELS, _mouseBeginDragPos.y * GameEngine.TO_PIXELS, 0); int posX = (int)Mathf.Round(_mouseBeginDragPos.x / GameEngine.CELL_SIZE); int posY = (int)Mathf.Round(_mouseBeginDragPos.y / GameEngine.CELL_SIZE); if (posX > -1 && posY > -1 && posY < _gameEngine.Board.Cells.Length && posX < ChessBoard.W) { Cell cell = _gameEngine.Board.Cells[posY, posX]; if (cell && !cell.HasFight && cell.Piece && cell.Piece.Relation == PieceRelation.SELF) { _state = GameInputState.MOVING; _isDragged = true; _currentCell = cell; BasePiece piece = cell.Piece; _beforeDragZIndex = piece.zIndex; piece.zIndex = ZIndex.DRAGGING_PIECE; Debug.Log("begin drag at " + posX + " " + posY); if (GameEngine.GameController != null) { GameEngine.GameController.OnPlayerBeginDragBoard(cell); } } else if (cell && cell.HasFight) { _state = GameInputState.FIGHT_CELL; _currentCell = cell; } } }
public override void Begin() { base.Begin(); GameSystem.SetTimeMultiplier(GameSystem.GAMEPLAY, 1.0); IdleState idle = new IdleState(this.listenerId); MovingForwardState movingForward = new MovingForwardState(this.listenerId); MovingBackwardState movingBackward = new MovingBackwardState(this.listenerId); QuickStepForwardState quickStepForward = new QuickStepForwardState(this.listenerId); QuickStepBackwardState quickStepBackward = new QuickStepBackwardState(this.listenerId); DashChargingState dashCharging = new DashChargingState(this.listenerId); DashState dash = new DashState(this.listenerId); FeintState feint = new FeintState(this.listenerId); ChargingState charging = new ChargingState(this.listenerId); ChargeRecoveryState chargeRecovery = new ChargeRecoveryState(this.listenerId); DashRecoveryState dashRecovery = new DashRecoveryState(this.listenerId); //SpecialActivateState specialActivate = new SpecialActivateState(this.listenerId); //SpecialChargingState specialCharging = new SpecialChargingState(this.listenerId); CollisionWinCondition collisionWinCond = new CollisionWinCondition(this.listenerId); CollisionLossCondition collisionLossCond = new CollisionLossCondition(this.listenerId); CollisionWinState collisionWin = new CollisionWinState(this.listenerId); CollisionLossState collisionLoss = new CollisionLossState(this.listenerId); PlayerReadyState ready = new PlayerReadyState(this.listenerId); PlayerPlayingState playing = new PlayerPlayingState(this.listenerId); PlayerPausedState paused = new PlayerPausedState(this.listenerId); VictoryState victory = new VictoryState(this.listenerId); DefeatState defeat = new DefeatState(this.listenerId); //SpecialActivateCondition specialActivateCond = new SpecialActivateCondition(this.listenerId); DefeatCondition defeatCond = new DefeatCondition(this.listenerId); idle.AddStateChange("moveForward", movingForward); idle.AddStateChange("moveBackward", movingBackward); idle.AddStateChange("charge", charging); idle.AddStateChange("dashCharge", dashCharging); idle.AddStateChange("feint", feint); idle.AddStateChange("collisionWin", collisionWin); idle.AddStateChange("collisionLoss", collisionLoss); //idle.AddStateChange("specialActivate", specialActivate); idle.AddGameStateCondition(collisionWinCond); idle.AddGameStateCondition(collisionLossCond); //idle.AddGameStateCondition(specialActivateCond); movingForward.AddStateChange("stop", idle); movingForward.AddStateChange("quickStep", quickStepForward); movingForward.AddStateChange("moveBackward", movingBackward); movingForward.AddStateChange("charge", charging); movingForward.AddStateChange("dashCharge", dashCharging); movingForward.AddStateChange("feint", feint); movingForward.AddStateChange("collisionWin", collisionWin); movingForward.AddStateChange("collisionLoss", collisionLoss); //movingForward.AddStateChange("specialActivate", specialActivate); movingForward.AddGameStateCondition(collisionWinCond); movingForward.AddGameStateCondition(collisionLossCond); //movingForward.AddGameStateCondition(specialActivateCond); quickStepForward.AddStateChange("stop", idle); quickStepForward.AddStateChange("charge", charging); quickStepForward.AddStateChange("dashCharge", dashCharging); quickStepForward.AddStateChange("feint", feint); quickStepForward.AddStateChange("collisionWin", collisionWin); quickStepForward.AddStateChange("collisionLoss", collisionLoss); //quickStepForward.AddStateChange("specialActivate", specialActivate); quickStepForward.AddGameStateCondition(collisionWinCond); quickStepForward.AddGameStateCondition(collisionLossCond); //quickStepForward.AddGameStateCondition(specialActivateCond); movingBackward.AddStateChange("stop", idle); movingBackward.AddStateChange("quickStep", quickStepBackward); movingBackward.AddStateChange("moveForward", movingForward); movingBackward.AddStateChange("charge", charging); movingBackward.AddStateChange("dashCharge", dashCharging); movingBackward.AddStateChange("feint", feint); movingBackward.AddStateChange("collisionWin", collisionWin); movingBackward.AddStateChange("collisionLoss", collisionLoss); //movingBackward.AddStateChange("specialActivate", specialActivate); movingBackward.AddGameStateCondition(collisionWinCond); movingBackward.AddGameStateCondition(collisionLossCond); //movingBackward.AddGameStateCondition(specialActivateCond); quickStepBackward.AddStateChange("stop", idle); quickStepBackward.AddStateChange("charge", charging); quickStepBackward.AddStateChange("dashCharge", dashCharging); quickStepBackward.AddStateChange("feint", feint); quickStepBackward.AddStateChange("collisionWin", collisionWin); quickStepBackward.AddStateChange("collisionLoss", collisionLoss); //quickStepBackward.AddStateChange("specialActivate", specialActivate); quickStepBackward.AddGameStateCondition(collisionWinCond); quickStepBackward.AddGameStateCondition(collisionLossCond); //quickStepBackward.AddGameStateCondition(specialActivateCond); charging.AddStateChange("stop", chargeRecovery); charging.AddStateChange("collisionWin", collisionWin); charging.AddStateChange("collisionLoss", collisionLoss); charging.AddGameStateCondition(collisionWinCond); charging.AddGameStateCondition(collisionLossCond); dashCharging.AddStateChange("dash", dash); dashCharging.AddStateChange("collisionWin", collisionWin); dashCharging.AddStateChange("collisionLoss", collisionLoss); dashCharging.AddGameStateCondition(collisionWinCond); dashCharging.AddGameStateCondition(collisionLossCond); dash.AddStateChange("stop", dashRecovery); dash.AddStateChange("collisionWin", collisionWin); dash.AddStateChange("collisionLoss", collisionLoss); dash.AddGameStateCondition(collisionWinCond); dash.AddGameStateCondition(collisionLossCond); feint.AddStateChange("stop", idle); feint.AddStateChange("charge", charging); feint.AddStateChange("dashCharge", dashCharging); feint.AddStateChange("feint", feint); feint.AddStateChange("collisionWin", collisionWin); feint.AddStateChange("collisionLoss", collisionLoss); feint.AddGameStateCondition(collisionWinCond); feint.AddGameStateCondition(collisionLossCond); chargeRecovery.AddStateChange("recover", idle); chargeRecovery.AddStateChange("collisionWin", collisionWin); chargeRecovery.AddStateChange("collisionLoss", collisionLoss); chargeRecovery.AddGameStateCondition(collisionWinCond); chargeRecovery.AddGameStateCondition(collisionLossCond); dashRecovery.AddStateChange("recover", idle); dashRecovery.AddStateChange("collisionWin", collisionWin); dashRecovery.AddStateChange("collisionLoss", collisionLoss); dashRecovery.AddGameStateCondition(collisionWinCond); dashRecovery.AddGameStateCondition(collisionLossCond); /*specialActivate.AddStateChange("specialCharge", specialCharging); * specialActivate.AddStateChange("collisionWin", collisionWin); * specialActivate.AddStateChange("collisionLoss", collisionLoss); * specialActivate.AddGameStateCondition(collisionWinCond); * specialActivate.AddGameStateCondition(collisionLossCond); * specialCharging.AddStateChange("stop", idle); * specialCharging.AddStateChange("collisionWin", collisionWin); * specialCharging.AddStateChange("collisionLoss", collisionLoss); * specialCharging.AddGameStateCondition(collisionWinCond); * specialCharging.AddGameStateCondition(collisionLossCond);*/ collisionWin.AddStateChange("recover", idle); collisionLoss.AddStateChange("recover", idle); ready.AddStateChange("play", playing); playing.AddStateChange("pause", paused); playing.AddGameStateCondition(defeatCond); paused.AddStateChange("play", playing); playing.AddStateChange("victory", victory); playing.AddStateChange("defeat", defeat); this.input = new GameInputState(this.listenerId, 0); this.input.SetInputMapping(GameInputState.LEFT_STICK_LEFT_RIGHT, "moveStick"); this.input.SetInputMapping(GameInputState.D_PAD_LEFT_RIGHT, "moveStick"); this.input.SetInputMapping(GameInputState.A, "chargeButton"); this.input.SetInputMapping(GameInputState.B, "quickStepButton"); this.input.SetInputMapping(GameInputState.X, "dashButton"); this.input.SetInputMapping(GameInputState.Y, "feintButton"); this.input.SetInputMapping(GameInputState.START, "start"); this.AddCurrentState(this.input); this.AddCurrentState(idle); this.AddCurrentState(ready); }
// Start is called before the first frame update void Start() { _gameEngine = GetComponent <GameEngine>(); _state = GameInputState.WAIT_MOVE; }
public void SetUiInput(bool isEnabled) { _state = isEnabled ? GameInputState.UI_INPUT : GameInputState.WAIT_MOVE; _currentCell = null; }
public override void Begin() { base.Begin(); this.SetListenerId(MainMenu.TAG); this.ListenTo(GameMaster.TAG); GameSystem.SetTimeMultiplier(MainMenu.TAG, 1.0); StartMatchFocusState startMatchFocus = new StartMatchFocusState(); StartMatchSelectedState startMatchSelected = new StartMatchSelectedState(); // TODO SettingsFocusState settingsFocus = new SettingsFocusState(); SettingsSelectedState settingsSelected = new SettingsSelectedState(); ControlsFocusState controlsFocus = new ControlsFocusState(); ControlsSelectedState controlsSelected = new ControlsSelectedState(); ExitGameFocusState exitGameFocus = new ExitGameFocusState(); ExitGameSelectedState exitGameSelected = new ExitGameSelectedState(); GameState waitingForLoadedState = new GameState(); MainMenuInputState mainMenuInput = new MainMenuInputState(this.listenerId); GameState subMenu = new GameState(); startMatchFocus.AddStateChange("down", controlsFocus); startMatchFocus.AddStateChange("selected", startMatchSelected); controlsFocus.AddStateChange("up", startMatchFocus); controlsFocus.AddStateChange("down", settingsFocus); controlsFocus.AddStateChange("selected", controlsSelected); controlsSelected.AddStateChange("closed", controlsFocus); settingsFocus.AddStateChange("up", controlsFocus); settingsFocus.AddStateChange("down", exitGameFocus); settingsFocus.AddStateChange("selected", settingsSelected); settingsSelected.AddStateChange("closed", settingsFocus); exitGameFocus.AddStateChange("up", settingsFocus); exitGameFocus.AddStateChange("selected", exitGameSelected); /* * startMatchFocus.AddStateChange("down", controlsFocus); * startMatchFocus.AddStateChange("selected", startMatchSelected); * controlsFocus.AddStateChange("up", startMatchFocus); * controlsFocus.AddStateChange("down", exitGameFocus); * controlsFocus.AddStateChange("selected", controlsSelected); * controlsSelected.AddStateChange("closed", controlsFocus); * exitGameFocus.AddStateChange("up", controlsFocus); * exitGameFocus.AddStateChange("selected", exitGameSelected); */ waitingForLoadedState.AddStateChange("loaded", mainMenuInput); mainMenuInput.AddStateChange("subMenu", subMenu); subMenu.AddStateChange("closed", mainMenuInput); GameInputState input = new GameInputState(this.listenerId, 1); input.SetInputMapping(GameInputState.LEFT_STICK_UP_DOWN, "leftStick"); input.SetInputMapping(GameInputState.D_PAD_UP_DOWN, "leftStick"); input.SetInputMapping(GameInputState.A, "select"); this.AddCurrentState(startMatchFocus); this.AddCurrentState(input); this.AddCurrentState(waitingForLoadedState); }