public void OnGiveUpThisRound() { isEnd = true; Battleinfo battleinfo_GiveUp = new Battleinfo(battleinfo_init.players[userNo].username, battleinfo_init.players[EnemyNo].username, GameHallManager.index_for_user, new Operation(0, 0, "End", 0)); Send(JsonConvert.SerializeObject(battleinfo_GiveUp)); }
//检查手牌区 private void checkHc() { isEndForCheckHc = true; for (int i = 0; i < 8; i++) { if (cardModel.GetCard(HcPanel.grids[i].name) != null) { isEndForCheckHc = false; } } if (isEndForCheckHc) { Battleinfo battleinfo_GiveUp = new Battleinfo(battleinfo_init.players[userNo].username, battleinfo_init.players[EnemyNo].username, GameHallManager.index_for_user, new Operation(0, 0, "End", 0)); Send(JsonConvert.SerializeObject(battleinfo_GiveUp)); checkhand = false; } }
private void Update() { if (ReceiveBattleinfo.operation.opera == "End" && ReceiveBattleinfo.receiver == userModel.getName()) { EnemyisEnd = true; } if (ReceiveBattleinfo.operation.opera == "End" && ReceiveBattleinfo.sender == userModel.getName()) { isEnd = true; } //检查手牌区以确认是否结束回合 if (!isEnd && checkhand) { checkHc(); } //战局结算 if (isEnd && EnemyisEnd) { if (loadnewround) { //重启新回合 string initbattleinfo_next = httpscript.PostHttp(getnextUrl, "roomindex=" + GameHallManager.index); battleinfo_init = JsonConvert.DeserializeObject <Battle>(initbattleinfo_next); loadnewround = false; Debug.Log(initbattleinfo_next); } //Debug.Log("进入战局结算"); //显示这一回合的获胜者,保持两秒 string winnername = httpscript.PostHttp(CurrrntRoundWinnerUrl, "roomindex=" + GameHallManager.index); string winnertext = winnername + "是本轮胜者"; ResultTip.text = winnertext; timer_for_tip -= Time.deltaTime; if (timer_for_tip <= 0) { ResultTip.text = ""; timer_for_tip = 2.0f; isEnd = false; EnemyisEnd = false; isEndForCheckHc = false; loadnewround = true; //初始化卡片信息展示区 FunctionText.text = ""; if (winnername == battleinfo_init.players[userNo].username) { EnemyScore--; } else if (winnername == battleinfo_init.players[EnemyNo].username) { PlayerScore--; } if (PlayerScore != 0 && EnemyScore != 0) { CleanZone(); InitCard(); } else { winnername = httpscript.PostHttp(LastWinnerUrl, "roomindex=" + GameHallManager.index); ResultTip.text = winnername + "是最终胜者"; Winner = ResultTip.text; Application.LoadLevel(7); } } } //更新接受到的信息 if (BattleMessageList.Count > 0) { battlemessage = BattleMessageList[0].ToString(); BattleMessageList.Remove(BattleMessageList[0]); ResultTip.text = ""; ReceiveBattleinfo = JsonConvert.DeserializeObject <Battleinfo>(battlemessage); if (ReceiveBattleinfo.sender == battleinfo_init.players[EnemyNo].username) { UpdateCard(); //魔法卡效果 switch (ReceiveBattleinfo.operation.id) { case 13: CleanHCZone(); ReInitHandCard(); break; case 15: CleanCloseZone(); break; default: break; } if (!isEnd && !EnemyisEnd) { ResultTip.text = "你的回合"; } else if (isEnd && !EnemyisEnd) { ResultTip.text = "等待对方出完牌"; } try { FunctionText.text = GetCardText(CardList[ReceiveBattleinfo.operation.id]); } catch { Debug.Log("发送了放弃信息,因此没有卡片信息可以显示"); } } else if (ReceiveBattleinfo.sender == battleinfo_init.players[userNo].username) { //魔法卡效果实现 switch (ReceiveBattleinfo.operation.id) { case 11: CleanHCZone(); ReInitHandCard(); break; case 12: CleanHCZone(); ReInitHandCard(); break; case 13: CleanHCZone(); ReInitHandCard(); break; case 14: CleanHCZone(); ReInitHandCard(); break; case 15: CleanCloseZone(); break; default: break; } try { FunctionText.text = GetCardText(CardList[ReceiveBattleinfo.operation.id]); } catch { Debug.Log("发送了放弃信息,因此没有卡片信息可以显示"); } } //获取当前双方卡片点数 PlayerPoint.text = httpscript.PostHttp(CardPointUrl, "username="******"&roomindex=" + GameHallManager.index); EnemyPoint.text = httpscript.PostHttp(CardPointUrl, "username="******"&roomindex=" + GameHallManager.index); //获取双方剩余手牌数量 PlayerCardCount.text = "剩余手牌:" + httpscript.PostHttp(HandCardCountUrl, "player=" + battleinfo_init.players[userNo].username + "&roomindex=" + GameHallManager.index); EnemyCardCount.text = "剩余手牌:" + httpscript.PostHttp(HandCardCountUrl, "player=" + battleinfo_init.players[EnemyNo].username + "&roomindex=" + GameHallManager.index); } }