void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: m_PanelTransform.sizeDelta = new Vector2(-10f, m_PanelTransform.sizeDelta.y); if (GameSettings.Instance.CurrentGameMode == GameSettings.GAMEMODE.CREATIVE) { m_ShowPanelButton.SetActive(true); EnabelElement(); } else { m_ShowPanelButton.SetActive(false); DisabelElement(); } break; case GameSettings.GAMESTATE.RUN: DisabelElement(); m_ShowPanelButton.SetActive(false); break; case GameSettings.GAMESTATE.BREAK: m_ShowPanelButton.SetActive(false); DisabelElement(); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { foreach (BorderSettings _settings in m_BorderSettings) { if (_settings.ChangeInState == _newState && GameSettings.Instance.CurrentGameMode == _settings.ChangeInMode) { ChangeBorder(_settings.BorderSize); break; } } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: EnabelElement(); break; default: DisabelElement(); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: DisabelElement(); break; case GameSettings.GAMESTATE.RUN: EnabelElement(); break; case GameSettings.GAMESTATE.BREAK: EnabelElement(); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: m_PanelTransform.sizeDelta = new Vector2(m_PanelTransform.sizeDelta.x, -190); DisabelElement(); break; case GameSettings.GAMESTATE.RUN: EnabelElement(); break; case GameSettings.GAMESTATE.BREAK: EnabelElement(); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: if (GameSettings.Instance.CurrentGameMode == GameSettings.GAMEMODE.GAME) { DisabelElement(); break; } else { EnabelElement(); } m_ObjectPatternsDropDown.SetActive(true); DisabelThisButton(m_NextStepButton); EnableThisButton(m_ClearButton); break; case GameSettings.GAMESTATE.RUN: EnabelElement(); DisabelThisButton(m_NextStepButton); m_ObjectPatternsDropDown.SetActive(false); EnableThisButton(m_ClearButton); break; case GameSettings.GAMESTATE.BREAK: EnabelElement(); EnableThisButton(m_NextStepButton); m_ObjectPatternsDropDown.SetActive(false); EnableThisButton(m_ClearButton); break; case GameSettings.GAMESTATE.END: DisabelElement(); DisabelThisButton(m_NextStepButton); m_ObjectPatternsDropDown.SetActive(false); DisabelThisButton(m_ClearButton); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: if (GameManager.Instance.Highscore.Highscore != 0) { EnableThisButton(m_FieldButton); EnabelElement(); } else { DisabelElement(); } break; case GameSettings.GAMESTATE.RUN: if (GameManager.Instance.Highscore.Highscore != 0) { DisabelThisButton(m_FieldButton); EnabelElement(); } else { DisabelElement(); } break; case GameSettings.GAMESTATE.BREAK: if (GameManager.Instance.Highscore.Highscore != 0) { DisabelThisButton(m_FieldButton); EnabelElement(); } else { DisabelElement(); } break; } }
void OnChangeGameState(GameSettings.GAMESTATE _currentState) { switch (_currentState) { case GameSettings.GAMESTATE.CREATE: EnabelElement(); break; case GameSettings.GAMESTATE.RUN: DisabelElement(); break; case GameSettings.GAMESTATE.BREAK: DisabelElement(); break; case GameSettings.GAMESTATE.END: DisabelElement(); break; } }
void OnChangeGameState(GameSettings.GAMESTATE _newState) { switch (_newState) { case GameSettings.GAMESTATE.CREATE: m_Button.interactable = false; EnabelElement(); m_ButtonText.text = m_ButonTextCreateMode; m_Button.onClick.RemoveAllListeners(); if (GameSettings.Instance.CurrentGameMode == GameSettings.GAMEMODE.GAME) { m_Button.onClick.AddListener(GameManager.Instance.TakeFieldScreenshot); } m_Button.onClick.AddListener(GameManager.Instance.StartGame); break; case GameSettings.GAMESTATE.RUN: EnabelElement(); m_ButtonText.text = m_ButtonTextPlayMode; m_Button.onClick.RemoveAllListeners(); m_Button.onClick.AddListener(GameManager.Instance.BreakGame); break; case GameSettings.GAMESTATE.BREAK: EnabelElement(); m_ButtonText.text = m_ButtonTextBreakMode; m_Button.onClick.RemoveAllListeners(); m_Button.onClick.AddListener(GameManager.Instance.StartGame); break; case GameSettings.GAMESTATE.END: DisabelElement(); break; } }
/// <summary> /// Start a new game /// </summary> /// <param name="mode"></param> public Connect4Game(GameSettings.GAMEMODE mode, int startingPlayer, GameSettings.DIFFICULTY difficulty, GameSettings settings) { startTime = DateTime.Now; RED_PLAYER = settings.RED_PLAYER; YELLOW_PLAYER = settings.YELLOW_PLAYER; COLUMNS = settings.COLUMNS; ROWS = settings.ROWS; this.aiStrength = difficulty; this.GameMode = mode; this.STARTING_PLAYER = startingPlayer; this.activePlayer = startingPlayer; map = new int[settings.COLUMNS, settings.ROWS]; switch (GameMode) { case (GameSettings.GAMEMODE.SinglePlayer): { position = new Position(); zuege = new MoveList(); comp = new ComputerPlayer(Position.WHITE, "Machine", true, difficulty); this.GameState = GameSettings.GAMESTATE.S_BeforeGame; break; } case (GameSettings.GAMEMODE.CPUvsCPU): { position = new Position(); zuege = new MoveList(); comp = new ComputerPlayer(Position.WHITE, "Machine1", true, difficulty); if (this.STARTING_PLAYER == RED_PLAYER) { this.GameState = GameSettings.GAMESTATE.S_WaitForCPU; this.HUMAN_PLAYER = RED_PLAYER; } else { this.GameState = GameSettings.GAMESTATE.S_WaitForCPU; this.HUMAN_PLAYER = YELLOW_PLAYER; } break; } case (GameSettings.GAMEMODE.LocalMultiPlayer): { position = new Position(); zuege = new MoveList(); this.GameState = GameSettings.GAMESTATE.S_BeforeGame; break; } case (GameSettings.GAMEMODE.NetworkGame): { position = new Position(); zuege = new MoveList(); /*string line = ""; using (StreamReader sr = new StreamReader("net.txt")) { string tmp; while ((tmp = sr.ReadLine()) != null) { line = tmp; } sr.Close(); } int port = Convert.ToInt32(line.Split(',')[0]); string ip = line.Split(',')[1]; if (Convert.ToInt32(line.Split(',')[2]) == 2) { netStartPlayer = 1; } else { netStartPlayer = 2; } NetGame = new Networking(port, ip);*/ this.GameState = GameSettings.GAMESTATE.S_WaitForConnection; break; } } }
/// <summary> /// Let the cpu make a move and update the game field /// </summary> private void CalcCPUMove() { //Thread.Sleep(200); if (this.AIStrength != GameSettings.DIFFICULTY.Confused) { // Get the next CPU-move int move = comp.returnMove(position); // Error handling if (move == -1) { //Exception e = new Exception("AI Error"); //throw(e); // Drop stone in a random column do { Random rand = new Random(); move = rand.Next(7); } while (map[move, 5] != 0); } zuege.append(new MoveListElement(move)); position.makeMove(move); // Update the game field this.column = this.GetColumnFromEncVal(move); this.SetRow(this.column); this.AddRowElement(this.column, this.row); //if (this.GameMode == GAMEMODE.CPUvsCPU) //{ // Thread.Sleep(500); //} this.NextGameState = GameSettings.GAMESTATE.S_DropCPUStone; } else { this.RandomPlayer(); this.NextGameState = GameSettings.GAMESTATE.S_DropCPUStone; } }
/// <summary> /// Check if the game is won by a player or a draw /// </summary> /// <returns></returns> public bool CheckIfFinished() { long checkWhite = position.isWonPos(Position.WHITE); long checkBlack = position.isWonPos(Position.BLACK); // Check if 4 stones are in a row and the game is won if (checkWhite != -1) { if (this.STARTING_PLAYER == this.RED_PLAYER) { this.won = this.RED_PLAYER; } else { this.won = this.YELLOW_PLAYER; } //winningStones = this.isWonConvert(checkWhite, this.zuege); this.NextGameState = GameSettings.GAMESTATE.S_GameFinished; return true; } if (checkBlack != -1) { if (this.STARTING_PLAYER == this.RED_PLAYER) { this.won = this.YELLOW_PLAYER; } else { this.won = this.RED_PLAYER; } //winningStones = this.isWonConvert(checkBlack, this.zuege); this.NextGameState = GameSettings.GAMESTATE.S_GameFinished; return true; } // Check for a draw game if (this.turn < 21) { return false; } else { // Draw game this.won = -1; this.NextGameState = GameSettings.GAMESTATE.S_GameFinished; return true; } }