//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, May 24, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.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] ScrollRect m_SkillScroller; [SerializeField] SkillBehaviour[] m_Skills; [SerializeField] RectTransform m_ContainerNewGotSkill; [SerializeField] SkillBehaviour m_NewGotSkill; [SerializeField] FrameEffect m_NewGotSkillFrame; [SerializeField] RectTransform m_NewGotSkillPoint; [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] RectTransform m_ContainerGodWeaponEffect; [SerializeField] Text m_GodWeaponStage; [SerializeField] Text m_CloseTip; [SerializeField] RectTransform m_ContainerNewGotFly; [SerializeField] RectTransform m_ContainerTreasureSoul; [SerializeField] Image m_TreasureSoulIcon; [SerializeField] Text m_TreasureSoulName; FunctionUnlockFlyObject flyObject; PackModel playerPack { get { return ModelCenter.Instance.GetModel(); } } 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.SetActive(false); m_ContainerSkill.SetActive(false); m_ContainerProperty.SetActive(false); m_ContainerLv.SetActive(false); m_ContainerNewGotSkill.SetActive(false); m_ContainerRealm.SetActive(false); m_ContainerTreasureSoul.SetActive(false); m_ContainerGodWeaponEffect.SetActive(false); m_NewGotSkillFrame.SetActive(false); m_DisplayAlphaTween.SetStartState(); flying = false; startFly = false; m_CloseTip.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.StopShow(); UI3DTreasureExhibition.Instance.Stop(); 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.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.JadeDynastySkill: DisplayFightPower(); DisplayNewGotSkill(); break; } } void DisplayFightPower() { m_PowerUpper.text = UIHelper.ReplaceLargeArtNum(ActivateShow.fightPower); } void DisplayLv() { m_ContainerLv.SetActive(true); m_LvBeforeValue.text = ActivateShow.beforeLv.ToString(); m_LvNowValue.text = ActivateShow.currentLv.ToString(); } void DisplayRealm() { m_ContainerRealm.SetActive(true); m_ContainerRealmActivity.SetActive(ActivateShow.beforeLv == 0); m_ContainerRealmUp.SetActive(ActivateShow.beforeLv > 0); var config = RealmConfig.Get(ActivateShow.currentLv); if (ActivateShow.beforeLv <= 0) { m_RealmActivity.text = Language.Get("RealmLevelUped", config.Name); } else { var beforeConfig = RealmConfig.Get(ActivateShow.beforeLv); m_NextRealmIcon.SetSprite(config.Img); m_PresentRealmIcon.SetSprite(beforeConfig.Img); } } void DisplayProperty() { m_ContainerProperty.SetActive(true); for (int i = 0; i < m_Properties.Length; i++) { if (i < ActivateShow.propertyCompares.Count) { m_Properties[i].SetActive(true); switch (ActivateShow.activateType) { 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].SetActive(false); } } } void DisplaySkill() { List displaySkills; switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.GodWeapon: var model = ModelCenter.Instance.GetModel(); displaySkills = model.TryGetDisplaySkillLevels(ActivateShow.godWeaponType); break; default: displaySkills = new List(); displaySkills.AddRange(ActivateShow.skills); break; } m_ContainerSkill.SetActive(displaySkills.Count > 0); if (displaySkills.Count == 0) { return; } m_SkillScroller.horizontalNormalizedPosition = 0f; for (int i = 0; i < m_Skills.Length; i++) { if (i < displaySkills.Count) { m_Skills[i].SetActive(true); switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.GodWeapon: var model = ModelCenter.Instance.GetModel(); Dictionary dict; if (model.TryGetGodWeaponSkills(ActivateShow.godWeaponType, out dict) && dict.ContainsKey(displaySkills[i])) { m_Skills[i].Display(dict[displaySkills[i]]); } break; default: m_Skills[i].Display(displaySkills[i]); break; } } else { m_Skills[i].SetActive(false); } } } void DisplayModel() { switch (ActivateShow.activateType) { //case ActivateShow.ActivateFunc.Realm: // m_ModelRawImage.SetActive(true); // m_ModelRawImage.rectTransform.sizeDelta = new Vector2(680, 510); // UI3DModelExhibition.Instance.ShowPlayer(m_ModelRawImage, PlayerDatas.Instance.baseData.Job, RoleEquipType.Wing); // break; case ActivateShow.ActivateFunc.GodWeapon: m_ModelRawImage.SetActive(true); m_ModelRawImage.rectTransform.sizeDelta = new Vector2(600, 600); UI3DTreasureExhibition.Instance.ShowGodWeapon(ActivateShow.godWeaponType, m_ModelRawImage); break; } } void DisplayNewGotSkill() { switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.JadeDynastySkill: m_ContainerNewGotSkill.SetActive(ActivateShow.skills.Count > 0); if (ActivateShow.skills.Count == 0) { return; } m_NewGotSkill.DisplayNewGot(ActivateShow.skills[0]); DisplaySkillFrame(ActivateShow.skills[0]); PrepareFly(ActivateShow.skills[0]); break; default: { m_ContainerNewGotSkill.SetActive(ActivateShow.skills.Count > 0); if (ActivateShow.skills.Count == 0) { return; } m_NewGotSkill.DisplayNewGot(ActivateShow.skills[0]); PrepareFly(ActivateShow.skills[0]); } break; } } void DisplayTreasureSoul() { var config = TreasurePrivilegeConfig.Get(ActivateShow.treasureSoulId); if (config != null) { m_ContainerTreasureSoul.SetActive(true); m_TreasureSoulIcon.SetSprite(config.Icon); m_TreasureSoulIcon.SetNativeSize(); m_TreasureSoulName.text = config.Name; } } void DisplaySkillFrame(int skillId) { m_NewGotSkillFrame.SetActive(true); var model = ModelCenter.Instance.GetModel(); Sprite[] sprites; if (model.TryGetSkillFrames(skillId, out sprites)) { var config = SkillFrameAnimationConfig.Get(skillId); m_NewGotSkillFrame.SetSprites(sprites, (float)config.totalTime / 1000); var rt = m_NewGotSkillFrame.transform as RectTransform; rt.sizeDelta = config.sizeDelta; } } 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.SetActive(false); } void SetFlyPosition() { var worldpos = m_NewGotSkillPoint.transform.TransformPoint(Vector3.zero); var localpos = transform.InverseTransformPoint(worldpos); m_ContainerNewGotFly.transform.localPosition = localpos; } 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; case ActivateShow.ActivateFunc.JadeDynastySkill: { if (startFly) { return; } startFly = true; StartFlySkill(); } break; default: CloseClick(); break; } } private void StartFlySkill() { SetFlyPosition(); if (flyObject != null) { flyObject.SetActive(true); } m_DisplayAlphaTween.Play(()=> { if (flyObject != null) { timer = 0f; flying = true; flyObject.Begin(OnReach); } else { CloseClick(); } }); } private void OnReach() { ActivateShow.CompleteSkillFly(); CloseClick(); } } }