public static MahjongTile Create(TileDef def) { if (!TileDef.IsValid(def.Value)) { Debug.LogError("tile : " + def.Value + " is not a valid tile"); return(null); } Transform inst = null; MahjongTile._Pool = PoolManager.Pools ["mahjongres"]; int point = def.GetPoint(); switch (def.GetKind()) { case TileDef.Kind.CRAK: inst = MahjongTile._Pool.Spawn("Crak_" + point); break; case TileDef.Kind.BAM: inst = MahjongTile._Pool.Spawn("Bam_" + point); break; case TileDef.Kind.DOT: inst = MahjongTile._Pool.Spawn("Dot_" + point); break; default: Debug.LogError("UnValid kind : " + def.GetKind()); return(null); } inst.gameObject.SetActive(true); inst.transform.parent = null; inst.transform.rotation = Quaternion.identity; inst.transform.position = Vector3.one * 9999f; MahjongTile tile = inst.gameObject.GetComponent <MahjongTile> () ?? inst.gameObject.AddComponent <MahjongTile> (); tile._def = def; tile.ClickCount = 0; BoxCollider collider = inst.gameObject.AddComponent <BoxCollider> (); collider.center = Vector3.zero; collider.size = ColliderSize; return(tile); }
public void ResetPlayList() { TileDef def = null; MahjongTile tile = null; destroyChildren(PlayLocator); for (int i = 0; i < Proxy.PlayList.Count; ++i) { def = Proxy.PlayList [i]; if (TileDef.IsValid(def.Value)) { tile = MahjongTile.Create(def); if (tile != null) { placePlayed(tile, false); } } } }
public void OnRestoreGameState(GameMessage.GameStateDef info) { _self.Proxy.PocketList.Clear(); // total 14 #if USE_MP2 for (int i = 0; i < info.cHandCards.Count; ++i) #else for (int i = 0; i < info.cHandCards.Length; ++i) #endif { if (TileDef.IsValid(info.cHandCards[i])) { TileDef def = TileDef.Create(info.cHandCards[i]); _self.Proxy.PocketList.Add(def); } } #if USE_MP2 //玩家已经出的牌 //List<List<TileDef>> lists = new List<List<TileDef>>(); List <TileDef>[] lists = new List <TileDef> [4]; for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { lists[i] = new List <TileDef>(); for (int j = 0; j < info.cSendCards[i].cCards.Count; ++j) { byte card = info.cSendCards[i].cCards[j]; lists[i].Add(TileDef.Create(card)); } } GameClient.Instance.MG.ArrangePlayer(_self.Proxy.Index, 4); GameClient.Instance.MG.ReBuildStack(3, 5, 108, 0, 0); for (int i = 0; i < info.cHandCardsNum.Count; ++i) { GameClient.Instance.MG.SetPocketCount(i, info.cHandCardsNum[i]); } for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { GameClient.Instance.MG.SetPlayList(i, lists[i]); } #else //玩家已经出的牌 List <TileDef> list = new List <TileDef>(); for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { for (int j = 0; j < 21; ++j) { //byte card = info.cSendCards[i * 21 + j]; byte card = info.cSendCards[i * 21 + j]; list.Add(TileDef.Create(card)); } } GameClient.Instance.MG.ArrangePlayer(_self.Proxy.Index, 4); GameClient.Instance.MG.ReBuildStack(3, 5, 108, 0, 0); //reset pocket data for (int i = 0; i < info.cHandCardsNum.Length; ++i) { GameClient.Instance.MG.SetPocketCount(i, info.cHandCardsNum[i]); } for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { var newList = list.GetRange(i * 21, 21); GameClient.Instance.MG.SetPlayList(i, newList); } #endif //combo for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { var comboCards = info.combo[i]; //for (int j = 0; j < comboCards.list.Count; ++j) { //SpecialCardReqDef special = comboCards [j]; //combo //} } UpdatePlayList(); UpdatePocketList(); UpdateComboList(); if (GameClient.Instance.SpecialCard > 0 && GameClient.Instance.SpecialType > 0) { UpdateCombo(); } }