示例#1
0
    // Use this for initialization
    void Start()
    {
        // First create the credentials object for the account. In this example email credentials are used

        Credentials credentials = new Credentials();

        credentials.email    = email;
        credentials.password = password;

        // Create the user account with some profile data and attach it to the credentials created in the previous block
        GDUser user = new GDUser();

        user.credentials         = credentials;
        user.profile["email"]    = email;
        user.profile["name"]     = "";
        user.profile["color"]    = "";
        user.profile["hobby"]    = "";
        user.profile["film"]     = "";
        user.profile["age"]      = 0;
        user.profile["lvl"]      = 1;
        user.profile["wonAttr"]  = 0;
        user.profile ["friends"] = new Dictionary <string, object> ();

        // Make the request to Gamedonia Backend to create the account and process the result in a block.
        GamedoniaUsers.CreateUser(user, delegate(bool success){
            if (success)
            {
                Debug.Log("Success");
            }
            else
            {
                Debug.Log("Fail");
            }
        });
    }
示例#2
0
 void ProcessLogin(bool success)
 {
     if (success)
     {
         if (GamedoniaUsers.me == null)
         {
             GamedoniaUsers.GetMe(HandleGetMe);
         }
         else
         {
             if (this.callback != null)
             {
                 callback(success);
             }
         }
     }
     else
     {
         Debug.LogError("Gamedonia session couldn't be started!");
         if (this.callback != null)
         {
             callback(false);
         }
     }
 }
    public static void Count(string collection, string query, Action <bool, int> callback = null)
    {
        query = Uri.EscapeDataString(query);
        string url = "/data/" + collection + "/count?query=" + query;

        Gamedonia.RunCoroutine(
            GamedoniaRequest.get(url, GamedoniaUsers.GetSessionToken(),
                                 delegate(bool success, object data) {
            if (callback != null)
            {
                if (success)
                {
                    IDictionary response = Json.Deserialize((string)data) as IDictionary;
                    int count            = int.Parse(response["count"].ToString());
                    callback(success, count);
                }
                else
                {
                    callback(success, -1);
                }
            }
        }
                                 )
            );
    }
示例#4
0
    /** DEFAULT LOGIN **/
    public void LoginUser()
    {
        checkInternet();
        errorLogin.SetActive(false);
        errorLoginImg.SetActive(false);
        validateFields();
        if (isValidated)
        {
            // Show loading screen
            loader.enableLoader();
            // Try to Login, if there is no access we are starting the waitForConnection
            if (i_access)
            {
                // Login with email and password, store session token
                GamedoniaUsers.LoginUserWithEmail(email.ToLower(), password, OnLogin);
                if (errorMsg != "")
                {
                    Debug.Log(errorMsg);
                }

                if (statusMsg != "")
                {
                    Debug.Log(statusMsg);
                }
            }
            else
            {
                loader.disableLoader();
                loader.enableBackground();
                errorPopup.SetActive(true);
                // Wait for connection, if there is a connection we try to login again
                //StartCoroutine (waitForConnection (waitForConnectionTime));
            }
        }
    }
示例#5
0
 public void LoadFriends()
 {
     GamedoniaUsers.GetMe(delegate(bool success, GDUserProfile data){
         if (success)
         {
             Debug.Log("I am here now");
             friends = (Dictionary <string, object>)data.profile["friends"];
             foreach (KeyValuePair <string, object> friend in friends)
             {
                 string friendKey = friend.Key;
                 GamedoniaUsers.GetUser(friendKey, delegate(bool succesFriends, GDUserProfile friendProfile) {
                     if (succesFriends)
                     {
                         Dictionary <string, object> oppProfile = new Dictionary <string, object>();
                         oppProfile = friendProfile.profile;
                         friendProfiles.Add(friendKey, oppProfile);
                     }
                     else
                     {
                         friends.Remove(friendKey);
                     }
                 });
             }
             startUpDone = true;
         }
     });
 }
