public static CUIPlayerChan 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/PlayerInfoPrefab")); obj.GetComponentInChildren <UISprite>().MakePixelPerfect(); obj.name = "Side Null " + slotIndex; obj.transform.parent = parentTransform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = scaleAvatar; CUIPlayerChan p = obj.GetComponent <CUIPlayerChan>(); p.slotIndex = slotIndex; if (GameModelChan.YourController != null && GameModelChan.YourController.isMaster) { p.btnPlus.gameObject.SetActive(true); } p.IsHasQuit(); listNoSlot.Add(slotIndex, obj); return(p); }
/// <summary> /// Cập nhật lại vị trí và giao diện /// </summary> public static void UpdatePlayerSide() { if (YourController != null) { YourController.mSide = ESide.Slot_0; } foreach (PlayerControllerChan p in ListPlayer) { p.mSide = SlotToSide(p.slotServer); } foreach (PlayerControllerChan 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 => { if (p.cuiPlayer == null && p.slotServer <= 3) { CUIPlayerChan.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) { CUIPlayerChan.Create(p, game.mPlaymat.locationPlayer[(int)p.mSide]); } }); DrawInfoPlayerNoSlot(); }
public static CUIPlayerChan Create(PlayerControllerChan p, Transform parentTransform) { if (listNoSlot.ContainsKey(p.slotServer)) { GameObject.Destroy(listNoSlot[p.slotServer]); } GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PlayerInfoPrefab")); obj.name = "Player " + (int)p.mSide; obj.transform.parent = parentTransform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = scaleAvatar; CUIPlayerChan cui = obj.GetComponent <CUIPlayerChan>(); cui.player = p; p.cuiPlayer = cui; p.AvatarTexture(delegate(Texture _texture) { if (cui != null && cui.avatar != null) { //if(cui.avatar.GetComponentInChildren<UITexture>() !=null) cui.avatar.GetComponentInChildren <UITexture>().mainTexture = _texture; } }); if (p.mSide == ESide.Slot_0 && GameModelChan.YourController != null) { cui.avatar.GetComponentInChildren <UITexture>().enabled = false; for (int i = 0; i < cui.avatar.childCount; i++) { GameObject.Destroy(cui.avatar.GetChild(i).gameObject); } GameObject.Destroy(cui.GetComponentInChildren <UISprite>().gameObject); cui.timerCountDown.FindChild("Background").GetComponent <UISprite>().spriteName = "bgYourTimer"; cui.timerCountDown.FindChild("Background").GetComponent <UISprite>().MakePixelPerfect(); cui.timerCountDown.FindChild("Foreground").GetComponent <UISprite>().spriteName = "bgYourTimer-1"; cui.timerCountDown.FindChild("Foreground").GetComponent <UISprite>().MakePixelPerfect(); Transform iconWarning = cui.gameObject.transform.FindChild("IconWarning"); Transform iconMaster = cui.gameObject.transform.FindChild("IconMaster"); iconWarning.parent = GameModelChan.game.mPlaymat.locationHand.parent.parent; iconMaster.parent = GameModelChan.game.mPlaymat.locationHand.parent.parent; iconWarning.localPosition = new Vector3(40f, 10f, -5f); iconMaster.localPosition = new Vector3(-50f, 10f, -5f); iconWarning.GetComponent <UISprite>().depth = 22; iconWarning.parent = cui.transform; iconMaster.parent = cui.transform; cui.ChangePositionYouLevelBar(); } else { cui.labelUserName.text = p.username; } cui.UpdateInfo(); return(cui); }
public static void DrawInfoPlayerNoSlot() { //Vẽ thông tin các slot trống ListSlotEmpty.ForEach(slot => CUIPlayerChan.CreateNoSlot(slot, game.mPlaymat.locationPlayer[(int)SlotToSide(slot)])); }