Ejemplo n.º 1
0
    public void setMission(int num)
    {
        missions.MissionActiveID = num;

        int idByVideogame = missions.GetActualMissionByVideogame();

        if (playMode == PlayModes.COMPETITION)
        {
            SocialEvents.OnMissionReady(num);
        }
        else
        {
            VideogameData vdata   = videogamesData.GetActualVideogameData();
            Mission       mission = Data.Instance.missions.missions [num];
            if (vdata.id == 0 && num > levelUnlocked_level_1)
            {
                levelUnlocked_level_1 = idByVideogame;
                PlayerPrefs.SetInt("levelUnlocked_level_1", idByVideogame);
            }
            else if (vdata.id == 1 && num > levelUnlocked_level_2)
            {
                levelUnlocked_level_2 = idByVideogame;
                PlayerPrefs.SetInt("levelUnlocked_level_2", idByVideogame);
            }
        }
    }
Ejemplo n.º 2
0
    protected void CheckIfUserExists(string facebookID)
    {
        Debug.Log("CheckIfUserExists: " + facebookID + username);


        string url = SocialManager.Instance.FIREBASE + "/users.json?orderBy=\"facebookID\"&equalTo=\"" + facebookID + "\"";

        Debug.Log(url);

        HTTP.Request someRequest = new HTTP.Request("get", url);
        someRequest.Send((request) =>
        {
            Hashtable decoded = (Hashtable)JSON.JsonDecode(request.response.Text);

            if (decoded == null)
            {
                Debug.Log("no existe el user or malformed response ):");
                return;
            }
            else if (decoded.Count == 0)
            {
                AddNewUser(facebookID);
            }
            else
            {
                SocialEvents.OnUserReady(username, facebookID);
            }
        });
    }
Ejemplo n.º 3
0
 public void ChangeLevels()
 {
     Data.Instance.events.OnResetLevel();
     SocialEvents.OnGetHiscores(1);
     Data.Instance.LoadLevel("MainMenu");
     Close();
 }
 public void Report()
 {
     reportEvent(SocialEvents.PASSENGERS, points.Passengers);
     reportEvent(SocialEvents.TIME, points.Time);
     reportEvent(SocialEvents.MATCHES, 1);
     reportEvent(isMultiplayer ? SocialEvents.MULTIPLAYER_MATCHES : SocialEvents.INDIVIDUAL_MATCHES, 1);
     reportEvent(SocialEvents.GetEventForMap(points.Map), 1);
 }
Ejemplo n.º 5
0
 public void Compite()
 {
     Data.Instance.playMode = Data.PlayModes.COMPETITION;
     Data.Instance.events.OnResetLevel();
     SocialEvents.OnGetHiscores(1);
     Data.Instance.LoadLevel("Competitions");
     Close();
 }
Ejemplo n.º 6
0
 public void Reset()
 {
     SocialEvents.ResetApp();
     PlayerPrefs.DeleteAll();
     Application.LoadLevel("01_Splash");
     CloseOff();
     Time.timeScale = 1;
     Events.OnMusicVolumeChanged(1);
     Events.OnMusicChange("");
 }
Ejemplo n.º 7
0
    void Start()
    {
        mInstance = this;
        DontDestroyOnLoad(this);
        dataController = GetComponent <DataController>();
        hiscores       = GetComponent <Hiscores>();
        dataController.Init();

        SocialEvents.OnGetHiscores(1);
    }
Ejemplo n.º 8
0
    public void resetProgress()
    {
        PlayerPrefs.DeleteAll();
        levelUnlocked_level_1 = 0;
        levelUnlocked_level_2 = 0;

        SocialEvents.OnCompetitionHiscore(1, 0, false);
        userData.resetProgress();
        Social.Instance.hiscores.Reset();
    }
Ejemplo n.º 9
0
 void SetUser(string username, string facebookID)
 {
     this.facebookID = facebookID;
     this.username   = username;
     if (username.Length > 1)
     {
         print("::::::::::::::" + username + " logged: " + logged);
         logged = true;
     }
     SocialEvents.OnFacebookLogin();
 }
    private List <AreaSet> Randomize(List <AreaSet> toRandom)
    {
        SocialEvents.OnCompetitionHiscore(1, 0, false);

        //if (!Data.Instance.isArcade && Data.Instance.playMode == Data.PlayModes.COMPETITION || Data.Instance.playMode == Data.PlayModes.GHOSTMODE)
        // Random.seed = Social.Instance.hiscores.GetMyScore();
        for (int i = 0; i < toRandom.Count; i++)
        {
            AreaSet temp        = toRandom[i];
            int     randomIndex = Random.Range(i, toRandom.Count);
            toRandom[i]           = toRandom[randomIndex];
            toRandom[randomIndex] = temp;
            temp.Restart();
        }
        return(toRandom);
    }