示例#6
0
    public static void Run(string script, Dictionary <string, object> parameters, Action <bool, object> callback = null)
    {
        string json = "{}";

        if (parameters != null)
        {
            json = JsonMapper.ToJson(parameters);
        }

        Gamedonia.RunCoroutine(
            GamedoniaRequest.post("/run/" + script, json, null, GamedoniaUsers.GetSessionToken(), null,
                                  delegate(bool success, object data) {
            if (callback != null)
            {
                if (success)
                {
                    string strData = data as String;
                    if (strData.Length > 0)
                    {
                        callback(success, Json.Deserialize(strData));
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
                else
                {
                    callback(success, null);
                }
            }
        }
                                  )
            );
    }
示例#7
0
    void OnGUI()
    {
        GUI.skin = skin;

        GUI.DrawTexture(UtilResize.ResizeGUI(new Rect(0, 0, 320, 480)), backgroundImg);

        GUI.enabled = (statusMsg == "");
        //Login Controls
        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 10, 220, 20)), "eMail", "LabelBold");
        email = GUI.TextField(UtilResize.ResizeGUI(new Rect(80, 30, 220, 40)), email, 100);

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 75, 220, 20)), "Password", "LabelBold");
        password = GUI.PasswordField(UtilResize.ResizeGUI(new Rect(80, 100, 220, 40)), password, '*');


        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 150, 220, 50)), "Login"))
        {
            GamedoniaUsers.LoginUserWithEmail(email.ToLower(), password, OnLogin);
        }

        GUIStyle fbButton = GUI.skin.GetStyle("ButtonFacebook");

        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 205, 220, 50)), "Facebook", fbButton))
        {
            statusMsg = "Initiating Facebook session...";
            FacebookBinding.OpenSessionWithReadPermissions(READ_PERMISSIONS, OnFacebookOpenSession);
        }

        GUIStyle separator = GUI.skin.GetStyle("separator");

        GUI.Box(UtilResize.ResizeGUI(new Rect(80, 277, 220, 1)), "", separator);

        //Sign Up
        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 300, 220, 50)), "Sign Up"))
        {
            //print ("you clicked the text button");
            Application.LoadLevel("CreateAccountScene");
        }

        //Password Recovery
        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 355, 220, 50)), "Remember Password"))
        {
            Application.LoadLevel("ResetPasswordScene");
        }

        if (errorMsg != "")
        {
            GUI.Box(new Rect((Screen.width - (UtilResize.resMultiplier() * 260)), (Screen.height - (UtilResize.resMultiplier() * 50)), (UtilResize.resMultiplier() * 260), (UtilResize.resMultiplier() * 50)), errorMsg);
            if (GUI.Button(new Rect(Screen.width - 20, Screen.height - UtilResize.resMultiplier() * 45, 16, 16), "x", "ButtonSmall"))
            {
                errorMsg = "";
            }
        }

        GUI.enabled = true;
        if (statusMsg != "")
        {
            GUI.Box(UtilResize.ResizeGUI(new Rect(80, 240 - 40, 220, 40)), statusMsg);
        }
    }
