Ejemplo n.º 1
0
    static public void StopGame()
    {
        UpdateHighScore();
        if (Social.Active.localUser.authenticated)
        {
            for (int ct = 1; ct <= PlayerPrefs.GetInt("clear"); ct++)
            {
                GooglePlayServiceManager.UnlockAchievement(ct);
            }
        }

        YellowCard.SetCardContent(int.Parse(modeSub.ToString()), ballHit, score, Time.time - startTime);
        YellowCard.Show();

        button.enable = true;
        modeSub       = '1';

        stageID = 0;
        score   = 0;
        combo   = 0;
        ballHit = 0;
        level   = 1;
        ballCt  = 1;
        removeAllBall();
        RemoveAllWhistle();
        LaunchMenu();
    }
Ejemplo n.º 2
0
    static public void UpdateHighScore()
    {
        int n = int.Parse(modeSub.ToString());

        if (score > PlayerPrefs.GetInt("highScore" + n.ToString()))
        {
            PlayerPrefs.SetInt("highScore" + n.ToString(), score);
        }

        GooglePlayServiceManager.postScore(n);
    }
 void MakeInstance()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Ejemplo n.º 4
0
    public IEnumerator leaderboard()
    {
        GooglePlayServiceManager.signIn();

        //Disabling button
        button.enabled     = false;
        crownImage.enabled = false;
        loadingImage.SetActive(true);

        //Waiting till sign-in process is complete, then renabling the button
        yield return(new WaitUntil(() => GooglePlayServiceManager.hasTriedToSignIn));

        button.enabled     = true;
        crownImage.enabled = true;
        loadingImage.SetActive(false);

        GooglePlayServiceManager.showHighScoreBoard();
    }
Ejemplo n.º 5
0
    void OnMouseDown()
    {
        if (!enable)
        {
            return;
        }

        if (PlayerPrefs.GetInt("clear") < id - 1 && id <= 4)
        {
            return;
        }

        switch (id)
        {
        case -1:
            Debug.Log("unknown button id on : " + gameObject.name);
            return;

        case 5:     //achievement
            if (!Social.Active.localUser.authenticated)
            {
                GooglePlayServiceManager.SignIn();
            }
            else
            {
                GooglePlayServiceManager.showAchievement();
            }
            return;

        case 6:     //leaderboard
            if (!Social.Active.localUser.authenticated)
            {
                GooglePlayServiceManager.SignIn();
            }
            else
            {
                GooglePlayServiceManager.showLeaderBoard();
            }
            return;
        }

        manager.LaunchGame(id);
    }
Ejemplo n.º 6
0
    static public void SignIn()
    {
        Debug.LogWarning("SignIn to google game does not support anymore");
        return;

        Social.localUser.Authenticate((bool success) =>
        {
            suc = success;

            if (suc)
            {
                GooglePlayServiceManager.UnlockAchievement(5);

                for (int ct1 = 1; ct1 <= 4; ct1++)
                {
                    postScore(ct1);
                }
            }
        });
    }
Ejemplo n.º 7
0
    //SCENE FUNCTION
    static public void LaunchMenu()
    {
        if (Social.Active.localUser.authenticated)
        {
            GooglePlayServiceManager.UnlockAchievement(5);
        }
        mode = SceneMode.Menu;

        stageID     = 0;
        whistleList = new List <Whistle>();
        maxWhistle  = 1;
        bgColor     = stageColor[0];
        floorColor  = stageFloorColor[0];
        g           = 0.4f;
        kickZone    = stageKickZone[0];
        level       = 1;
        ballCt      = 1;
        GameObject newBall = Instantiate(startBallPref, new Vector3(0, 7.25f, 0), Quaternion.identity) as GameObject;

        ballList.Add(newBall);
    }