Ejemplo n.º 11
0
    IEnumerator GetHiscoresRoutine(int levelID)
    {
        string post_url = getHighscores_URL + "levelID=" + levelID;

        print("GetHiscoresRoutine : " + post_url);
        WWW receivedData = new WWW(post_url);

        yield return(receivedData);

        if (receivedData.error != null)
        {
            print("There was an error in getting hiscores: " + receivedData.error);
        }
        else
        {
            SocialEvents.OnHiscoresLoaded(receivedData.text);
        }
    }
Ejemplo n.º 12
0
    public void Init()
    {
        Events.OnMusicChange("Raticity");
        Events.OnPoolAllItemsInScene();
        if (SocialManager.Instance.userData.logged)
        {
            ranking.gameObject.SetActive(true);
            challengeButton.SetActive(false);
        }
        else
        {
            ranking.gameObject.SetActive(false);
            challengeButton.SetActive(true);
        }
        panel.SetActive(true);
        // panel.GetComponent<Animator>().Play("PopupOn");
        score = Game.Instance.gameManager.score;
        if (score > SocialManager.Instance.userHiscore.GetHiscore())
        {
            SendHiscore((int)score);
            hiscoreStaticField.text = "NUEVO RECORD! $" + score;
        }
        else
        {
            hiscoreStaticField.text = "Hicites $" + score;
        }
        total_from     = SocialManager.Instance.userHiscore.totalScore;
        total_bar_from = SocialManager.Instance.userHiscore.barProgress;
        total_to       = (int)total_from + (int)score;
        total_bar_to   = (int)total_bar_from + (int)score;
        SocialEvents.OnAddToTotalScore((int)score);

        if (total_bar_to > totalToWin)
        {
            SocialEvents.OnSetToTotalBarScore(0);
        }
        else
        {
            SocialEvents.OnSetToTotalBarScore(total_bar_to);
        }

        state = states.COUNT_DOWN;
    }
Ejemplo n.º 13
0
    IEnumerator AddFacebookId(int userId, string facebookId)
    {
        string hash     = Md5Test.Md5Sum(userId.ToString() + facebookId + secretKey);
        string post_url = addFacebookId + "facebookId=" + facebookId + "&id=" + userId + "&hash=" + hash;

        print("AddFacebookId : " + post_url);
        WWW hs_post = new WWW(post_url);

        yield return(hs_post);

        if (hs_post.error != null)
        {
            Debug.Log("addFacebookID ERROR" + hs_post.error);
        }
        else
        {
            SocialEvents.OnFacebookIdAdded();
        }
    }
Ejemplo n.º 14
0
    void checkToSaveHiscore(int competitionID, float score)
    {
        Debug.Log("Check to save HISCORE: competitionID: " + competitionID + " oldScore: " + levels[competitionID - 1].myScore + " new score: " + score);
        if (levels[competitionID - 1].myScore >= score)
        {
            return;
        }

        bool isNew = false;

        if (levels[competitionID - 1].myScore == 0)
        {
            isNew = true;
        }

        levels[competitionID - 1].myScore = (int)score;

        PlayerPrefs.SetInt("scoreLevel_" + competitionID, (int)score);
        SocialEvents.OnCompetitionHiscore(competitionID, (int)score, isNew);
    }
Ejemplo n.º 15
0
    void OnHeroDie()
    {
        //muestra el summar directamente:
        if (!SocialManager.Instance.challengeData.isOn)
        {
            return;
        }

        panel.SetActive(true);

        ChallengeData challengeData = SocialManager.Instance.challengeData;

        profile1.setPicture(SocialManager.Instance.userData.facebookID);
        profile1.setPicture(challengeData.facebookID);

        int myScore       = (int)Game.Instance.gameManager.score;
        int oponent_score = (int)challengeData.score;

        score1.text = "$" + myScore;
        score2.text = "$" + oponent_score;

        string winner      = SocialManager.Instance.userData.facebookID;
        int    winnerScore = myScore;

        if (myScore > oponent_score)
        {
            title.text = "Ganaste GATO!";
        }
        else if (myScore < oponent_score)
        {
            title.text  = "La tenes adentro!";
            winner      = challengeData.facebookID;
            winnerScore = oponent_score;
        }
        else
        {
            title.text = "Empate!";
        }
        //OnChallengeClose(string objectID, string op_facebookID, string winner, float newScore)
        SocialEvents.OnChallengeClose(challengeData.objectID, challengeData.facebookID, winner, winnerScore);
    }