示例#8
0
    public void Authenticate(Action <bool> callback)
    {
        if (Gamedonia.INSTANCE.debug)
        {
            Debug.Log("Facebook Authentication");
        }
        _callback = callback;

        if (!String.IsNullOrEmpty(_fb_uid) && !String.IsNullOrEmpty(_fb_access_token))
        {
            GDUser      user        = new GDUser();
            Credentials credentials = new Credentials();
            credentials.fb_uid          = _fb_uid;
            credentials.fb_access_token = _fb_access_token;
            user.credentials            = credentials;

            GamedoniaUsers.CreateUser(user, ProcessCreateUser);
        }
        else
        {
            Debug.LogError("Facebook id or token not present impossible to perform login with it");
            if (_callback != null)
            {
                _callback(false);
            }
        }
    }
    void OnGUI()
    {
        GUI.skin = skin;
        // Make a text field that modifies stringToEdit.
        //GUI.backgroundColor = Color.black;
        GUI.DrawTexture(UtilResize.ResizeGUI(new Rect(0, 0, 320, 480)), backgroundImg);

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 10, 220, 20)), "eMail*", "LabelBold");
        email = GUI.TextField(UtilResize.ResizeGUI(new Rect(80, 30, 220, 40)), email, 100);

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 75, 220, 20)), "Password*", "LabelBold");
        password = GUI.PasswordField(UtilResize.ResizeGUI(new Rect(80, 100, 220, 40)), password, '*');

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 145, 200, 20)), "Repeat Password*", "LabelBold");
        repassword = GUI.PasswordField(UtilResize.ResizeGUI(new Rect(80, 170, 220, 40)), repassword, '*');

        GUI.Label(UtilResize.ResizeGUI(new Rect(80, 215, 200, 20)), "Nickname*", "LabelBold");
        nickname = GUI.TextField(UtilResize.ResizeGUI(new Rect(80, 240, 220, 40)), nickname, 25);


        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 290, 220, 50)), "Create"))
        {
            if ((email != "") &&
                (password != "") &&
                (repassword != "") &&
                (password == repassword))
            {
                Credentials credentials = new Credentials();
                credentials.email    = email.ToLower();
                credentials.password = password;
                GDUser user = new GDUser();
                user.credentials = credentials;
                user.profile.Add("nickname", nickname);
                user.profile.Add("registerDate", DateTime.Now);

                GamedoniaUsers.CreateUser(user, OnCreateUser);
            }
            else
            {
                errorMsg = "Fill all the fields with (*) correctly";
                Debug.Log(errorMsg);
            }
        }

        if (GUI.Button(UtilResize.ResizeGUI(new Rect(80, 345, 220, 50)), "Cancel"))
        {
            Application.LoadLevel("LoginScene");
        }

        if (errorMsg != "")
        {
            GUI.Box(new Rect((Screen.width - (UtilResize.resMultiplier() * 260)), (Screen.height - (UtilResize.resMultiplier() * 50)), (UtilResize.resMultiplier() * 260), (UtilResize.resMultiplier() * 50)), errorMsg);
            if (GUI.Button(new Rect(Screen.width - 20, Screen.height - UtilResize.resMultiplier() * 45, 16, 16), "x", "ButtonSmall"))
            {
                errorMsg = "";
            }
        }
    }
 public static void Delete(string collection, string entityId, Action <bool> callback = null)
 {
     Gamedonia.RunCoroutine(
         GamedoniaRequest.delete("/data/" + collection + "/delete/" + entityId, GamedoniaUsers.GetSessionToken(),
                                 delegate(bool success, object data) {
         callback(success);
     }
                                 )
         );
 }
示例#11
0
    void Start()
    {
        GamedoniaUsers.Authenticate(OnLogin);
        printToConsole("Starting session with Gamedonia...");

        //Handle push
        GDPushService pushService = new GDPushService();

        pushService.RegisterEvent += new RegisterEventHandler(OnNotification);
        GamedoniaPushNotifications.AddService(pushService);
    }
