备份CatanBuilding瘦身独立工程
This commit is contained in:
82
Assets/Scripts/EventGatherCore/EventGatherCoreRewardView.cs
Normal file
82
Assets/Scripts/EventGatherCore/EventGatherCoreRewardView.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using asap.core;
|
||||
using Game;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventGatherCoreRewardView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RewardItemNew reward;
|
||||
[SerializeField] private GameObject backgroundNormal, backgroundSpecial, fxHit;
|
||||
public RectTransform RewardIcon => reward.icon.rectTransform;
|
||||
public RectTransform Text => reward.text_num.rectTransform;
|
||||
private EventGatherCoreTriggerItemFly _flyingTrigger;
|
||||
private int _idx;
|
||||
public int RewardIndex => _idx;
|
||||
private int _id;
|
||||
public int RewardId => _id;
|
||||
public bool IsClaimed => reward.received.activeSelf;
|
||||
private string _sfxHit;
|
||||
|
||||
public void Init(EventGatherCoreRewardInfo info, EventGatherCoreTriggerItemFly fly, string audioUrl)
|
||||
{
|
||||
_idx = info.Idx;
|
||||
if (info.ItemData != null)
|
||||
reward.SetData(info.ItemData);
|
||||
else
|
||||
reward.gameObject.SetActive(false);
|
||||
backgroundSpecial.SetActive(info.IsSpecial);
|
||||
backgroundNormal.SetActive(!info.IsSpecial);
|
||||
reward.SetReceived(info.IsClaimed);
|
||||
_flyingTrigger = fly;
|
||||
fxHit.SetActive(false);
|
||||
_sfxHit = audioUrl;
|
||||
}
|
||||
|
||||
public void Set(EventGatherCoreRewardInfo info)
|
||||
{
|
||||
_idx = info.Idx;
|
||||
if (info.ItemData != null)
|
||||
reward.SetData(info.ItemData);
|
||||
else
|
||||
reward.gameObject.SetActive(false);
|
||||
backgroundSpecial.SetActive(info.IsSpecial);
|
||||
backgroundNormal.SetActive(!info.IsSpecial);
|
||||
reward.gameObject.SetActive(!info.IsClaimed);
|
||||
fxHit.SetActive(false);
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task OnTriggerAsync(Vector2 position, float triggerItemShakeDuration,
|
||||
float triggerItemKickDuration, float triggerItemFlyDuration, float triggerItemHitDuration)
|
||||
{
|
||||
var itemFly = new CollectionItemFly
|
||||
{
|
||||
iconName = "sp_football_ball",
|
||||
numStr = "",
|
||||
targetIconSize = reward.icon.rectTransform.rect.width,
|
||||
sourcePos = position,
|
||||
destPos = reward.icon.transform.position,
|
||||
isPlayOpen = false,
|
||||
isPlayClose = false,
|
||||
};
|
||||
var flyingItem = Instantiate(_flyingTrigger.gameObject, transform.parent).GetComponent<EventGatherCoreTriggerItemFly>();
|
||||
flyingItem.gameObject.SetActive(true);
|
||||
// Debug.Log("[EventGatherCore] 1: shake.");
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(triggerItemShakeDuration));
|
||||
// Debug.Log("[EventGatherCore] 2: kick.");
|
||||
flyingItem.showDuration = triggerItemKickDuration;
|
||||
flyingItem.flyDuration = triggerItemFlyDuration;
|
||||
await flyingItem.ShowAsync(itemFly);
|
||||
Destroy(flyingItem.gameObject);
|
||||
fxHit.SetActive(true);
|
||||
GContext.Publish(new EventUISound(_sfxHit));
|
||||
// Debug.Log("[EventGatherCore] 4: Hit.");
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(triggerItemHitDuration));
|
||||
// Debug.Log("[EventGatherCore] 5: Reward.");
|
||||
reward.SetReceived(true);
|
||||
}
|
||||
|
||||
public void SetReceived()
|
||||
{
|
||||
fxHit.SetActive(true);
|
||||
reward.SetReceived(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user