备份CatanBuilding瘦身独立工程
This commit is contained in:
8
Assets/Scripts/UI/Potion/Action.meta
Normal file
8
Assets/Scripts/UI/Potion/Action.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48f96480082419b4aaaa16d34bd880e2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/UI/Potion/Action/PotionAction.cs
Normal file
29
Assets/Scripts/UI/Potion/Action/PotionAction.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionAction
|
||||
{
|
||||
protected float m_WaitTime;
|
||||
public void SetWaitTime(float time)
|
||||
{
|
||||
m_WaitTime = time;
|
||||
}
|
||||
#region 生命周期
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
m_WaitTime -= deltaTime;
|
||||
}
|
||||
public virtual bool IsValid()
|
||||
{
|
||||
return m_WaitTime > 0f;
|
||||
}
|
||||
public virtual void Action()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/Action/PotionAction.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/Action/PotionAction.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1ee0091058c15c408b238b9e5b285df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Scripts/UI/Potion/Action/PotionDelay1Action.cs
Normal file
32
Assets/Scripts/UI/Potion/Action/PotionDelay1Action.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionDelay1Action : PotionAction
|
||||
{
|
||||
int m_Type = 0;
|
||||
PotionGridUI m_PotionGridUI;
|
||||
Action<int, PotionGridUI> m_Callback;
|
||||
|
||||
public void SetData(int type, PotionGridUI gridUI, Action<int, PotionGridUI> callback)
|
||||
{
|
||||
m_Type = type;
|
||||
m_PotionGridUI = gridUI;
|
||||
m_Callback = callback;
|
||||
}
|
||||
#region 生命周期
|
||||
public override void Action()
|
||||
{
|
||||
base.Action();
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback.Invoke(m_Type, m_PotionGridUI);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/Action/PotionDelay1Action.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/Action/PotionDelay1Action.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fedf046332e44e46b6024fd9f63f8ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Scripts/UI/Potion/Action/PotionDelayAction.cs
Normal file
36
Assets/Scripts/UI/Potion/Action/PotionDelayAction.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionDelayAction : PotionAction
|
||||
{
|
||||
int m_Type = 0;
|
||||
PotionGridUI m_TargetGridUI;
|
||||
PotionGridUI m_SrcGridUI;
|
||||
PotionGridUI m_TemporaryGridUI;
|
||||
public Func<int, PotionGridUI, PotionGridUI, PotionGridUI, int> m_Callback = null;
|
||||
|
||||
public void SetData(int type, PotionGridUI src, PotionGridUI target, PotionGridUI temporary, Func<int, PotionGridUI, PotionGridUI, PotionGridUI, int> callback)
|
||||
{
|
||||
m_Type = type;
|
||||
m_SrcGridUI = src;
|
||||
m_TargetGridUI = target;
|
||||
m_TemporaryGridUI = temporary;
|
||||
m_Callback = callback;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
public override void Action()
|
||||
{
|
||||
base.Action();
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback.Invoke(m_Type, m_SrcGridUI, m_TargetGridUI, m_TemporaryGridUI);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/Action/PotionDelayAction.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/Action/PotionDelayAction.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84eee872742bca94990c711790d84e39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/UI/Potion/EventPotionInfoPopupPanel.cs
Normal file
33
Assets/Scripts/UI/Potion/EventPotionInfoPopupPanel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class EventPotionInfoPopupPanel : BasePanel
|
||||
{
|
||||
Button btn_close;
|
||||
|
||||
#region UI
|
||||
private async void OnBtnCloseClickListener()
|
||||
{
|
||||
EventPotionDataManager dataManager = GContext.container.Resolve<EventPotionDataManager>();
|
||||
|
||||
await UIManager.Instance.ShowUI(dataManager.GetUIPanel());
|
||||
UIManager.Instance.DestroyUI(dataManager.GetInfoPanel());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
protected override void Start()
|
||||
{
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_close.onClick.AddListener(OnBtnCloseClickListener);
|
||||
base.Start();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/EventPotionInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/EventPotionInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b38cfe7413b8cf847ae6ef182e6c198b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1814
Assets/Scripts/UI/Potion/EventPotionPanel.cs
Normal file
1814
Assets/Scripts/UI/Potion/EventPotionPanel.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Scripts/UI/Potion/EventPotionPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/EventPotionPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29c37e579c4fb1d4e895649a08f0d0be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/Scripts/UI/Potion/EventPotionRewardPopupPanel.cs
Normal file
55
Assets/Scripts/UI/Potion/EventPotionRewardPopupPanel.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class EventPotionRewardPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnNormal;
|
||||
[SerializeField] private GameObject rewardRoot;
|
||||
[SerializeField] private ShootingRewardLayout normalRewardLayout;
|
||||
IDisposable disposable;
|
||||
public void Init(List<ItemData> rewardItems, bool isFinalStage = false)
|
||||
{
|
||||
btnNormal.onClick.AddListener(OnClickClaim);
|
||||
rewardRoot.SetActive(true);
|
||||
normalRewardLayout.SetRewards(rewardItems, true);
|
||||
}
|
||||
|
||||
private void OnClickClaim()
|
||||
{
|
||||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||||
GContext.Publish(curRewardQCount);
|
||||
if (curRewardQCount.count <= 0)
|
||||
{
|
||||
Exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
disposable = GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose);
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
}
|
||||
|
||||
void OnRewardPanelClose(RewardPanelClose rewardPanelClose)
|
||||
{
|
||||
Exit();
|
||||
}
|
||||
|
||||
void Exit()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
FishingPotionAct.Publish<EventPotionCloseCameraData>(new EventPotionCloseCameraData());
|
||||
// 关闭当前Act
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
UIManager.Instance.DestroyUI(UITypes.EventPotionRewardPopupPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/EventPotionRewardPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/EventPotionRewardPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeb059104ee23554b8be700668171444
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Scripts/UI/Potion/EventPotionRewardTips.cs
Normal file
63
Assets/Scripts/UI/Potion/EventPotionRewardTips.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class EventPotionRewardTips : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject rewardEmptyGo1, rewardEmptyGo2;
|
||||
[SerializeField] private GameObject[] rewardGos;
|
||||
[SerializeField] private RewardItemNew[] rewards;
|
||||
//[SerializeField] private TMP_Text textTarget, textOwned;
|
||||
[SerializeField] private Button btnClose;
|
||||
[SerializeField] private GameObject tipGo;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
tipGo.SetActive(false);
|
||||
btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.EventPotionRewardTips));
|
||||
}
|
||||
/// <summary>
|
||||
/// Init this tip.
|
||||
/// </summary>
|
||||
/// <param name="items">Items to be shown in this tip.</param>
|
||||
/// <param name="btnTransform">The position where this tip shows up.</param>
|
||||
public void Init(List<ItemData> items, Transform btnTransform = null)
|
||||
{
|
||||
if (items.Count == 1)
|
||||
{
|
||||
rewardEmptyGo1.SetActive(true);
|
||||
rewardEmptyGo2.SetActive(true);
|
||||
rewardGos[0].SetActive(true);
|
||||
for (int i = 1; i < rewardGos.Length; i++)
|
||||
{
|
||||
rewardGos[i].SetActive(false);
|
||||
}
|
||||
rewards[0].SetData(items[0]);
|
||||
}
|
||||
else if (items.Count > 1)
|
||||
{
|
||||
rewardEmptyGo1.SetActive(false);
|
||||
rewardEmptyGo2.SetActive(false);
|
||||
for (int i = 0; i < rewardGos.Length; i++)
|
||||
{
|
||||
rewardGos[i].SetActive(i < items.Count);
|
||||
if (i < items.Count)
|
||||
rewards[i].SetData(items[i]);
|
||||
}
|
||||
}
|
||||
// textPoint.text = LocalizationMgr.GetFormatTextValue("UI_EventPartnerFishbowlPanel_7", score, targetScore);
|
||||
//if (textOwned)
|
||||
// textOwned.text = LocalizationMgr.GetFormatTextValue("UI_item_tips_1", score);
|
||||
//if (textTarget)
|
||||
// textTarget.text = LocalizationMgr.GetFormatTextValue("UI_EventRankPopupPanel_16", targetScore);
|
||||
if (btnTransform)
|
||||
tipGo.transform.position = btnTransform.position;
|
||||
tipGo.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/EventPotionRewardTips.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/EventPotionRewardTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e342102b954460b43a7efe510c8eb8ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
491
Assets/Scripts/UI/Potion/PotionGridUI.cs
Normal file
491
Assets/Scripts/UI/Potion/PotionGridUI.cs
Normal file
@@ -0,0 +1,491 @@
|
||||
using cfg;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using Spine.Unity;
|
||||
using System;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionGridUI : MonoBehaviour
|
||||
{
|
||||
private int m_Index;
|
||||
public int Index { get { return m_Index; } }
|
||||
|
||||
private int m_ColorType;
|
||||
public int ColorType { get { return m_ColorType; } }
|
||||
|
||||
private bool m_IsIdle = false;
|
||||
public bool IsIdle {
|
||||
get { return m_IsIdle; }
|
||||
set
|
||||
{
|
||||
m_IsIdle = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private List<GameObject> m_PourWaterEffectList = new List<GameObject>();
|
||||
[SerializeField] private List<GameObject> m_JudgmentFailedEffectList = new List<GameObject>();
|
||||
|
||||
[SerializeField] private List<GameObject> m_AudioFlyList = new List<GameObject>();
|
||||
|
||||
[NonSerialized] public PotionGridUI fromPotionGridUI = null;
|
||||
|
||||
private PotionItemData m_Data;
|
||||
public PotionItemData ItemData { get { return m_Data; } }
|
||||
|
||||
private PotionItem m_PotionItem;
|
||||
public PotionItem PotionItem { get => m_PotionItem; }
|
||||
|
||||
private RectTransform m_RectTransform;
|
||||
private Button m_btn_gild;
|
||||
private Image m_bg_nml;
|
||||
private Image m_bg_light;
|
||||
private Image m_paint;
|
||||
private GameObject m_icon;
|
||||
private SkeletonGraphic m_spine_icon;
|
||||
private Animation m_Animation = null;
|
||||
|
||||
private UnityAction<PotionGridUI> m_Callback = null;
|
||||
|
||||
private EventPotionDataManager m_DataManager;
|
||||
|
||||
#region 音效相关
|
||||
public void CloseAudioFly()
|
||||
{
|
||||
foreach (var gameObject in m_AudioFlyList)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
public void OpenAudioFly()
|
||||
{
|
||||
foreach (var gameObject in m_AudioFlyList)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据相关
|
||||
public void SetData(PotionItemData pData, int pIndex, EventPotionBlock potionBlock, bool isShow)
|
||||
{
|
||||
if (isShow == false)
|
||||
{
|
||||
m_Index = pIndex;
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
gameObject.SetActive(true);
|
||||
|
||||
m_Data = pData;
|
||||
m_Index = pIndex;
|
||||
m_ColorType = m_Data.ColorTypeList[m_Index];
|
||||
|
||||
int itemType = m_ColorType;
|
||||
if (itemType > 100)
|
||||
{
|
||||
itemType = itemType % 100;
|
||||
|
||||
m_icon.gameObject.SetActive(false);
|
||||
m_paint.gameObject.SetActive(true);
|
||||
}
|
||||
else if (itemType > 0)
|
||||
{
|
||||
m_icon.gameObject.SetActive(true);
|
||||
m_paint.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_icon.gameObject.SetActive(false);
|
||||
m_paint.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
EventPotionResource res = m_DataManager.GetPotionResource(itemType);
|
||||
if (!string.IsNullOrEmpty(res.PaintResName)) m_paint.sprite = m_DataManager.SpriteAtlas.GetSprite(res.PaintResName);
|
||||
if (!string.IsNullOrEmpty(res.ItemResName)) SetIconSkin(res.ItemResName);
|
||||
|
||||
if (m_ColorType > 0 && m_ColorType < 100)
|
||||
{
|
||||
PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
}
|
||||
|
||||
if (potionBlock != null)
|
||||
{
|
||||
int num = m_Data.ColorTypeList.Count;
|
||||
m_bg_nml.sprite = m_DataManager.SpriteAtlas.GetSprite(potionBlock.ResourceList[m_Index]);
|
||||
m_bg_light.sprite = m_DataManager.SpriteAtlas.GetSprite(potionBlock.ResourceLightList[m_Index]);
|
||||
|
||||
if (m_Data.ShelfTypeList[m_Index] == EventPotionShelfType.Shelf_Success)
|
||||
{
|
||||
m_bg_nml.gameObject.SetActive(false);
|
||||
m_bg_light.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bg_nml.gameObject.SetActive(true);
|
||||
m_bg_light.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Copy(PotionGridUI potionGridUI, bool copyDataEntirely, bool copyPosition = true)
|
||||
{
|
||||
this.m_RectTransform.sizeDelta = potionGridUI.m_RectTransform.sizeDelta;
|
||||
this.m_RectTransform.localScale = potionGridUI.m_RectTransform.localScale;
|
||||
if (copyPosition)
|
||||
{
|
||||
this.m_RectTransform.position = potionGridUI.m_RectTransform.position;
|
||||
}
|
||||
|
||||
this.m_ColorType = potionGridUI.m_ColorType;
|
||||
if (this.m_ColorType > 0 && this.m_ColorType < 100)
|
||||
{
|
||||
EventPotionResource res = m_DataManager.GetPotionResource(this.m_ColorType);
|
||||
if (!string.IsNullOrEmpty(res.PaintResName) && !string.IsNullOrEmpty(res.ItemResName))
|
||||
{
|
||||
int typeIndex = res.TypeIndex;
|
||||
if (typeIndex >= 0 && typeIndex < res.TypeCount)
|
||||
{
|
||||
int count = m_PourWaterEffectList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i == typeIndex)
|
||||
{
|
||||
m_PourWaterEffectList[i].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PourWaterEffectList[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
count = m_JudgmentFailedEffectList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i == typeIndex)
|
||||
{
|
||||
m_JudgmentFailedEffectList[i].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_JudgmentFailedEffectList[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.m_paint.sprite = potionGridUI.m_paint.sprite;
|
||||
SetIconSkin(potionGridUI.GetIconSkin());
|
||||
}
|
||||
public void ResetImageSprite()
|
||||
{
|
||||
m_ColorType = m_Data.ColorTypeList[m_Index];
|
||||
if (m_ColorType <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int itemType = m_ColorType;
|
||||
if (itemType > 100)
|
||||
{
|
||||
itemType = itemType % 100;
|
||||
}
|
||||
|
||||
EventPotionResource res = m_DataManager.GetPotionResource(itemType);
|
||||
if (string.IsNullOrEmpty(res.PaintResName) == false) m_paint.sprite = m_DataManager.SpriteAtlas.GetSprite(res.PaintResName);
|
||||
if (string.IsNullOrEmpty(res.ItemResName) == false) SetIconSkin(res.ItemResName);
|
||||
|
||||
int num = m_Data.ColorTypeList.Count;
|
||||
EventPotionBlock potionBlock = m_DataManager.GetEventPotionBlock(num);
|
||||
if (potionBlock != null)
|
||||
{
|
||||
m_bg_nml.sprite = m_DataManager.SpriteAtlas.GetSprite(potionBlock.ResourceList[m_Index]);
|
||||
m_bg_light.sprite = m_DataManager.SpriteAtlas.GetSprite(potionBlock.ResourceLightList[m_Index]);
|
||||
}
|
||||
}
|
||||
public string GetIconSkin()
|
||||
{
|
||||
return m_spine_icon.Skeleton.Skin.Name;
|
||||
}
|
||||
public void SetIconSkin(string skin)
|
||||
{
|
||||
m_spine_icon.Skeleton.SetSkin(skin);
|
||||
}
|
||||
public void PlaySpinAnimation(int trackIndex, string animationName, bool loop)
|
||||
{
|
||||
m_spine_icon.AnimationState.SetAnimation(trackIndex, animationName, loop);
|
||||
}
|
||||
public void SetFromGridUI(PotionGridUI gridUI)
|
||||
{
|
||||
if (gridUI == null)
|
||||
{
|
||||
this.fromPotionGridUI = null;
|
||||
return;
|
||||
}
|
||||
this.fromPotionGridUI = gridUI;
|
||||
SetFromDisplayAreaIndex(gridUI.Index);
|
||||
}
|
||||
public int GetColorType()
|
||||
{
|
||||
if (m_Data == null) return -1;
|
||||
return m_Data.GetColorType(Index);
|
||||
}
|
||||
public void SetColorType(int type)
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
m_Data.SetColorType(m_Index, type);
|
||||
}
|
||||
public EventPotionShelfType GetShelfType()
|
||||
{
|
||||
if (m_Data == null) return EventPotionShelfType.Shelf_Default;
|
||||
return m_Data.ShelfTypeList[m_Index];
|
||||
}
|
||||
public void SetShelfTypeSuccess()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
m_Data.ShelfTypeList[m_Index] = EventPotionShelfType.Shelf_Success;
|
||||
}
|
||||
public void SetShelfTypeDefault()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
m_Data.ShelfTypeList[m_Index] = EventPotionShelfType.Shelf_Default;
|
||||
}
|
||||
public EventPotionGridState GetGridState()
|
||||
{
|
||||
if (m_Data == null) return EventPotionGridState.GridState_Invalid;
|
||||
return m_Data.GetGridState(m_Index);
|
||||
}
|
||||
public void SetGridState(EventPotionGridState state)
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
m_Data.SetGridState(m_Index, state);
|
||||
}
|
||||
public int GetFromDisplayAreaIndex()
|
||||
{
|
||||
if (m_Data == null) return -1;
|
||||
return m_Data.GetFromDisplayAreaIndex(m_Index);
|
||||
}
|
||||
public void SetFromDisplayAreaIndex(int value)
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
m_Data.SetFromDisplayAreaIndex(m_Index, value);
|
||||
}
|
||||
public int ClearFromPotionGridUI()
|
||||
{
|
||||
fromPotionGridUI = null;
|
||||
SetFromDisplayAreaIndex(-1);
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
public void Init(int gridIndex, UnityAction<PotionGridUI> btnCallback, PotionItem pItem, EventPotionDataManager pDataManager)
|
||||
{
|
||||
m_Index = gridIndex;
|
||||
m_Callback = btnCallback;
|
||||
m_PotionItem = pItem;
|
||||
m_DataManager = pDataManager;
|
||||
|
||||
m_RectTransform = transform.GetComponent<RectTransform>();
|
||||
|
||||
m_Animation = transform.GetComponent<Animation>();
|
||||
|
||||
m_btn_gild = transform.Find("btn_gild").GetComponent<Button>();
|
||||
m_btn_gild.onClick.RemoveAllListeners();
|
||||
m_btn_gild.onClick.AddListener(OnBtnClickListener);
|
||||
|
||||
m_bg_nml = transform.Find("btn_gild/bg_nml").GetComponent<Image>();
|
||||
m_bg_light = transform.Find("btn_gild/bg_light").GetComponent<Image>();
|
||||
m_paint = transform.Find("btn_gild/paint").GetComponent<Image>();
|
||||
m_icon = transform.Find("btn_gild/icon").gameObject;
|
||||
m_spine_icon = transform.Find("btn_gild/icon/spine").GetComponent<SkeletonGraphic>();
|
||||
|
||||
CloseAudioFly();
|
||||
}
|
||||
public void SetRootPosition(Vector3 position)
|
||||
{
|
||||
transform.GetComponent<RectTransform>().localPosition = position;
|
||||
}
|
||||
public void ShowIcon()
|
||||
{
|
||||
m_icon.gameObject.SetActive(true);
|
||||
}
|
||||
public bool IsIconActive()
|
||||
{
|
||||
return m_icon.activeSelf;
|
||||
}
|
||||
public bool IsBtnGildActive()
|
||||
{
|
||||
return m_btn_gild.gameObject.activeSelf;
|
||||
}
|
||||
public bool IsActive()
|
||||
{
|
||||
return this.gameObject.activeSelf;
|
||||
}
|
||||
public void HideUpperUI()
|
||||
{
|
||||
m_icon.gameObject.SetActive(false);
|
||||
m_paint.gameObject.SetActive(false);
|
||||
}
|
||||
public void HideNetherUI()
|
||||
{
|
||||
m_bg_nml.gameObject.SetActive(false);
|
||||
m_bg_light.gameObject.SetActive(false);
|
||||
}
|
||||
public void ShowPaint()
|
||||
{
|
||||
m_icon.gameObject.SetActive(false);
|
||||
m_paint.gameObject.SetActive(true);
|
||||
}
|
||||
public void SetPourWaterLeft()
|
||||
{
|
||||
GameObject gameObject = GetPourWaterEffectGameObject();
|
||||
RectTransform rectTransform = gameObject.transform.GetComponent<RectTransform>();
|
||||
if (rectTransform != null)
|
||||
{
|
||||
Vector3 localScale = rectTransform.localScale;
|
||||
localScale.x = 1;
|
||||
rectTransform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
public void SetPourWaterRight()
|
||||
{
|
||||
GameObject gameObject = GetPourWaterEffectGameObject();
|
||||
RectTransform rectTransform = gameObject.transform.GetComponent<RectTransform>();
|
||||
if (rectTransform != null)
|
||||
{
|
||||
Vector3 localScale = rectTransform.localScale;
|
||||
localScale.x = -1;
|
||||
rectTransform.localScale = localScale;
|
||||
}
|
||||
}
|
||||
private GameObject GetPourWaterEffectGameObject()
|
||||
{
|
||||
if (this.m_ColorType > 0 && this.m_ColorType < 100)
|
||||
{
|
||||
EventPotionResource res = m_DataManager.GetPotionResource(this.m_ColorType);
|
||||
if (!string.IsNullOrEmpty(res.PaintResName) && !string.IsNullOrEmpty(res.ItemResName))
|
||||
{
|
||||
int count = m_PourWaterEffectList.Count;
|
||||
if (res.TypeIndex >= 0 && res.TypeIndex < count)
|
||||
{
|
||||
return m_PourWaterEffectList[res.TypeIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 动画相关
|
||||
public void PlayAnimation(string anim)
|
||||
{
|
||||
if (m_Animation == null || string.IsNullOrEmpty(anim) == true) return;
|
||||
m_Animation.Play(anim);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 展示区处理
|
||||
public IEnumerator HandleShowStep(float delayTime, float waitforSpineTime, string spineAnim, float spineDurationTime, EventPotionGridState gridState)
|
||||
{
|
||||
yield return new WaitForSeconds(delayTime);
|
||||
|
||||
if (gridState == EventPotionGridState.GridState_Empty)
|
||||
{
|
||||
this.gameObject.SetActive(true);
|
||||
PlayAnimation(EventPotionConfig.anim_gild_show);
|
||||
PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
|
||||
yield return new WaitForSeconds(waitforSpineTime);
|
||||
|
||||
PlaySpinAnimation(0, spineAnim, true);
|
||||
|
||||
yield return new WaitForSeconds(spineDurationTime);
|
||||
|
||||
PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
//public IEnumerator HandleShowStep2(float delayTime, EventPotionGridState gridState)
|
||||
//{
|
||||
// yield return new WaitForSeconds(delayTime);
|
||||
// //PlaySpinAnimation(0, "potion_idle", true);
|
||||
// PlaySpinAnimation(0, "potion_idle", true);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 引导相关
|
||||
public void FirstWrongGuide()
|
||||
{
|
||||
Canvas canvas = gameObject.AddComponent<Canvas>();
|
||||
canvas.overrideSorting = true;
|
||||
canvas.sortingOrder = 10;
|
||||
canvas.additionalShaderChannels = AdditionalCanvasShaderChannels.TexCoord1;
|
||||
|
||||
m_btn_gild.enabled = false;
|
||||
}
|
||||
public void ResumeFromGuide()
|
||||
{
|
||||
Canvas canvas = gameObject.GetComponent<Canvas>();
|
||||
if (canvas != null)
|
||||
{
|
||||
Destroy(canvas);
|
||||
}
|
||||
m_btn_gild.enabled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 操作相关
|
||||
private bool m_IsLocking = false;
|
||||
public void LockOperation()
|
||||
{
|
||||
m_IsLocking = true;
|
||||
}
|
||||
public void UnlockOperation()
|
||||
{
|
||||
m_IsLocking = false;
|
||||
}
|
||||
public void SetTemporaryData(PotionGridUI src)
|
||||
{
|
||||
Clear();
|
||||
IsIdle = false;
|
||||
Copy(src, true);
|
||||
//fromPotionGridUI = src;
|
||||
SetFromGridUI(src);
|
||||
LockOperation();
|
||||
gameObject.SetActive(true);
|
||||
//PlayAnimation(anim);
|
||||
}
|
||||
public void ChangeToSuccess(PotionGridUI item)
|
||||
{
|
||||
if (m_DataManager == null) return;
|
||||
item.PlayAnimation("gild_success");
|
||||
//int num = data.ItemTypeList.Count;
|
||||
//EventPotionBlock potionBlock = m_DataManager.GetEventPotionBlock(num);
|
||||
//if (data.ShelfTypeList[index] == EventPotionShelfType.Shelf_Success)
|
||||
// bg_nml.sprite = m_DataManager.SpriteAtlas.GetSprite(potionBlock.ResourceLightList[index]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void OnBtnClickListener()
|
||||
{
|
||||
if (m_Data == null || m_Data.isOver) return;
|
||||
if (m_IsLocking == true) return;
|
||||
if (m_Callback != null) m_Callback(this);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
fromPotionGridUI = null;
|
||||
IsIdle = true;
|
||||
m_IsLocking = false;
|
||||
CloseAudioFly();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/PotionGridUI.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/PotionGridUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc347e619ba8f5d4ea6d6264f3d312b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
461
Assets/Scripts/UI/Potion/PotionItem.cs
Normal file
461
Assets/Scripts/UI/Potion/PotionItem.cs
Normal file
@@ -0,0 +1,461 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionItem : EnhancedScrollerCellView
|
||||
{
|
||||
public void SetData(EventPotionPanel potionPanel, EventPotionDataManager dataManager, PotionItemData data)
|
||||
{
|
||||
m_Panel = potionPanel;
|
||||
m_DataManager = dataManager;
|
||||
m_Data = data;
|
||||
if (!m_IsInited) InitUI();
|
||||
if (data.DataType == EventPotionDataType.Data_Wall)
|
||||
{
|
||||
shadow.gameObject.SetActive(false);
|
||||
int count = m_GridList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
m_GridList[i].Clear();
|
||||
m_GridList[i].SetData(data, i, null, false);
|
||||
}
|
||||
}
|
||||
else if (data.DataType == EventPotionDataType.Data_Item || data.DataType == EventPotionDataType.Data_ItemAndOperation)
|
||||
{
|
||||
int count = m_GridList.Count;
|
||||
int num = data.ColorTypeList.Count;
|
||||
data.Log("111 " + this.gameObject.name);
|
||||
EventPotionBlock potionBlock = m_DataManager.GetEventPotionBlock(num);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
m_GridList[i].Clear();
|
||||
if (i < num)
|
||||
{
|
||||
int itemType = data.ColorTypeList[i];
|
||||
m_GridList[i].SetData(data, i, potionBlock, true);
|
||||
HandleFromPotionGridUI(m_GridList[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_GridList[i].SetData(data, i, potionBlock, false);
|
||||
}
|
||||
}
|
||||
data.Log("222 " + this.gameObject.name);
|
||||
shadowRectTransform.sizeDelta = new Vector2(potionBlock.ShadowLength, shadowRectTransform.sizeDelta.y);
|
||||
shadow.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
#region 数据相关
|
||||
private EventPotionDataManager m_DataManager;
|
||||
private PotionItemData m_Data;
|
||||
public PotionItemData Data { get { return m_Data; } }
|
||||
|
||||
public int GetVaildNum()
|
||||
{
|
||||
if (m_Data == null) return 0;
|
||||
return m_Data.ColorTypeList.Count;
|
||||
}
|
||||
public int GetLastValidIndex()
|
||||
{
|
||||
int count = GetVaildNum();
|
||||
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
{
|
||||
var gridState = m_Data.GetGridState(i);
|
||||
if (gridState == EventPotionGridState.GridState_Over) continue;
|
||||
if (gridState == EventPotionGridState.GridState_Occupied && m_Data.GetColorType(i) > 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GridUI从操作区跳回展示区操作
|
||||
public int HandleFromPotionGridUI(PotionGridUI gridUI)
|
||||
{
|
||||
if (gridUI == null) return 0;
|
||||
if (m_Panel == null) return 0;
|
||||
if (m_DataManager == null) return 0;
|
||||
|
||||
int num = m_DataManager.PotionData.LevelDisplayData.ColorTypeList.Count;
|
||||
int fromDisplayAreaIndex = gridUI.GetFromDisplayAreaIndex();
|
||||
|
||||
if (fromDisplayAreaIndex < 0 || fromDisplayAreaIndex >= num) return gridUI.ClearFromPotionGridUI();
|
||||
|
||||
PotionGridUI displayPotionGridUI = m_Panel.GetDisplayPotionGridUI(fromDisplayAreaIndex);
|
||||
if (displayPotionGridUI == null) return gridUI.ClearFromPotionGridUI();
|
||||
|
||||
//gridUI.fromPotionGridUI = displayPotionGridUI;
|
||||
gridUI.SetFromGridUI(displayPotionGridUI);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 操作相关
|
||||
public bool CheckOperationAreaIsAllOnline()
|
||||
{
|
||||
if (m_Data == null) return false;
|
||||
|
||||
int count = m_Data.ColorTypeList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
EventPotionGridState gridState = m_Data.GridStateList[i];
|
||||
// 于该位置,状态应该为 GridState_Occupied 或者 GridState_Over
|
||||
if (gridState != EventPotionGridState.GridState_Occupied && gridState != EventPotionGridState.GridState_Over)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int colorType = m_Data.ColorTypeList[i];
|
||||
if (colorType <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool CheckGridListIsAllOnline()
|
||||
{
|
||||
if (m_Data == null) return false;
|
||||
|
||||
int count = m_Data.ColorTypeList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (m_Data.ColorTypeList[i] <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool CheckOperationIsOver()
|
||||
{
|
||||
if (m_Data == null) return true;
|
||||
|
||||
int count = m_Data.ColorTypeList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var item = m_GridList[i];
|
||||
|
||||
EventPotionGridState gridState = item.GetGridState();
|
||||
if (gridState == EventPotionGridState.GridState_Over) continue;
|
||||
|
||||
if (gridState != EventPotionGridState.GridState_Wrong && gridState != EventPotionGridState.GridState_Ok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool CheckGridListIsAllOccupied()
|
||||
{
|
||||
foreach (var gridUI in m_GridList)
|
||||
{
|
||||
if (gridUI.GetGridState() == EventPotionGridState.GridState_Occupied)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool CheckGridListIsOk(Action<int, PotionGridUI> successCallback, Action<int, PotionGridUI> wrongCallback)
|
||||
{
|
||||
if (m_Data == null || m_Panel == null) return false;
|
||||
|
||||
bool flag = true;
|
||||
int count = m_GridList.Count;
|
||||
int num = m_Data.ColorTypeList.Count;
|
||||
float baseTime = m_Panel.check_base_waiting_time;
|
||||
float gapTime = m_Panel.check_gap_time;
|
||||
int lastIndex = num - 1;
|
||||
|
||||
m_Panel.CommitColorTypeList.Clear();
|
||||
|
||||
for (var i = num - 1; i >= 0; --i)
|
||||
{
|
||||
if (i == lastIndex && m_Data.GridStateList[i] == EventPotionGridState.GridState_Over)
|
||||
{
|
||||
lastIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i < num)
|
||||
{
|
||||
float time = baseTime + index * gapTime;
|
||||
var item = m_GridList[i];
|
||||
EventPotionGridState gridState = item.GetGridState();
|
||||
if (gridState == EventPotionGridState.GridState_Over)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int colorType = item.GetColorType() % 100;
|
||||
|
||||
m_Panel.CommitColorTypeList.Add(colorType);
|
||||
|
||||
if (colorType == m_DataManager.PotionData.LevelTargetData.ColorTypeList[i])
|
||||
{
|
||||
m_DataManager.PotionData.CorrectNum++;
|
||||
item.SetShelfTypeSuccess();
|
||||
item.SetGridState(EventPotionGridState.GridState_Ok);
|
||||
if (item.fromPotionGridUI != null)
|
||||
{
|
||||
item.fromPotionGridUI.SetGridState(EventPotionGridState.GridState_Ok);
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (i == lastIndex)
|
||||
{
|
||||
m_Data.isOver = true;
|
||||
m_Panel.StartCoroutine(HandleCheckSucessStep(1, item, time, successCallback));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Panel.StartCoroutine(HandleCheckSucessStep(1, item, time, null));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_Panel.StartCoroutine(PotionGridUIChangeToSuccess(1, item, time + 0.1f, i == lastIndex, wrongCallback, m_Panel.Animation_Time_Vase_Success + 2f));
|
||||
m_Panel.StartCoroutine(HandleCheckSucessStep(1, item, time, i == lastIndex ? wrongCallback : null));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
|
||||
item.SetGridState(EventPotionGridState.GridState_Wrong);
|
||||
|
||||
//if (item.fromPotionGridUI != null)
|
||||
//{
|
||||
// item.fromPotionGridUI.SetGridState(EventPotionGridState.GridState_Wrong);
|
||||
//}
|
||||
|
||||
int itemType = colorType;
|
||||
itemType = 100 + itemType;
|
||||
item.SetColorType(itemType);
|
||||
item.ResetImageSprite();
|
||||
|
||||
m_Panel.StartCoroutine(HandleCheckWrongStep(1, item, time, i == lastIndex ? wrongCallback : null));
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public IEnumerator HandleCheckSucessStep(int type, PotionGridUI gridUI, float waitTime, Action<int, PotionGridUI> callback)
|
||||
{
|
||||
gridUI.PlaySpinAnimation(0, m_Panel.check_spine_shake1_anim, true);
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
|
||||
gridUI.PlayAnimation(EventPotionConfig.anim_gild_success);
|
||||
|
||||
yield return new WaitForSeconds(m_Panel.check_waitfor_spine_shake2_time);
|
||||
|
||||
gridUI.PlaySpinAnimation(0, m_Panel.check_spine_shake2_anim, true);
|
||||
|
||||
yield return new WaitForSeconds(m_Panel.check_spine_shake2_duration_time);
|
||||
|
||||
gridUI.PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.Invoke(type, gridUI);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator HandleCheckWrongStep(int type, PotionGridUI gridUI, float waitTime, Action<int, PotionGridUI> callback)
|
||||
{
|
||||
gridUI.PlaySpinAnimation(0, m_Panel.check_spine_shake1_anim, true);
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
|
||||
gridUI.PlayAnimation(EventPotionConfig.anim_gild_wrong);
|
||||
|
||||
yield return new WaitForSeconds(m_Panel.check_waitfor_spine_shake2_time);
|
||||
|
||||
//gridUI.PlaySpinAnimation(0, m_Panel.check_spine_shake2_anim, true);
|
||||
|
||||
yield return new WaitForSeconds(m_Panel.check_spine_shake2_duration_time);
|
||||
|
||||
//gridUI.PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.Invoke(type, gridUI);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset_FromPotionGridUI_GridState()
|
||||
{
|
||||
int count = m_GridList.Count;
|
||||
foreach (var item in m_GridList)
|
||||
{
|
||||
if (item.fromPotionGridUI != null)
|
||||
{
|
||||
EventPotionGridState gridState = item.fromPotionGridUI.GetGridState();
|
||||
if (gridState == EventPotionGridState.GridState_Ok)
|
||||
{
|
||||
item.fromPotionGridUI.SetGridState(EventPotionGridState.GridState_Over);
|
||||
}
|
||||
else if (gridState == EventPotionGridState.GridState_Wrong)
|
||||
{
|
||||
item.fromPotionGridUI.SetGridState(EventPotionGridState.GridState_Empty);
|
||||
}
|
||||
else if (gridState == EventPotionGridState.GridState_Occupied)
|
||||
{
|
||||
item.fromPotionGridUI.SetGridState(EventPotionGridState.GridState_Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerator HandleJumpDownStep(int type, PotionGridUI src, PotionGridUI target, PotionGridUI temporary)
|
||||
{
|
||||
yield return new WaitForSeconds(m_Panel.jumpdown_waitfor_spine_shake_time);
|
||||
|
||||
target.PlaySpinAnimation(0, m_Panel.jumpdown_spine_shake_anim, true);
|
||||
target.ShowIcon();
|
||||
target.gameObject.SetActive(true);
|
||||
|
||||
temporary.IsIdle = true;
|
||||
temporary.gameObject.SetActive(false);
|
||||
|
||||
yield return new WaitForSeconds(m_Panel.jumpdown_spine_shake_duration_time);
|
||||
|
||||
m_Panel.StopLockClickOperation();
|
||||
|
||||
target.PlaySpinAnimation(0, EventPotionConfig.spine_potion_idle, true);
|
||||
}
|
||||
|
||||
public bool HandleJumpDown(PotionGridUI gridUI)
|
||||
{
|
||||
// 找到停靠点
|
||||
if (gridUI.fromPotionGridUI == null) return false;
|
||||
PotionGridUI target = gridUI.fromPotionGridUI;
|
||||
target.Copy(gridUI, false, false);
|
||||
target.HideUpperUI();
|
||||
|
||||
// 找到用于显示飞行轨迹的临时PotionGridUI并初始化和播放初始动画
|
||||
PotionGridUI temporary = m_Panel.GetIdleTemporaryGridUI();
|
||||
if (temporary == null) return false;
|
||||
temporary.SetTemporaryData(gridUI);
|
||||
|
||||
// 返还代币
|
||||
m_Panel.ConsumeTokens(EventPotionConfig.Token_Return_Num);
|
||||
|
||||
// 锁定操作
|
||||
m_Panel.StartLockClickOperation();
|
||||
m_Panel.StartLockScrollView();
|
||||
|
||||
// 更新数据
|
||||
gridUI.SetGridState(EventPotionGridState.GridState_Empty);
|
||||
gridUI.SetColorType(-1);
|
||||
gridUI.HideUpperUI();
|
||||
gridUI.ClearFromPotionGridUI();
|
||||
|
||||
target.SetGridState(EventPotionGridState.GridState_Empty);
|
||||
|
||||
temporary.PlaySpinAnimation(0, EventPotionConfig.spine_potion_fly, true);
|
||||
temporary.PlayAnimation(EventPotionConfig.anim_gild_jump_down);
|
||||
|
||||
Vector3 targetPosition = target.transform.position;
|
||||
temporary.DOKill();
|
||||
temporary.transform.DOMove(targetPosition, m_Panel.jumpdown_move_duration_time).SetEase(Ease.OutQuad);
|
||||
|
||||
m_Panel.StartCoroutine(HandleJumpDownStep(1, gridUI, target, temporary));
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 引导相关
|
||||
public void ResumeFromGuide()
|
||||
{
|
||||
if (m_GridList == null || m_GridList.Count < 1) return;
|
||||
|
||||
foreach (var gridUI in m_GridList)
|
||||
{
|
||||
gridUI.ResumeFromGuide();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReturnAllUncertainGridUI()
|
||||
{
|
||||
int count = m_GridList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var gridUI = m_GridList[i];
|
||||
if (gridUI.GetGridState() == EventPotionGridState.GridState_Over) continue;
|
||||
|
||||
HandleJumpDown(gridUI);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
private EventPotionPanel m_Panel;
|
||||
private bool m_IsInited = false;
|
||||
private List<PotionGridUI> m_GridList = new List<PotionGridUI>();
|
||||
public List<PotionGridUI> GridList { get => m_GridList; }
|
||||
private Image shadow;
|
||||
private RectTransform shadowRectTransform;
|
||||
private void InitUI()
|
||||
{
|
||||
shadow = transform.Find("shadow").GetComponent<Image>();
|
||||
shadowRectTransform = shadow.GetComponent<RectTransform>();
|
||||
int num = 8;
|
||||
for (int i = 1; i < num; i++)
|
||||
{
|
||||
PotionGridUI gridUI = transform.Find($"gild_group/gild{i}").GetComponent<PotionGridUI>();
|
||||
gridUI.Init(i - 1, OnBtnClickCallback, this, m_DataManager);
|
||||
|
||||
m_GridList.Add(gridUI);
|
||||
}
|
||||
|
||||
m_IsInited = true;
|
||||
}
|
||||
|
||||
public PotionGridUI GetGridUI(int index)
|
||||
{
|
||||
if (m_GridList == null || m_GridList.Count < 1) return null;
|
||||
if (index < 0 || index > m_GridList.Count) return null;
|
||||
return m_GridList[index];
|
||||
}
|
||||
public void OnBtnClickCallback(PotionGridUI gridUI)
|
||||
{
|
||||
if (m_Panel.IsClickOperationLocked) return;
|
||||
|
||||
HandleJumpDown(gridUI);
|
||||
|
||||
if (m_DataManager != null)
|
||||
{
|
||||
m_DataManager.SyncData();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/PotionItem.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/PotionItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17d92a3c8dc8c514a82be41071a78e61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
119
Assets/Scripts/UI/Potion/PotionScrollViewController.cs
Normal file
119
Assets/Scripts/UI/Potion/PotionScrollViewController.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using asap.core;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionScrollViewController : EnhancedScroller, IEnhancedScrollerDelegate
|
||||
{
|
||||
private EventPotionPanel m_Panel;
|
||||
private EventPotionDataManager m_DataManager;
|
||||
|
||||
public void Init(EnhancedScroller scroller, EventPotionPanel potionPanel, EventPotionDataManager dataManager)
|
||||
{
|
||||
m_Scroller = scroller;
|
||||
m_Panel = potionPanel;
|
||||
m_DataManager = dataManager;
|
||||
|
||||
InitScrollerListData();
|
||||
|
||||
m_Scroller.Delegate = this;
|
||||
m_Scroller.cellViewVisibilityChanged = CellViewVisibilityChanged;
|
||||
m_Scroller.cellViewWillRecycle = CellViewWillRecycle;
|
||||
m_Scroller.ReloadData();
|
||||
}
|
||||
|
||||
#region 操作相关
|
||||
public void LockScrollView()
|
||||
{
|
||||
if (ScrollRect.vertical)
|
||||
{
|
||||
ScrollRect.vertical = false;
|
||||
}
|
||||
}
|
||||
public void UnlockScrollView()
|
||||
{
|
||||
if (!ScrollRect.vertical)
|
||||
{
|
||||
ScrollRect.vertical = true;
|
||||
}
|
||||
}
|
||||
|
||||
public PotionItem GetOperationPotionItem()
|
||||
{
|
||||
if (Container == null) return null;
|
||||
PotionItem[] items = Container.GetComponentsInChildren<PotionItem>();
|
||||
if (items == null || items.Length < 1) return null;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Data.DataType == EventPotionDataType.Data_ItemAndOperation) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region EnhancedScroller Handlers
|
||||
private EnhancedScroller m_Scroller;
|
||||
public PotionItem potionItem;
|
||||
List<PotionItemData> scrollerDataList = new List<PotionItemData>();
|
||||
|
||||
void InitScrollerListData()
|
||||
{
|
||||
scrollerDataList = m_DataManager.ScrollerDataList;
|
||||
}
|
||||
public int GetTypeDataIndex(EventPotionDataType dataType, int index)
|
||||
{
|
||||
if (dataType == EventPotionDataType.Data_Wall)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
else if (dataType == EventPotionDataType.Data_ItemAndOperation)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int tmp = m_Panel.ScrollViewMinimumQuantity - 1;
|
||||
return index - tmp;
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
PotionItem cellView = scroller.GetCellView(potionItem) as PotionItem;
|
||||
var data = scrollerDataList[dataIndex];
|
||||
cellView.gameObject.name = data.DataType + "-" + GetTypeDataIndex(data.DataType, dataIndex);
|
||||
cellView.SetData(m_Panel, m_DataManager, data);
|
||||
return cellView;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
return 200f;
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return scrollerDataList.Count;
|
||||
}
|
||||
|
||||
private void CellViewVisibilityChanged(EnhancedScrollerCellView cellView)
|
||||
{
|
||||
|
||||
}
|
||||
private void CellViewWillRecycle(EnhancedScrollerCellView cellView)
|
||||
{
|
||||
PotionItem potionItem = cellView as PotionItem;
|
||||
string name = "Recycle-";
|
||||
if (potionItem != null)
|
||||
{
|
||||
if (potionItem.Data != null)
|
||||
{
|
||||
name += potionItem.Data.DataType + "-";
|
||||
}
|
||||
name += potionItem.dataIndex + "-" + potionItem.cellIndex;
|
||||
}
|
||||
cellView.gameObject.name = name;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/PotionScrollViewController.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/PotionScrollViewController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 711f65df6aa1b2d4d88232c2d02ecf97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Scripts/UI/Potion/PotionWallItem.cs
Normal file
15
Assets/Scripts/UI/Potion/PotionWallItem.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionWallItem : EnhancedScrollerCellView
|
||||
{
|
||||
public void SetData(PotionItemData data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Potion/PotionWallItem.cs.meta
Normal file
11
Assets/Scripts/UI/Potion/PotionWallItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9771955b96e1e3c4d846beae41a6a0a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Scripts/UI/Potion/PotionWallScrollViewController.cs
Normal file
54
Assets/Scripts/UI/Potion/PotionWallScrollViewController.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using asap.core;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PotionWallScrollViewController : EnhancedScroller, IEnhancedScrollerDelegate
|
||||
{
|
||||
private EventPotionDataManager m_DataManager;
|
||||
|
||||
public void Init(EnhancedScroller scroller, EventPotionDataManager dataManager)
|
||||
{
|
||||
m_Scroller = scroller;
|
||||
m_DataManager = dataManager;
|
||||
|
||||
InitScrollerListData();
|
||||
|
||||
m_Scroller.Delegate = this;
|
||||
|
||||
m_Scroller.ReloadData();
|
||||
}
|
||||
|
||||
#region EnhancedScroller Handlers
|
||||
private EnhancedScroller m_Scroller;
|
||||
public PotionWallItem potionWallItem;
|
||||
List<PotionItemData> scrollerDataList = new List<PotionItemData>();
|
||||
|
||||
void InitScrollerListData()
|
||||
{
|
||||
scrollerDataList = m_DataManager.ScrollerDataList;
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
PotionWallItem cellView = scroller.GetCellView(potionWallItem) as PotionWallItem;
|
||||
var data = scrollerDataList[dataIndex];
|
||||
cellView.SetData(data);
|
||||
return cellView;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
return 200f;
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return scrollerDataList.Count;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a2de924a877b254fba015753ceac115
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user