using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class ReliveWin : Window { [SerializeField] private Text _timeDownText; [SerializeField] private Image _ringImage; [SerializeField] Text dieDesText; [SerializeField] Text buffText; [SerializeField] Button inplaceRebornBtn; PlayerDeadModel _deadModel; PlayerDeadModel DeadModel { get { return _deadModel ?? (_deadModel = ModelCenter.Instance.GetModel()); } } public const int ElderBattleMapID = 31160; //上古战场地图Id public const int UnionleagueMapID = 31220; //仙盟联赛地图 int questTimes = 0; #region Built-in protected override void BindController() { } protected override void AddListeners() { inplaceRebornBtn.onClick.AddListener(OnClickInplaceRebornBtn); } protected override void OnPreOpen() { TimeDownMgr.CoolTimeData coolDown; TimeDownMgr.Instance.Get(TimeDownMgr.CoolTimeType.DuplicatesReborn, out coolDown); RefreshTime(Mathf.RoundToInt(coolDown.duration - coolDown.time)); DeadModel.RefreshDuplicatesRebornCDEvent = RefreshTime; int curMapId = PlayerDatas.Instance.baseData.MapID; MapConfig mapConfig = MapConfig.Get(curMapId); dieDesText.SetActive(false); buffText.SetActive(curMapId == ElderBattleMapID); inplaceRebornBtn.SetActive(curMapId == UnionleagueMapID || curMapId == JadeDynastyBossModel.JADEDYNASTY_MAP); switch (curMapId) { case ElderBattleMapID: SetBuffDes(); break; case UnionleagueMapID: break; } for (int i = 0; i < DeadModel.dungeonKillArray.Length; i++) { if(DeadModel.dungeonKillArray[i] == curMapId) { dieDesText.SetActive(true); string msg = StringUtility.Contact(Language.Get("AncientBattlefield_Text_1", mapConfig.Name, UIHelper.ServerStringTrim(DeadModel.killerName))); dieDesText.text = msg; } } } protected override void OnAfterOpen() { this.transform.SetAsLastSibling(); } protected override void OnPreClose() { StopAllCoroutines(); } protected override void OnAfterClose() { } #endregion private void SetBuffDes() { List buffIds = new List(); StatusMgr.Instance.GetBuffIds(PlayerDatas.Instance.PlayerId, ref buffIds); var skillIds = SkillConfig.GetSkills(0, 0, DeadModel.deadBuffId); string skillName = string.Empty; int buffLv = 0; bool isMaxBuff = false; if (buffIds.Count > 0) { for (int i = 0; i < buffIds.Count; i++) { int buffId = buffIds[i]; SkillConfig skillConfig = SkillConfig.Get(buffId); if (skillConfig.SkillTypeID == DeadModel.deadBuffId) { buffLv = skillConfig.SkillLV + 1; isMaxBuff = buffLv > DeadModel.maxDeadBuffLV ? true : false; break; } } } if (skillIds != null && skillIds.Count > 0) { var skillId = skillIds[0]; var skillConfig = SkillConfig.Get(skillId); skillName = skillConfig.SkillName; } buffText.text = Language.Get("AncientBattlefield_Text_2", skillName); buffText.SetActive(!isMaxBuff); } public void RefreshTime(int time) { _timeDownText.text = time.ToString(); _ringImage.fillAmount = (float)time / DeadModel.duplicatesRebornTime; if (time <= 0) { DeadModel.SendRebornQuest(0); StartCoroutine(CheckPlayerIsReborn()); } } IEnumerator CheckPlayerIsReborn() { questTimes = 0; while (questTimes < 5) { yield return new WaitForSeconds(1); questTimes += 1; if (DeadModel.playerIsDie) { DeadModel.SendRebornQuest(0); } else { questTimes = 5; } } } private void OnClickInplaceRebornBtn() { DeadModel.InpacleReborn(); } private void CloseWin() { Close(); } } }