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 <UserTileSignalView>(); go.transform.parent = contextView.transform; UserTileSignalView view = go.GetComponent <UserTileSignalView>() as UserTileSignalView; 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 <AwardSignalView>(); REWARD_TEXT.Dispatch(msg); }
public override void Execute() { GameObject go = UnityEngine.Object.Instantiate(Resources.Load("GameTile")) as GameObject; go.transform.parent = contextView.transform; go.AddComponent <UserTileSignalView>(); //Here's something interesting. I'm technically bypassing the mediator here. //Stylistically I think this is fine during instantiation. Your team might decide differently. UserTileSignalView view = go.GetComponent <UserTileSignalView>() as UserTileSignalView; 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); }