Beispiel #1
0
    /*  StartGame - FUNZIONE DI INIZIO PARTITA
     *
     *  - Controllo connessione ad internet
     *  - Resetto la scena per nuova partita
     *  - Eseguo coroutine WaitandPlay
     *
     */

    public void StartGame()
    {
        StartCoroutine(checkInternetConnection(() => {  }));

        SkinManager.FindNextSkin();

        if (!Advertisement.isShowing)
        {
            ResetMenu();
            points           = 0;
            ReachedHighscore = false;
            playing          = true;
            palla.GetComponent <BallPhysics>().ResetBall();
            barra.GetComponent <PolygonCollider2D>().enabled = true;
            StartCoroutine(WaitAndPlay());
        }
    }
Beispiel #2
0
    // SetMenu: In base al menu selezionato da SelectEndGameMenu(), mostro risultati in tale menu.
    // Qui terminano le chiamate di fine partita.

    GameObject SetMenu(GameObject result)
    {
        if (isConnected && points > Player.highscore)
        {
            Player.highscore = points;
            PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_apong_leaderboard, Player.highscore);
        }

        result.SetActive(true);

        if (Player.gamesPlayed != 5 || (points < nextColor && !SkinManager.AllUnlocked()))
        {
            result.transform.Find("Custom").gameObject.SetActive(false);
        }

        // Se connesso ad internet

        if (isConnected)
        {
            // Sezione relativa alla skin giornaliera

            if (Player.Rewarded() || Player.gifts == -1)
            {
                result.transform.Find("AuxMenu").gameObject.SetActive(false);
                StartCoroutine(WaitForJob(1f, () => {
                    if (points >= nextColor && !SkinManager.AllUnlocked())
                    {
                        result.transform.Find("Custom").gameObject.SetActive(true);
                        result.transform.Find("Custom").GetComponent <Animation>().Play();
                        SkinManager.FindNextSkin();
                    }
                    else
                    {
                        result.transform.Find("Custom").gameObject.SetActive(false);
                    }
                }));
            }
            else
            {
                result.transform.Find("AuxMenu").gameObject.SetActive(true);

                for (int i = 0; i < result.transform.Find("AuxMenu/CirclesBox").childCount; i++)
                {
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).GetComponent <Image>().color = Color.black;
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).GetComponent <RectTransform>().localScale = new Vector3(0.5f, 0.5f, 1f);
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).Find("Checkmark").gameObject.SetActive(false);
                }

                for (int i = 0; i < (Player.gamesPlayed - 1); i++)
                {
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).GetComponent <Image>().color = new Color32(0, 222, 94, 255);
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).GetComponent <RectTransform>().localScale = Vector3.one;
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(i).Find("Checkmark").gameObject.SetActive(true);
                }

                StartCoroutine(WaitForJob(1f, () => {
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(Player.gamesPlayed - 1).GetComponent <Image>().color = new Color32(0, 222, 94, 255);
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(Player.gamesPlayed - 1).Find("Checkmark").gameObject.SetActive(true);
                    result.transform.Find("AuxMenu/CirclesBox").GetChild(Player.gamesPlayed - 1).GetComponent <Animation>().Play();
                    PlaySound(result.transform.Find("AuxMenu").GetComponent <AudioSource>(), 0f);

                    print(points + "\n" + nextColor);

                    if (Player.gamesPlayed == 5 || (points >= nextColor && !SkinManager.AllUnlocked()))
                    {
                        if (Player.gamesPlayed == 5)
                        {
                            SkinManager.RandomSkin[Player.gifts - 1].transform.Find("AlertIcon").gameObject.SetActive(true);
                        }

                        result.transform.Find("Custom").gameObject.SetActive(true);
                        result.transform.Find("Custom").GetComponent <Animation>().Play();
                    }

                    SkinManager.FindNextSkin();

                    if (Player.gifts == SkinManager.RandomSkin.Length)
                    {
                        Player.gifts = -1;
                    }
                }));
            }
        }
        else
        {
            result.transform.Find("AuxMenu").gameObject.SetActive(false);
        }

        if (result.name == "HighscoreMenu")
        {
            result.transform.Find("HighscoreCircle/InnerCircle").GetComponentInChildren <Text>().text = points.ToString();
        }

        if (result.name == "LoseMenu")
        {
            result.transform.Find("HighscoreCircle/InnerCircle/Text").GetComponent <Text>().text = Player.highscore.ToString();
            result.transform.Find("ScoreCircle/InnerCircle/Text").GetComponent <Text>().text     = points.ToString();
        }

        return(result);
    }