using System; using I2.Loc; using UnityEngine; using wf; [RequireComponent(typeof(UIWidget))] public class SceneTrophyCardFade : WfFadeBehaviour { private void Awake() { this.contentWidget = base.GetComponent(); this.cardFadeMgr = this.cardWidget.GetComponent(); this.cardDrawPos = this.cardSprite.transform.position; this.cardWidget.alpha = 0f; } private void OnDestroy() { if (this.cardSprite.sprite2D != null && this.cardSprite.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.cardSprite.sprite2D.texture); } } public void CallCard(Trophy.Data tropheyData, Vector3 cardWorldPos) { if (this.cardSprite.sprite2D != null && this.cardSprite.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.cardSprite.sprite2D.texture); } this.cardSprite.sprite2D = null; if (!string.IsNullOrEmpty(tropheyData.cardTextureFileName)) { string texturFileName = tropheyData.cardTextureFileName; if (Product.supportMultiLanguage) { texturFileName = LocalizationManager.GetTranslation(tropheyData.cardTextureFileNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage)); } Sprite sprite = Utility.CreateTextureSprite(texturFileName); this.cardSprite.sprite2D = sprite; this.cardSprite.SetDimensions((int)sprite.rect.width, (int)sprite.rect.height); } this.cardSprite.transform.position = cardWorldPos; this.uiCardPos = cardWorldPos; WfFadeJob.Create(null, this, this.fadeTime, iTween.EaseType.easeInOutSine); } public void CallMainContent() { WfFadeJob.Create(this, null, this.fadeTime, iTween.EaseType.easeInOutSine); } public override void OnUpdateFadeIn(float val) { this.contentWidget.alpha = val; val = 1f - val; this.cardWidget.alpha = val; float num = Mathf.SmoothStep(0f, 0.88f, val); num = ((1f >= 0.12f + num) ? (0.12f + num) : 1f); this.cardSprite.transform.localScale = new Vector3(num, num, 1f); this.cardSprite.transform.position = Vector3.Lerp(this.uiCardPos, this.cardDrawPos, val); } public override void OnUpdateFadeOut(float val) { this.contentWidget.alpha = val; val = 1f - val; this.cardWidget.alpha = val; float num = Mathf.SmoothStep(0f, 0.88f, val); num = ((1f >= 0.12f + num) ? (0.12f + num) : 1f); this.cardSprite.transform.localScale = new Vector3(num, num, 1f); this.cardSprite.transform.position = Vector3.Lerp(this.uiCardPos, this.cardDrawPos, val); } public override void OnCompleteFadeOut() { base.OnCompleteFadeOut(); this.cardSprite.transform.localScale = Vector3.one; } [SerializeField] private float fadeTime; [SerializeField] private UIWidget cardWidget; [SerializeField] private UI2DSprite cardSprite; private UIWidget contentWidget; private WfFadeBehaviour cardFadeMgr; private Vector3 uiCardPos; private Vector3 cardDrawPos; }