Ejemplo n.º 16
0
    IEnumerator GetPicture(string facebookID)
    {
        if (facebookID == "")
        {
            yield break;
        }

        WWW receivedData = new WWW("https" + "://graph.facebook.com/" + facebookID + "/picture?width=128&height=128");

        yield return(receivedData);

        if (receivedData.error == null)
        {
            SetLoadedPicture(receivedData.texture);
            SocialEvents.OnFacebookImageLoaded(facebookID, receivedData.texture);
        }
        else
        {
            Debug.Log("ERROR trayendo imagen");
        }
    }
Ejemplo n.º 17
0
    void Update()
    {
        if (loaded)
        {
            return;
        }

        if (!SocialManager.Instance.userHiscore.isLoaded)
        {
            return;
        }

        if (SocialManager.Instance.facebookFriends.all.Count == 0)
        {
            return;
        }

        if (SocialManager.Instance.ranking.data.Count > 0)
        {
            SocialEvents.OnRefreshRanking();
            loaded = true;
            foreach (Ranking.RankingData data in  SocialManager.Instance.ranking.data)
            {
                RankingButton newButton = Instantiate(button);

                newButton.transform.SetParent(container.transform);
                newButton.Init(data.facebookID, data.score, data.playerName);

                newButton.transform.localScale = Vector2.one;

                if (data.isYou)
                {
                    newButton.IsYou();
                }
            }
        }
    }
Ejemplo n.º 18
0
    protected void AddNewUser(string facebookID)
    {
        Debug.Log("AddNewUser" + facebookID + username);

        Hashtable data = new Hashtable();

        data.Add("playerName", username);
        data.Add("facebookID", facebookID);

        HTTP.Request theRequest = new HTTP.Request("post", SocialManager.Instance.FIREBASE + "/users.json", data);
        theRequest.Send((request) =>
        {
            Hashtable jsonObj = (Hashtable)JSON.JsonDecode(request.response.Text);
            if (jsonObj == null)
            {
                Debug.LogError("server returned null or malformed response ):");
            }
            else
            {
                Debug.Log("nuevo usuario!!");
                SocialEvents.OnUserReady(username, facebookID);
            }
        });
    }
Ejemplo n.º 19
0
    void FBFriendsCallback(IGraphResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            // Let's just try again
            FB.API("/me?fields=id,name,friends.limit(100).fields(name,id)", Facebook.Unity.HttpMethod.GET, FBFriendsCallback);
            return;
        }

        var         data    = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as Dictionary <string, object>;
        IDictionary dict    = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as IDictionary;
        var         friends = dict["friends"] as Dictionary <string, object>;

        System.Collections.Generic.List <object> ff = friends["data"] as System.Collections.Generic.List <object>;

        foreach (var obj in ff)
        {
            Dictionary <string, object> facebookFriendData = obj as Dictionary <string, object>;
            SocialEvents.AddFacebookFriend(facebookFriendData["id"].ToString(), facebookFriendData["name"].ToString());
        }
        print("OnFacebookFriends");
        SocialEvents.OnFacebookFriends();
    }
Ejemplo n.º 20
0
 public void Challenge(string _username, string _facebookID)
 {
     SocialEvents.OnChallengeCreate(_username, _facebookID, SocialManager.Instance.userHiscore.GetHiscore());
     lastSelectedFacebookId = facebookFriendId;
 }
Ejemplo n.º 21
0
 public void Login()
 {
     SocialEvents.FBLogin();
 }
Ejemplo n.º 22
0
 void SetUserData(string userName, string facebookID, int userId, int hiscore, string email)
 {
     SocialEvents.OnSetUserData(userName, userId, hiscore, true);
 }
Ejemplo n.º 23
0
 public void  Clicked()
 {
     SocialEvents.OnChallengeCreate(username, facebookID, 43);
 }
Ejemplo n.º 24
0
 public void SendHiscore(int distance)
 {
     SocialEvents.OnNewHiscore(distance);
 }
Ejemplo n.º 25
0
 public void Confirm(string username, string objectID, string facebookID, float op_score)
 {
     SocialEvents.OnChallengeConfirm(objectID, username, facebookID, op_score);
 }
Ejemplo n.º 26
0
 public void CancelChallenge(string objectID)
 {
     SocialEvents.OnChallengeDelete(objectID);
 }
Ejemplo n.º 27
0
 public void Login()
 {
     SocialEvents.OnFacebookNotConnected();
 }