private void onGameRestart() { UserVO viewUserVO = view.getUser(); if (viewUserVO != null && viewUserVO.serviceId != userVO.serviceId) { GameObject.Destroy(gameObject); } }
public void setUser(UserVO vo) { if (userVO == null || vo.serviceId == userVO.serviceId) { userVO = vo; updateImage(userVO.imgUrl); updateName(userVO.userFirstName); updateScore(userVO.highScore); } }
private UserVO getUserData(string name, string id, string imgUrl, int score) { UserVO retv = new UserVO(); retv.userFirstName = name; retv.serviceId = id; retv.imgUrl = imgUrl; retv.highScore = score; return(retv); }
public void setUser(UserVO vo) { if (userVO == null || vo.serviceId == userVO.serviceId) { userVO = vo; updateImage(userVO.imgUrl); updateName(userVO.userFirstName); updateScore(userVO.highScore); } }
private IEnumerator waitASecondThenReturnCurrentUser() { yield return(new WaitForSeconds(1f)); //...then pass back some fake data UserVO user = getUserData("Zaphod", "12345", "http://upload.wikimedia.org/wikipedia/en/7/72/Mark_Wing-Davey_as_Zaphod_Beeblebrox.jpg", 100); dispatcher.Dispatch(SocialEvent.FULFILL_CURRENT_USER_REQUEST, user); }
private IEnumerator waitASecondThenReturnCurrentUser() { yield return(new WaitForSeconds(1f)); //...then pass back some fake data UserVO user = getUserData("Kirk", "54321", "http://upload.wikimedia.org/wikipedia/commons/a/a5/Star_Trek_William_Shatner.JPG", 100); dispatcher.Dispatch(SocialEvent.FULFILL_CURRENT_USER_REQUEST, user); }
private void onResponse(IEvent evt) { social.dispatcher.RemoveListener(SocialEvent.FULFILL_CURRENT_USER_REQUEST, onResponse); UserVO vo = evt.data as UserVO; //We're going to Bind this for injection, since we'll need it later when we compare //the user's highscore with his own score and the highscore of others. injectionBinder.Bind <UserVO>().ToValue(vo); dispatcher.Dispatch(SocialEvent.FULFILL_CURRENT_USER_REQUEST, vo); Release(); }
public override void Execute() { ArrayList list = data as ArrayList; int highScore = 0; int aa = list.Count; for (int a = 0; a < aa; a++) { UserVO vo = list[a] as UserVO; GameObject go = UnityEngine.Object.Instantiate(Resources.Load("GameTile")) as GameObject; go.AddComponent <UserTileView>(); go.transform.parent = contextView.transform; UserTileView view = go.GetComponent <UserTileView>() as UserTileView; view.setUser(vo); Vector3 pos = new Vector3(.2f + (.1f * a), .1f, (Camera.main.farClipPlane - Camera.main.nearClipPlane) / 2f); Vector3 dest = Camera.main.ViewportToWorldPoint(pos); view.SetTilePosition(dest); highScore = Math.Max(highScore, vo.highScore); } string msg; if (userVO.currentScore > highScore) { msg = "Score of " + userVO.currentScore + " is the new High Score!!!"; } else if (userVO.currentScore > userVO.highScore) { msg = "Score of " + userVO.currentScore + " is a personal best!"; } else { msg = "Score of " + userVO.currentScore + " is nothing special."; } GameObject award = new GameObject(); award.transform.parent = contextView.transform; award.AddComponent <AwardView>(); dispatcher.Dispatch(SocialEvent.REWARD_TEXT, msg); }
public override void Execute() { UserVO vo = evt.data as UserVO; GameObject go = UnityEngine.Object.Instantiate(Resources.Load("GameTile")) as GameObject; go.transform.parent = contextView.transform; go.AddComponent <UserTileView>(); //Here's something interesting. I'm technically bypassing the mediator here. //Stylistically I think this is fine during instantiation. Your team might decide differently. UserTileView view = go.GetComponent <UserTileView>() as UserTileView; view.setUser(vo); Vector3 bottomLeft = new Vector3(.1f, .1f, (Camera.main.farClipPlane - Camera.main.nearClipPlane) / 2f); Vector3 dest = Camera.main.ViewportToWorldPoint(bottomLeft); view.SetTilePosition(dest); }
private UserVO getUserData(string name, string id, string imgUrl, int score) { UserVO retv = new UserVO (); retv.userFirstName = name; retv.serviceId = id; retv.imgUrl = imgUrl; retv.highScore = score; return retv; }