void UpdateHandCard(bool silent = false) { if (!silent) { AudioManager.GetInstance().PlayEffectAudio("sort"); } HandCardItem item = null; for (int i = 0; i < _handCardList.Count; i++) { float x = _handCardList.Count / 2.0f - i; item = _handCardList[i]; if (item.getLayer() == "ZhuoPai") { Debug.LogError("UpdateHandCard zhuopai"); continue; } Transform tm = item.getObj().transform; tm.localPosition = Vector3.zero; tm.localRotation = Quaternion.Euler(Vector3.zero); tm.Translate(offSetX * x, 0, 0); } bool replay = ReplayMgr.GetInstance().isReplay(); _MoHandPos.localPosition = !isMyself() && replay ? new Vector3(0, 0, 0.04f) : Vector3.zero; _MoHandPos.Translate(-(_handCardList.Count / 2.0f + 0.5f) * offSetX, 0, 0); }
int GetOldIndex() { HandCardItem item = null; item = _MoHand; if (item != null && item.getLayer() == "ZhuoPai") { return(-1); } for (int i = 0; i < _handCardList.Count; i++) { item = _handCardList[i]; if (item != null && item.getLayer() == "ZhuoPai") { return(i); } } return(-2); }
public void onMJClicked(HandCardItem item) { if (item == null || !item.valid()) { return; } RoomMgr rm = RoomMgr.GetInstance(); if (_gangState == 0) { onMJChoosed(item); return; } if (!rm.isMyTurn() || shot) { return; } HandCardItem old = selected; GameObject ob = item.getObj(); if (old != null && item.checkObj(old)) { if (_tingState != 0) { old.choosed(false); } Highlight(old.getId(), false); ob.transform.position = selPos; selected = null; selPos = Vector3.zero; shoot(item); shot = true; hidePrompt(); return; } if (old != null && old.valid()) { ob = old.getObj(); // NOTE: old maybe in recycle if (old.getLayer() == "Self") { ob.transform.position = selPos; if (_tingState != 0) { old.choosed(false); } Highlight(old.getId(), false); } selected = null; } ob = item.getObj(); selPos = ob.transform.position; selected = item; ob.transform.Translate(0, 0.01f, 0); onMJChoosed(item); }
public void MoveHandCard() { HandCardItem item = null; if (newIndex == oldIndex) { } else if (newIndex < oldIndex) { //newIndex~oldIndex,数组中后移,手牌上右移 GameObject obj = new GameObject("tempParent"); obj.transform.SetParent(_HandCardPlace);//获取父节点的方式有问题 obj.transform.localPosition = Vector3.zero; obj.transform.rotation = _HandCardPlace.rotation; for (int i = oldIndex - 1; i >= newIndex; i--) { item = _handCardList[i]; if (item.getLayer() == "ZhuoPai") { Debug.LogError("move handcard zhuopai"); continue; } _handCardList[i + 1] = item; item.getObj().transform.SetParent(obj.transform); } obj.transform.Translate(-offSetX, 0, 0); Transform[] tran = obj.GetComponentsInChildren <Transform>(); for (int j = 0; j < tran.Length; j++) { if (!tran[j].gameObject.Equals(obj.gameObject)) { tran[j].transform.SetParent(_HandCardPlace);//获取父节点的方式有问题 } } Destroy(obj); } else if (newIndex > oldIndex) { //oldIndex~list.count:数组前移,牌桌上的手牌左移,item入数组尾部 GameObject obj = new GameObject("tempParent"); obj.transform.SetParent(_HandCardPlace);//获取父节点的方式有问题 obj.transform.localPosition = Vector3.zero; obj.transform.rotation = _HandCardPlace.rotation; for (int i = oldIndex; i < newIndex; i++) { item = _handCardList[i + 1]; if (item.getLayer() == "ZhuoPai") { Debug.LogError("move handcard2 zhuopai"); continue; } _handCardList[i] = item; item.getObj().transform.SetParent(obj.transform); } obj.transform.Translate(offSetX, 0, 0); Transform[] tran = obj.GetComponentsInChildren <Transform>(); for (int j = 0; j < tran.Length; j++) { if (!tran[j].gameObject.Equals(obj.gameObject)) { tran[j].transform.SetParent(_HandCardPlace);//获取父节点的方式有问题 } } Destroy(obj); } _handCardList[newIndex] = _MoHand; }