/// <summary> /// Delete pieces. /// Delete the board. /// Creates the texts of the end screen. /// </summary> /// <returns></returns> IEnumerator endGame() { StartCoroutine(deletePieces()); StartCoroutine(deleteBoard()); if (m_scoreArray[Globals.PLAYER_ONE - 1] > m_scoreArray[Globals.PLAYER_TWO - 1]) { m_winText = TextSystem.initializeText("Player 1 wins !\n\n\t Badass !", "m_winText", new Vector3(45f, 54f, 90f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 78, ColorMgt.p_cyan); } else if (m_scoreArray[Globals.PLAYER_ONE - 1] < m_scoreArray[Globals.PLAYER_TWO - 1]) { m_winText = TextSystem.initializeText("Player 2 wins !\n\n\t Badass !", "m_winText", new Vector3(45f, 54f, 90f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 78, ColorMgt.p_cyan); } else { m_winText = TextSystem.initializeText("Draw " + m_scoreArray[Globals.PLAYER_ONE - 1] + " : " + m_scoreArray[Globals.PLAYER_TWO - 1] + " !\n\n Again !", "m_winText", new Vector3(55f, 54f, 90f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 78, ColorMgt.p_cyan); } m_restartText = TextSystem.initializeText("Click to restart", "Restart Text", new Vector3(58f, 54f, 58f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 48, ColorMgt.p_cyan); m_restartText.AddComponent <TextBlinker>().blink(Globals.BLINK_TIME, Globals.BLINK_TIME, true, false, false); GameObject.Find("SideSurfaces").GetComponent <SideBoardSystem>().deleteSidePieces(); yield return(new WaitForSeconds(Globals.ENDSCREEN_TIMER)); m_endGameLaunched = true; yield return(true); }
/// <summary> /// Score initialization : text and values /// </summary> void initializeScore() { for (int i = 0; i < Globals.PLAYER_NUMBER; ++i) { m_scoreArray[i] = 0; if (m_scoreTextArray[i] != null) { Destroy(m_scoreTextArray[i]); } } //TODO : remove hard-coded values m_scoreTextArray[Globals.PLAYER_ONE - 1] = TextSystem.initializeText(m_scoreArray[Globals.PLAYER_ONE - 1].ToString(), "Score1", new Vector3(48.5f, 69f, 96f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 50, ColorMgt.p_paleBlue); m_scoreTextArray[Globals.PLAYER_TWO - 1] = TextSystem.initializeText(m_scoreArray[Globals.PLAYER_TWO - 1].ToString(), "Score2", new Vector3(100f, 69f, 96f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 50, ColorMgt.p_paleRed); for (int i = 0; i < Globals.PLAYER_NUMBER; ++i) { m_scoreTextArray[i].AddComponent <TextBlinker>(); } highlightPlayerScore(); }
/// <summary> /// A popup is created, blinking once, following the active player. /// </summary> /// <returns></returns> IEnumerator playerChangePopup() { //script deactivated during movements and popups m_scriptActive = false; // wait the end of the pieces movements before displaying the popup yield return(new WaitForSeconds(Globals.PIECE_MOVE_TIME)); switch (m_activePlayer) { case Globals.PLAYER_ONE: m_playerOnePopup = TextSystem.initializeText("Player 1", "Player One Popup", new Vector3(Globals.PLAYER_TEXT_X, Globals.PLAYER_TEXT_Y, Globals.PLAYER_TEXT_Z), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 78, ColorMgt.p_paleBlue); m_playerOnePopup.AddComponent <TextBlinker>().blink(Globals.PLAYER_TEXT_APPEAR, Globals.PLAYER_TEXT_FADE, false, false, true); break; case Globals.PLAYER_TWO: m_playerTwoPopup = TextSystem.initializeText("Player 2", "Player Two Popup", new Vector3(Globals.PLAYER_TEXT_X, Globals.PLAYER_TEXT_Y, Globals.PLAYER_TEXT_Z), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 78, ColorMgt.p_paleRed); m_playerTwoPopup.AddComponent <TextBlinker>().blink(Globals.PLAYER_TEXT_APPEAR, Globals.PLAYER_TEXT_FADE, false, false, true); break; default: break; } // wait the end of the popup yield return(new WaitForSeconds(Globals.PLAYER_TEXT_TIME)); m_scriptActive = true; }
void Start() { // TODO : remove hard-coded values m_titleObj = TextSystem.initializeText("ShockWave", "Title", new Vector3(53f, 64f, 93f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 78, ColorMgt.p_cyan); m_versionObj = TextSystem.initializeText("v0.1", "Version", new Vector3(70f, 64f, 83f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontGames, 48, ColorMgt.p_cyan); m_startObj = TextSystem.initializeText("Click to start", "Start", new Vector3(61f, 64f, 70f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 48, ColorMgt.p_cyan); // highlight the start text m_startObj.AddComponent <TextBlinker>().blink(Globals.BLINK_TIME, Globals.BLINK_TIME, true, true, false); }
/// <summary> /// Chooses randomly the first player /// Creates the first popup following the player chosen /// </summary> void playerStart() { m_activePlayer = (byte)UnityEngine.Random.Range(Globals.PLAYER_ONE, Globals.PLAYER_TWO + 1); GameObject playerStartPopup; switch (m_activePlayer) { case Globals.PLAYER_ONE: playerStartPopup = TextSystem.initializeText("Player 1 starts", "Player One Popup", new Vector3(51f, 65f, 86f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 78, ColorMgt.p_paleBlue); playerStartPopup.AddComponent <TextBlinker>().blink(Globals.PLAYER_TEXT_APPEAR, Globals.PLAYER_TEXT_FADE, false, false, true); break; case Globals.PLAYER_TWO: playerStartPopup = TextSystem.initializeText("Player 2 starts", "Player Two Popup", new Vector3(51f, 65f, 86f), Quaternion.Euler(new Vector3(Globals.PLAYER_TEXT_RX, Globals.PLAYER_TEXT_RY, Globals.PLAYER_TEXT_RZ)), Globals.p_fontThirsty, 78, ColorMgt.p_paleRed); playerStartPopup.AddComponent <TextBlinker>().blink(Globals.PLAYER_TEXT_APPEAR, Globals.PLAYER_TEXT_FADE, false, false, true); break; default: break; } }