using System.Collections.Generic; using MoleMole.Config; using UnityEngine; using UnityEngine.UI; using proto; namespace MoleMole { public class EquipPowerUpEffectDialogContext : BaseDialogContext { public enum DialogType { PowerUp = 0, Evo = 1, NewAffix = 2 } public enum EffectType { Small = 0, Large = 1 } private const string POWERUP_RESULT_PREFAB_PRE = "SpriteOutput/EquipPowerUpResult/Success"; private const float EFFECT_POSITION_RANGE = 50f; private const string SMALL_SPOT_EFFECT_PREFAB_PATH = "UI/Menus/Widget/Storage/SmallSpot"; private const string SUCCESS_EFFECT_PREFAB_PATH = "UI/Menus/Widget/Storage/UpgradeSuccess"; private const string BIG_SUCCESS_EFFECT_PREFAB_PATH = "UI/Menus/Widget/Storage/UpgradingBigSuccess"; private const string LARGE_SUCCESS_EFFECT_PREFAB_PATH = "UI/Menus/Widget/Storage/UpgradingLargeSuccess"; private const string EVOLUTION_EFFECT_PREFAB_PATH = "UI/Menus/Widget/Storage/Evolution"; private const string STAR_ICON_PATH = "SpriteOutput/StarBig"; private const string STAR_GREY_ICON_PATH = "SpriteOutput/StarBigGray"; private const string SUB_STAR_ICON_PATH = "SpriteOutput/SubStarActive"; private const string SUB_STAR_GREY_ICON_PATH = "SpriteOutput/SubStarActiveGray"; public readonly StorageDataItemBase itemDataAfter; public readonly StorageDataItemBase itemDataBefore; private List _materialList; public readonly int boostRate; public readonly DialogType dialogType; private SequenceAnimationManager _animationManager; private CanvasTimer _effectDelayTimer; private int _powerUpResultIndex; private List _effectPosition = new List { new Vector2(50f, 0f), new Vector2(-50f, 0f), new Vector2(0f, 50f), new Vector2(0f, -50f), new Vector2(50f, 50f), new Vector2(0f, 0f) }; private int _effectIndex; private CanvasTimer _flashStartTimer; private CanvasTimer _flashResetTimer; public EquipPowerUpEffectDialogContext(StorageDataItemBase itemDataBefore, StorageDataItemBase itemDataAfter, List materialList, DialogType type = DialogType.PowerUp, int boostRate = 100) { config = new ContextPattern { contextName = "EquipPowerUpEffectDialogContext", viewPrefabPath = "UI/Menus/Dialog/EquipPowerUpEffectDialog", cacheType = ViewCacheType.DontCache }; this.itemDataAfter = itemDataAfter; this.itemDataBefore = itemDataBefore; _materialList = new List(); foreach (StorageDataItemBase material in materialList) { _materialList.Add(material.Clone()); } this.boostRate = boostRate; dialogType = type; } public override void StartUp(Transform canvasTrans, Transform viewParent) { base.StartUp(canvasTrans, viewParent); if (dialogType == DialogType.Evo) { string text = null; if (itemDataAfter is WeaponDataItem) { text = "VO_M_Con_05_Weapon_Upgread"; } else if (itemDataAfter is StigmataDataItem) { text = "VO_M_Con_06_Stigmata_Upgread"; } if (text != null) { Singleton.Instance.Post(text); } } } public override bool OnNotify(Notify ntf) { if (ntf.type == NotifyTypes.PowerUpAndEvoEffect) { return PlayEffect(ntf); } return false; } public override bool OnPacket(NetPacketV1 pkt) { ushort cmdId = pkt.getCmdId(); if (cmdId == 196) { return OnSelectNewStigmataAffixRsp(pkt.getData()); } return false; } protected override void BindViewCallbacks() { BindViewCallback(base.view.transform.Find("Button").GetComponent