示例#12
0
    private void showTopTenPlayers()
    {
        float delayRow = 0;
        float minus    = 0;

        // Get the top 10 players of the game
        GamedoniaUsers.Search("{}", 10, "{profile.wonAttr:-1}", 0, delegate(bool success, IList data) {
            if (success)
            {
                if (data != null)
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        Dictionary <string, object> resultUser    = (Dictionary <string, object>)data[i];
                        Dictionary <string, object> resultProfile = (Dictionary <string, object>)resultUser["profile"];

                        if (i == 0)
                        {
                            if (resultUser["_id"].ToString() == PlayerManager.I.player.playerID)
                            {
                                AchievementManager.I.EarnAchievement("Kampioen");
                            }
                            avatarWon.GetComponent <buildAvatar>().setCustomAvatarByString(resultProfile["avatar"].ToString());
                            avatarWon.SetActive(true);
                            avatarWon.transform.DOScale(30, 2).SetEase(Ease.OutExpo).SetDelay(1);
                        }
                        GameObject row = gameObject.transform.GetChild(i).gameObject;
                        row.SetActive(true);
                        if (i <= 2)
                        {
                            row.transform.GetChild(5).GetComponent <Text>().text = resultProfile["wonAttr"].ToString();
                            row.GetComponent <RectTransform> ().DOScale(1.2f - minus, .5f).SetEase(Ease.InFlash).SetDelay(delayRow);
                            row.GetComponent <RectTransform> ().DOScale(1, 1f).SetEase(Ease.OutExpo).SetDelay((.5f + delayRow));
                            delayRow += .2f;
                            minus    += 0.05f;
                        }
                        else
                        {
                            row.transform.GetChild(6).GetComponent <Text>().text = resultProfile["wonAttr"].ToString();
                        }
                        row.transform.GetChild(0).GetComponent <Image>().sprite = PlayerManager.I.GetRankSprite(int.Parse(resultProfile["lvl"].ToString()));
                        row.transform.GetChild(1).GetComponent <Text>().text    = resultProfile["name"].ToString();



                        //
                    }
                }
            }
            else
            {
            }
        });
    }
示例#13
0
 void OnCreateUser(bool success)
 {
     if (success)
     {
         GamedoniaUsers.LoginUserWithEmail(email.ToLower(), password, OnLogin);
     }
     else
     {
         errorMsg = Gamedonia.getLastError().ToString();
         Debug.Log(errorMsg);
     }
 }
示例#14
0
 public void GetPlayerInformationById(string playerID)
 {
     ;
     GamedoniaUsers.GetUser(playerID, delegate(bool success, GDUserProfile data) {
         if (success)
         {
             //returnInformation["name"] = data.profile["name"].ToString();
             currentOpponentInfo = data.profile;
             currentOpponentInfo.Add("_id", data._id);
         }
     });
 }
示例#15
0
 private void setAddedByInfo(string playerID)
 {
     GamedoniaUsers.GetUser(playerID, delegate(bool success, GDUserProfile data) {
         if (success)
         {
             //returnInformation["name"] = data.profile["name"].ToString();
             Dictionary <string, object> playerInfo = data.profile;
             addedBy.transform.GetChild(0).GetComponent <Image>().sprite = PlayerManager.I.GetRankSprite(int.Parse(playerInfo["lvl"].ToString()));
             addedBy.transform.GetChild(2).GetComponent <Text>().text    = playerInfo["name"].ToString();
         }
     });
 }
示例#16
0
    public Dictionary <string, object> GetPlayerById(string playerID)
    {
        Dictionary <string, object> returnprofile = new Dictionary <string, object> ();

        GamedoniaUsers.GetUser(playerID, delegate(bool success, GDUserProfile data) {
            if (success)
            {
                returnprofile = data.profile;
            }
        });
        return(returnprofile);
    }
示例#17
0
 void ProcessCreateUser(bool success)
 {
     if (Social.localUser.authenticated)
     {
         //Login with gamecenter id
         GamedoniaUsers.LoginUserWithGameCenterId(Social.localUser.id, ProcessLogin);
     }
     else
     {
         //Login with open_udid
         GamedoniaUsers.LoginUserWithOpenUDID(OpenUDIDPlugin.GetOpenUDID(), null);
     }
 }