Ejemplo n.º 8
0
    //Called externally when player dies
    public void calculateHighScore(int endgameScore)
    {
        if (!GooglePlayServiceManager.hasTriedToSignIn)
        {
            GooglePlayServiceManager.signIn();
        }

        if (!GooglePlayServiceManager.hasCachedHiScore &&
            !GooglePlayServiceManager.isRetrievingHiScore)
        {
            GooglePlayServiceManager.retrieveHighScore();
        }


        //This may not return the value immediately, since retrieveHighScore() is asynchronous and it's speed depends on the user's internet speed
        //May take a few player deaths before this kicks in, but that's okay.
        if (GooglePlayServiceManager.hasCachedHiScore)
        {
            leaderboardHiScore = GooglePlayServiceManager.cachedLeaderboardScore;
        }

        /*
         * This was done to make sure that the highest score among the local and leaderboard high scores is the score being considered
         * Because sometimes the player may make a new high score while not connected to the internet
         * This also allows high scores to remain synched when two people are playing with two different devices with the same account
         */
        currentHighScore = Mathf.Max(currentHighScore, leaderboardHiScore);
        if (endgameScore > currentHighScore)
        {
            currentHighScore = endgameScore;
        }
        internalMemory.saveHiScore(currentHighScore);
        if (leaderboardHiScore != currentHighScore)
        {
            GooglePlayServiceManager.postHighScore(currentHighScore);
            leaderboardHiScore = currentHighScore; //That may not seem necessary, but it ensures that it only posts when there is a new high score
        }
    }
Ejemplo n.º 9
0
    public void Kick(float sin, float cos)
    {
        //manager.LastBallHit = gameObject;
        manager.HitBall();

        sVelo = Mathf.Sqrt(2 * GetComponent <Rigidbody2D>().gravityScale * 10 * (top - transform.position.y));

        mesh.angularVelo = 2500 * -sin * manager.g;

        if (Mathf.Abs(sin) < 0.4f)
        {
            GetComponent <ParticleSystem>().gravityModifier = manager.g;
            GetComponent <ParticleSystem>().Play();
            manager.combo++;

            SoundManager.CallFunction(SoundManager.Action.PlaySound, SoundManager.SoundTag.PerfectKick);
        }
        else
        {
            manager.combo = 1;
            SoundManager.CallFunction(SoundManager.Action.PlaySound, SoundManager.SoundTag.BallClashed);
        }

        GetComponent <Rigidbody2D>().velocity = new Vector2(sin, cos) * sVelo;

        if (manager.ballHit == 150)
        {
            GooglePlayServiceManager.UnlockAchievement(8);
        }
        if (manager.ballHit == 500)
        {
            GooglePlayServiceManager.UnlockAchievement(9);
        }
        if (manager.ballHit == 1000)
        {
            GooglePlayServiceManager.UnlockAchievement(10);
        }
    }
Ejemplo n.º 10
0
 void Awake()
 {
     instance = this;
 }
Ejemplo n.º 11
0
    static public void LaunchGame(int n)
    {
        PlayerPrefs.SetInt("gamePlayed", PlayerPrefs.GetInt("gamePlayed") + 1);
        if (PlayerPrefs.GetInt("gamePlayed") >= 100)
        {
            GooglePlayServiceManager.UnlockAchievement(6);
        }
        if (PlayerPrefs.GetInt("gamePlayed") >= 250)
        {
            GooglePlayServiceManager.UnlockAchievement(7);
        }

        YellowCard.Hide();
        PlayerPrefs.SetInt("lastGameType", n - 1);

        startTime = Time.time;

        combo = 1;
        mode  = SceneMode.Game;
        ballList[0].GetComponent <ballPhysics>().StartKick();

        if (n == 4)
        {
            modeSub  = '4';
            maxLevel = 3;
            g        = 0.2f;
            kickZone = stageKickZone[1];
        }

        if (n == 1)
        {
            modeSub  = '1';
            maxLevel = 1;
            g        = 0.2f;
            kickZone = stageKickZone[1];
        }


        if (n == 2)
        {
            fCallList.Add(new FunctionCall(5, 3));

            modeSub  = '2';
            maxLevel = 1;
            g        = 0.1f;
            kickZone = stageKickZone[2];
        }

        if (n == 3)
        {
            fCallList.Add(new FunctionCall(5, 3));
            fCallList.Add(new FunctionCall(5, 5));

            modeSub  = '3';
            maxLevel = 1;
            g        = 0.1f;
            kickZone = stageKickZone[3];
        }

        button.enable = false;
        SetGravity();
    }
