Esempio n. 1
0
    /// <summary>
    /// Cập nhật lại vị trí và giao diện
    /// </summary>
    public static void UpdatePlayerSide()
    {
        YourController.mSide = ESide.You;

        foreach (PlayerControllerPhom p in ListPlayer)
        {
            p.mSide = SlotToSide(p.slotServer);
        }

        foreach (PlayerControllerPhom p in ListJoinGameWhenPlaying)
        {
            p.mSide = SlotToSide(p.slotServer);
        }

        //Vẽ thông tin người đang tham gia trận đấu. Khi vẽ thông tin người dùng sẽ tự động destroy các slot trống.
        ListPlayer.ForEach(p => {
            Debug.Log("Vi tri nguoi choi:" + (int)p.mSide);
            if (p.cuiPlayer == null && p.slotServer <= 3)
            {
                CUIPlayerPhom.Create(p, game.mPlaymat.locationPlayer[(int)p.mSide]);
            }
        });
        //Vẽ thông tin người đang chờ trận đấu mới.
        ListJoinGameWhenPlaying.ForEach(p => { if (p.cuiPlayer == null)
                                               {
                                                   CUIPlayerPhom.Create(p, game.mPlaymat.locationPlayer[(int)p.mSide]);
                                               }
                                        });

        DrawInfoPlayerNoSlot();
    }
Esempio n. 2
0
    public static CUIPlayerPhom Create(PlayerControllerPhom p, Transform parentTransform)
    {
        if (listNoSlot.ContainsKey(p.slotServer))
        {
            GameObject.Destroy(listNoSlot[p.slotServer]);
        }

        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PlayerInfoPhomPrefab"));

        obj.name                    = "Player " + (int)p.mSide;
        obj.transform.parent        = parentTransform;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localScale    = Vector3.one;
        CUIPlayerPhom cui = obj.GetComponent <CUIPlayerPhom>();

        cui.player  = p;
        p.cuiPlayer = cui;

        p.AvatarTexture(delegate(Texture _texture) { if (cui != null)
                                                     {
                                                         cui.avatar.GetComponentInChildren <UITexture>().mainTexture = _texture;
                                                     }
                        });

        if (p.mSide == ESide.You)
        {
            //cui.avatar.GetComponentInChildren<UITexture>().enabled = false;
            NGUITools.SetActive(cui.avatar.gameObject, false);
            //GameObject.Destroy(cui.avatar.GetComponentInChildren<CUIHandle>().gameObject.collider);
            GameObject.Destroy(cui.GetComponentInChildren <UISprite>().gameObject);

            //cui.avatar.FindChild("lbMoney").GetComponent<UILabel>().pivot = UIWidget.Pivot.Left;
            //cui.avatar.FindChild("lbUsername").GetComponent<UILabel>().pivot = UIWidget.Pivot.Left;

            //cui.avatar.FindChild("lbMoney").transform.localPosition = new Vector3(-95f, -117f, -5f);
            //cui.avatar.FindChild("lbUsername").transform.localPosition = new Vector3(-95f, -97f, -5f);

            //cui.avatar.FindChild("lbUsername").transform.localScale = cui.avatar.FindChild("lbMoney").transform.localScale = new Vector3(19f, 19f, 1f);
            //cui.avatar.FindChild("lbUsername").GetComponent<UILabel>().width = cui.avatar.FindChild("lbMoney").GetComponent<UILabel>().width = 250;
            //cui.avatar.FindChild("lbMoney").GetComponent<UILabel>().color = Color.green;
            cui.gameObject.transform.FindChild("IconWarning").localPosition = new Vector3(35f, -46f, -5f);
            cui.gameObject.transform.FindChild("IconMaster").localPosition  = new Vector3(125f, -138f, -5f);
        }
        cui.avatar.Find("lbUsername").GetComponent <UILabel>().text = p.mSide == ESide.You ? (string.IsNullOrEmpty(GameManager.Instance.mInfo.FullName) ? p.username : GameManager.Instance.mInfo.FullName.Trim()) : p.username; //(p.mSide == ESide.You ? "Username: "******"") + p.username;

        cui.UpdateInfo();

        return(cui);
    }
Esempio n. 3
0
    public static CUIPlayerPhom CreateNoSlot(int slotIndex, Transform parentTransform)
    {
        if (listNoSlot.ContainsKey(slotIndex))
        {
            GameObject.Destroy(listNoSlot[slotIndex]);
            listNoSlot.Remove(slotIndex);
        }

        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PlayerInfoPhomPrefab"));

        obj.GetComponentInChildren <UISprite>().MakePixelPerfect();
        obj.name                    = "Side Null " + slotIndex;
        obj.transform.parent        = parentTransform;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localScale    = Vector3.one;
        CUIPlayerPhom p = obj.GetComponent <CUIPlayerPhom>();

        p.slotIndex = slotIndex;
        p.IsHasQuit();

        listNoSlot.Add(slotIndex, obj);
        return(p);
    }
Esempio n. 4
0
 public static void DrawInfoPlayerNoSlot()
 {
     //Vẽ thông tin các slot trống
     ListSlotEmpty.ForEach(slot => CUIPlayerPhom.CreateNoSlot(slot, game.mPlaymat.locationPlayer[(int)SlotToSide(slot)]));
 }