public void Restart() { victoryState = VictoryState.None; Gold = startGold; OpponentGold = startGold; Food = startFood; OpponentFood = startFood; DefenseUnit = 0; OpponentDefenseUnit = 0; DefenseUnitMax = defenseUnitMax; Score = 0; OpponentScore = 0; }
public void initGameState() { playingState = new PlayingState(); menuState = new MenuState(); pauseState = new PauseState(); settingsState = new SettingsState(); pausesettingsState = new PauseSettingsState(); victoryState = new VictoryState(); defeatState = new DefeatState(); //Console.WriteLine("SET VOLUME TO 0 FOR DEBUGGING"); //MediaPlayer.Volume = 0.0f; }
// Start is called before the first frame update void Start() { victoryState = VictoryState.None; Gold = startGold; OpponentGold = startGold; Food = startFood; OpponentFood = startFood; DefenseUnit = 0; OpponentDefenseUnit = 0; DefenseUnitMax = defenseUnitMax; Score = 0; OpponentScore = 0; InvokeRepeating("GainPerTick", 0f, 1f); }
// Update is called once per frame void Update() { switch( m_VictoryState ) { case VictoryState.VictoryState_UnActive : if( true == Debug_ToWin ) { ToWin() ; break ; } if( true == Debug_ToLose ) { ToLose() ; break ; } if( true == CheckLose() ) m_VictoryState = VictoryState.VictoryState_Lose ; else if( true == CheckWin() ) m_VictoryState = VictoryState.VictoryState_Win ; break ; case VictoryState.VictoryState_Win : ShowBattleScore( true ) ; m_VictoryState = VictoryState.ShowBattleScore ; break ; case VictoryState.VictoryState_Lose : ShowBattleScore( false ) ; m_VictoryState = VictoryState.ShowBattleScore ; break ; case VictoryState.ShowBattleScore : break ; } }
public void ToWin() { Win() ; m_VictoryState = VictoryState.VictoryState_Win ; }
public void ToLose() { Lose() ; m_VictoryState = VictoryState.VictoryState_Lose ; }
//Function to start the fight after the Game Manager has set up the players and enemies public void StartBattle() { //sets the first flag for the victory screen m_victoryState = VictoryState.VICTORYSTATE_START; m_SelectableSpaces = new List <BattleSpace>(); m_battleSpaces = new BattleSpace[8, 4]; int spaceNum = 0; //set up battle spaces for (int x = 0; x < 8; x++) { for (int y = 0; y < 4; y++) { m_battleSpaces[x, y] = new BattleSpace(); m_battleSpaces[x, y].m_cube = r_spaces[spaceNum]; m_battleSpaces[x, y].x = x; m_battleSpaces[x, y].y = y; spaceNum++; } } m_battleState = BattleState.BATTLESTATE_START; m_selectedCommand = Command.COMMAND_NONE; foreach (BattlePawn pawn in m_charactersInBattle) { m_battleSpaces[pawn.m_x, pawn.m_y].m_pawn = pawn; if (pawn.gameObject.tag == "Player") { m_partyMembers.Add(pawn); m_StatusBoxes[m_partyMembers.Count - 1].r_character = pawn; } pawn.StartBattle(); } TurnOrder(); EventSystem.current.SetSelectedGameObject(null); r_attackButton.Select(); if (m_charactersInBattle[0].gameObject.tag == "Player") { m_battleState = BattleState.BATTLESTATE_PLAYER_TURN; r_characterActionButtons.SetActive(true); EventSystem.current.SetSelectedGameObject(null); r_attackButton.Select(); } else if (m_charactersInBattle[0].gameObject.tag == "Enemy") { m_battleState = BattleState.BATTLESTATE_ENEMY_TURN; r_characterActionButtons.SetActive(false); } m_currentTurnPawn = m_charactersInBattle[0]; m_charactersInBattle[0].TakeTurn(); }
// Update is called once per frame void Update() { if (m_playingSkillAnimation || m_playingItemAnimation) { return; } if (EventSystem.current.currentSelectedGameObject == null) { r_attackButton.Select(); } if (m_enemies == 0) { Victory(); } switch (m_battleState) { case BattleState.BATTLESTATE_START: break; case BattleState.BATTLESTATE_PLAYER_TURN: if (Input.GetAxis("Horizontal") < 0.1 && Input.GetAxis("Horizontal") > -0.1 && Input.GetAxis("Vertical") < 0.1 && Input.GetAxis("Vertical") > -0.1 && Input.GetAxis("Submit") > 0.1 && Input.GetAxis("Cancel") > 0.1) { m_inputTimer = m_inputDelay; } if (m_inputTimer < m_inputDelay) { m_inputTimer += Time.deltaTime; return; } switch (m_selectedCommand) { case Command.COMMAND_NONE: break; case Command.COMMAND_ATTACK: BattleCursorMovement(); if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; if (m_battleSpaces[m_selectionX, m_selectionY].m_selectable && m_battleSpaces[m_selectionX, m_selectionY].m_occupied) { foreach (BattleSpace space in m_SelectableSpaces) { space.m_cube.GetComponent <MeshRenderer>().material = m_materialNormal; space.m_selectable = false; } foreach (BattleSpace space in m_battleSpaces) { if (space.m_occupied) { space.m_pawn.r_turnMarker.SetActive(false); space.m_pawn.r_myTurnMarker.SetActive(false); } } m_SelectableSpaces.Clear(); //ATTACK CODE m_currentTurnPawn.Attack(m_selectionX, m_selectionY, new Vector3(m_battleSpaces[m_selectionX, m_selectionY].m_cube.transform.position.x, m_currentTurnPawn.transform.position.y, m_battleSpaces[m_selectionX, m_selectionY].m_cube.transform.position.z)); } } if (Input.GetAxis("Cancel") > 0.1) { m_inputTimer = 0; AttackEnd(true); } break; case Command.COMMAND_SKILL: if (Input.GetAxis("Cancel") > 0.1) { m_inputTimer = 0; SkillEnd(true); return; } if (!m_isAimingSkill) { return; } BattleCursorMovement(); if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; if (r_selectedSkill.ValidTarget(m_currentTurnPawn, m_selectionX, m_selectionY)) { foreach (BattleSpace space in m_SelectableSpaces) { space.m_cube.GetComponent <MeshRenderer>().material = m_materialNormal; space.m_selectable = false; } foreach (BattleSpace space in m_battleSpaces) { if (space.m_occupied) { space.m_pawn.r_turnMarker.SetActive(false); space.m_pawn.r_myTurnMarker.SetActive(false); } } m_SelectableSpaces.Clear(); r_selectedSkill.UseSkill(m_currentTurnPawn, m_selectionX, m_selectionY); } } break; case Command.COMMAND_ITEM: if (Input.GetAxis("Cancel") > 0.1) { m_inputTimer = 0; ItemEnd(true); return; } if (!m_isAimingItem) { return; } BattleCursorMovement(); if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; if (r_selectedItem.ValidTarget(m_currentTurnPawn, m_selectionX, m_selectionY)) { foreach (BattleSpace space in m_SelectableSpaces) { space.m_cube.GetComponent <MeshRenderer>().material = m_materialNormal; space.m_selectable = false; } m_SelectableSpaces.Clear(); foreach (BattleSpace space in m_battleSpaces) { if (space.m_occupied) { space.m_pawn.r_turnMarker.SetActive(false); space.m_pawn.r_myTurnMarker.SetActive(false); } } r_selectedItem.UseItem(m_currentTurnPawn, m_selectionX, m_selectionY); } } break; case Command.COMMAND_MOVE: BattleCursorMovement(); if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; if (m_battleSpaces[m_selectionX, m_selectionY].m_selectable) { foreach (BattleSpace space in m_SelectableSpaces) { space.m_cube.GetComponent <MeshRenderer>().material = m_materialNormal; space.m_selectable = false; } m_SelectableSpaces.Clear(); foreach (BattleSpace space in m_battleSpaces) { if (space.m_occupied) { space.m_pawn.r_turnMarker.SetActive(false); space.m_pawn.r_myTurnMarker.SetActive(false); } } m_currentTurnPawn.MoveTo(m_selectionX, m_selectionY, new Vector3(m_battleSpaces[m_selectionX, m_selectionY].m_cube.transform.position.x, m_currentTurnPawn.transform.position.y, m_battleSpaces[m_selectionX, m_selectionY].m_cube.transform.position.z)); MoveEnd(false); } } if (Input.GetAxis("Cancel") > 0.1) { m_inputTimer = 0; MoveEnd(true); } break; case Command.COMMAND_DEFEND: break; default: break; } break; case BattleState.BATTLESTATE_ENEMY_TURN: break; case BattleState.BATTLESTATE_WIN: if (m_inputTimer < m_inputDelay) { m_inputTimer += Time.deltaTime; return; } switch (m_victoryState) { case VictoryState.VICTORYSTATE_START: if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; LevelUp(); m_victoryState = VictoryState.VICTORYSTATE_LEVELUP; } break; case VictoryState.VICTORYSTATE_LEVELUP: if (Input.GetAxis("Submit") > 0.1) { m_inputTimer = 0; EndBattle(true); } break; case VictoryState.VICTORYSTATE_END: break; default: break; } break; case BattleState.BATTLESTATE_LOSE: break; case BattleState.BATTLESTATE_INBETWEENTURN: m_turnTimer -= Time.deltaTime; if (m_turnTimer <= 0) { foreach (BattlePawn pawn in m_charactersInBattle) { pawn.r_turnMarker.GetComponentInChildren <Text>().text = (pawn.m_timeUntilTurn).ToString(); if (pawn.m_timeUntilTurn == 0) { pawn.r_turnMarker.SetActive(false); pawn.r_myTurnMarker.SetActive(true); } else { pawn.r_turnMarker.SetActive(true); pawn.r_myTurnMarker.SetActive(false); } if (pawn.m_isDead) { pawn.r_turnMarker.SetActive(false); pawn.r_myTurnMarker.SetActive(false); } } m_currentTurnPawn.TakeTurn(); } break; default: break; } }
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); }
//状態を変更 public void SetVictoryState(VictoryState state) { currentVictoryState.Value = state; }