Ejemplo n.º 12
0
    static public void HitBall()
    {
        int hitCountInLevel = ballHit - exp[level - 1];

        if (modeSub == '4')
        {
            maxWhistle = level;
            if (level <= 3)
            {
                if (level == 1)
                {
                    g = 0.5f + Mathf.Sqrt(4 / 60f * (float)hitCountInLevel);

                    if (g <= 0.5f)
                    {
                        g = 0.5f;
                    }
                }

                if (level == 2)
                {
                    g = 0.2f + Mathf.Sqrt(4 / 120f * (float)hitCountInLevel);

                    if (g <= 0.2f)
                    {
                        g = 0.2f;
                    }
                }

                if (level == 3)
                {
                    g = 0.1f + Mathf.Sqrt(1.5f * 1.5f / 250 * (float)hitCountInLevel);
                }

                /*original
                 * if ((level - 1) % 3 != 2)
                 * {
                 *  g = Mathf.Sqrt(0.14f * (float)hitCountInLevel / ballList.Count);//max = 2
                 * }
                 * else
                 * {
                 *  g = Mathf.Sqrt(1f/90f * (float)hitCountInLevel);//max = 1
                 * }
                 */
            }
            else
            {
                if ((level - 1) % 3 != 2)
                {
                    g = Mathf.Sqrt(0.14f * (float)hitCountInLevel / ballList.Count);//max = 2
                }
                else
                {
                    //g = 0.1f + hitCountInLevel * 0.9f/30;
                    g = Mathf.Sqrt(1f / 90f * (float)hitCountInLevel);//max = 1
                }
            }
        }
        else
        {
            if (modeSub == '1')
            {
                g = 0.2f + Mathf.Sqrt(1.8f * 1.8f / 150f * (float)hitCountInLevel);
            }

            if (modeSub == '2')
            {
                g = 0.2f + Mathf.Sqrt(1.8f * 1.8f / 300f * (float)hitCountInLevel);
            }

            if (modeSub == '3')
            {
                g = 0.1f + Mathf.Sqrt(0.9f * 0.9f / 450f * (float)hitCountInLevel);
            }
        }

        ballHit++;
        score += combo;

        if (modeSub == '4')
        {
            if (level < maxLevel)
            {
                if (ballHit == exp[level])
                {
                    g = 0.1f;

                    level++;
                    transStage = true;
                    stageID    = (level - 1);
                    kickZone   = stageKickZone[level];

                    if ((level - 1) % 3 != 0)//minor lv up
                    {
                        addBall();
                    }
                    else                    //major lv up
                    {
                        //removeBall(2);
                    }

                    if (level == 4)
                    {
                        GooglePlayServiceManager.UnlockAchievement(4);
                    }
                }
            }
        }
        else
        {
            if (ballHit >= 25 * ballList.Count)
            {
                if (stageID == 0)
                {
                    maxWhistle = 2;

                    stageID    = 1;
                    transStage = true;
                }
            }

            if (ballHit >= (75) * ballList.Count)
            {
                if (stageID == 1)
                {
                    maxWhistle = 3;

                    stageID    = 2;
                    transStage = true;

                    if (int.Parse(modeSub.ToString()) > PlayerPrefs.GetInt("clear"))
                    {
                        PlayerPrefs.SetInt("clear", int.Parse(modeSub.ToString()));
                    }
                }
            }
        }

        SetGravity();

        Flash();
    }