public void GameOver() { level.SetRobots(3); _txtRounds.text = "Rounds: " + _rounds; _rounds = 0; GameObject.FindWithTag("Audio").GetComponent <PassAudioToNextScene>().Play(4); _milliseconds = 0; _gameState = GameStateEnum.GAMEOVER; Time.timeScale = 0; var robots = GameObject.FindGameObjectsWithTag("Robot"); foreach (var r in robots) { Destroy(r); } var pieces = GameObject.FindGameObjectsWithTag("Piece"); foreach (var p in pieces) { Destroy(p); } GameObject.FindWithTag("LevelManager").GetComponent <Level>().RestartHook(); _panelGameOver.gameObject.SetActive(true); _panelGame.gameObject.SetActive(false); }
public void EndGame() { _rounds++; GameObject.FindWithTag("Audio").GetComponent <PassAudioToNextScene>().Play(3); _gameState = GameStateEnum.POSGAME; Time.timeScale = 0; var robots = GameObject.FindGameObjectsWithTag("Robot"); foreach (var r in robots) { Destroy(r); } var pieces = GameObject.FindGameObjectsWithTag("Piece"); foreach (var p in pieces) { Destroy(p); } level.RestartHook(); level.SetRobots(level.GetRobots() + 2); var time = _maxMilliseconds - _milliseconds; _time = new TimeSpan(0, 0, 0, 0, (int)(time * 1000)); _txtResult.text = _time.ToString(@"mm\:ss\.fff"); _panelVictory.gameObject.SetActive(true); _panelGame.gameObject.SetActive(false); }
//等这一帧运行完,在进行调用 protected void LateChangeState(GameStateEnum eGameStateEnum) { if (m_curGameStateEnum == eGameStateEnum) { return; } if (m_gameState != null) { m_gameState.Exit(); m_gameState.Deinitialization(); m_gameState = null; } switch (eGameStateEnum) { case GameStateEnum.GameStateEnum_Login: case GameStateEnum.GameStateEnum_Resert: m_gameState = new GameLoginState(); break; } m_gameState.Initalize(); if (eGameStateEnum == GameStateEnum.GameStateEnum_Resert) { eGameStateEnum = GameStateEnum.GameStateEnum_Login; } m_curGameStateEnum = eGameStateEnum; }
void HandleTuto() { InfoPanel.SetActive(true); if (Input.GetKeyDown(KeyCode.LeftArrow)) { selectedTuto--; } if (Input.GetKeyDown(KeyCode.RightArrow)) { selectedTuto++; } if (selectedTuto < 0) { selectedTuto = 0; } if (selectedTuto >= tutorialScreens.Length) { selectedTuto = tutorialScreens.Length - 1; } InfoTitle.text = $"Tutorial {selectedTuto + 1}/{tutorialScreens.Length}"; InfoContent.text = tutorialScreens[selectedTuto]; if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space)) { // End here state = GameStateEnum.inGame; } }
void Pause() { Time.timeScale = 0; gameState = GameStateEnum.Pause; ChangeCanvas(false); }
private void GameOver() { GameState = GameStateEnum.Waiting; GameRestartTime = (uint)(World.Time + RestartDelayMS); //World.Hook.WorldSizeDeltaPerPlayer = OriginalWorldsizeDeltaPerPlayer; //World.Hook.WorldResizeSpeed = OriginalWorldResizeSpeed; }
/// <summary> /// Writes some information about the game to the console. When the game finishes, the player /// standings of the top three players are written as well. /// </summary> /// <param name="message">Message received from the server</param> private void WriteGameInfo(GameUpdate message) { var currentState = message.GameState; // Don't spam the console if the game state hasn't changed yet. if (currentState != _previousState) { switch (currentState) { case GameStateEnum.Pregame: WriteLineWithColor(ConsoleColor.Green, "The game is about to start!"); break; case GameStateEnum.InProgress: WriteLineWithColor(ConsoleColor.Green, "The game is in progress!"); break; case GameStateEnum.EndingSoon: WriteLineWithColor(ConsoleColor.Yellow, "The game is about to end soon!"); break; case GameStateEnum.PostGame: WriteLineWithColor(ConsoleColor.Red, "The game has ended!"); WriteStandings(message.Podium); break; case GameStateEnum.Unknown: throw new ApplicationException("Received an unknown game state?"); } } _previousState = currentState; }
public void StartGame(int slot) { currentSlot = slot; if (slots[currentSlot] != null && slots[currentSlot].success) { return; //FIXME: Play a negative beep or something. } else if (slots[currentSlot] == null || !slots[currentSlot].started) { universe.ClearGameObjects(); menuState = MenuStateEnum.NONE; gameState = GameStateEnum.PLAYING; NewGame(); state.playingState = PlayStateEnum.INTRO; } else { universe.ClearGameObjects(); menuState = MenuStateEnum.NONE; gameState = GameStateEnum.PLAYING; state = slots[currentSlot]; LoadGame(); state.playingState = PlayStateEnum.PLAY; } soundtrack.Stop(); player.transform.position = new Vector2(state.playerState.playerPositionX, state.playerState.playerPositionY); SaveGame(); soundtrack.Play(); }
void SetState(GameStateEnum state) { if (m_gameState != state) { ExitState(m_gameState); m_gameState = state; m_stateStartTime = Time.time; } switch (state) { case GameStateEnum.Title: Camera.main.transform.position = new Vector3(0, 0, -10); m_title = Instantiate(TitlePrefab); break; case GameStateEnum.Playing: Score.gameObject.SetActive(true); m_score = 0; Score.text = "Score: 0"; var playerTrf = (Transform)Instantiate(PlayerPrefab); m_player = playerTrf.GetComponent <PlayerController>(); FindObjectOfType <CameraFollow>().Target = playerTrf; Background.BroadcastMessage("Init", playerTrf); break; case GameStateEnum.Postgame: break; } }
// Use this for initialization void Start() { audio1 = Camera.main.GetComponent <AudioSource>(); setGoal(); leftWall.transform.DOMoveX(-20, 0.75f).From(); rightWall.transform.DOMoveX(20, 0.75f).From(); foreach (var item in Aliens) { item.transform.DOMoveY(20, 1.0f).From(); } foreach (var item in Humans) { item.transform.DOMoveY(-20, 1.0f).From(); } PlayerPrefs.SetInt("level", levelNum); PlayerPrefs.SetInt("maxLevel", levelNum - 1); if (levelNum == 1) { GameState = GameStateEnum.Paused; pauseCanvas.SetActive(true); Time.timeScale = 0; } else { GameState = GameStateEnum.Running; } }
public void ResumeButton() { if (GameState == GameStateEnum.Paused) { GameState = GameStateEnum.Unpausing; } }
public void PauseButton() { if (GameState == GameStateEnum.Running) { GameState = GameStateEnum.Pausing; } }
void Unpausing() { GameState = GameStateEnum.Running; pauseCanvas.SetActive(false); Time.timeScale = .01f; DOTween.To(() => Time.timeScale, x => Time.timeScale = x, 1.0f, 0.3f).OnComplete(() => {}); }
private void CheckOtherActions() { // Pause check if (Input.GetKeyDown(KeyCode.P)) { if (gameState == GameStateEnum.Game) { Time.timeScale = 0; gameState = GameStateEnum.Pause; } else { Time.timeScale = 1; gameState = GameStateEnum.Game; } } // Game restart check if (Input.GetKeyDown(KeyCode.Alpha0)) { SceneManager.LoadScene("Main"); } // Game exit check if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if (newState == GameStateEnum.Running) { mSection.Enable (); } else { mSection.Disable(); } }
void OnGUI() { if (Input.GetButton("Fire1")) { if (!buttonPressed) { if (currentState == GameStateEnum.Start) { StartGame(); } else if (currentState == GameStateEnum.Gameover) { Restart(); } else if (currentState == GameStateEnum.Win) { currentState = GameStateEnum.Flying; currentLevel = "Level2"; SceneManager.LoadScene("Level2"); if (hudController) { hudController.Hide(); } } } buttonPressed = true; } else { buttonPressed = false; } }
public void Confirm() { if (GameState != GameStateEnum.WaitingPlayerConfirm && GameState != GameStateEnum.WaitingDevice) { return; } foreach (var cell in _playSet.Cells) { cell.IsPending = false; cell.IsPlaying = false; } WhitePoints += WhitePointsPending; BlackPoints += BlackPointsPending; Turn = Turn.GetOpposite(); ResetPendingPoints(); //IsPlaying = false; if (!IsPlayPossible(Turn)) { GameState = GameStateEnum.GameOver; } else if (_gameOptions.IsSinglePlayer && Turn == OthelloColor.Black) { GameState = GameStateEnum.WaitingDevice; Device.StartTimer(TimeSpan.FromMilliseconds(1000), DevicePlayCallback); } else { GameState = GameStateEnum.WaitingPlayerPlay; } PrintCells("Confirm.End"); }
public void NewGame(GameOptions gameOptions) { _playSet.Reset(); _gameOptions = gameOptions; foreach (var cell in Cells.Where(c => c.Disc != null)) { Debug.WriteLine($"NewGame clear cell C={cell.Column} R={cell.Row}"); MoveDiscFromCell(cell); } MoveNextDiscToCell(OthelloColor.White, GetCell(3, 3)); MoveNextDiscToCell(OthelloColor.Black, GetCell(3, 4)); MoveNextDiscToCell(OthelloColor.Black, GetCell(4, 3)); MoveNextDiscToCell(OthelloColor.White, GetCell(4, 4)); Turn = OthelloColor.White; WhitePoints = 2; BlackPoints = 2; WhitePointsPending = 0; BlackPointsPending = 0; //IsPlaying = false; GameState = GameStateEnum.WaitingPlayerPlay; }
public void RestoreFromGameProgress(GameProgress progress) { Reset(); Turn = progress.Turn; BlackPoints = progress.BlackPoints; WhitePoints = progress.WhitePoints; _gameOptions = progress.GameOptions; MoveNextDiscToCell(OthelloColor.White, GetCell(3, 3)); MoveNextDiscToCell(OthelloColor.Black, GetCell(3, 4)); MoveNextDiscToCell(OthelloColor.Black, GetCell(4, 3)); MoveNextDiscToCell(OthelloColor.White, GetCell(4, 4)); foreach (var progressCell in progress.Cells) { var cell = GetCell(progressCell.Column, progressCell.Row); Debug.WriteLine($"Restore cell R{progressCell.Row},C{progressCell.Column} {progressCell.DiscColor}"); if (cell.Disc == null) { MoveNextDiscToCell(progressCell.DiscColor, cell); } else if (cell.Disc.DiscColor != progressCell.DiscColor) { FlipCellDisc(cell); } } if (_gameOptions.IsSinglePlayer && Turn == OthelloColor.Black) { GameState = GameStateEnum.WaitingDevice; Device.StartTimer(TimeSpan.FromMilliseconds(1000), DevicePlayCallback); } else { GameState = GameStateEnum.WaitingPlayerPlay; } }
void TransitionToWaiting() { Debug.Log("Transitioned to waiting state"); state = GameStateEnum.WAITING; timer = waitingTime; ResetGame(); }
public void StartNewGame() { GamePoints = 0; TimeRemaining = gameSessionTime; player.State = Player.PlayerStateEnum.BouncingBall; State = GameStateEnum.Play; }
private static GameState ResolveState(GameStateEnum state, GameController controller, GameState previous) { GameState result; switch (state) { case GameStateEnum.Help: result = new HelpState(controller, previous); break; case GameStateEnum.HighScores: throw new NotImplementedException(); case GameStateEnum.InGame: result = new InGameState(controller, previous); break; case GameStateEnum.MainMenu: result = new MainMenuState(controller, previous); break; case GameStateEnum.MapSelection: throw new NotImplementedException(); case GameStateEnum.PlaceUnits: throw new NotImplementedException(); default: throw new InvalidProgramException("Unreacheable path."); } return(result); }
void TransitionToWaiting() { Debug.Log("Transitioned to waiting state"); state = GameStateEnum.WAITING; MenuController.Instance.GoToWaitMenu(); ResetGame(); }
public void PlayAgain() { GameState = GameStateEnum.firstStage; DeviceController.Stage1Started(); Application.LoadLevel(Application.loadedLevelName); DeviceController.Stage1Started(); }
public static void OnRun() { while (GameState == GameStateEnum.Running) { GameState = _newMatch.Play(); } }
public GameStateEnum CheckCurrentGameState(GameObject playersModel, PlayerEnum currentPlayer) { CountMoves(playersModel); CountWins(playersModel); xWins = playersModel.GetComponent <PlayersModel>().GetWins(playerXID); oWins = playersModel.GetComponent <PlayersModel>().GetWins(playerOID); TotalMovesPlayed = playersModel.GetComponent <PlayersModel>().GetTotalMoves(); if (xWins == 0 && oWins > 0) { currentGameState = GameStateEnum.OWin; } else if (xWins > 0 && oWins == 0) { currentGameState = GameStateEnum.XWin; } else if (xWins == 0 && oWins == 0) { if (TotalMovesPlayed < 9) { currentGameState = GameStateEnum.Playing; } else if (TotalMovesPlayed == 9) { currentGameState = GameStateEnum.Draw; } } return(currentGameState); }
public void UndoLastSequence() { var prevCells = new List <CellModel>(); prevCells.AddRange(_playSet.Cells); var prevDiscs = new List <DiscModel>(); _playSet.Reset(); foreach (var cell in prevCells) { if (cell.IsPlaying) { MoveDiscFromCell(cell); } else { FlipCellDisc(cell); } cell.IsPending = false; cell.IsPlaying = false; } ResetPendingPoints(); //Turn = Turn.GetOpposite(); //IsPlaying = false; GameState = GameStateEnum.WaitingPlayerPlay; PrintCells("Undo.End"); }
public static bool Initialize() { var result = true; CellPrefab = Resources.Load <GameObject>("Prefabs/Cell"); Assert.IsNotNull(CellPrefab, "Cell prefab not found"); if (CellPrefab == null) { GameState = GameStateEnum.Invalid; Debug.LogError("Cell prefab not found"); result = false; } CellMaterials = new[] { Resources.Load <Material>("Materials/Dead"), Resources.Load <Material>("Materials/Alive") }; for (var i = 0; i < CellMaterials.Length; i++) { if (CellMaterials[i] != null) { continue; } GameState = GameStateEnum.Invalid; Debug.LogErrorFormat("Cell Material {0} not found", i); result = false; break; } return(result); }
private void Start() { Instance = this; gameState = GameStateEnum.Init; if (!PhotonNetwork.IsMasterClient) { return; } Debug.Log("Connected Players: " + PhotonNetwork.PlayerList.Length); //Instantiate a player if it is the first load if (playerPrefab == null) { Debug.LogError( "<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'", this); return; } Debug.LogFormat("We are Instantiating LocalPlayer from {0}", Application.loadedLevelName); for (var i = 0; i < PhotonNetwork.PlayerList.Length; i++) { Player player = PhotonNetwork.PlayerList[i]; Transform initPos = LevelInfo.GetInitPos(i); photonView.RPC("RpcInstantiatePlayer", player, initPos.position, initPos.rotation); } }
public void PlayTheGame(int cellID) { if (CurrentGameState == GameStateEnum.Pausing) { return; } GetCurrentPlayer(); if (UpdateCell(cellID)) { RecordPlayerMove(cellID, CurrentPlayer); SetCellAsFull(cellID); SetNextPlayer(); UIViewScript.HideInvalidCellAlert(); } else { UIViewScript.DisplayInvalidCellAlert(); } CurrentGameState = CheckCurrentGameState(); if (CurrentGameState == GameStateEnum.Playing) { return; } DisplayResult(CurrentGameState); DisplayEndGameMenu(); }
/// <summary> /// This is the handler of each snapping in the scroller. The /// cell index will only be different from the data index if looping is on. /// </summary> /// <param name="scroller">The EnhancedScroller that fired the event</param> /// <param name="cellIndex">The index of the cell that snapped on</param> /// <param name="dataIndex">The data index of the cell that snapped on</param> private void ScrollerSnapped(EnhancedScroller scroller, int cellIndex, int dataIndex) { // if we are not playing, ignore this event if (GameState != GameStateEnum.Playing) { return; } // increment the snap count. We will need three total snaps to tally the score _snapCount++; // set the slot of the snapped scroller for use in tallying the score _snappedDataIndices[_snapCount - 1] = dataIndex; if (_snapCount == _slotControllers.Length) { // if we've reached the final snap count, then tally the score TallyScore(); // reenable the lever pullLeverButton.interactable = true; } if (Credits == 0) { // if we are out of credits after tallying the score, go to a game over state GameState = GameStateEnum.GameOver; } }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if (newState == GameStateEnum.GameOver) { mAnimator.SetTrigger ("Death"); mAudio.Play (); } else if (newState == GameStateEnum.GameWon) { mAnimator.SetTrigger("Win"); } }
// update this later *** public void Switch_GameState (GameStateEnum _targetState) { // get current state --> _temp // enable targeted states Manager // switch over to it (camera and all) // disable current // update GM state to the new one }
public void checkLoss() { foreach (var item in Aliens) { if (item.AlienState == AlienStateEnum.Alive) { return; } } Debug.Log("Lost"); GameState = GameStateEnum.Lost; }
public void hitSide(string tag) { bool shouldMove = false; if (tag == "human") { foreach (var item in Humans) { if (!item.isDead) return; } GameState = GameStateEnum.Won; } else if (tag == "bullet") { foreach (var item in Aliens) { if (item.AlienState == AlienStateEnum.Alive) { return; } } GameState = GameStateEnum.Lost; } else if (tag == "left") { movementDirection = Dir.right; hasHit = true; if (goalDirection == Dir.left) { goalDirection = Dir.right; shouldMove = true; setGoal(); } } else if (tag == "right") { movementDirection = Dir.left; hasHit = true; if (goalDirection == Dir.right) { goalDirection = Dir.left; shouldMove = true; setGoal(); } } if (shouldMove) { foreach (var item in Aliens){ var p = item.gameObject.transform.position; item.gameObject.transform.DOMoveY(p.y-1,0.5f); } } }
public void Get_Manager (GameStateEnum _targetManager) { // update this later *** switch (_targetManager) { case GameStateEnum.Building: break; case GameStateEnum.Hub: break; case GameStateEnum.Map: break; case GameStateEnum.Paused: break; case GameStateEnum.Raiding: break; default: break; } Debug.Log("wHY SO SERIOUS???"); }
public void ChangeState(GameStateEnum state) { var oldState = mCurrentState; mCurrentState = state; OnStateChanged (oldState, state); }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { mRunning = newState == GameStateEnum.Running; }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if(newState == GameStateEnum.GameOver) { mAudio.Stop(); } }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if (newState == GameStateEnum.GameOver) { mChasing = false; mAnimator.Play("Win"); } }
/// <summary> /// /// </summary> /// <param name="state"></param> public StateUpdateMessage(GameStateEnum state) { State = state; }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if (newState == GameStateEnum.GameWon) { mSection.Enable(); mAnimator.Play("Flash"); } }
void Awake() { Game.State = this; mCurrentState = GameStateEnum.Running; }
/// <summary> /// /// </summary> public override void Deserialize() { State = (GameStateEnum)base.ReadInt(); }
void Won() { Victory.gameObject.SetActive(true); Victory.transform.DOScale(new Vector3(0,0,0),1.5f).From(); GameState = GameStateEnum.WonDone; }
void Unpausing() { GameState = GameStateEnum.Running; pauseCanvas.SetActive(false); Time.timeScale = .01f; DOTween.To(()=> Time.timeScale,x=>Time.timeScale = x,1.0f,0.3f).OnComplete(()=> {}); }
// Use this for initialization void Start() { audio1 = Camera.main.GetComponent<AudioSource>(); setGoal(); leftWall.transform.DOMoveX(-20,0.75f).From(); rightWall.transform.DOMoveX(20,0.75f).From(); foreach (var item in Aliens) { item.transform.DOMoveY(20,1.0f).From(); } foreach (var item in Humans) { item.transform.DOMoveY(-20,1.0f).From(); } PlayerPrefs.SetInt("level",levelNum); PlayerPrefs.SetInt("maxLevel",levelNum-1); if (levelNum == 1) { GameState = GameStateEnum.Paused; pauseCanvas.SetActive(true); Time.timeScale = 0; } else { GameState = GameStateEnum.Running; } }
void Lost() { Defeat.gameObject.SetActive(true); Defeat.transform.DOScale(new Vector3(0,0,0),1.5f).From(); GameState = GameStateEnum.LostDone; }
public void RestartButton() { if (Debug.isDebugBuild){ GameState = GameStateEnum.Won; } else { Application.LoadLevel(Application.loadedLevel); } }
public void ResumeButton() { if (GameState == GameStateEnum.Paused) GameState = GameStateEnum.Unpausing; }
void Pausing() { GameState = GameStateEnum.Paused; DOTween.To(()=> Time.timeScale,x=>Time.timeScale = x,0.0f,0.3f).OnComplete(()=> {Debug.Log("Paused"); }); StartCoroutine(PausingIEnum()); }
protected override void OnUpdateFrame(FrameEventArgs E) { base.OnUpdateFrame(E); if (Paused) { return; } var CurrentFallSpeed = Keyboard[Key.Down] ? FastFallSpeed : FallSpeed; if (GameStateEnum.Fall == GameState) { StickPosition.Y += CurrentFallSpeed; var FellOnFloor = (StickPosition.Y >= MapHeight - 1); for (var i = 0; i < StickLength; i++) { if (StickColors[i] >= 0) { var X = (int)StickPosition.X + i; var Y = (int)Math.Floor(StickPosition.Y); if (FellOnFloor || (Map[X, Y + 1] >= 0)) { Map[X, Y] = StickColors[i]; StickColors[i] = -1; } } } var WholeStickFell = true; for (var i = 0; i < StickLength; i++) { if (StickColors[i] >= 0) { WholeStickFell = false; break; } } if (WholeStickFell) { GameState = GameStateEnum.Impact; } } else if (GameStateEnum.Impact == GameState) { var Stabilized = true; for (var X = 0; X < MapWidth; X++) { for (var Y = MapHeight - 2; Y >= 0; Y--) { if ((Map[X, Y] >= 0) && ((Map[X, Y + 1] < 0) || (ImpactFallOffset[X, Y + 1] > 0))) { Stabilized = false; ImpactFallOffset[X, Y] += CurrentFallSpeed; if (ImpactFallOffset[X, Y] >= 1) { Map[X, Y + 1] = Map[X, Y]; Map[X, Y] = -1; ImpactFallOffset[X, Y] = 0; } } } } if (Stabilized) { Destroyables.Clear(); for (var X = 0; X < MapWidth; X++) { for (var Y = 0; Y < MapHeight; Y++) { CheckDestroyableLine(X, Y, 1, 0); CheckDestroyableLine(X, Y, 0, 1); CheckDestroyableLine(X, Y, 1, 1); CheckDestroyableLine(X, Y, 1, -1); } } if (Destroyables.Count > 0) { foreach (var Coords in Destroyables) { Map[(int)Coords.X, (int)Coords.Y] = -1; } Score += (int)Math.Ceiling(Destroyables.Count + Math.Pow(1.5, Destroyables.Count - 3) - 1) + TotalDestroyedThisMove; TotalDestroyedThisMove += Destroyables.Count; Stabilized = false; } } if (Stabilized) { var GameOver = false; for (var X = 0; X < MapWidth; X++) { if (Map[X, 0] >= 0) { GameOver = true; break; } } if (GameOver) { GameState = GameStateEnum.GameOver; if (Score > HighScore) { HighScore = Score; using (var Stream = new FileStream(HighScoreFilename, FileMode.Create)) { using (var Writer = new BinaryWriter(Stream)) { Writer.Write(HighScore); } } } } else { GenerateNextStick(); TotalDestroyedThisMove = 0; GameState = GameStateEnum.Fall; } } } }
private PokerGame(AbstractDealer dealer, PokerTable table) { Observer = new PokerGameObserver(this); m_Dealer = dealer; Table = table; Params = table.Params; m_State = GameStateEnum.Init; m_RoundState = RoundStateEnum.Cards; }
private void AdvanceToNextGameState() { if (m_State == GameStateEnum.End) return; m_State = (GameStateEnum)(((int)m_State) + 1); switch (m_State) { case GameStateEnum.Init: break; case GameStateEnum.WaitForPlayers: TryToBegin(); break; case GameStateEnum.WaitForBlinds: Table.HigherBet = 0; //If we got all the blinds, what are we waiting for ?! if (GameTable.TotalBlindNeeded == 0) AdvanceToNextGameState(); //Advancing to Playing State break; case GameStateEnum.Playing: Table.Round = RoundTypeEnum.Preflop; m_RoundState = RoundStateEnum.Cards; StartRound(); break; case GameStateEnum.Showdown: ShowAllCards(); break; case GameStateEnum.DecideWinners: DecideWinners(); break; case GameStateEnum.DistributeMoney: DistributeMoney(); StartANewGame(); break; case GameStateEnum.End: Observer.RaiseEverythingEnded(); break; } }
public void PauseButton() { if (GameState == GameStateEnum.Running) GameState = GameStateEnum.Pausing; }
private void New() { Rand = new Random(); Map = new int[MapWidth, MapHeight]; for (var X = 0; X < MapWidth; X++) { for (var Y = 0; Y < MapHeight; Y++) { Map[X, Y] = -1; } } ImpactFallOffset = new float[MapWidth, MapHeight]; StickColors = new int[StickLength]; NextStickColors = new int[StickLength]; GenerateNextStick(); GenerateNextStick(); // because 1st call makes current stick all zeros GameState = GameStateEnum.Fall; Score = 0; TotalDestroyedThisMove = 0; }
private void StartANewGame() { Observer.RaiseGameEnded(); m_NbGamePlayed++; m_State = GameStateEnum.WaitForPlayers; TryToBegin(); }
void StateChanged (GameStateEnum oldState, GameStateEnum newState) { if (newState != GameStateEnum.Running) { mMoving = false; } }
/// <summary> /// The player is leaving the game /// </summary> public void LeaveGame(PlayerInfo p) { var sitOutOk = SitOut(p); if (sitOutOk && Table.LeaveTable(p)) { Observer.RaisePlayerLeft(p); if (Table.Players.Count == 0) m_State = GameStateEnum.End; } }