コード例 #1
0
ファイル: PlayerManager.cs プロジェクト: nagyistge/Medical
 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;
         }
     });
 }
コード例 #2
0
ファイル: PlayerManager.cs プロジェクト: nagyistge/Medical
    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);
    }
コード例 #3
0
ファイル: PlayerManager.cs プロジェクト: nagyistge/Medical
 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);
         }
     });
 }
コード例 #4
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();
         }
     });
 }
コード例 #5
0
ファイル: PlayerManager.cs プロジェクト: nagyistge/Medical
    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);
    }
コード例 #6
0
ファイル: ApproveQuestions.cs プロジェクト: nagyistge/Medical
    private IEnumerator showMyQuestions()
    {
        while (!QuestionBackend.I.retrievedQuestions)
        {
            yield return(new WaitForSeconds(1f));
        }
        QuestionBackend.I.retrievedQuestions = false;
        if (questions.Count > 0)
        {
            for (int i = 0; i < questions.Count; i++)
            {
                GameObject questionRow = Instantiate(Resources.Load("QuestionRow")) as GameObject;
                questionRow.name = questions[i].q_Id;
                questionRow.transform.SetParent(this.transform, false);
                GameObject titleParent = questionRow.transform.GetChild(0).transform.GetChild(0).gameObject;
                GameObject content     = questionRow.transform.GetChild(1).transform.GetChild(0).gameObject;

                titleParent.GetComponentInChildren <Text>().text = questions[i].qT;
                content.transform.GetChild(1).GetChild(1).GetComponent <Text>().text = questions[i].qA;
                content.transform.GetChild(2).GetChild(1).GetComponent <Text>().text = questions[i].qB;
                content.transform.GetChild(3).GetChild(1).GetComponent <Text>().text = questions[i].qC;
                content.transform.GetChild(4).GetChild(1).GetComponent <Text>().text = questions[i].qD;
                if (questions[i].qCA == "A")
                {
                    content.transform.GetChild(1).GetComponent <Image>().color = correctColor;
                }
                else if (questions[i].qCA == "B")
                {
                    content.transform.GetChild(2).GetComponent <Image>().color = correctColor;
                }
                else if (questions[i].qCA == "C")
                {
                    content.transform.GetChild(3).GetComponent <Image>().color = correctColor;
                }
                else if (questions[i].qCA == "D")
                {
                    content.transform.GetChild(4).GetComponent <Image>().color = correctColor;
                }
                content.transform.GetChild(5).GetChild(1).GetComponent <Text>().text = Categories.getCategoryNameById(questions[i].cId);
                content.transform.GetChild(6).gameObject.SetActive(false);
                content.transform.GetChild(7).gameObject.SetActive(true);

                GamedoniaUsers.GetUser(questions[i].sID, delegate(bool success, GDUserProfile data) {
                    if (success)
                    {
                        Dictionary <string, object> playerInfo = data.profile;
                        content.transform.GetChild(7).GetChild(1).GetComponent <Text>().text = playerInfo["name"].ToString();
                    }
                });
                content.transform.GetChild(8).gameObject.SetActive(true);
                content.transform.GetChild(8).GetChild(0).GetComponent <Button> ().onClick.AddListener(delegate {
                    QuestionBackend.I.SetQuestionState(questionRow.name, 1);
                    deleteRow(questionRow.name);
                });
                content.transform.GetChild(8).GetChild(1).GetComponent <Button> ().onClick.AddListener(delegate {
                    QuestionBackend.I.SetQuestionState(questionRow.name, 2);
                    deleteRow(questionRow.name);
                });
            }
        }
        Loader.I.disableLoader();
    }
コード例 #7
0
ファイル: Loader.cs プロジェクト: nagyistge/Medical
    public void showFinishedPopup(string playerName, string matchWon, string oppId = "")
    {
        if (oppId != "")
        {
            GamedoniaUsers.GetUser(oppId, delegate(bool success, GDUserProfile data) {
                if (success)
                {
                    Dictionary <string, object> oppProfile = new Dictionary <string, object> ();
                    oppProfile = data.profile;
                    playerName = oppProfile ["name"].ToString();
                }
                else
                {
                }
            });
        }
        string infoText  = "";
        string infoTitle = "";

        gameObject.GetComponent <Canvas> ().enabled = true;
        Scene currentScene = SceneManager.GetActiveScene();

        if (currentScene.name == "Home")
        {
            GameObject.FindObjectOfType <CurrentMatches>().updateMatches();
        }


        finished.SetActive(true);
//		enableBackground ();
        if (matchWon == PlayerManager.I.player.playerID)
        {
            infoTitle = "Gewonnen";
            infoText  = "Gefeliciteerd je hebt gewonnen van " + playerName + "!";
            finished.transform.GetChild(0).GetComponent <Image> ().sprite = wonSprite;
        }
        else
        {
            if (matchWon == "tie")
            {
                infoTitle = "Gelijkspel";
                infoText  = "Je hebt een gelijkspel met " + playerName + "!";
                finished.transform.GetChild(0).GetComponent <Image> ().sprite = tieSprite;
            }
            else
            {
                infoTitle = "Verloren";
                infoText  = "Helaas je hebt verloren van " + playerName + "!";
                finished.transform.GetChild(0).GetComponent <Image> ().sprite = loseSprite;
            }
        }

        finished.transform.GetChild(1).GetComponent <Text> ().text = infoTitle;
        finished.transform.GetChild(2).GetComponent <Text> ().text = infoText;


        finished.GetComponent <Image> ().DOFade(1, 0.5f);
        finished.transform.GetChild(0).GetComponent <Image> ().DOFade(1, 0.5f);
        finished.transform.GetComponentInChildren <Image> ().DOFade(1, 0.5f);
        foreach (Text text in finished.transform.GetComponentsInChildren <Text>())
        {
            text.DOFade(1, 0.5f);
        }

        finished.transform.DOScale(1.1f, 0.5f);
        finished.transform.DOScale(1, 0.2f).SetDelay(0.5f);
        StartCoroutine(HideFinishedPopup(2f));
    }