示例#18
0
	// Use this for initialization
	void Start () {
		RuntimeData.I.Load ();
        AudioManagerScript.I.Load();
		//ProductManager.I.Load();
        if(!PlayerManager.I.player.verificationComplete)
        {
            SceneManager.LoadScene("First_Login");
        }
        else
        {

            if (!PlayerManager.I.player.loggedIn)
            {
                SceneManager.LoadScene("Login");
            }
            else
            {
			    if (PlayerManager.I.player.createdProfile)
                {
                    if (!PlayerManager.I.player.completedIntro)
                    {
                        sceneName = "Introduction";
                    }
                    else
                    {
                        sceneName = "Home";
                    }
                }
                else
                {
                    sceneName = "Profile_Create";
                }
                GamedoniaUsers.LoginUserWithSessionToken (delegate (bool success) {
				    if (success) {
						ProductManager.I.RequestProducts();
						PlayerManager.I.LoadFriends ();
						if(sceneName == "Home") {
							Loader.I.enableLoader();
							StartCoroutine(waitBeforeInformationIsProcessed());
						} else {
							SceneManager.LoadScene (sceneName);
						}
				    } else {
						
					    SceneManager.LoadScene ("Login");
				    }
			    });
		    }
	    }
    }//end start
示例#19
0
    void ProcessAuthentication(bool success)
    {
        GDUser      user        = new GDUser();
        Credentials credentials = new Credentials();

        credentials.open_udid = OpenUDIDPlugin.GetOpenUDID();
        user.credentials      = credentials;

        if (success)
        {
            credentials.gamecenter_id = Social.localUser.id;
        }

        GamedoniaUsers.CreateUser(user, ProcessCreateUser);
    }
示例#20
0
    private void OnFacebookMe(IDictionary data)
    {
        statusMsg  = "Initiating Gamedonia session...";
        fbUserId   = data ["id"] as string;
        fbUserName = data ["name"] as string;
        Debug.Log("AccessToken: " + FacebookBinding.GetAccessToken() + " fbuid: " + fbUserId);


        Dictionary <string, object> facebookCredentials = new Dictionary <string, object> ();

        facebookCredentials.Add("fb_uid", fbUserId);
        facebookCredentials.Add("fb_access_token", FacebookBinding.GetAccessToken());

        GamedoniaUsers.Authenticate(GamedoniaBackend.CredentialsType.FACEBOOK, facebookCredentials, OnFacebookLogin);
    }
    public static void VerifyPurchase(Dictionary <string, object> parameters, Action <bool> callback = null)
    {
        string json = JsonMapper.ToJson(parameters);

        Gamedonia.RunCoroutine(
            GamedoniaRequest.post("/purchase/verify", json, null, GamedoniaUsers.GetSessionToken(), null,
                                  delegate(bool success, object data) {
            if (callback != null)
            {
                callback(success);
            }
        }
                                  )
            );
    }
示例#22
0
    public void Authenticate(Action <bool> callback)
    {
        if (Gamedonia.INSTANCE.debug)
        {
            Debug.Log("Silent Authentication");
        }
        this.callback = callback;

        GDUser      user        = new GDUser();
        Credentials credentials = new Credentials();

        credentials.open_udid = OpenUDIDPlugin.GetOpenUDID();
        user.credentials      = credentials;

        GamedoniaUsers.CreateUser(user, ProcessCreateUser);
    }
示例#23
0
    void Start()
    {
        GamedoniaUsers.Authenticate(OnLogin);
        printToConsole("Starting session with Gamedonia...");

        //Register the callback
        GDInAppService reqService = new GDInAppService();

        reqService.RegisterEvent += new InAppEventHandler(OnProductsRequested);
        GamedoniaStoreInAppPurchases.AddRequestService(reqService);

        GDInAppService buyService = new GDInAppService();

        buyService.RegisterEvent += new InAppEventHandler(OnProductPurchased);
        GamedoniaStoreInAppPurchases.AddPurchaseService(buyService);
    }
示例#24
0
 void OnFacebookLogin(bool success)
 {
     if (success)
     {
         // Optional stuff if you want to store the Facebook username inside the Gamedonia user profile
         Dictionary <string, object> profile = new Dictionary <string, object>();
         profile.Add("nickname", fbUserName);
         profile.Add("registerDate", DateTime.Now);
         GamedoniaUsers.UpdateUser(profile, OnLogin);
     }
     else
     {
         errorMsg = GamedoniaBackend.getLastError().ToString();
         Debug.Log(errorMsg);
     }
 }
