//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, May 24, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using TableConfig; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class RealmPropertyUpWin : Window { [SerializeField] UIAlphaTween m_DisplayAlphaTween; [SerializeField] RawImage m_ModelRawImage; [SerializeField] Image m_TitleIcon; [SerializeField] Text m_PowerUpper; [SerializeField] Button m_CloseBtn; [SerializeField] RectTransform m_ContainerLv; [SerializeField] Text m_LvBeforeValue; [SerializeField] Text m_LvNowValue; [SerializeField] RectTransform m_ContainerProperty; [SerializeField] PropertyCompareBehaviour[] m_Properties; [SerializeField] RectTransform m_ContainerSkill; [SerializeField] SkillBehaviour[] m_Skills; [SerializeField] RectTransform m_ContainerNewGotSkill; [SerializeField] SkillBehaviour m_NewGotSkill; [SerializeField] RectTransform m_ContainerRealm; [SerializeField] RectTransform m_ContainerRealmUp; [SerializeField] RectTransform m_ContainerRealmActivity; [SerializeField] Image m_PresentRealmIcon; [SerializeField] Image m_NextRealmIcon; [SerializeField] Text m_RealmActivity; [SerializeField] Text m_CloseTip; [SerializeField] RectTransform m_ContainerNewGotFly; [SerializeField] RectTransform m_ContainerTreasureSoul; [SerializeField] Image m_TreasureSoulIcon; [SerializeField] Text m_TreasureSoulName; FunctionUnlockFlyObject flyObject; DateTime openTime = DateTime.Now; #region Built-in protected override void BindController() { } protected override void AddListeners() { m_CloseBtn.onClick.AddListener(OnClickClose); } protected override void OnPreOpen() { m_ModelRawImage.gameObject.SetActive(false); m_ContainerSkill.gameObject.SetActive(false); m_ContainerProperty.gameObject.SetActive(false); m_ContainerLv.gameObject.SetActive(false); m_ContainerNewGotSkill.gameObject.SetActive(false); m_ContainerRealm.gameObject.SetActive(false); m_ContainerTreasureSoul.gameObject.SetActive(false); m_DisplayAlphaTween.SetStartState(); flying = false; startFly = false; m_CloseTip.gameObject.SetActive(false); openTime = DateTime.Now; if (flyObject != null) { GameObject.Destroy(flyObject); flyObject = null; } Display(); } protected override void OnActived() { base.OnActived(); m_TitleIcon.SetSprite(ActivateShow.titleIconKey); m_TitleIcon.SetNativeSize(); DisplayModel(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { UI3DModelExhibition.Instance.StopShowPlayer(); UI3DTreasureExhibition.Instance.StopShow(); flying = false; } protected override void OnAfterClose() { } float timer = 0f; bool flying = false; protected override void LateUpdate() { base.LateUpdate(); if ((DateTime.Now - openTime).TotalSeconds > 2f && !m_CloseTip.gameObject.activeSelf) { m_CloseTip.gameObject.SetActive(true); } if (flying) { timer += Time.deltaTime; if (timer > 3f) { CloseClick(); } } } #endregion void Display() { switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.Realm: DisplayFightPower(); DisplayProperty(); DisplayRealm(); break; case ActivateShow.ActivateFunc.GodWeapon: DisplayFightPower(); if (ActivateShow.beforeLv == 0) { DisplayProperty(); DisplaySkill(); } else { DisplayLv(); DisplayNewGotSkill(); } break; case ActivateShow.ActivateFunc.TreasureSoul: DisplayTreasureSoul(); DisplayFightPower(); DisplayProperty(); break; } } void DisplayFightPower() { m_PowerUpper.text = ActivateShow.fightPower.ToString(); } void DisplayLv() { m_ContainerLv.gameObject.SetActive(true); m_LvBeforeValue.text = ActivateShow.beforeLv.ToString(); m_LvNowValue.text = ActivateShow.currentLv.ToString(); } void DisplayRealm() { m_ContainerRealm.gameObject.SetActive(true); m_ContainerRealmActivity.gameObject.SetActive(ActivateShow.beforeLv == 0); m_ContainerRealmUp.gameObject.SetActive(ActivateShow.beforeLv > 0); var config = Config.Instance.Get(ActivateShow.currentLv); if (ActivateShow.beforeLv <= 0) { m_RealmActivity.text = Language.Get("RealmLevelUped", config.Name); } else { var beforeConfig = Config.Instance.Get(ActivateShow.beforeLv); m_NextRealmIcon.SetSprite(config.Img); m_PresentRealmIcon.SetSprite(beforeConfig.Img); } } void DisplayProperty() { m_ContainerProperty.gameObject.SetActive(true); for (int i = 0; i < m_Properties.Length; i++) { if (i < ActivateShow.propertyCompares.Count) { m_Properties[i].gameObject.SetActive(true); switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.TreasureSoul: case ActivateShow.ActivateFunc.Realm: m_Properties[i].Display(ActivateShow.propertyCompares[i].key , ActivateShow.propertyCompares[i].beforeValue, ActivateShow.propertyCompares[i].currentValue); break; case ActivateShow.ActivateFunc.GodWeapon: if (ActivateShow.beforeLv != 0) { m_Properties[i].Display(ActivateShow.propertyCompares[i].key , ActivateShow.propertyCompares[i].beforeValue, ActivateShow.propertyCompares[i].currentValue); } else { m_Properties[i].Display(ActivateShow.propertyCompares[i].key, ActivateShow.propertyCompares[i].currentValue); } break; } } else { m_Properties[i].gameObject.SetActive(false); } } } void DisplaySkill() { m_ContainerSkill.gameObject.SetActive(ActivateShow.skills.Count > 0); if (ActivateShow.skills.Count == 0) { return; } for (int i = 0; i < m_Skills.Length; i++) { if (i < ActivateShow.skills.Count) { m_Skills[i].gameObject.SetActive(true); m_Skills[i].Display(ActivateShow.skills[i]); } else { m_Skills[i].gameObject.SetActive(false); } } } void DisplayModel() { switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.Realm: m_ModelRawImage.gameObject.SetActive(true); m_ModelRawImage.rectTransform.sizeDelta = new Vector2(680, 510); UI3DModelExhibition.Instance.BeginShowPlayer(m_ModelRawImage, PlayerDatas.Instance.baseData.Job, RoleEquipType.retWing); break; case ActivateShow.ActivateFunc.GodWeapon: m_ModelRawImage.gameObject.SetActive(true); m_ModelRawImage.rectTransform.sizeDelta = new Vector2(600, 600); UI3DTreasureExhibition.Instance.BeginShowGodWeapon(ActivateShow.godWeaponType, m_ModelRawImage); break; } } void DisplayNewGotSkill() { m_ContainerNewGotSkill.gameObject.SetActive(ActivateShow.skills.Count > 0); if (ActivateShow.skills.Count == 0) { return; } m_NewGotSkill.DisplayNewGot(ActivateShow.skills[0]); PrepareFly(ActivateShow.skills[0]); } void DisplayTreasureSoul() { var config = Config.Instance.Get(ActivateShow.treasureSoulId); if (config != null) { m_ContainerTreasureSoul.gameObject.SetActive(true); m_TreasureSoulIcon.SetSprite(config.Icon); m_TreasureSoulName.text = config.Name; } } void PrepareFly(int _skillId) { ActivateShow.PrepareSkillFly(); var instance = UIUtility.CreateWidget("SkillUnlockFlyObject", "SkillUnlockFlyObject"); instance.transform.SetParentEx(m_ContainerNewGotFly, Vector3.zero, Quaternion.identity, Vector3.one); flyObject = instance.GetComponent(); flyObject.SetContent(FunctionUnlockType.Skill, _skillId); flyObject.gameObject.SetActive(false); } private bool startFly = false; private void OnClickClose() { if ((DateTime.Now - openTime).TotalSeconds < 2f) { return; } switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.GodWeapon: if (ActivateShow.beforeLv != 0) { if (startFly) { return; } startFly = true; StartFlySkill(); } else { CloseClick(); } break; default: CloseClick(); break; } } private void StartFlySkill() { if (flyObject != null) { flyObject.gameObject.SetActive(true); } m_DisplayAlphaTween.Play(()=> { if (flyObject != null) { timer = 0f; flying = true; flyObject.Begin(OnReach); } else { CloseClick(); } }); } private void OnReach() { ActivateShow.CompleteSkillFly(); CloseClick(); } } }