| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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;
- int avatarID = GlobalData.matchPlayerInfos[playerIndex].avatarID;
- string avatarUrl = GlobalData.matchPlayerInfos[playerIndex].avatarUrl;
- string nickName = GlobalData.matchPlayerInfos[playerIndex].nickname;
- RoleMgr.SetAvatarToImage(this.transform.Find("Avatar" + i + "/Sprite").GetComponent<Image>(),
- avatarID, avatarUrl);
- //this.transform.Find("Name" + i).GetComponent<Text>().text = nickName;
- TextEllipsis.SetTextWithEllipsis(transform.Find("Name" + i).GetComponent<Text>(), nickName);
- } else if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
- string nickName = RoleMgr.GetRoleInfo(PKGameMode.playerRoleIDs[i - 1],
- this.transform.Find("Avatar" + i + "/Sprite").GetComponent<Image>());
- //this.transform.Find("Name" + i).GetComponent<Text>().text = nickName;
- TextEllipsis.SetTextWithEllipsis(transform.Find("Name" + i).GetComponent<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.Instance.uploadPKGameRes(gameRes);
- } catch (System.Exception e) { Debug.LogError(e.Message); }
- }
- if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- if (SocketPlayer.ins) SocketPlayer.ins.isGameOver = true;
- }
- SimulateMouseController.ins?.AddOpenLocker("NotGame");
- GameOverInterface.OnGameOver(GameMgr.gameType);
- }
- public void OnClick_Back() {
- AudioMgr.ins.PlayBtn();
- GoHomeLogic();
- }
- private void GoHomeLogic() {
- //SceneManager.LoadScene("Home", LoadSceneMode.Single);
- GameMgr.ins.gameMode.gameMgr.userGameAnalyse.showResultView(() => {
- SceneManager.LoadScene("Home", LoadSceneMode.Single);
- });
- }
- JCUnityLib.Throttler throttlerTryAgainOnline = new JCUnityLib.Throttler(3000);
- public void OnClick_Again() {
- 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);
- }
- }
- }
|