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);
        }
Ejemplo n.º 2
0
        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);
        }