public static void setAllPokerWeiXuanZe() { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PokerScript_hotfix", "setAllPokerWeiXuanZe")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PokerScript_hotfix", "setAllPokerWeiXuanZe", null, null); return; } // 升级 for (int i = 0; i < GameData.getInstance().m_myPokerObjList.Count; i++) { PokerScript pokerScript = GameData.getInstance().m_myPokerObjList[i].GetComponent <PokerScript>(); pokerScript.setIsSelect(false); pokerScript.setIsJump(false); } // 斗地主 for (int i = 0; i < DDZ_GameData.getInstance().m_myPokerObjList.Count; i++) { PokerScript pokerScript = DDZ_GameData.getInstance().m_myPokerObjList[i].GetComponent <PokerScript>(); pokerScript.setIsSelect(false); pokerScript.setIsJump(false); } }
public void OnPointerUp(PointerEventData eventData) { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PokerScript_hotfix", "OnPointerUp")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PokerScript_hotfix", "OnPointerUp", null, eventData); return; } if (m_canTouch) { // 升级 for (int i = 0; i < GameData.getInstance().m_myPokerObjList.Count; i++) { PokerScript pokerScript = GameData.getInstance().m_myPokerObjList[i].GetComponent <PokerScript>(); pokerScript.setIsJump(pokerScript.getIsSelect()); } // 斗地主 for (int i = 0; i < DDZ_GameData.getInstance().m_myPokerObjList.Count; i++) { PokerScript pokerScript = DDZ_GameData.getInstance().m_myPokerObjList[i].GetComponent <PokerScript>(); pokerScript.setIsJump(pokerScript.getIsSelect()); } } }
public void setPlayer_ddz(string uid) { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GameUserInfoPanelScript_hotfix", "setPlayer")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GameUserInfoPanelScript_hotfix", "setPlayer", null, uid); return; } if (uid.CompareTo(UserData.uid) == 0) { m_text_name.text = UserData.name; if (UserData.gameData.allGameCount == 0) { m_text_shenglv.text = "0%"; m_text_taopaolv.text = "0%"; } else { float shenglv = (float)UserData.gameData.winCount / (float)UserData.gameData.allGameCount * 100.0f; float taopaolv = (float)UserData.gameData.runCount / (float)UserData.gameData.allGameCount * 100.0f; m_text_shenglv.text = (int)shenglv + "%"; m_text_taopaolv.text = (int)taopaolv + "%"; } m_text_zongjushu.text = UserData.gameData.allGameCount.ToString(); m_text_meilizhi.text = UserData.gameData.meiliZhi.ToString(); m_gameobj_down.transform.localScale = new Vector3(0, 0, 0); m_headIcon.GetComponent <HeadIconScript>().setIcon(UserData.head); } else { PlayerData playerData = DDZ_GameData.getInstance().getPlayerDataByUid(uid); m_text_name.text = playerData.m_name; if (playerData.m_allGameCount == 0) { m_text_shenglv.text = "0%"; m_text_taopaolv.text = "0%"; } else { float shenglv = (float)playerData.m_winCount / (float)playerData.m_allGameCount * 100.0f; float taopaolv = (float)playerData.m_runCount / (float)playerData.m_allGameCount * 100.0f; m_text_shenglv.text = (int)shenglv + "%"; m_text_taopaolv.text = (int)taopaolv + "%"; } m_text_zongjushu.text = playerData.m_allGameCount.ToString(); m_text_meilizhi.text = playerData.m_meiliZhi.ToString(); m_headIcon.GetComponent <HeadIconScript>().setIcon(playerData.m_head); } }
// Use this for initialization void Start() { OtherData.s_ddz_gameResult = this; // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc(m_hotfix_class, "Start")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke(m_hotfix_path, "Start", null, null); return; } JsonData jd = JsonMapper.ToObject(m_jsonData); initUI_Image(); // 胜负图片显示 { int isDiZhuWin = (int)jd["isDiZhuWin"]; if (DDZ_GameData.getInstance().m_isDiZhu == 1) { // 地主赢 if (isDiZhuWin == 1) { CommonUtil.setImageSpriteByAssetBundle(gameObject.transform.Find("Image_result").GetComponent <Image>(), "doudizhu.unity3d", "doudizhu_dizhusuccess"); AudioScript.getAudioScript().playSound_DouDiZhu_win(); } else { CommonUtil.setImageSpriteByAssetBundle(gameObject.transform.Find("Image_result").GetComponent <Image>(), "doudizhu.unity3d", "doudizhu_dizhufail"); AudioScript.getAudioScript().playSound_DouDiZhu_lose(); } } else { // 农民赢 if (isDiZhuWin == 0) { CommonUtil.setImageSpriteByAssetBundle(gameObject.transform.Find("Image_result").GetComponent <Image>(), "doudizhu.unity3d", "doudizhu_nongminsuccess"); AudioScript.getAudioScript().playSound_DouDiZhu_win(); } else { CommonUtil.setImageSpriteByAssetBundle(gameObject.transform.Find("Image_result").GetComponent <Image>(), "doudizhu.unity3d", "doudizhu_nongminfail"); AudioScript.getAudioScript().playSound_DouDiZhu_lose(); } } } // 每个玩家的金币输赢 { int hasSetOtherCount = 0; for (int i = 0; i < DDZ_GameData.getInstance().m_playerDataList.Count; i++) { PlayerData playerData = DDZ_GameData.getInstance().m_playerDataList[i]; string score = jd[playerData.m_uid]["score"].ToString(); int scire_i = int.Parse(score); int beishu = (int)(jd[playerData.m_uid]["beishu"]); if (int.Parse(score) > 0) { score = ("+" + score); } // 我的 if (playerData.m_uid.CompareTo(UserData.uid) == 0) { // 倍数 gameObject.transform.Find("Text_beishu").GetComponent <Text>().text = beishu.ToString(); gameObject.transform.Find("playerScore_my/Text_name").GetComponent <Text>().text = UserData.name; gameObject.transform.Find("playerScore_my/Text_score").GetComponent <Text>().text = score.ToString(); // 金币变化 { GameUtil.changeData(1, scire_i); m_parentScript.m_playerHead_down.transform.Find("Text_gold").GetComponent <Text>().text = UserData.gold.ToString(); } } else { ++hasSetOtherCount; gameObject.transform.Find("playerScore_other" + hasSetOtherCount + "/Text_name").GetComponent <Text>().text = playerData.m_name; gameObject.transform.Find("playerScore_other" + hasSetOtherCount + "/Text_score").GetComponent <Text>().text = score.ToString(); } } } // 倍数 { string key = ("beishu_" + UserData.uid); for (int i = 0; i < jd[key].Count; i++) { string str = jd[key][i].ToString(); m_beishu.text += (str + "\r\n"); } } }
// 斗地主出牌音效 public void playSound_DouDiZhu_ChuPai(List <TLJCommon.PokerInfo> list, string uid) { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("playSound_DouDiZhu_ChuPai_hotfix", "playSound_DouDiZhu_ChuPai")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.playSound_DouDiZhu_ChuPai_hotfix", "playSound_DouDiZhu_ChuPai", null, list, uid); return; } CrazyLandlords.Helper.LandlordsCardsHelper.SetWeight(list); CrazyLandlords.Helper.CardsType cardsType; CrazyLandlords.Helper.LandlordsCardsHelper.GetCardsType(list.ToArray(), out cardsType); if (list.Count == 0) { playSound("guo"); return; } switch (cardsType) { case CrazyLandlords.Helper.CardsType.JokerBoom: { playSound("huojian"); { GameObject obj = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "huojian1")); PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>(); playAnimation.start("animations.unity3d", "huojian", true, 0.07f); obj.transform.localPosition = new Vector3(0, -200, 0); obj.transform.DOMoveY(10, 3).OnComplete(() => { GameObject.Destroy(obj); }); } } break; case CrazyLandlords.Helper.CardsType.Boom: { playSound("bomb"); { GameObject obj = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "zhadan1")); PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>(); playAnimation.start("animations.unity3d", "zhadan", false, 0.07f); } } break; case CrazyLandlords.Helper.CardsType.BoomAndOne: //四带一 { playSound("four_one"); } break; case CrazyLandlords.Helper.CardsType.BoomAndTwo: //四带二 { playSound("four_two"); } break; case CrazyLandlords.Helper.CardsType.OnlyThree: { playSound("three"); } break; case CrazyLandlords.Helper.CardsType.ThreeAndOne: { playSound("three_one"); } break; case CrazyLandlords.Helper.CardsType.ThreeAndTwo: { playSound("three_two"); } break; case CrazyLandlords.Helper.CardsType.Straight: { playSound("shunzi"); { GameObject obj = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "shunzi1")); PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>(); playAnimation.start("animations.unity3d", "shunzi", false, 0.1f); obj.transform.localScale = new Vector3(2, 2, 2); int middle = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList.Count / 2; float y = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.y + 80; obj.transform.localPosition = new Vector3(0, y, 0); } } break; case CrazyLandlords.Helper.CardsType.DoubleStraight: { playSound("liandui"); { GameObject obj = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "liandui1")); PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>(); playAnimation.start("animations.unity3d", "liandui", false, 0.1f); obj.transform.localScale = new Vector3(2, 2, 2); int middle = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList.Count / 2; float x = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.x; float y = DDZ_GameData.getInstance().getPlayerDataByUid(uid).m_outPokerObjList[middle].transform.position.y; obj.transform.position = new Vector3(x, y, 0); } } break; case CrazyLandlords.Helper.CardsType.TripleStraight: case CrazyLandlords.Helper.CardsType.TripleStraightAndOne: case CrazyLandlords.Helper.CardsType.TripleStraightAndTwo: { playSound("feiji"); { GameObject obj = CreateUGUI.createImageObj(GameObject.Find("Canvas_Middle").gameObject, CommonUtil.getImageSpriteByAssetBundle("animations.unity3d", "feiji1")); PlayAnimation playAnimation = obj.AddComponent <PlayAnimation>(); playAnimation.start("animations.unity3d", "feiji", true, 0.07f); obj.transform.localPosition = new Vector3(-500, 0, 0); obj.transform.DOMoveX(10, 3).OnComplete(() => { GameObject.Destroy(obj); }); } } break; case CrazyLandlords.Helper.CardsType.Double: { int num = list[0].m_num; if ((num >= 2) && (num <= 10)) { playSound("double_" + num.ToString()); } else if (num == 11) { playSound("double_J"); } else if (num == 12) { playSound("double_Q"); } else if (num == 13) { playSound("double_K"); } else if (num == 14) { playSound("double_A"); } } break; case CrazyLandlords.Helper.CardsType.Single: { int num = list[0].m_num; if ((num >= 2) && (num <= 10)) { playSound(num.ToString()); } else if (num == 11) { playSound("J"); } else if (num == 12) { playSound("Q"); } else if (num == 13) { playSound("K"); } else if (num == 14) { playSound("A"); } else if (num == 15) { playSound("xiaowang"); } else if (num == 16) { playSound("dawang"); } } break; } }
// 请求出牌 public void reqOutPoker() { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc(m_hotfix_class, "reqOutPoker")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke(m_hotfix_path, "reqOutPoker", null, null); return; } JsonData data = new JsonData(); data["tag"] = DDZ_GameData.getInstance().m_tag; data["uid"] = UserData.uid; data["playAction"] = (int)TLJCommon.Consts.DDZ_PlayAction.PlayAction_PlayerOutPoker; bool hasOutPoker = false; List <TLJCommon.PokerInfo> myOutPokerList = new List <TLJCommon.PokerInfo>(); // 自己出的牌 { JsonData jarray = new JsonData(); for (int i = 0; i < DDZ_GameData.getInstance().m_myPokerObjList.Count; i++) { PokerScript pokerScript = DDZ_GameData.getInstance().m_myPokerObjList[i].GetComponent <PokerScript>(); if (pokerScript.getIsJump()) { hasOutPoker = true; JsonData jd = new JsonData(); jd["num"] = pokerScript.getPokerNum(); jd["pokerType"] = pokerScript.getPokerType(); jarray.Add(jd); myOutPokerList.Add(new TLJCommon.PokerInfo(pokerScript.getPokerNum(), (TLJCommon.Consts.PokerType)pokerScript.getPokerType())); } } data["hasOutPoker"] = hasOutPoker; if (hasOutPoker) { data["pokerList"] = jarray; } } // 检测出牌合理性 { List <TLJCommon.PokerInfo> m_maxPlayerOutPokerList = DDZ_GameData.getInstance().m_maxPlayerOutPokerList; LandlordsCardsHelper.SetWeight(myOutPokerList); LandlordsCardsHelper.SetWeight(m_maxPlayerOutPokerList); if (myOutPokerList.Count != 0) { CardsType type; if (LandlordsCardsHelper.GetCardsType(myOutPokerList.ToArray(), out type)) { if (!DDZ_GameData.getInstance().m_isFreeOutPoker) { CardsType lastType; if (LandlordsCardsHelper.GetCardsType(m_maxPlayerOutPokerList.ToArray(), out lastType)) { List <PokerInfo[]> pokerInfoses = LandlordsCardsHelper.GetPrompt(myOutPokerList, m_maxPlayerOutPokerList, lastType); if (pokerInfoses.Count == 0) { ToastScript.createToast("出牌不符合规则"); return; } } else { ToastScript.createToast("上一家出牌不符合规则"); return; } } } else { ToastScript.createToast("自己出牌不符合规则"); return; } } else { if (DDZ_GameData.getInstance().m_isFreeOutPoker) { ToastScript.createToast("请选择您出的牌"); return; } else { // 不要 } } } PlayServiceSocket.s_instance.sendMessage(data.ToJson()); // 所有牌设为未选中 PokerScript.setAllPokerWeiXuanZe(); }