private void TurnManage() { for (int i = 0; i < allGhost.Length; i++) { GhostController csGC = allGhost[i].GetComponent <GhostController>(); //このコマが現在のターンと同じIDなら if (csGC.playerID == PlayerTurn) { csGC.SetGhostMask(GhostController.GHOST_MASK.REAL); //生存中なら if (csGC.alive) { //1ターン前に動いているなら if (csGC.tilePosition != csGC.oldTilePosition) { //ターンの入れ替え処理 if (PlayerTurn == GhostController.CHECK_PLAYER.PLAYER1) { PlayerTurn = GhostController.CHECK_PLAYER.PLAYER2; } else { PlayerTurn = GhostController.CHECK_PLAYER.PLAYER1; } //ターンの加算 turnCount++; } } } else { if (csGC.alive) { csGC.SetGhostMask(GhostController.GHOST_MASK.UNKNOWN); } } } }
// Update is called once per frame void Update() { Debug.Log("ターン数 : " + turnCount); Debug.Log("プレイヤー : " + PlayerTurn); //選択したボタンの強調表示処理 for (int i = 0; i < allGhost.Length; i++) { GhostController csGC = allGhost[i].GetComponent <GhostController>(); if (csGC.isSelected) { selectedGhost = allGhost[i]; selectedcsGC = csGC; break; } } //選択されているゴーストが変わっていた場合1度だけ処理 if (oldSelectedGhost != selectedGhost) { RefreshTileColor(); } //退室ボタンが押された場合 if (setupReadyButton[2].GetComponent <ButtonClick>().Click) { } //降参ボタンが押された場合 if (setupReadyButton[3].GetComponent <ButtonClick>().Click) { winState = GhostController.CHECK_PLAYER.PLAYER2; } if (otherButton[0].GetComponent <ButtonClick>().Click) { SceneManager.LoadScene("Title"); } //お互いのプレイヤーが設置モードのボタンを押したかを判定 if (setupReadyButton[0].GetComponent <ButtonClick>().Click == true && setupReadyButton[1].GetComponent <ButtonClick>().Click == true) { Debug.Log("ゲームスタート!"); //セットアップモード終了 isSetup = false; //準備完了ボタンを非表示にする setupReadyButton[0].gameObject.SetActive(false); setupReadyButton[1].gameObject.SetActive(false); //ターンと同じコマの画像を切り替え for (int i = 0; i < allGhost.Length; i++) { GhostController csGC = allGhost[i].GetComponent <GhostController>(); if (csGC.alive == true) { if (csGC.playerID == PlayerTurn /* && csGC.alive == true*/) { csGC.SetGhostMask(GhostController.GHOST_MASK.REAL); } else { csGC.SetGhostMask(GhostController.GHOST_MASK.UNKNOWN); } } } //SEを鳴らす if (soundEffectFlg[(int)SoundEffect.GAMESTART]) { audioSource.PlayOneShot(SoundEffects[(int)SoundEffect.GAMESTART]); soundEffectFlg[(int)SoundEffect.GAMESTART] = false; } } else if (setupReadyButton[0].GetComponent <ButtonClick>().Click == true) { setupReadyButton[0].gameObject.SetActive(false); for (int i = 0; i < allGhost.Length; i++) { GhostController csGC = allGhost[i].GetComponent <GhostController>(); if (csGC.playerID == GhostController.CHECK_PLAYER.PLAYER1 && csGC.alive == true && csGC.deadProcess == false) { csGC.SetGhostMask(GhostController.GHOST_MASK.UNKNOWN); } } } else if (setupReadyButton[1].GetComponent <ButtonClick>().Click == true) { setupReadyButton[1].gameObject.SetActive(false); for (int i = 0; i < allGhost.Length; i++) { GhostController csGC = allGhost[i].GetComponent <GhostController>(); if (csGC.playerID == GhostController.CHECK_PLAYER.PLAYER2 && csGC.alive == true && csGC.deadProcess == false) { csGC.SetGhostMask(GhostController.GHOST_MASK.UNKNOWN); } } } else { setupReadyButton[0].gameObject.SetActive(true); setupReadyButton[1].gameObject.SetActive(true); } //選択したボタンの強調表示処理 if (selectedcsGC != null) { Vector3 tempSelectPos = GhostController.playArea.CellToWorld(selectedcsGC.tilePosition); selectedObject.transform.position = tempSelectPos; selectedObject.SetActive(true); } //設置モードではない場合 if (!isSetup) { CheckXYColumns(selectedcsGC.tilePosition, selectedcsGC.oldTilePosition); CheckDeadGhost(); CheckCorner(); //ターンの変更と加算を行う TurnManage(); } if (isSetup) { CheckSetUpColumns(GhostController.playArea.WorldToCell(selectedcsGC.startPos), selectedcsGC.tilePosition, selectedGhost); } CheckWin(); //バッファの更新 oldSelectedGhost = selectedGhost; }