// Start is called before the first frame update void Start() { uiReady.SetActive(true); Status = GAME_STATUS.Ready; this.player.OnDeath += Player_OnDeath; this.player.OnScore = OnPlayerScore; }
private void UpdateRoundState(GAME_STATUS nextState) { if (m_GameState != GAME_STATUS.Unknown && m_GameState != GAME_STATUS.NotWorking) { m_RoundUpdateTime = DateTime.Now; dynamic currentRoundState = Snapshot(); if (currentRoundState != null) { try { CacheSnapshot(currentRoundState); } catch (Exception ex) { m_Logger.Error("Faild to cache snapshot: " + ex.ToString()); m_Logger.Error(ex.StackTrace); } } m_GameState = nextState; m_Logger.Info("CurrentRoundState - [" + currentRoundState.status + "]"); } }
void Start() { //開始と同時に再生してみる StartTimeline.Play(); //終わったので状態をGAMEにする gameStatus = GAME_STATUS.GAME; }
void Update() { switch (GameState) { case GAME_STATUS.GAME_START: GameOverUI.SetActive(false); //点击屏幕 开始游戏 if (Input.GetMouseButtonDown(0)) { GameState = GAME_STATUS.GAME_PLAYING; BridHandler.intance.StartGame(); } break; case GAME_STATUS.GAME_PLAYING: break; case GAME_STATUS.GAME_END: // 游戏结束,显示面板 ,维护分数 GameOverUI.SetActive(true); GameOverScore.text = score.ToString(); GameOverBest.text = PlayerPrefs.GetInt("Best").ToString(); break; default: break; } }
public void StartGame() { this.Status = GAME_STATUS.InGame; pipelineManger.StartRun(); player.Fly(); Debug.LogFormat("StartGame:{0}", this.Status); }
IEnumerator TimeOver() { Debug.Log("time over"); gamestatus = GAME_STATUS.TIMEOVER; yield return(new WaitForSeconds(2.0f)); //while (!Input.GetButtonDown("Fire1") || Input.touches.Length > 0) yield return; Application.LoadLevel("Main"); }
/// <summary> /// ゲームプレイ /// </summary> /// <returns>遅延</returns> private IEnumerator Play() { // ワープゾーンの選択を可能とする StartCoroutine(player.SelectWarpZone()); // タイムオーバーになるまで待機 yield return(StartCoroutine(timer.CountDown(120))); StopCoroutine(player.SelectWarpZone()); spawner.Active = false; State = GAME_STATUS.END; }
public void StartGame() { Score.ResetScore(); if(AudioController.isMute){ // GUI_Start.sound_Button.isOn = true; }else{ // GUI_Start.sound_Button.isOn = false; } gameStatus = GAME_STATUS.PLAYING; }
/// <summary> /// ゲームエンド /// </summary> /// <returns>遅延</returns> private IEnumerator End() { message.SetMessage("Game Over"); yield return(new WaitForSeconds(1.0f)); message.Activate(false); yield return(StartCoroutine(result.ShowResult())); yield return(new WaitForSeconds(5)); State = GAME_STATUS.MENU; }
public BaccaratGame(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_GameState = GAME_STATUS.Unknown; m_WaitingForDealing = false; m_IsRunningGameLoop = false; PlayerPoints = -1; BankerPoints = -1; m_ShoeCode = ""; m_RoundIndex = 0; }
public TanksGame(MainMenuForm mainMenu) { InitializeComponent(); buttons.Add(level1Button); buttons.Add(level2Button); buttons.Add(level3Button); buttons.Add(level4Button); this.mainMenu = mainMenu; gameStatus = GAME_STATUS.LEVEL_SELECT; Size = new Size(350, 150); TanksGame.gameRef = this; }
public void Start() { Stop(); m_Logger.Info("Clean up old cache..."); Thread.Sleep(500); try { var dbhelper = m_Node.GetDataHelper(); using (var cnn = dbhelper.OpenDatabase(m_MainCache)) { using (var cmd = cnn.CreateCommand()) { dbhelper.AddParam(cmd, "@server_code", m_Node.GetName()); dbhelper.AddParam(cmd, "@table_code", TableCode); cmd.CommandText = " delete from tbl_round_state " + " where server_code = @server_code ; "; cmd.CommandText = cmd.CommandText + " delete from tbl_round_state " + " where table_code = @table_code ; "; cmd.ExecuteNonQuery(); } } Thread.Sleep(500); m_Logger.Info("Done"); } catch (Exception ex) { m_Logger.Error("Failed to clean up old cache: "); m_Logger.Error(ex.ToString()); } m_RoundIndex = 0; //m_GameCode = Guid.NewGuid().ToString(); m_ShoeCode = DateTime.Now.ToString("yyyyMMddHHmmss"); m_History.Clear(); m_GameReadyCountdown = GET_READY_COUNTDOWN; m_GameState = GAME_STATUS.GetGameReady; m_WaitingForDealing = false; m_IsRunningGameLoop = false; m_Timer = new Timer(Tick, m_Rng, 500, 1000 * 1); }
public void Stop() { m_GameState = GAME_STATUS.NotWorking; if (m_Timer != null) { Thread.Sleep(500); m_Timer.Dispose(); m_Timer = null; } m_PlayerCards.Clear(); m_BankerCards.Clear(); m_GameReadyCountdown = -1; m_BettingTimeCountdown = -1; PlayerPoints = -1; BankerPoints = -1; m_IsRunningGameLoop = false; }
private void configureGameField(int level) { gameStatus = GAME_STATUS.GAME; Size = new Size(1260, 660); foreach (Button b in buttons) { b.Hide(); } switch (level) { case 1: levelOneConfigure(); break; } }
private void DealingOnePlayerCard(GAME_STATUS nextState = GAME_STATUS.Unknown) { if (m_WaitingForDealing) { return; } try { m_WaitingForDealing = true; Task.Run(async() => { try { string card1 = await RemoteCaller.RandomCall(m_Node.GetRemoteServices(), "dealing", "cards", "1"); if (String.IsNullOrEmpty(card1)) { throw new Exception("Table controller no response."); } else { m_PlayerCards.Add(card1); } } catch (Exception ex) { m_WaitingForDealing = false; Console.WriteLine("DealingOnePlayerCard Error - " + ex.ToString()); return; } m_WaitingForDealing = false; //if (nextState != GAME_STATUS.Unknown) m_GameState = nextState; if (nextState != GAME_STATUS.Unknown) { UpdateRoundState(nextState); } }); } catch (Exception ex) { m_WaitingForDealing = false; Console.WriteLine("DealingOnePlayerCard Error - " + ex.ToString()); } }
private void restartGame() { foreach (CompTank tank in compTanks) { Controls.Remove(tank); tank.Close(); } userTank.Close(); gameStatus = GAME_STATUS.LEVEL_SELECT; Size = new Size(350, 150); foreach (Button b in buttons) { b.Show(); } }
public bool GetGameReady(bool withNewShoe = false) { if (m_GameState == GAME_STATUS.Unknown || m_GameState == GAME_STATUS.EndRound) { m_GameState = GAME_STATUS.WaitToStart; if (withNewShoe || string.IsNullOrEmpty(m_ShoeCode)) { m_ShoeCode = DateTime.Now.ToString("yyyyMMddHHmmss"); m_RoundIndex = 0; } m_CurrentTurns = 0; return(true); } return(m_GameState == GAME_STATUS.WaitToStart); }
/// <summary> /// メニュー /// </summary> /// <returns>遅延</returns> private IEnumerator Menu() { // タイトル表示 if (!showTitle) { yield return(StartCoroutine(title.ShowTitle())); showTitle = true; } // スタート選択表示 // プレイヤがスタートを選択するまで待機する message.SetMessage("Start"); yield return(StartCoroutine(player.Selected())); message.Activate(false); spawner.Active = true; State = GAME_STATUS.PLAY; }
public TennisGame(MainMenuForm mainMenu) { InitializeComponent(); this.mainMenu = mainMenu; gameStatus = GAME_STATUS.IN_GAME; table = TablePanel.CreateGraphics(); userRacket = new UserRacket(this); compRacket = new CompRacket(this); ball = new Ball(this); TablePanel.Controls.Add(userRacket); TablePanel.Controls.Add(compRacket); TablePanel.Controls.Add(ball); userRacket.Show(); compRacket.Show(); ball.Show(); }
void Start() { // print("start"); //프리팹 Read. boxPrefab = Resources.Load("Prefabs/box") as GameObject; ballPrefab = Resources.Load("Prefabs/Ball") as GameObject; TriPrefab = Resources.Load("Prefabs/Triangle") as GameObject; addBallItem = Resources.Load("Prefabs/BallAddItem") as GameObject; //초기 ball세팅값. ballCount = 1; firstFalledBallPos = new Vector3(StartBallPosX, StartBallPosY + ballPrefab.GetComponent <CircleCollider2D>().radius); ballPrefab.transform.position = firstFalledBallPos; moveScript = ballPrefab.GetComponent <move>(); firstBall = Instantiate(ballPrefab); //기타 세팅값. arrow.SetActive(false); guideLineScale = arrow.GetComponentInChildren <BigScale>(); gameStatus = GAME_STATUS.BLOCK_DOWN; gameOverUI.SetActive(false); }
public bool StartNewRound() { if (m_GameState != GAME_STATUS.WaitToStart) { return(false); } if (m_Players.Count <= 1) { return(false); } m_RoundIndex++; m_LastPlay.Clear(); m_LastTurnPlay.Clear(); m_LastPlayerName = ""; m_LastTurnPlayerName = ""; m_CurrentTurnPlayerName = ""; m_CurrentTurns = 0; m_Deck.Shuffle(); var hands = m_Deck.Distribute(m_Players.Count, "3D"); for (var i = 0; i < m_Players.Count; i++) { hands[i].SortCards(); m_Players[i].CurrentHand = hands[i]; if (hands[i].IndexOfCard("3D") >= 0) { m_CurrentTurnPlayerName = m_Players[i].PlayerName; } } m_GameState = GAME_STATUS.PlayingCards; return(true); }
private void setPlayersOrder() { // UNDONE: la seguente riga e' per testing if (debug) humanRoll = computerRoll+1; // Controllo chi dei due giocatori ha totalizzato il punteggio piu' alto if (humanRoll > computerRoll) { setLabel("Il computer ha totalizzato " + computerRoll + "." + "Complimenti! Sei il primo a tirare i dadi!"); curPlayer = Players[0]; // Imposto le pedine sulla casella iniziale moveTokenToCell(Players[1], Cells[0]); // Imposto il gameStatus nel turno gameStatus = GAME_STATUS.START_TURN; moveTokenToCell(Players[0], Cells[0]); playersSet = true; } else if (humanRoll < computerRoll) { setLabel("Il computer ha totalizzato " + computerRoll + "." + "Dannazione, il computer inizia gia' a vincere..."); curPlayer = Players[1]; // Imposto le pedine sulla casella iniziale moveTokenToCell(Players[0], Cells[0]); // Imposto il gameStatus nel turno gameStatus = GAME_STATUS.START_TURN; moveTokenToCell(Players[1], Cells[0]); playersSet = true; // Posiziono le pedine sulla prima cella Human.transform.position = new Vector3(1710, 0, 57); Computer.transform.position = new Vector3(1660, 0, 57); } else { // In caso di pareggio faccio rilanciare i dadi ad entrambi setLabel("Il computer ha totalizzato " + computerRoll + "." + "Pareggio! Ricominciamo daccapo..."); playersOrder(); } }
/** Gestore del turno per un giocatore */ private void TurnManager(Player player) { bool human = (player.getPlayerType() == Player.PLAYER_TYPE.HUMAN); switch (gameStatus) { // Se il turno deve iniziare case (GAME_STATUS.START_TURN): // Controllo che tipo di giocatore e' quello che deve iniziare il turno // se il giocatore e' umano if (human) humanRollDice(); else computerRollDice(); // Dopo il lancio dei dadi, lo status e' IN_TURN (turno iniziato) gameStatus = GAME_STATUS.IN_TURN; break; // Se siamo all'interno del turno case (GAME_STATUS.IN_TURN): // Controllo che tipo di giocatore e' quello che deve giocare il turno // se il giocatore e' umano avversario = (Players[0] == curPlayer ? Players[1] : Players[0]); if (human) { // TODO: PARTE DI GIOCO UMANO // Avviso dell'inizio del caricamento guiMgr.setLabel("Caricamento cella in corso..."); // Avvio la parte di apparizione cella GameObject.Find("MAIN").GetComponent<LevelLoader>().loadLevel(player.getCurrentCell().getPosition()); // Dico al GUIManager chi e' il giocatore guiMgr.curPlayer = curPlayer; } // Controllo il tipo di cella, per capire come comportarmi switch (player.getCurrentCell().getType()) { case (Cell.CELL_TYPE.VIA): curPlayer.increaseMoney(200); Debug.Log("VIA!"); break; case (Cell.CELL_TYPE.IMPREVISTO): Debug.Log("Imprevisto"); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; /*int num_rand = Random.Range(-500, +500); if(num_rand > 0) { curPlayer.increaseMoney(num_rand); setLabel("Guadagni " + num_rand); } else { int pos = -num_rand; curPlayer.decreaseMoney(pos); setLabel("Perdi " + pos); }*/ break; case (Cell.CELL_TYPE.PROBABILITA): if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; Debug.Log("Probabilita'"); /* int to_pay = Random.Range(-500, +500); if(to_pay > 0) { curPlayer.increaseMoney(to_pay); setLabel("Guadagni " + to_pay); } else { int pos = -to_pay; curPlayer.decreaseMoney(pos); setLabel("Perdi " + pos); }*/ break; case (Cell.CELL_TYPE.POSTEGGIO): Debug.Log("Posteggio"); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; break; case (Cell.CELL_TYPE.TRANSITO): Debug.Log("Transito"); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; break; case (Cell.CELL_TYPE.VAI_PRIGIONE): Debug.Log("Vai in prigione!"); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; // curPlayer.decreaseMoney(200); break; case (Cell.CELL_TYPE.PRIGIONE): Debug.Log("Prigione"); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; break; case (Cell.CELL_TYPE.TASSA): Debug.Log("Tassa!"); curPlayer.decreaseMoney(200); if (human) guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; break; case (Cell.CELL_TYPE.PROPRIETA): // controllo di chi è la proprietà // se la proprieta' e' dell'umano Property relProperty = curPlayer.getCurrentCell().getProperty(); Group grup = relProperty.getGroup(); if(player.getCurrentCell().getProperty().getOwner().getPlayerType() == curPlayer.getPlayerType() ) { if(human) { // se l'umano possiede tutte le proprieta' del gruppo, puo' costruire if (player.canBuild(relProperty) && grup != Groups[8] && grup != Groups[9]) { // mostro la GUI per la costruzione su questo terreno (Vendi, ipoteca e costruisci qui) guiMgr.guiMode = GUIManager.GUIMode.OnCanBuildHere; } else guiMgr.guiMode = GUIManager.GUIMode.OnMyCell; } else if (player.canBuild(relProperty) && grup != Groups[8] && grup != Groups[9]) { int i = 5 - curPlayer.getCurrentCell().getProperty().getNumberOfBuildings(); int randomNumber = Random.Range(1, i); if (curPlayer.getMoney() > curPlayer.getCurrentCell().getProperty().getBuildingsCost(randomNumber)) { curPlayer.build(curPlayer.getCurrentCell().getProperty(),randomNumber); setLabel("Il computer ha costruito" + randomNumber + "case"); // Faccio apparire solo le case effettivamente costruite updateAllBuildings(); break; } } else { setLabel("Il computer ha deciso di non comprare nulla."); Debug.Log("Proprieta' del computer"); } } else if(player.getCurrentCell().getProperty().getOwner().getPlayerType() == avversario.getPlayerType()) { float decrease = player.getCurrentCell().getProperty().getRent(); player.decreaseMoney(decrease); avversario.increaseMoney(decrease); setLabel("Disdetta! Sei finito su una cella dell'avversario! Hai pagato " + decrease + "M."); if(human) { guiMgr.guiMode = GUIManager.GUIMode.OnOtherCell; } } else if(player.getCurrentCell().getProperty().getOwner().getPlayerType() == Player.PLAYER_TYPE.BANK) { if(human) { // imposto la cella corrente guiMgr.curCell = player.getCurrentCell(); // se il giocatore ha abbastanza soldi per acquistare la proprieta' if (player.getMoney() > player.getCurrentCell().getProperty().getPropertyCost()) { // il GUIManager disegna i pulsanti per la proprieta' libera guiMgr.guiMode = GUIManager.GUIMode.OnFreeCell; Debug.Log("Proprieta' libera."); } else { // il GUIManager viene avvisato dell'impossibilita' di comprare il terreno guiMgr.guiMode = GUIManager.GUIMode.OnCantBuyCell; Debug.Log("Proprieta' libera. NON puo' essere acquistata, troppi pochi soldi!"); } } else { guiMgr.curCell = player.getCurrentCell(); // se il giocatore ha abbastanza soldi per acquistare la proprieta' Group gruppo = curPlayer.getCurrentCell().getProperty().getGroup(); int y = Random.Range(0,100); Debug.Log(gruppo.getDimension()- curPlayer.countGroupPropertiesOwned(gruppo)); switch(gruppo.getDimension()- curPlayer.countGroupPropertiesOwned(gruppo)) { case(1): if (player.getMoney() > player.getCurrentCell().getProperty().getPropertyCost()) { // il GUIManager disegna i pulsanti per la proprieta' libera //guiMgr.guiMode = GUIManager.GUIMode.OnFreeCell; //compra curPlayer.buyProperty(curPlayer.getCurrentCell().getProperty()); setLabel("Il computer ha acquistato la cella " + curPlayer.getCurrentCell().getProperty().getName().ToString()); TurnManager(curPlayer); return; } else setLabel("Il computer ha deciso di non acquistare"); break; case(2): if(y > 25) { if (player.getMoney() > player.getCurrentCell().getProperty().getPropertyCost()) {curPlayer.buyProperty(curPlayer.getCurrentCell().getProperty()); setLabel("Il computer ha acquistato la cella " + curPlayer.getCurrentCell().getProperty().getName().ToString());} } else setLabel("Il computer ha deciso di non acquistare"); break; case (3): if(y > 45) {if (player.getMoney() > player.getCurrentCell().getProperty().getPropertyCost()) {curPlayer.buyProperty(curPlayer.getCurrentCell().getProperty()); setLabel("Il computer ha acquistato la cella " + curPlayer.getCurrentCell().getProperty().getName().ToString());} } else setLabel("Il computer ha deciso di non acquistare"); break; default: if(y > 55) {if (player.getMoney() > player.getCurrentCell().getProperty().getPropertyCost()) {curPlayer.buyProperty(curPlayer.getCurrentCell().getProperty()); setLabel("Il computer ha acquistato la cella " + curPlayer.getCurrentCell().getProperty().getName().ToString());} } else setLabel("Il computer ha deciso di non acquistare"); break; } } } break; default: break; } if(!human) { // UNDONE: far terminare il turno alla fine delle azioni dell'AIManager Wait(2); guiMgr.rollComputer = false; turnOver(); } break; case (GAME_STATUS.TURN_OVER): // Se il turno era dell'umano if (human) { // faccio riapparire tutto GameObject.Find("MAIN").GetComponent<LevelLoader>().returnToBoard(); // se la cella su cui l'umano si trovava e' una proprieta' ancora libera if ((curPlayer.getCurrentCell().getType() == Cell.CELL_TYPE.PROPRIETA) && (curPlayer.getCurrentCell().getProperty().getOwner().getPlayerType() != Player.PLAYER_TYPE.HUMAN)) { // TODO: inserire la proprieta' in asta per tutti Debug.Log("Proprieta' inserita in asta."); } // Faccio apparire solo le case effettivamente costruite updateAllBuildings(); } if(Players[0].getMoney() <= 0 || Players[1].getMoney() <= 0) { gameOver(); return; } // UNDONE: se sono in debug, il turno e' sempre dell'umano if (!debug && !ritira) { // Modifico il curPlayer curPlayer = (Players[0] == curPlayer ? Players[1] : Players[0]); } Wait(1); if(ritira) setLabel("E' uscito un numero doppio.. Ritira i dadi"); // Modifico lo status del turno: inizio un nuovo turno gameStatus = GAME_STATUS.START_TURN; // Riavvio il turno TurnManager(curPlayer); break; default:break; } }
public void GameOver() { gameStatus = GAME_STATUS.GAMEOVER; }
/// <summary> /// 初期化 /// </summary> void Start() { State = GAME_STATUS.MENU; }
private void Pause() { GAME_STATUS previousStatus = GAME_STATUS.START; if(isPause) { previousStatus = gameStatus; gameStatus = GAME_STATUS.PAUSE; statusTest = gameStatus.ToString(); } else { gameStatus = previousStatus; statusTest = gameStatus.ToString(); } }
private void turnOver() { // Il turno e' finito gameStatus = GAME_STATUS.TURN_OVER; // Chiamo il gestore dei turni TurnManager(curPlayer); }
public void PauseGame() { gameStatus = GAME_STATUS.PAUSED; }
public void Restart() { this.Status = GAME_STATUS.Ready; this.pipelineManger.Init(); this.player.Init(); }
private void Player_OnDeath() { this.Status = GAME_STATUS.GameOver; this.pipelineManger.Stop(); }
private void TennisMainForm_FormClosed(object sender, FormClosedEventArgs e) { gameStatus = GAME_STATUS.STOP; mainMenu.Show(); }
public void ResetLevel(){ gameFlag = GAME_STATUS.PLAYING; winPanel.SetActive (false); }
public void StopGame() { gameStatus = GAME_STATUS.STOPPED; }
/** Funzione per decidere l'ordine dei giocatori. * Restituisce l'ID del giocatore che deve iniziare la partita **/ private void playersOrder() { // Se sono in debug, salto la fase di decisione del turno: // inizia sempre l'umano if (debug) { curPlayer = Players[0]; // Imposto le pedine sulla casella iniziale moveTokenToCell(Players[1], Cells[0]); // Imposto il gameStatus nel turno gameStatus = GAME_STATUS.START_TURN; moveTokenToCell(Players[0], Cells[0]); } else { // Imposto lo status al roll for order gameStatus = GAME_STATUS.ROLL_FOR_ORDER; // Avvio il rolling dell'umano humanRollDice(); } }
private void Lose() { if(maxRaceTime < _playerTime) { gameStatus = GAME_STATUS.LOSE; statusTest = gameStatus.ToString(); } if(player == null) { gameStatus = GAME_STATUS.LOSE; statusTest = gameStatus.ToString(); } }
public bool AcceptPlay(string playerName, List <int> cardList) { if (m_GameState != GAME_STATUS.PlayingCards) { return(false); } if (string.IsNullOrEmpty(m_CurrentTurnPlayerName)) { return(false); } if (m_CurrentTurnPlayerName != playerName) { return(false); } Player lastPlayer = null; Player currentPlayer = null; int currentPlayerIndex = -1; for (var i = 0; i < m_Players.Count; i++) { if (m_Players[i].PlayerName == m_CurrentTurnPlayerName) { currentPlayer = m_Players[i]; currentPlayerIndex = i; } if (!string.IsNullOrEmpty(m_LastPlayerName) && m_Players[i].PlayerName == m_LastPlayerName) { lastPlayer = m_Players[i]; } } if (currentPlayer == null) { return(false); } var playerCards = currentPlayer.CurrentHand.GetCards(); List <Card> playCards = new List <Card>(); foreach (var idx in cardList) { if (idx < 0 || idx >= playerCards.Count) { return(false); } else { playCards.Add(playerCards[idx]); } } Hand playHand = playCards.Count > 0 ? new Hand(playCards) : null; if (playHand != null) { playHand.SortCards(); } List <Card> lastPlay = m_LastPlay == null || m_LastPlay.Count == 0 ? null : new List <Card>(); if (lastPlay != null && m_LastPlay != null) { lastPlay.AddRange(m_LastPlay); } // if it's first play if (lastPlayer == null) { if (playHand == null) { return(false); // cannot pass } if (playHand.IndexOfCard("3D") < 0) { return(false); // must contain Diamond 3 } //if (playCards.Count == 3) return false; // not allow triple as first play var playHandCards = playHand.GetCards(); if (BigTwoLogic.CheckBetterCards(playHandCards, null)) { m_LastTurnPlay.Clear(); m_LastTurnPlay.AddRange(playHandCards); m_LastPlay.Clear(); m_LastPlay.AddRange(playHandCards); m_LastPlayerName = string.Copy(m_CurrentTurnPlayerName); m_LastTurnPlayerName = string.Copy(m_CurrentTurnPlayerName); foreach (var playCard in playCards) { currentPlayer.CurrentHand.Discard(playCard.ToString()); } currentPlayer.CurrentHand.SortCards(); int nextPlayerIndex = (currentPlayerIndex + 1) % m_Players.Count; m_CurrentTurnPlayerName = m_Players[nextPlayerIndex].PlayerName; m_CurrentTurns++; return(true); } else { return(false); } } else { int nextPlayerIndex = (currentPlayerIndex + 1) % m_Players.Count; var nextPlayer = m_Players[nextPlayerIndex]; var nextPlayerCards = nextPlayer.CurrentHand.GetCards(); if (nextPlayerCards.Count == 1) { if (cardList == null || cardList.Count == 0) // want to pass { if (lastPlay != null && lastPlay.Count == 1) { var best = BigTwoLogic.TryToGetBestSingle(currentPlayer.CurrentHand.GetCards()); if (best != null && best.Count > 0) { var cards = currentPlayer.CurrentHand.GetCards(best); if (BigTwoLogic.CheckBetterSingle(cards[0], lastPlay[0])) { return(false); // cannot pass } } } else if (lastPlay != null && lastPlayer == nextPlayer) { var best = BigTwoLogic.TryToGiveOutBest(currentPlayer.CurrentHand.GetCards(), lastPlay.Count); if (best != null && best.Count > 0) { var cards = currentPlayer.CurrentHand.GetCards(best); if (BigTwoLogic.CheckBetterCards(cards, lastPlay)) { return(false); // cannot pass } } } } else { if (cardList.Count == 1 && cardList[0] != playerCards.Count - 1) { return(false); // must be the biggest one } } } if (lastPlayer == currentPlayer) { if (playHand == null) { return(false); // cannot pass } var playHandCards = playHand.GetCards(); if (BigTwoLogic.CheckBetterCards(playHandCards, null)) { m_LastTurnPlay.Clear(); m_LastTurnPlay.AddRange(playHandCards); m_LastPlay.Clear(); m_LastPlay.AddRange(playHandCards); m_LastPlayerName = string.Copy(m_CurrentTurnPlayerName); m_LastTurnPlayerName = string.Copy(m_CurrentTurnPlayerName); foreach (var playCard in playCards) { currentPlayer.CurrentHand.Discard(playCard.ToString()); } if (currentPlayer.CurrentHand.GetNumberOfCards() == 0) { m_CurrentTurnPlayerName = ""; m_GameState = GAME_STATUS.EndRound; } else { currentPlayer.CurrentHand.SortCards(); m_CurrentTurnPlayerName = nextPlayer.PlayerName; } m_CurrentTurns++; return(true); } else { return(false); } } else { if (playHand == null) // pass { m_LastTurnPlay.Clear(); m_LastTurnPlayerName = string.Copy(m_CurrentTurnPlayerName); m_CurrentTurnPlayerName = nextPlayer.PlayerName; m_CurrentTurns++; return(true); } else { var playHandCards = playHand.GetCards(); if (BigTwoLogic.CheckBetterCards(playHandCards, lastPlay)) { m_LastTurnPlay.Clear(); m_LastTurnPlay.AddRange(playHandCards); m_LastPlay.Clear(); m_LastPlay.AddRange(playHandCards); m_LastPlayerName = string.Copy(m_CurrentTurnPlayerName); m_LastTurnPlayerName = string.Copy(m_CurrentTurnPlayerName); foreach (var playCard in playCards) { currentPlayer.CurrentHand.Discard(playCard.ToString()); } if (currentPlayer.CurrentHand.GetNumberOfCards() == 0) { m_CurrentTurnPlayerName = ""; m_GameState = GAME_STATUS.EndRound; } else { currentPlayer.CurrentHand.SortCards(); m_CurrentTurnPlayerName = nextPlayer.PlayerName; } m_CurrentTurns++; return(true); } else { return(false); } } } } //return false; }
// Update is called once per frame void Update() { switch (gameStatus) { case GAME_STATUS.IDLE: { if (Input.GetMouseButtonDown(0)) { prePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z); prePos = Camera.main.ScreenToWorldPoint(prePos); arrow.transform.position = firstFalledBallPos; arrow.SetActive(true); } else if (Input.GetMouseButton(0)) { nowPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y); nowPos = Camera.main.ScreenToWorldPoint(nowPos); float zRotateAngle = GetAngle(nowPos, prePos); if (zRotateAngle > 15 && zRotateAngle < 165) { arrow.transform.rotation = Quaternion.Euler(0, 0, zRotateAngle); float scaleFactor = Vector3.Magnitude(prePos - nowPos); guideLineScale.ScaleBig(scaleFactor); arrowDirection = (prePos - nowPos).normalized; } } else if (Input.GetMouseButtonUp(0)) { gameStatus = GAME_STATUS.SHOOTING; arrow.SetActive(false); ShotBall(); } break; } case GAME_STATUS.BLOCK_DOWN: { //턴당 한번 진입. print("nextRound IN Update"); NextRound(); gameStatus = GAME_STATUS.IDLE; ballCount += addBallNum; addBallNum = 0; AllBlockDownSucess = false; break; } case GAME_STATUS.SHOOTING: { if (ballCount == ballComeBackCount) { gameStatus = GAME_STATUS.BLOCK_DOWN; } break; } case GAME_STATUS.GAMEOVER: { for (int i = 0; i < shapeList.Count; ++i) { shapeList[i].AddComponent <Rigidbody2D>(); } gameOverUI.SetActive(true); gameStatus = GAME_STATUS.DONOTHING; break; } case GAME_STATUS.DONOTHING: { break; } } //if (Application.platform == RuntimePlatform.Android) //{ // if (Input.GetKey(KeyCode.Escape)) // { // quitUI.SetActive(true); // Time.timeScale = 0; // } //} //else if(Application.platform == RuntimePlatform.WindowsEditor) //{ // if (Input.GetKey(KeyCode.Escape)) // { // quitUI.SetActive(true); // Time.timeScale = 0; // } //} }
public void UnPauseGame() { gameStatus = GAME_STATUS.PLAYING; }
private void Win() { if(doorList.Count == 0) { CalculateScore(); gameStatus = GAME_STATUS.WIN; statusTest = gameStatus.ToString(); } }