public override void SetLastCardPos(int value) { if (value == UtilDef.NullMj || MahjongList.Find(item => item.Value == value) == null)//当前不是抓牌 是吃碰杠后的 { base.SetLastCardPos(value); return; } if (MahjongList.Count > 1) { MahjongItem findItem = MahjongList.Find((item) => { return(item.Value == value); }); if (findItem != null) { MahjongList.Remove(findItem); } MahjongList.Add(findItem); SetMahjongPos(); findItem.transform.localPosition = GetHardLastMjPos(); } }
public virtual MahjongItem ThrowOut(int value) { MahjongItem Mahjong = GetMahjongItemByValue(value); Mahjong.ShowNormal(); MahjongManager.Instance.ExchangeByValue(value, Mahjong); MahjongList.Remove(Mahjong); SortMahjongForHand(); if (GameConfig.GetInEffect) { PickUpMahjongAction(Mahjong); } else { SetMahjongPos(); } MahjongManager.Instance.Recycle(Mahjong); LastGetIn = null; return(Mahjong); }
//互换模型与值 public void Exchange(MahjongItem item) { GameObject objTemp = Model; Model = item.Model; item.Model = objTemp; ResetModel(); item.ResetModel(); int tempValue = item.Value; int tempIndex = item.MahjongIndex; item.Value = Value; Value = tempValue; item.MahjongIndex = MahjongIndex; MahjongIndex = tempIndex; if (item.IsSign) { item.IsSign = false; } if (IsSign) { IsSign = false; } }
protected virtual void OnOutPutCard(Transform transf) { //如果允许当前用户出牌 if (HasToken) { ChooseMj = transf.GetComponent <MahjongItem>(); if (ChooseMj.Lock) { return; } bool branch = false; if (!ChooseMj.IsSign) { branch = true; } else { branch = ChooseMj.IsSign && AllowLaiziPut; } if (branch) { HasToken = false; OutCard(ChooseMj); } } }
/// <summary> /// 倒序摸牌 /// </summary> /// <returns></returns> public MahjongItem RevPopMahjong() { int index = 0; var mayIndex = MahjongList.Count - 2; if (mayIndex >= 0 && MahjongList.Count % 2 == 0) { index = mayIndex; } else { index = MahjongList.Count - 1; } MahjongItem item = MahjongList[index]; MahjongList.RemoveAt(index); MahjongManager.Instance.Recycle(item); if (MahjongList.Count <= 0) { EventDispatch.Dispatch((int)GameEventId.RevWallMahjongFinish, new EventData()); } return(item); }
public virtual MahjongItem ThrowOutByValue(int value) { MahjongItem Mahjong = null; for (int i = MahjongList.Count - 1; i >= 0; i--) { if (MahjongList[i].Value == value) { Mahjong = MahjongList[i]; } } if (Mahjong == null) { Mahjong = GetMahjongItemByValue(value); } Mahjong.ShowNormal(); MahjongManager.Instance.ExchangeByValue(value, Mahjong); MahjongList.Remove(Mahjong); SortMahjongForHand(); if (GameConfig.GetInEffect) { PickUpMahjongAction(Mahjong); } else { SetMahjongPos(); } MahjongManager.Instance.Recycle(Mahjong); LastGetIn = null; return(Mahjong); }
//用来处理 获取最后麻将时候 index 的偏移 public override MahjongItem GetLastMj() { MahjongItem item = null; if (MahjongList.Count == 0) { return(null); } else if (MahjongList.Count == 1) { item = MahjongList[0]; MahjongList.RemoveAt(0); return(item); } int index = MahjongList.Count - 2; if (MahjongList[index].transform.position.y > 0.4f) { item = MahjongList[index]; MahjongList.RemoveAt(index); return(item); } item = MahjongList[index + 1]; MahjongList.RemoveAt(index + 1); return(item); }
public virtual void SetLastCardPos(int value) { if (MahjongList.Count > 1) { MahjongItem lastMj = MahjongList[MahjongList.Count - 1]; lastMj.transform.localPosition = GetHardLastMjPos(); } }
public virtual MahjongItem PopMahjong() { MahjongItem item = MahjongList[MahjongList.Count - 1]; MahjongList.RemoveAt(MahjongList.Count - 1); MahjongManager.Instance.Recycle(item); return(item); }
protected override void AddMahjong(MahjongItem item) { base.AddMahjong(item); item.ChangeToHardLayer(true); item.SetMahjongScript(); item.SetThowOutCall(OnOutPutCard); item.SetSelectCall(OnItemSelect); }
public virtual MahjongItem GetInMahjong(MahjongItem item) { AddMahjong(item); SetMahjongPos(); return(item); }
public void ExchangeByValue(int value, MahjongItem item, int index = UtilDef.DefInt) { MahjongItem itemFind = FindMjFromList(CanExchangeMahjongList, value, index); if (itemFind) { item.Exchange(itemFind); } }
public override MahjongItem ThrowOut(int value) { MahjongItem Mahjong = base.ThrowOut(value); if (Mahjong) { Mahjong.ChangeToHardLayer(false); } return(Mahjong); }
public virtual MahjongItem GetInMahjong(int value, bool isSign) { MahjongItem item = GetInMahjong(value); if (isSign) { item.IsSign = true; } return(item); }
public virtual MahjongItem GetInMahjong(int value) { MahjongItem item = MahjongManager.Instance.GetMahjong(value); AddMahjong(item); SetMahjongPos(); return(item); }
public virtual void PickUpMahjongAction(MahjongItem item) { if (LastGetIn == null) { SetMahjongPos(); return; } //扔出的牌 是刚刚抓上来的 不需要处理 if (item == LastGetIn) { return; } //获得 最后麻将 应该在的位子 var index = new MjIndex(); foreach (var mjItem in MahjongList) { if (mjItem == LastGetIn) { break; } index = GetNextIndex(index); } //如果在最后 直接排序 不要动作 if (index.x + 1 == MahjongList.Count) { SetMahjongPos(); return; } var pos = GetPos(index); LastGetIn.GetInMjAction(pos, (s) => { //移动结束后 所有的麻将 要移动到相对应的位子 if (s.Equals("MoveFinish")) { index = new MjIndex(); foreach (var mahjongItem in MahjongList) { if (mahjongItem != LastGetIn) { var mjPos = GetPos(index); mahjongItem.MoveToAction(mjPos, GameConfig.PickUpTime); } index = GetNextIndex(index); } } else if (s.Equals("PutDownFinish")) { SetMahjongPos(); } }); }
public void Recycle(MahjongItem item) { item.gameObject.SetActive(false); item.transform.parent = transform; item.Reset(); if (UnusedMahjongList.Find(mj => mj == item) == null) { UnusedMahjongList.Insert(0, item); } }
public List <MahjongItem> GetMahjongList(int[] value) { var ret = new List <MahjongItem>(); for (int i = 0; i < value.Length; i++) { MahjongItem item = GetMahjong(value[i]); ret.Add(item); } return(ret); }
//当抢杠胡 public virtual void OnQiangganghu(int value) { MahjongItem findItem = MahjongList.Find((item) => { return(item.Value == value); }); MahjongManager.Instance.Recycle(findItem); MahjongList.Remove(findItem); SortMahjongForHand(); findItem.gameObject.SetActive(false); }
public GameObject CreateCloneMajong(MahjongItem item) { GameObject ret = null; if (item != null) { ret = Instantiate(item.gameObject); var itemScp = ret.GetComponent <MahjongItem>(); itemScp.Reset(); _cloneMahjongList.Add(itemScp); } return(ret); }
protected virtual void OutCard(MahjongItem chooseMj) { int value = chooseMj.Value; YxDebug.Log("出牌 值 " + value); //通知网络 发送出牌消息 EventDispatch.Dispatch((int)NetEventId.OnOutMahjong, new EventData(value)); //如果打出的牌是抬起状态放下 if (chooseMj.Roll != null && chooseMj.Roll.IsUp) { chooseMj.Roll.ResetPos(); } //当用户出牌之后 需要隐藏操作菜单 EventDispatch.Dispatch((int)UIEventId.OperationMenu, new EventData()); }
public void RemoveMahjong(int value, bool sort = true) { MahjongItem item = GetMahjongItemByValue(value); if (item != null) { MahjongList.Remove(item); MahjongManager.Instance.Recycle(item); } if (sort) { SetMahjongPos(); } }
public MahjongItem PopMahjong() { MahjongItem item = MahjongList[StartIndex]; MahjongList.RemoveAt(StartIndex); MahjongManager.Instance.Recycle(item); if (StartIndex >= MahjongList.Count) { StartIndex = 0; EventDispatch.Dispatch((int)GameEventId.WallMahjongFinish, new EventData()); } return(item); }
public void PopMahjong(int cnt) { for (int i = 0; i < cnt; i++) { MahjongItem item = MahjongList[StartIndex]; MahjongList.RemoveAt(StartIndex); MahjongManager.Instance.Recycle(item); if (StartIndex >= MahjongList.Count) { StartIndex = 0; EventDispatch.Dispatch((int)GameEventId.WallMahjongFinish, new EventData(cnt - (i + 1))); break; } } }
public void RemoveMahjong(List <int> value, bool sort = true) { for (int i = 0; i < value.Count; i++) { MahjongItem item = GetMahjongItemByValue(value[i]); if (item != null) { MahjongList.Remove(item); MahjongManager.Instance.Recycle(item); } } if (sort) { SetMahjongPos(); } }
public List <MahjongItem> GetMahjongList(int cnt) { List <MahjongItem> Ret = new List <MahjongItem>(); if (cnt > UnusedMahjongList.Count) { YxDebug.LogError("没有用到的麻将队列中 没有足够的麻将"); return(null); } for (int i = 0; i < cnt; i++) { MahjongItem item = UnusedMahjongList[0]; UnusedMahjongList.Remove(item); item.gameObject.SetActive(true); Ret.Add(item); } YxDebug.Log("剩余的没有用到的牌个数 = " + UnusedMahjongList.Count); return(Ret); }
public override MahjongItem GetInMahjong(int value) { LastGetIn = MahjongManager.Instance.GetMahjong(value); AddMahjong(LastGetIn); string strValue = ""; foreach (MahjongItem item1 in MahjongList) { strValue += "[" + item1.ToString() + "] "; } YxDebug.Log("查找麻将 " + strValue); //位子放到最后 LastGetIn.transform.localPosition = GetHardLastMjPos(); //转动方向 LastGetIn.RotaTo(new Vector3(-90, 0, 0), Vector3.zero, GameConfig.GetInCardRoteTime, GameConfig.GetInCardWaitTime); return(LastGetIn); }
public GameObject CreateCloneMajong(int value) { GameObject ret = null; MahjongItem findItem = null; foreach (var mahjongItem in MahjongList) { if (mahjongItem.Value == value) { findItem = mahjongItem; break; } } if (findItem != null) { ret = Instantiate(findItem.gameObject); var item = ret.GetComponent <MahjongItem>(); item.Reset(); _cloneMahjongList.Add(item); } return(ret); }
public virtual void RemoveMahjongByValue(int value, bool sort = true) { MahjongItem temp = MahjongList.Find((a) => { return(a.Value == value); }); if (temp != null) { MahjongList.Remove(temp); MahjongManager.Instance.Recycle(temp); } else { MahjongItem item = GetMahjongItemByValue(value); if (item != null) { MahjongList.Remove(item); MahjongManager.Instance.Recycle(item); } } if (sort) { SetMahjongPos(); } }
protected virtual void AddMahjong(MahjongItem item) { MahjongList.Add(item); item.transform.SetParent(transform); item.Reset(); }