| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- /* PK模式的结算界面 */
- public class PKGameSettleView : MonoBehaviour
- {
- void Start()
- {
- GameMode gameMode = GameMgr.ins.gameMode;
- if (PKGameView.ins) {
- PKGameView.ins.gameObject.SetActive(false);
- }
- string[] results = (string[]) gameMode.Settle();
- for (int i = 1; i <= 2; i++) {
- if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- int playerIndex = i - 1;
- (Sprite avatar, string nickName) = RoleMgr.GetRoleInfo(GlobalData.matchPlayerInfos[playerIndex].avatarID);
- nickName = GlobalData.matchPlayerInfos[playerIndex].nickname;
- this.transform.Find("Avatar" + i + "/Sprite").GetComponent<Image>().sprite = avatar;
- this.transform.Find("Name" + i).GetComponent<Text>().text = nickName;
- } else if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
- (Sprite avatar, string nickName) = RoleMgr.GetRoleInfo(PKGameMode.playerRoleIDs[i - 1]);
- this.transform.Find("Avatar" + i + "/Sprite").GetComponent<Image>().sprite = avatar;
- this.transform.Find("Name" + i).GetComponent<Text>().text = nickName;
- }
- this.transform.Find("Win" + i).gameObject.SetActive(results[i - 1] == "胜利");
- this.transform.Find("Fail" + i).gameObject.SetActive(results[i - 1] == "失败");
- if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
- this.transform.Find("Score" + i + "/Text").GetComponent<Text>().text = ((PKGameMode)gameMode).totalScores[i - 1].ToString();
- } else if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- this.transform.Find("Score" + i + "/Text").GetComponent<Text>().text = ((PKGameMode_OnlinePK)gameMode).gameLogic.totalScores[i - 1].ToString();
- }
- }
- AudioMgr.ins.PlayWin();
- if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- int gameRes = 2;
- if (results[0] == "胜利") {
- gameRes = 0;
- } else if (results[1] == "胜利") {
- gameRes = 1;
- }
- try {
- RankComp.ins.uploadPKGameRes(gameRes);
- } catch (System.Exception e) { Debug.LogError(e.Message); }
- }
- if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- if (SocketPlayer.ins) SocketPlayer.ins.isGameOver = true;
- }
- }
- public void GoHome() {
- AudioMgr.ins.PlayBtn();
- GoHomeLogic();
- }
- private void GoHomeLogic() {
- SceneManager.LoadScene("Home", LoadSceneMode.Single);
- HomeMgr.DestroyCacheViews();
- }
- JC.CS.Throttler throttlerTryAgainOnline = new JC.CS.Throttler(3000);
- public void TryAgain() {
- AudioMgr.ins.PlayBtn();
- if (GameAssistUI.ins) GameAssistUI.ins.recordPlayerRecordsWhenGameTryAgain();
- if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- if (throttlerTryAgainOnline.CanPass() == false) {
- PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("操作过于频繁"));
- return;
- }
- PKMatchingView view = PKMatchingView.Create();
- view.InitForInviterToTryAgain();
- view.eventOnRejectPKInvite += () => {
- view.banBackBtnLogic = true;
- DoTweenUtil.CallDelay(2f, GoHomeLogic);
- };
- } else {
- SceneManager.LoadScene("Game", LoadSceneMode.Single);
- }
- }
- }
|