//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, May 24, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { [XLua.Hotfix] 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.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_ContainerGodWeaponEffect.gameObject.SetActive(false); m_NewGotSkillFrame.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.StopShow(); 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; case ActivateShow.ActivateFunc.GodWeaponEffect: DisplayFightPower(); DisplayLv(); DisplayGodWeaponEffect(); DisplayNewGotSkill(); break; case ActivateShow.ActivateFunc.JadeDynastySkill: DisplayFightPower(); DisplayNewGotSkill(); 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 = 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.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() { 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.gameObject.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].gameObject.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]]); } else { var config = GodWeaponEffectConfig.Get(ActivateShow.godWeaponType, displaySkills[i]); if (config != null) { m_Skills[i].DisplayGodWeaponEffect(config); } } break; default: m_Skills[i].Display(displaySkills[i]); break; } } 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.ShowPlayer(m_ModelRawImage, PlayerDatas.Instance.baseData.Job, RoleEquipType.Wing); break; case ActivateShow.ActivateFunc.GodWeaponEffect: m_ModelRawImage.gameObject.SetActive(true); m_ModelRawImage.rectTransform.sizeDelta = new Vector2(680, 510); var clothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Clothes); var _clothesId = clothes == null ? 0 : (int)clothes.itemId; var weapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon); var _weaponId = weapon == null ? 0 : (int)weapon.itemId; var secondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.Weapon2); var _secondaryId = secondary == null ? 0 : (int)secondary.itemId; var fashionClothes = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes); var fashionClothesId = fashionClothes == null ? 0 : (int)fashionClothes.itemId; var fashionWeapon = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon); var fashionWeaponId = fashionWeapon == null ? 0 : (int)fashionWeapon.itemId; var fashionSecondary = playerPack.GetItemByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2); var fashionSecondaryId = fashionSecondary == null ? 0 : (int)fashionSecondary.itemId; var model = ModelCenter.Instance.GetModel(); Dictionary dict = new Dictionary(); var level = model.GetGodWeaponStageRequireLevel(ActivateShow.godWeaponType, ActivateShow.godWeaponStage); dict.Add(ActivateShow.godWeaponType, level); UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData() { job = PlayerDatas.Instance.baseData.Job, fashionClothesId = fashionClothesId, clothesId = _clothesId, fashionWeaponId = fashionWeaponId, weaponId = _weaponId, fashionSecondaryId = fashionSecondaryId, secondaryId = _secondaryId, godWeapons = dict, }; UI3DModelExhibition.Instance.ShowOtherPlayer(m_ModelRawImage, data); 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() { switch (ActivateShow.activateType) { case ActivateShow.ActivateFunc.GodWeaponEffect: { m_ContainerNewGotSkill.gameObject.SetActive(true); var model = ModelCenter.Instance.GetModel(); var requireLevel = model.GetGodWeaponStageRequireLevel(ActivateShow.godWeaponType, ActivateShow.godWeaponStage); var config = GodWeaponEffectConfig.Get(ActivateShow.godWeaponType, requireLevel); if (config != null) { m_NewGotSkill.DisplayGodWeaponEffect(config); PrepareFly(config); } } break; case ActivateShow.ActivateFunc.JadeDynastySkill: m_ContainerNewGotSkill.gameObject.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.gameObject.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.gameObject.SetActive(true); m_TreasureSoulIcon.SetSprite(config.Icon); m_TreasureSoulIcon.SetNativeSize(); m_TreasureSoulName.text = config.Name; } } void DisplayGodWeaponEffect() { m_ContainerGodWeaponEffect.gameObject.SetActive(true); var model = ModelCenter.Instance.GetModel(); var config = GodWeaponConfig.GetConfig(ActivateShow.godWeaponType, 1); var stage = model.GetGodWeaponStage(ActivateShow.godWeaponType); m_GodWeaponStage.text = Language.Get("MagicWin_9", config.Name, stage); } void DisplaySkillFrame(int skillId) { m_NewGotSkillFrame.gameObject.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.gameObject.SetActive(false); } void PrepareFly(GodWeaponEffectConfig config) { ActivateShow.PrepareSkillFly(); var instance = UIUtility.CreateWidget("SkillUnlockFlyObject", "SkillUnlockFlyObject"); instance.transform.SetParentEx(m_ContainerNewGotFly, Vector3.zero, Quaternion.identity, Vector3.one); flyObject = instance.GetComponent(); flyObject.SetContent(config); flyObject.gameObject.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.GodWeaponEffect: case ActivateShow.ActivateFunc.JadeDynastySkill: { if (startFly) { return; } startFly = true; StartFlySkill(); } break; default: CloseClick(); break; } } private void StartFlySkill() { SetFlyPosition(); 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(); } } }