/// <summary> /// 显示相应的聊天内容 /// </summary> /// <param name="content"></param> /// <param name="UId"></param> public void ShowChatContent(string content, long UId) { UI ui = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = ui.GetComponent <GamerComponent>(); int index = gamerComponent.GetGamerSeat(UId); //设置文本框随着字数缩放 float width = content.Length * 30 + 90; chatObjArr[index].GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width); //如果多次点击发送文本,隐掉前一个显示当前的 if (chatObjArr[index].activeInHierarchy) { isExit = true; time = -1; chatObjArr[index].SetActive(false); } isExit = false; chatObjArr[index].SetActive(true); chatObjArr[index].transform.GetChild(0).GetComponent <Text>().text = content; time = 8; StartTimer(chatObjArr[index]); }
/// <summary> /// 其他人碰刚 /// </summary> /// <param name="type"></param> /// <param name="mahjongInfo"></param> /// <param name="operatedUid"></param> /// <param name="messageUid"></param> /// <param name="messageOperatedUid"></param> public void SetOtherPeng(int type, MahjongInfo mahjongInfo, long operatedUid, long uid) { GameObject obj = null; int temp = 0; if (type == 0) { if (Index == 2) { obj = CommonUtil.getGameObjByBundle("Item_Peng_Card"); } else { obj = CommonUtil.getGameObjByBundle("Item_Right_Peng_Card"); } temp = 3; } else if (type == 1 || type == 4) { if (Index == 2) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); } else { obj = CommonUtil.getGameObjByBundle("Item_Right_Gang_Card"); } temp = 3; } else { if (Index == 2) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); } else { obj = CommonUtil.getGameObjByBundle("Item_Right_Gang_Card"); } temp = 4; } //设置谁碰刚 UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); int gamerSeat = gamerComponent.GetGamerSeat(operatedUid); int mySeat = gamerComponent.GetGamerSeat(uid); int offset = gamerSeat - mySeat; if (offset < 0) { offset += 4; } if (Index == 1) { if (offset == 1) { offset = 3; } else if (offset == 3) { offset = 1; } } else if (Index == 2) { } else if (Index == 3) { } //设置碰杠位置 GameObject gameObject = GameObject.Instantiate(obj, this.pengObj.transform); int count = this.pengObj.transform.childCount; if (Index == 1) { gameObject.transform.localPosition = new Vector3(0, (count - 1) * 115, 0); } else if (Index == 2) { gameObject.transform.localPosition = new Vector3((count - 1) * (-160.93f), 0, 0); } else { gameObject.transform.localPosition = new Vector3(count * (postionX) * 3.5f, count * (postionY) * 3.5f, 0); } if (type == 0) { pengDic.Add(mahjongInfo.weight, gameObject); } //显示出牌 string item1 = null; string item2 = null; string item3 = null; string itemBack = null; if (Index == 1) { item1 = "Item_Horizontal_Card"; item2 = "Image_Right_Card"; item3 = "right_" + mahjongInfo.weight; itemBack = "right_back"; } else if (Index == 2) { item1 = "Item_Vertical_Card"; item2 = "Image_Top_Card"; item3 = "card_" + mahjongInfo.weight; itemBack = "card_back"; } else if (Index == 3) { item1 = "Item_Horizontal_Card"; item2 = "Image_Left_Card"; item3 = "left_" + mahjongInfo.weight; itemBack = "left_back"; } for (int i = 1; i < 4; i++) { Image image = gameObject.transform.Find("Item_" + i).GetComponent <Image>(); //暗杠显示 if (type == 4) { if (i == 2) { image.sprite = CommonUtil.getSpriteByBundle(item2, item3); } else { image.sprite = CommonUtil.getSpriteByBundle(item2, itemBack); } } else { if (i == offset) { image.sprite = CommonUtil.getSpriteByBundle(item2, itemBack); } else { image.sprite = CommonUtil.getSpriteByBundle(item2, item3); } } } num++; if (Index == 3) { for (int i = 0; i < temp; i++) { GameObject.Destroy(CardBottom.transform.GetChild(i).gameObject); } } else { for (int i = 0; i < temp; i++) { int childCount = this.CardBottom.transform.childCount; Log.Debug("销毁childCount:" + (childCount)); GameObject.DestroyImmediate(CardBottom.transform.GetChild(childCount - 1).gameObject); } Vector3 localPosition = this.CardBottom.transform.localPosition; float x = localPosition.x - postionX * 0.2f; float y = localPosition.y - postionY * 0.2f; this.CardBottom.transform.localPosition = new Vector3(x, y, localPosition.z); } }
public void SetOtherPengGang(int messageOperationType, MahjongInfo mahjong, long operatedUid, long uid) { GameObject obj = null; if (Index == 2) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); } else { obj = CommonUtil.getGameObjByBundle("Item_Right_Gang_Card"); } //显示碰 GameObject gameObject = GameObject.Instantiate(obj, this.pengObj.transform); GameObject lastPengObj = null; if (pengDic.TryGetValue(mahjong.weight, out lastPengObj)) { gameObject.transform.SetSiblingIndex(lastPengObj.transform.GetSiblingIndex()); gameObject.transform.localPosition = lastPengObj.transform.localPosition; GameObject.Destroy(lastPengObj); pengDic.Remove(mahjong.weight); } //显示出牌 string item1 = null; string item2 = null; string item3 = null; string itemBack = null; if (Index == 1) { item1 = "Item_Horizontal_Card"; item2 = "Image_Right_Card"; item3 = "right_" + mahjong.weight; itemBack = "right_back"; } else if (Index == 2) { item1 = "Item_Vertical_Card"; item2 = "Image_Top_Card"; item3 = "card_" + mahjong.weight; itemBack = "card_back"; } else if (Index == 3) { item1 = "Item_Horizontal_Card"; item2 = "Image_Left_Card"; item3 = "left_" + mahjong.weight; itemBack = "left_back"; } UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); int gamerSeat = gamerComponent.GetGamerSeat(operatedUid); int mySeat = gamerComponent.GetGamerSeat(uid); int offset = gamerSeat - mySeat; if (offset < 0) { offset += 4; } if (Index == 1) { if (offset == 1) { offset = 3; } else if (offset == 3) { offset = 1; } } else if (Index == 2) { } else if (Index == 3) { } for (int i = 1; i < 4; i++) { Image image = gameObject.transform.Find("Item_" + i).GetComponent <Image>(); if (i == offset) { image.sprite = CommonUtil.getSpriteByBundle(item2, itemBack); } else { image.sprite = CommonUtil.getSpriteByBundle(item2, item3); } } if (Index == 3) { // for (int i = 0; i < 1; i++) // { // GameObject.Destroy(CardBottom.transform.GetChild(i).gameObject); // } } else { // for (int i = 0; i < 1; i++) // { // int childCount = this.CardBottom.transform.childCount; // GameObject.Destroy(CardBottom.transform.GetChild(childCount - 1 - i).gameObject); // } // // Vector3 localPosition = this.CardBottom.transform.localPosition; // float x = localPosition.x - postionX * 1f; // float y = localPosition.y - postionY * 1f; // // this.CardBottom.transform.localPosition = new Vector3(x, y, localPosition.z); } }
/// <summary> /// 碰刚 /// </summary> /// <param name="messageOperationType"></param> /// <param name="mahjong"></param> public void SetPengGang(int messageOperationType, MahjongInfo mahjong, long operatedUid) { Log.Debug("显示碰后杠"); GameObject obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); UpdateCards(); //设置谁碰刚 UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); int gamerSeat = gamerComponent.GetGamerSeat(operatedUid); int mySeat = gamerComponent.GetGamerSeat(PlayerInfoComponent.Instance.uid); int offset = gamerSeat - mySeat; if (offset < 0) { offset += 4; } if (offset == 1) { offset = 3; } else if (offset == 3) { offset = 1; } //显示碰 GameObject gameObject = GameObject.Instantiate(obj, this.pengObj.transform); for (int i = 1; i < 4; i++) { Image image = gameObject.transform.Find("Item_" + i).GetComponent <Image>(); if (i == offset) { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_back"); } else { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); } } // for (int i = 0; i < 2; i++) // { // gameObject.transform.GetChild(i).GetComponent<Image>().sprite = // CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); // } GameObject lastPengObj = null; if (pengDic.TryGetValue(mahjong.weight, out lastPengObj)) { gameObject.transform.SetSiblingIndex(lastPengObj.transform.GetSiblingIndex()); gameObject.transform.localPosition = lastPengObj.transform.localPosition; GameObject.Destroy(lastPengObj); pengDic.Remove(mahjong.weight); } }
public void SetPeng(int type, MahjongInfo mahjong, long operatedUid, bool isReconnect) { GameObject obj = null; if (type == 0) { obj = CommonUtil.getGameObjByBundle("Item_Peng_Card"); //更新手牌 for (int i = 0; i < 2; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //明杠 else if (type == 1) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); //更新手牌 for (int i = 0; i < 3; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //暗杆 else if (type == 4) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); int temp; if (isReconnect) { temp = 3; } else { temp = 4; } for (int i = 0; i < temp; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //碰刚 else if (type == 5) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); for (int i = 0; i < 1; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } UpdateCards(); //设置谁碰刚 UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); int gamerSeat = gamerComponent.GetGamerSeat(operatedUid); int mySeat = gamerComponent.GetGamerSeat(PlayerInfoComponent.Instance.uid); int offset = gamerSeat - mySeat; Log.Debug($"{operatedUid}:" + gamerSeat); Log.Debug($"{PlayerInfoComponent.Instance.uid}:" + mySeat); if (offset < 0) { offset += 4; } if (offset == 1) { offset = 3; } else if (offset == 3) { offset = 1; } //显示碰 GameObject gameObject = GameObject.Instantiate(obj, this.pengObj.transform); for (int i = 1; i < 4; i++) { Image image = gameObject.transform.Find("Item_" + i).GetComponent <Image>(); //暗杠显示 if (type == 4) { if (i == 2) { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); } else { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_back"); } } else { if (i == offset) { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_back"); } else { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); } } } if (type == 0) { pengDic.Add(mahjong.weight, gameObject); } Vector3 localPosition = this.CardBottom.transform.localPosition; this.CardBottom.transform.localPosition = new Vector3(localPosition.x + (postionX) * 2f, localPosition.y + (postionY) * 2f, localPosition.z); }