コード例 #8
0
ファイル: CurrentMatches.cs プロジェクト: nagyistge/Medical
 private void setChildInformation(string oppId, string matchId, GameObject parent, string listname, int i = 0)
 {
     if (oppId != "")
     {
         float timeLeft = 0;
         Match match    = MatchManager.I.GetMatch(matchId);
         GamedoniaUsers.GetUser(oppId, delegate(bool success, GDUserProfile data) {
             if (success)
             {
                 Dictionary <string, object> oppProfile = new Dictionary <string, object> ();
                 oppProfile = data.profile;
                 foreach (Transform child in parent.transform)
                 {
                     if (child.name == "playerName")
                     {
                         if (oppId != "")
                         {
                             string extraText = "";
                             if (match.m_status == "invite" && match.m_cp == oppId)
                             {
                                 extraText = " (wachten op acceptatie)";
                             }
                             child.GetComponent <Text> ().text = oppProfile ["name"].ToString() + extraText;
                         }
                     }
                     if (child.name == "Score")
                     {
                         if (listname != "inviteTurn")
                         {
                             string _score = MatchManager.I.getMatchScore(matchId, oppId);
                             child.GetComponent <Text> ().text = MatchManager.I.getMatchScore(matchId, oppId);
                         }
                     }
                     if (child.name == "line")
                     {
                         if (listname == "yourTurn")
                         {
                             if (yourTurn.Count == 1 || (yourTurn.Count - 1) == i)
                             {
                                 child.gameObject.SetActive(false);
                             }
                         }
                         else if (listname == "hisTurn")
                         {
                             if (hisTurn.Count == 1 || (hisTurn.Count - 1) == i)
                             {
                                 child.gameObject.SetActive(false);
                             }
                         }
                         else if (listname == "finished")
                         {
                             if (finishedMatches.Count == 1 || (finishedMatches.Count - 1) == i)
                             {
                                 child.gameObject.SetActive(false);
                             }
                         }
                     }
                     if (child.name == "rankImg")
                     {
                         if (oppId != "")
                         {
                             child.GetComponent <Image> ().sprite = PlayerManager.I.GetRankSprite(int.Parse(oppProfile ["lvl"].ToString()));
                         }
                     }
                     if (child.name == "TimeRemaining")
                     {
                         timeLeft = getHoursRemaining(match.m_date);
                         if (listname == "finished")
                         {
                             child.GetComponent <Text>().text = Mathf.Abs(timeLeft) + " uur geleden beëindigd";
                         }
                         else if (listname == "inviteTurn")
                         {
                             child.GetComponent <Text>().text = "nog " + timeLeft + " uur";
                         }
                         else if (listname == "yourTurn")
                         {
                             child.GetComponent <Text>().text = "nog " + timeLeft + " uur om te reageren";
                         }
                         else if (listname == "hisTurn")
                         {
                             child.GetComponent <Text>().text = "heeft nog " + timeLeft + " uur om te reageren";
                         }
                         if (timeLeft <= 0)
                         {
                             if (listname == "yourTurn")
                             {
                                 MatchManager.I.setWinner(match, oppId);
                                 StartCoroutine(waitBeforeUpdateMatches(1f));
                             }
                             else if (listname == "hisTurn")
                             {
                                 if (oppId != "")
                                 {
                                     MatchManager.I.setWinner(match, PlayerManager.I.player.playerID);
                                     PlayerManager.I.UnlockNewAttribute(oppId);
                                     Loader.I.showFinishedPopup(oppProfile ["name"].ToString(), PlayerManager.I.player.playerID);
                                 }
                                 else
                                 {
                                     MatchManager.I.RemoveMatch(match, "", true, true);
                                     GamedoniaData.Delete("randomqueue", match.m_ID, null);
                                 }
                             }
                             else if (listname == "inviteTurn")
                             {
                                 MatchManager.I.DenyMatch(match);
                             }
                         }
                     }
                     if (child.name == "HourGlass")
                     {
                         SetHourGlassImage(timeLeft, child.gameObject);
                     }
                 }
                 parent.SetActive(true);
             }
         });
     }
     else
     {
         foreach (Transform child in parent.transform)
         {
             if (child.name == "Score")
             {
                 if (listname != "inviteTurn")
                 {
                     string _score = MatchManager.I.getMatchScore(matchId, oppId);
                     child.GetComponent <Text> ().text = (_score == "" ? "0-0" : _score);
                 }
             }
         }
         parent.SetActive(true);
     }
 }