using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System; using UnityEngine.SceneManagement; [System.Serializable] public class RankingText { public Text m_score; public Text m_time; } [System.Serializable] public class MyResult { public Text stageName; public Text stageResult; public Text clearTime; public Text totalScore; public Text myRanking; } public class UIResult : UIBase { GameObject result; string m_stage = null; int m_score = 0; float m_time = 0; int m_rank = 0; List<ClearData> m_getList = new List<ClearData>(); bool m_infoOn; float m_alpha = 0f; public Text m_infoText; public MyResult m_myResult; // 이름, 시간, 점수, 랭킹 public List<RankingText> m_rankListUI = new List<RankingText>(); public void Update() { if( ControllerManager.Instance.RightTrackController.padPressed || ControllerManager.Instance.LeftTrackController.padPressed || Input.GetKeyDown(KeyCode.N) ) { GameManager.Instance.LoadScene("Lobby"); } if(m_infoOn == false) { m_alpha += Time.deltaTime; m_infoText.color = new Color(m_infoText.color.r, m_infoText.color.g, m_infoText.color.b, m_alpha); if (m_alpha >= 1f) { m_infoOn = true; } } else { m_alpha -= Time.deltaTime; m_infoText.color = new Color(m_infoText.color.r, m_infoText.color.g, m_infoText.color.b, m_alpha); if (m_alpha <= 0f) { m_infoOn = false; } } } public void OnEnable() { } public override void OnOpened() { #region 플레이어와 유아이의 위치 result = GameObject.Find("ClaerUI_Position"); if (result != null) { transform.position = new Vector3(3075.8f, 132.9f, 914.1f); transform.eulerAngles = new Vector3(2.761f, -0.945f, 0); } m_stage = StageRankManager.Instance.SetStage(); m_score = InGameManager.Instance.InGameData.TotalScore; m_time = InGameManager.Instance.InGameData.PlayTime; #endregion GetRanking(); #region 불필요한 유아이나 미니맵 끄기 GameObject minimap = GameObject.Find("Render Camera"); if (minimap != null) { minimap.SetActive(false); } if (UIManager.Instance.IsOpen("UIUserHP")) { UIManager.Instance.Close("UIUserHP"); } if (UIManager.Instance.IsOpen("UIDead")) { UIManager.Instance.Close("UIDead"); } #endregion #region Stage text setting 스테이지 추가시 수정 요망 if (StageRankManager.Instance.CurrentStage == StageType.Cpt) { m_myResult.stageName.text = "Desert Storm SHOT VERSION"; } else if(StageRankManager.Instance.CurrentStage == StageType.Hope) { m_myResult.stageName.text = "Operation 'RESTORE HOPE'"; } else if (StageRankManager.Instance.CurrentStage == StageType.Hope2) { m_myResult.stageName.text = "Operation 'RESTORE HOPE NIGHT'"; } else if(StageRankManager.Instance.CurrentStage == StageType.Desert) { m_myResult.stageName.text = "Operation 'DESERT STORM'"; } else if (StageRankManager.Instance.CurrentStage == StageType.Desert2) { m_myResult.stageName.text = "Operation 'NIGHT HAWK'"; } else if (StageRankManager.Instance.CurrentStage == StageType.Ruin) { m_myResult.stageName.text = "Operation 'RUIN'"; } else if (StageRankManager.Instance.CurrentStage == StageType.Ruin2) { m_myResult.stageName.text = "Operation 'SUNSET RUIN'"; } else { m_myResult.stageName.text = "NONE NAME STAGE"; } #endregion if (InGameManager.Instance.InGameData.GameClear == true) { m_myResult.stageResult.text = "VICTORY"; m_myResult.stageResult.color = new Color(0.35f, 0.674f, 0.8f); } else { m_myResult.stageResult.text = "DEFEAT"; m_myResult.stageResult.color = new Color(0.8f, 0.231f, 0.137f); } m_myResult.clearTime.text = string.Format("{0:00}:{1:00}", m_time / 60, m_time % 60); m_myResult.totalScore.text = m_score.ToString(); m_myResult.myRanking.text = m_rank.ToString(); } public override void OnClosed() { } private void GetRanking() { StageRankManager.Instance.AddClearData(m_score, m_time); m_getList = StageRankManager.Instance.GetStageRanking(m_stage, m_score, m_time); m_rank = GetMyRanking(m_getList, m_score, m_time); for(int i = 0; i < m_rankListUI.Count; i++) { if(m_getList.Count > i) { m_rankListUI[i].m_score.text = m_getList[i].score.ToString(); m_rankListUI[i].m_time.text = string.Format("{0:00}:{1:00}", m_getList[i].time / 60, m_getList[i].time % 60); } } } public int GetMyRanking(List<ClearData> list, int score, float time) { int count = 1; for (int i = 0; i < list.Count; i++) { if(list == null) { return 0; } if (m_score == list[i].score && m_time == list[i].time) { return count; } count++; } return 0; } } | cs |
'NOTE > SaveSource' 카테고리의 다른 글
[SaveSource] TutorialManager (0) | 2017.02.08 |
---|---|
[SaveSource] StageRankManager (0) | 2017.01.20 |
[SaveSource] CameraOrbit (0) | 2017.01.12 |
[SaveSource] WaveMoveTrigger (0) | 2017.01.12 |
[SaveSource] SpeicalWeapon (0) | 2017.01.12 |