Example #1
0
    // 0  = "Do you want to log in"
    // 1 = "Do you want to log out"
    // 2 = login successful
    // 3 = Login unsuccessful, retry?
    // 4 = Signout successful
    // 5 = working...

    // Use this for initialization
    void Start()
    {
        //first check to see if google play is even an option and the handler exist
        GameObject gpgObject = GameObject.FindGameObjectWithTag("Google Play");

        if (gpgObject == null)
        {
            Destroy(gameObject);
            return;
        }


        rectTransform     = GetComponent <RectTransform> ();
        inactivePos       = rectTransform.position;
        gpgh              = gpgObject.GetComponent <GPG_Handler> ();
        gpgh.notification = this;
        isActive          = false;
        isBusy            = false;

        distance = Vector3.Distance(inactivePos, activePos);

        loadingIcon.color = new Color(1, 1, 1, 0);

        speed = Mathf.Abs(distance / transitionLength);
    }
    // Use this for initialization
    void Start()
    {
        currScope = 0;
        prevScope = -1;
        currMode  = 0;
        prevMode  = 0;

        GameObject temp = GameObject.FindGameObjectWithTag("Google Play");

        if (temp != null)
        {
            gpgh = temp.GetComponent <GPG_Handler>();
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        GameObject GPGHObject = GameObject.FindGameObjectWithTag("Google Play");

        if (GPGHObject == null)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            gpgh = GPGHObject.GetComponent <GPG_Handler>();
        }
        bts = GetComponent <Button_Image_Swapper> ();
        if (gpgh.isLoggedIn)
        {
            GPActive = true;
            bts.Change_Image(0);
        }
        else
        {
            GPActive = false;
            bts.Change_Image(1);
        }


        // make sure the button has the correct functions loaded
        Button button = GetComponent <Button> ();

        switch (type)
        {
        case "Games":
            button.onClick.AddListener(() => gpgh.Show_Notification());
            break;

        case "Leaderboards":
            button.onClick.AddListener(() => gpgh.Show_Leaderboards());
            break;

        case "Achievements":
            achievementHandler = GameObject.FindGameObjectWithTag("Achievement Handler").GetComponent <Achievement_Script>();
            button.onClick.AddListener(() => gpgh.Show_Achievements());
            button.onClick.AddListener(() => achievementHandler.Sync_With_Google_Play());
            break;

        default:
            button.onClick.AddListener(() => gpgh.Show_Notification());
            break;
        }
    }
Example #4
0
    //use this to add new high scores
    public void Add_Score(string gameMode, int score)
    {
        //you need to actually score to save a high score
        if (score == 0)
        {
            return;
        }
        int tempScore = score;

        GameObject temp = GameObject.FindGameObjectWithTag("Google Play");

        if (temp != null)
        {
            gpgh = temp.GetComponent <GPG_Handler>();
            if (gpgh.isSignedIn())
            {
                gpgh.Post_Score(gameMode, score);
            }
        }

        for (int i = 0; i < 15; i++)
        {
            int currScore = PlayerPrefs.GetInt(gameMode + " score " + i, 0);
            if (currScore == 0)
            {
                //We've hit the end of the list. Place the score here and exit
                PlayerPrefs.SetInt(gameMode + " score " + i, tempScore);
                break;
            }
            else if (currScore <= tempScore)
            {
                //continue looking through the list
                PlayerPrefs.SetInt(gameMode + " score " + i, tempScore);
                tempScore = currScore;
            }
        }
    }
Example #5
0
    // Use this for initialization
    void Awake()
    {
        //there should only ever be 1 of these
        DontDestroyOnLoad(transform.gameObject);
        //get rid of redundant Achievement Handlers
        GameObject[] mcs = GameObject.FindGameObjectsWithTag("Achievement Handler");
        if (mcs.Length > 1)
        {
            Destroy(gameObject);
            return;
        }

        GameObject temp = GameObject.FindGameObjectWithTag("Google Play");

        if (temp != null)
        {
            gpgh = temp.GetComponent <GPG_Handler>();
        }

        //make sure default sets are always unlocked at start of game to prevent crashes
        PlayerPrefs.SetInt("Wiz unlocked", 1);
        PlayerPrefs.SetInt("Default Splitter unlocked", 1);
        PlayerPrefs.SetInt("Default Pieceset unlocked", 1);
        PlayerPrefs.SetInt("Symbol Pieceset unlocked", 1);

        splittersUnlocked = new bool[Splitters.Length];
        piecesetsUnlocked = new bool[Piecesets.Length];

        //load the arrays for unlocks with the proper values already saved in prefs. This prevents longer lookups later
        for (int i = 0; i < splittersUnlocked.Length; i++)
        {
            if (PlayerPrefs.GetInt(Splitter_Lookup_Name_by_Index(i) + " Splitter unlocked", 0) == 0)
            {
                splittersUnlocked[i] = false;
            }
            else
            {
                splittersUnlocked[i] = true;
            }
        }

        for (int i = 0; i < piecesetsUnlocked.Length; i++)
        {
            if (PlayerPrefs.GetInt(Pieceset_Lookup_Name_by_Index(i) + " Pieceset unlocked", 0) == 0)
            {
                piecesetsUnlocked[i] = false;
            }
            else
            {
                piecesetsUnlocked[i] = true;
            }
        }
        //the programmer unlocks require all other things to be unlocked, so do that check now
        if (PlayerPrefs.GetInt("Programmer Splitter unlocked", 0) == 0)
        {
            bool check = true;
            for (int i = 0; i < splittersUnlocked.Length; i++)
            {
                if (splittersUnlocked[i] == false && Splitter_Lookup_Name_by_Index(i) != "Programmer")
                {
                    check = false;
                    break;
                }
            }
            if (check)
            {
                Unlock_Splitter("Programmer");
            }
        }

        if (PlayerPrefs.GetInt("Programmer Pieceset unlocked", 0) == 0)
        {
            bool check = true;
            for (int i = 0; i < piecesetsUnlocked.Length; i++)
            {
                if (piecesetsUnlocked[i] == false && Pieceset_Lookup_Name_by_Index(i) != "Programmer")
                {
                    check = false;
                    break;
                }
            }
            if (check)
            {
                Unlock_Pieceset("Programmer");
            }
        }
    }