示例#25
0
    public void saveAvatar()
    {
        string avatar = skinCode.ToString() + "_" +
                        a_hairstyle + "_" +
                        currentHairstyleMaterial.ToString() + "_" +
                        currentHead.ToString() + "_" +
                        a_shirt + "_" +
                        currentShirtMaterial.ToString() + "_" +
                        a_trouser + "_" +
                        currentTrouserMaterial.ToString();

        Dictionary <string, object> profile = new Dictionary <string, object>();

        profile.Add("avatar", avatar);
        PlayerManager.I.player.avatar = avatar;
        GamedoniaUsers.UpdateUser(profile, OnUpdate);
    }
示例#26
0
 void OnCreateUser(bool success)
 {
     if (success)
     {
         GamedoniaUsers.LoginUserWithEmail(email.text, password.text, OnLogin);
     }
     else
     {
         Loader.I.disableLoader();
         if (GamedoniaBackend.getLastError().code == 10001)
         {
             emailImg.DOColor(errorColor, 1);
             errorMsgText.text = "Dit e-mailadres is al in gebruik";
             errorMsgText.DOFade(1, 1);
         }
     }
 }
    public static void Update(string collection, Dictionary <string, object> entity, Action <bool, IDictionary> callback = null, bool overwrite = false)
    {
        string json = JsonMapper.ToJson(entity);

        if (!overwrite)
        {
            Gamedonia.RunCoroutine(
                GamedoniaRequest.post("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null,
                                      delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        callback(success, Json.Deserialize((string)data) as IDictionary);
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
            }
                                      )
                );
        }
        else
        {
            Gamedonia.RunCoroutine(
                GamedoniaRequest.put("/data/" + collection + "/update", json, null, GamedoniaUsers.GetSessionToken(), null,
                                     delegate(bool success, object data) {
                if (callback != null)
                {
                    if (success)
                    {
                        callback(success, Json.Deserialize((string)data) as IDictionary);
                    }
                    else
                    {
                        callback(success, null);
                    }
                }
            }
                                     )
                );
        }
    }
示例#28
0
    void OnFacebookLogin(bool success)
    {
        if (success)
        {
            //Application.LoadLevel("UserDetailsScene");

            //Optional stuf if oyu want to store the facebook username inside the Gamedonia user profile
            Dictionary <string, object> profile = new Dictionary <string, object>();
            profile.Add("nickname", fbUserName);
            profile.Add("registerDate", DateTime.Now);
            GamedoniaUsers.UpdateUser(profile, OnLogin);
        }
        else
        {
            errorMsg = Gamedonia.getLastError().ToString();
            Debug.Log(errorMsg);
        }
    }
示例#29
0
 public void loggingOut()
 {
     Loader.I.enableLoader();
     GamedoniaUsers.LogoutUser(delegate(bool success)
     {
         if (success)
         {
             player.playerID       = "";
             player.loggedIn       = false;
             player.createdProfile = false;
             SceneManager.LoadScene("Login");
         }
         else
         {
             //TODO Your fail processing
         }
     });
 }
示例#30
0
    public void AddFriend(string name)
    {
        friends.Add(name, new List <int> ());
        GamedoniaUsers.GetUser(name, delegate(bool success, GDUserProfile friendProfile) {
            if (success)
            {
                Dictionary <string, object> oppProfile = new Dictionary <string, object>();
                oppProfile = friendProfile.profile;
                friendProfiles.Add(name, oppProfile);
                Save();
            }
        });
        // Update player list in backend
        Dictionary <string, object> profile = GetPlayerById(player.playerID);

        profile ["friends"] = friends;
        GamedoniaUsers.UpdateUser(profile);
    }