using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class PKGameSettleViewNew : MonoBehaviour { // Start is called before the first frame update void OnEnable() { SimulateMouseController.ins?.AddOpenLocker(this); int[] pkResults = { 0, 0 }; var gc = GameController.ins; if (gc.scores[0] > gc.scores[1]) { pkResults[0] = 1; pkResults[1] = -1; } else if (gc.scores[0] < gc.scores[1]) { pkResults[0] = -1; pkResults[1] = 1; } for (int i = 1; i <= 2; i++) { int index = i - 1; transform.Find("Win" + i).gameObject.SetActive(pkResults[index] == 1); transform.Find("Fail" + i).gameObject.SetActive(pkResults[index] == -1); transform.Find("Draw" + i).gameObject.SetActive(pkResults[index] == 0); string _format = "F" + CommonConfig.ringsPrecision; //显示保留一位小数 transform.Find("Score" + i + "/Text").GetComponent().text = gc.scores[index].ToString(_format); } } void OnDisable() { SimulateMouseController.ins?.RemoveOpenLocker(this); } public void OnClick_Again() { gameObject.SetActive(false); AudioMgr.ins.PlayBtn(); GameController.ins.InitGame(); GameController.ins.HandleSelectDistance(GameController.ins.targetDistance); //清除箭矢,1p 和 2p foreach (var arrow in ArrowNew2.arrowSet) { try { GameObject.Destroy(arrow.gameObject); } catch (UnityException e) { Debug.Log("Delete Arrow Error\n" + e.Message); } } //重新load game //SceneManager.LoadScene("GameDouble", LoadSceneMode.Single); } public void OnClick_Back() { gameObject.SetActive(false); AudioMgr.ins.PlayBtn(); //重新load game SceneManager.LoadScene("GameDouble", LoadSceneMode.Single); //GameController.ins.InitGame(); //GameController.ins.SetDisplayDistanceSelectView(true); } }