备份CatanBuilding瘦身独立工程
This commit is contained in:
8
Assets/Scripts/SupplyDrop/GrabCashFloatingNum.cs
Normal file
8
Assets/Scripts/SupplyDrop/GrabCashFloatingNum.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class GrabCashFloatingNum : MonoBehaviour
|
||||
{
|
||||
public TMP_Text num;
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/GrabCashFloatingNum.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/GrabCashFloatingNum.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c02063fa963db2e42a7366418ae505ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
151
Assets/Scripts/SupplyDrop/GrabCashPanel.cs
Normal file
151
Assets/Scripts/SupplyDrop/GrabCashPanel.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GrabCashPanel : MonoBehaviour
|
||||
{
|
||||
public float RollingTimer = 1.5f;
|
||||
|
||||
GameObject root;
|
||||
Transform GrabCashRewardPanel;
|
||||
Transform GrabCashInfoPanel;
|
||||
Button btn_play;
|
||||
List<TMP_Text> result_text_num = new List<TMP_Text>();
|
||||
TMP_Text result_text;
|
||||
Button btn_confirm;
|
||||
SupplyDropGameplayCashCtrl ctrl;
|
||||
int layerMask;
|
||||
Camera ui3d;
|
||||
int allCashCount = 0;
|
||||
List<int> cashType = new List<int>() { 0, 0, 0, 0 };
|
||||
bool inUse = false;
|
||||
private void Awake()
|
||||
{
|
||||
root = transform.Find("root").gameObject;
|
||||
GrabCashRewardPanel = transform.Find("GrabCashRewardPanel");
|
||||
btn_play = GrabCashRewardPanel.Find("root/reward/receive/btn_play/btn_green").GetComponent<Button>();
|
||||
Transform result = GrabCashRewardPanel.Find("root/reward/result");
|
||||
int textCount = result.childCount;
|
||||
for (int i = 0; i < textCount; i++)
|
||||
{
|
||||
result_text_num.Add(result.Find($"result{i + 1}/text_num").GetComponent<TMP_Text>());
|
||||
}
|
||||
|
||||
result_text = GrabCashRewardPanel.Find("root/reward/reward_layout/text_num").GetComponent<TMP_Text>();
|
||||
|
||||
GrabCashInfoPanel = transform.Find("GrabCashInfoPanel");
|
||||
btn_confirm = GrabCashInfoPanel.Find("root/btn_confirm/btn_green").GetComponent<Button>();
|
||||
|
||||
layerMask = 1 << LayerMask.NameToLayer("UI3D");
|
||||
ui3d = UIManager.Instance.UI3DCamera;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (inUse && Input.GetMouseButtonUp(0))
|
||||
{
|
||||
var ray = ui3d.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out var hit, 100, layerMask))
|
||||
{
|
||||
SupplyDropCashItem item = hit.collider.transform.GetComponentInParent<SupplyDropCashItem>();
|
||||
if (item != null)
|
||||
{
|
||||
//Debug.Log($"<color=#e94242>SupplyDropCashGame: {item.cashCount}</color>");
|
||||
allCashCount += item.cashCount;
|
||||
cashType[item.type]++;
|
||||
OnClick(item);
|
||||
if (item.type == 3)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_supplydrop_minigame_cashgun_click_big"));
|
||||
|
||||
}
|
||||
else
|
||||
GContext.Publish(new EventUISound("audio_supplydrop_minigame_cashgun_click_normal"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Clicked on an invalid item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick(SupplyDropCashItem item)
|
||||
{
|
||||
//飘字,播放特效
|
||||
//Vector3 w = UIManager.Instance.UI3DWordlToScreen(item.);
|
||||
ctrl.ShowNum(item);
|
||||
item.OnClick();
|
||||
item.transform.DOKill();
|
||||
item.transform.DOScale(Vector3.zero, 0.5f).OnComplete(() =>
|
||||
{
|
||||
ctrl.Recycle(item, true);
|
||||
});
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btn_play.onClick.AddListener(Disable);
|
||||
btn_confirm.onClick.AddListener(Disable);
|
||||
}
|
||||
public void Init(SupplyDropGameplayCashCtrl supplyDropGameCtrl)
|
||||
{
|
||||
ctrl = supplyDropGameCtrl;
|
||||
}
|
||||
|
||||
|
||||
public void SetUse()
|
||||
{
|
||||
inUse = true;
|
||||
}
|
||||
|
||||
public void GameOver()
|
||||
{
|
||||
inUse = false;
|
||||
root.SetActive(false);
|
||||
if (allCashCount > 0)
|
||||
{
|
||||
ctrl.AddPlayerItem(new ItemData(1002, allCashCount));
|
||||
GrabCashRewardPanel.gameObject.SetActive(true);
|
||||
for (int i = 0; i < result_text_num.Count; i++)
|
||||
{
|
||||
result_text_num[i].text = $"x{cashType[i]}";
|
||||
}
|
||||
//result_text.SetData(new ItemData(1002, allCashCount));
|
||||
float progress = 0f;
|
||||
DOTween.To(() => progress, x => progress = x, 1f, RollingTimer).OnUpdate(() =>
|
||||
{
|
||||
result_text.text = ConvertTools.GetNumberString2((int)(allCashCount * progress));
|
||||
}).SetId("AddCash");
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("supplydrop_game_cashgun"))
|
||||
{
|
||||
e.AddContent("reward_totalcash", allCashCount)
|
||||
.AddContent("count_cash_1", cashType[0])
|
||||
.AddContent("count_cash_2", cashType[1])
|
||||
.AddContent("count_cash_3", cashType[2])
|
||||
.AddContent("count_cash_4", cashType[3])
|
||||
|
||||
;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
GrabCashInfoPanel.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Disable()
|
||||
{
|
||||
ctrl.Dispose();
|
||||
UIManager.Instance.DestroyUI(UITypes.GrabCashPanel);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/GrabCashPanel.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/GrabCashPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee6f73ecad4c7bc46a33e2b129cfab02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/Scripts/SupplyDrop/ISupplyDropGameCtrl.cs
Normal file
11
Assets/Scripts/SupplyDrop/ISupplyDropGameCtrl.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
|
||||
public interface ISupplyDropGameCtrl
|
||||
{
|
||||
SupplyDropCtrl supplyDropCtrl { get; set; }
|
||||
GameObject containerModel { get; set; }
|
||||
void InitData(SupplyDropCtrl supplyDropCtrl, int supplyDropId, ResetFishingStatusEvent resetFishing);
|
||||
void AddPlayerItem(ItemData itemData);
|
||||
void Dispose();
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/ISupplyDropGameCtrl.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/ISupplyDropGameCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ad35d9b3ee7aae40863a72e11656ca9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs
Normal file
61
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
|
||||
public class Lucky3choose1Panel : MonoBehaviour
|
||||
{
|
||||
SupplyDropGameplayLureCtrl supplyDropGameCtrl;
|
||||
CanvasGroup canvasGroup;
|
||||
GameObject text_info;
|
||||
|
||||
int layerMask;
|
||||
Camera ui3d;
|
||||
bool notClick = true;
|
||||
private void Awake()
|
||||
{
|
||||
layerMask = 1 << LayerMask.NameToLayer("UI3D");
|
||||
ui3d = UIManager.Instance.UI3DCamera;
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
text_info = transform.Find("root/text_info").gameObject;
|
||||
canvasGroup.alpha = 0f; // Start with the panel invisible
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
ShowPanel();
|
||||
}
|
||||
public void Init(SupplyDropGameplayLureCtrl supplyDropGameCtrl)
|
||||
{
|
||||
this.supplyDropGameCtrl = supplyDropGameCtrl;
|
||||
}
|
||||
|
||||
void ShowPanel()
|
||||
{
|
||||
notClick = false;
|
||||
canvasGroup.DOFadeAlpha(1f, 0.5f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (notClick)
|
||||
return;
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
var ray = ui3d.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out var hit, 100, layerMask))
|
||||
{
|
||||
Debug.Log($"<color=#e94242>hit: {hit.collider.gameObject.layer}</color>");
|
||||
LurecardItem lurecardItem = hit.collider.transform.GetComponentInParent<LurecardItem>();
|
||||
if (lurecardItem != null)
|
||||
{
|
||||
supplyDropGameCtrl.AddPlayerItem(lurecardItem.data);
|
||||
supplyDropGameCtrl.ShowAllItem(lurecardItem.index);
|
||||
notClick = true;
|
||||
text_info.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Clicked on an invalid item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee76c87d1dbf1684094d332b02529ffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Assets/Scripts/SupplyDrop/LuckyGameRoot.cs
Normal file
140
Assets/Scripts/SupplyDrop/LuckyGameRoot.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class LuckyGameRoot : MonoBehaviour
|
||||
{
|
||||
public List<LurecardItem> lurecardItems;
|
||||
|
||||
[Space(30)]
|
||||
|
||||
public float FlyingTime = 0.75f;
|
||||
public float FlyingInterval = 0.25f;
|
||||
public float FlippingInterval = 0.25f;
|
||||
public float FlipDuration = 0.6f;
|
||||
|
||||
// 互换次数
|
||||
public int maxSwapCount = 15;
|
||||
// 间隔随机区间
|
||||
public float IntervalMin = 0.3f;
|
||||
public float IntervalMax = 0.5f;
|
||||
//间隔缩短时间
|
||||
public float IntervalShortenTime = 0.1f;
|
||||
//间隔缩短最大次数
|
||||
public int IntervalShortenMaxCount = 5;
|
||||
//互换时间
|
||||
public float SwapTime = 0.3f;
|
||||
//互换每次缩短时间
|
||||
public float SwapShortenTime = 0.05f;
|
||||
//互换缩短最大次数
|
||||
public int SwapShortenMaxCount = 5;
|
||||
|
||||
//y轴偏移
|
||||
public float YOffset = 0.2f;
|
||||
//z轴偏移
|
||||
public float ZOffset = -0.1f;
|
||||
|
||||
//上曲线
|
||||
public AnimationCurve upCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
//下曲线
|
||||
public AnimationCurve downCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
|
||||
public float RotationOffset = 7.5f;
|
||||
|
||||
public float CheckZMove1 = -1f;
|
||||
public float CheckYMove1 = 0.5f;
|
||||
public float CheckMoveTime1 = 0.5f;
|
||||
public float CheckFxDelay = 0.2f;
|
||||
public float CheckStayTime = 1;
|
||||
public float CheckZMove2 = -0.5f;
|
||||
public float CheckYMove2 = 0.25f;
|
||||
public float CheckMoveTime2 = 0.25f;
|
||||
|
||||
public float DesertedCheckDelay = 1.5f;
|
||||
|
||||
public float DesertedZMove = -0.5f;
|
||||
public float DesertedMoveTime = 0.5f;
|
||||
|
||||
public float ExitDelay = 1;
|
||||
|
||||
public AnimationCurve DesertedAnimationCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
|
||||
public void Init(Vector3 containerPos, Quaternion rotation)
|
||||
{
|
||||
transform.position = containerPos;
|
||||
foreach (var item in lurecardItems)
|
||||
{
|
||||
item.transform.rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Fly()
|
||||
{
|
||||
foreach (var item in lurecardItems)
|
||||
{
|
||||
await Awaiters.Seconds(FlyingInterval);
|
||||
item.gameObject.SetActive(true);
|
||||
item.Fly(FlyingTime);
|
||||
}
|
||||
PlayPrepared();
|
||||
}
|
||||
|
||||
async void PlayPrepared()
|
||||
{
|
||||
await Awaiters.Seconds(FlyingTime);
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_prepared"));
|
||||
}
|
||||
|
||||
public async Task ShowAllItem(int index)
|
||||
{
|
||||
var selectItem = lurecardItems[index];
|
||||
|
||||
selectItem.Checked();
|
||||
selectItem.root.DOLocalMoveY(CheckYMove1, CheckMoveTime1);
|
||||
selectItem.root.DOLocalMoveZ(CheckZMove1, CheckMoveTime1);
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_click"));
|
||||
|
||||
await Awaiters.Seconds(CheckFxDelay);
|
||||
if (index == 2)
|
||||
{
|
||||
//GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_bigreward"));
|
||||
|
||||
selectItem.fx_card_reward_big.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_normalreward"));
|
||||
|
||||
selectItem.fx_card_reward_normal.SetActive(true);
|
||||
}
|
||||
await Awaiters.Seconds(CheckMoveTime1 + CheckStayTime - CheckFxDelay);
|
||||
lurecardItems[index].CheckOver();
|
||||
lurecardItems[index].root.DOLocalMoveY(CheckYMove2, CheckMoveTime2);
|
||||
lurecardItems[index].root.DOLocalMoveZ(CheckZMove2, CheckMoveTime2);
|
||||
await Awaiters.Seconds(DesertedCheckDelay);
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_deserted"));
|
||||
|
||||
for (int i = 0; i < lurecardItems.Count; i++)
|
||||
{
|
||||
if (i != index)
|
||||
{
|
||||
lurecardItems[i].Deserted();
|
||||
lurecardItems[i].root.DOLocalMoveZ(DesertedZMove, DesertedMoveTime)
|
||||
.SetLoops(2, LoopType.Yoyo)
|
||||
.SetEase(DesertedAnimationCurve);
|
||||
}
|
||||
}
|
||||
await Awaiters.Seconds(DesertedCheckDelay + DesertedMoveTime * 2);
|
||||
if (index == 2)
|
||||
{
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_bigreward"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_normalreward"));
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/LuckyGameRoot.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/LuckyGameRoot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbccfb90ce1289a4c957cf8b79b0c903
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Assets/Scripts/SupplyDrop/LurecardItem.cs
Normal file
67
Assets/Scripts/SupplyDrop/LurecardItem.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class LurecardItem : MonoBehaviour
|
||||
{
|
||||
public SkinnedMeshRenderer skinned_meshe;
|
||||
public TMP_Text text_num;
|
||||
public Vector3 startPos;
|
||||
public ItemData data;
|
||||
public Animator ani;
|
||||
public Transform root;
|
||||
[Space(10)]
|
||||
[Header("FX")]
|
||||
public GameObject fx_card_reward_big;
|
||||
public GameObject fx_card_reward_normal;
|
||||
public GameObject fx_chooceone_prepared;
|
||||
|
||||
[NonSerialized]
|
||||
public int index;
|
||||
public void Fly(float flyTime)
|
||||
{
|
||||
transform.DOMove(startPos, flyTime).OnComplete(()=>
|
||||
{
|
||||
if (fx_chooceone_prepared)
|
||||
{
|
||||
fx_chooceone_prepared.SetActive(true);
|
||||
}
|
||||
});
|
||||
PlayFly();
|
||||
//if (fx_card_fly)
|
||||
//{
|
||||
// fx_card_fly.SetActive(true);
|
||||
//}
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_minigame_choose_cardfly"));
|
||||
|
||||
transform.DORotate(Vector3.zero, flyTime);
|
||||
}
|
||||
void PlayFly()
|
||||
{
|
||||
|
||||
ani.SetTrigger("Fly");
|
||||
}
|
||||
|
||||
public void SetNum(string num)
|
||||
{
|
||||
text_num.text = num;
|
||||
}
|
||||
public void Checked()
|
||||
{
|
||||
ani.SetTrigger("Checked");
|
||||
}
|
||||
|
||||
public void CheckOver()
|
||||
{
|
||||
ani.SetTrigger("CheckOver");
|
||||
}
|
||||
|
||||
public void Deserted()
|
||||
{
|
||||
ani.SetTrigger("Deserted");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/LurecardItem.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/LurecardItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4c0c7f88a9a18f4c8656dd10ce0c464
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
104
Assets/Scripts/SupplyDrop/SupplyDropCashEmitter.cs
Normal file
104
Assets/Scripts/SupplyDrop/SupplyDropCashEmitter.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropCashEmitter : MonoBehaviour
|
||||
{
|
||||
//目标区域
|
||||
public Transform targetAreaAA;
|
||||
public Transform targetAreaBB;
|
||||
//飞行时间
|
||||
public float flyTime = 2f;
|
||||
//发射间隔
|
||||
public float emissionInterval = 0.5f;
|
||||
//发射数量
|
||||
public float emissionCount = 2f;
|
||||
|
||||
public int FlyIndexStart = 1;
|
||||
public int FlyIndexEnd = 5;
|
||||
|
||||
SupplyDropGameplayCashCtrl ctrl;
|
||||
float allWeight = 0f;
|
||||
List<float> weightList = new List<float>();
|
||||
List<int> dropCount = new List<int>();
|
||||
public void StartPlay(SupplyDropGameplayCashCtrl ctrl,
|
||||
float allWeight,
|
||||
List<float> weightList,
|
||||
List<int> dropCount)
|
||||
{
|
||||
this.ctrl = ctrl;
|
||||
this.allWeight = allWeight;
|
||||
this.weightList = weightList;
|
||||
this.dropCount = dropCount;
|
||||
|
||||
StartCoroutine(EmitCash());
|
||||
}
|
||||
|
||||
public Vector3 GetTargetAreaPos()
|
||||
{
|
||||
if (targetAreaAA != null && targetAreaBB != null)
|
||||
{
|
||||
float x = Random.Range(targetAreaAA.position.x, targetAreaBB.position.x);
|
||||
float y = Random.Range(targetAreaAA.position.y, targetAreaBB.position.y);
|
||||
float z = Random.Range(targetAreaAA.position.z, targetAreaBB.position.z);
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
else if (targetAreaAA != null)
|
||||
{
|
||||
return targetAreaAA.position;
|
||||
}
|
||||
else if (targetAreaBB != null)
|
||||
{
|
||||
return targetAreaBB.position;
|
||||
}
|
||||
return transform.position; // 默认返回当前对象位置
|
||||
}
|
||||
|
||||
IEnumerator EmitCash()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int type = 0;
|
||||
float curWeight = 0f;
|
||||
float randomValue = UnityEngine.Random.Range(0f, allWeight);
|
||||
for (int i = 0; i < weightList.Count; i++)
|
||||
{
|
||||
curWeight += weightList[i];
|
||||
if (randomValue <= curWeight)
|
||||
{
|
||||
// 找到对应的类型
|
||||
type = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < emissionCount; i++)
|
||||
{
|
||||
SupplyDropCashItem item = ctrl.GetCashItem(type, true);
|
||||
if (item != null)
|
||||
{
|
||||
item.gameObject.name = $"Cash_Down_{type}";
|
||||
item.gameObject.SetActive(true);
|
||||
item.SetClick(dropCount[type]);
|
||||
|
||||
if (FlyIndexStart < FlyIndexEnd)
|
||||
{
|
||||
item.PlayAni(UnityEngine.Random.Range(FlyIndexStart, FlyIndexEnd + 1)); // 随机播放动画
|
||||
}
|
||||
else
|
||||
{
|
||||
item.PlayAni(FlyIndexStart); // 随机播放动画
|
||||
}
|
||||
|
||||
item.transform.position = transform.position;
|
||||
item.transform.DOMove(GetTargetAreaPos(),
|
||||
flyTime)
|
||||
.OnComplete(() => ctrl.Recycle(item, true));
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(emissionInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropCashEmitter.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropCashEmitter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0151534fc37a4f5468ec1cfd66d9f72e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
204
Assets/Scripts/SupplyDrop/SupplyDropCashGameRoot.cs
Normal file
204
Assets/Scripts/SupplyDrop/SupplyDropCashGameRoot.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropCashGameRoot : MonoBehaviour
|
||||
{
|
||||
public SupplyDropItemCashGun gun;
|
||||
public GameObject GrabCashTextReady;
|
||||
public GameObject GrabCashTextTitle;
|
||||
public Transform[] posFlyEndLeft;
|
||||
public Transform[] posFlyEndRight;
|
||||
public List<GameObject> cashs = new List<GameObject>();
|
||||
public GameObject cashNum;
|
||||
public List<SupplyDropCashEmitter> cashPosList = new List<SupplyDropCashEmitter>();
|
||||
public SupplyDropCashEmitter pos_start;
|
||||
public float CashGunFlyTime = 0.45f;
|
||||
public Vector3 CashGunFlyPos = new(0, -1.5f, 3f);
|
||||
|
||||
//钞票枪发射阶段
|
||||
public float PlaySprayStartDelay = 0.533f;
|
||||
public float PlaySprayDuration = 1.5f;
|
||||
public float PlaySprayCashFlyTime = 1f;
|
||||
public float PlaySprayCashInterval = 0.066f;
|
||||
public AnimationCurve PlayCashSprayAnimationCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
|
||||
//下落表现阶段
|
||||
public float PlayCashFallStartDelay = 0.8f;
|
||||
public float PlayCashFallDuration = 2f;
|
||||
|
||||
//抓钞票阶段
|
||||
public float PlayFallToGrabDelay = 2;
|
||||
public float GameDuration = 7.5f;
|
||||
public float GrabCashDelay = 0.5f;
|
||||
|
||||
|
||||
public float PlayUITitleDelay = 0.1f;
|
||||
public float PlayUIReadyDelay = 2.5f;
|
||||
|
||||
float allWeight = 0f;
|
||||
List<float> weightList = new List<float>();
|
||||
List<int> dropCount = new List<int>();
|
||||
SupplyDropGameplayCashCtrl ctrl;
|
||||
|
||||
public void Init(SupplyDropGameplayCashCtrl ctrl,
|
||||
Vector3 startPos,
|
||||
float allWeight,
|
||||
List<float> weightList,
|
||||
List<int> dropCount)
|
||||
{
|
||||
gun.gameObject.SetActive(true);
|
||||
gun.transform.position = startPos;
|
||||
GunMove();
|
||||
this.ctrl = ctrl;
|
||||
this.allWeight = allWeight;
|
||||
this.weightList = weightList;
|
||||
this.dropCount = dropCount;
|
||||
ShowUI();
|
||||
}
|
||||
|
||||
void GunMove()
|
||||
{
|
||||
gun.transform.DOMove(CashGunFlyPos, CashGunFlyTime);
|
||||
|
||||
}
|
||||
|
||||
async void ShowUI()
|
||||
{
|
||||
await Awaiters.Seconds(PlayUITitleDelay);
|
||||
GrabCashTextTitle.SetActive(true);
|
||||
await Awaiters.Seconds(PlayUIReadyDelay);
|
||||
GrabCashTextReady.SetActive(true);
|
||||
}
|
||||
|
||||
public async Task IntialStage()
|
||||
{
|
||||
//开始发射钞票
|
||||
PlaySpray();
|
||||
//开始降落钞票
|
||||
await PlayCashFall();
|
||||
}
|
||||
|
||||
public async Task StartPlay()
|
||||
{
|
||||
await Awaiters.Seconds(GrabCashDelay);
|
||||
for (int i = 0; i < cashPosList.Count; i++)
|
||||
{
|
||||
SupplyDropCashEmitter emitter = cashPosList[i];
|
||||
emitter.StartPlay(ctrl, allWeight, weightList, dropCount);
|
||||
}
|
||||
|
||||
await Awaiters.Seconds(GameDuration);
|
||||
|
||||
for (int i = 0; i < cashPosList.Count; i++)
|
||||
{
|
||||
SupplyDropCashEmitter emitter = cashPosList[i];
|
||||
emitter.StopAllCoroutines();
|
||||
}
|
||||
}
|
||||
|
||||
async Task PlaySpray()
|
||||
{
|
||||
await Awaiters.Seconds(PlaySprayStartDelay);
|
||||
float sprayTime = 0;
|
||||
int type = 0;
|
||||
while (sprayTime < PlaySprayDuration)
|
||||
{
|
||||
sprayTime += 0.1f;
|
||||
type = UnityEngine.Random.Range(0, cashs.Count);
|
||||
SupplyDropCashItem item = ctrl.GetCashItem(type);
|
||||
if (item != null)
|
||||
{
|
||||
Vector3 posW = gun.Point01.position;
|
||||
item.gameObject.name = $"Cash_UP_{type}";
|
||||
item.transform.position = posW;
|
||||
item.PlayAni(1); // 随机播放动画
|
||||
item.gameObject.SetActive(true);
|
||||
//item.transform.rotation = point01.rotation;
|
||||
if (posFlyEndLeft.Length > 1)
|
||||
{
|
||||
float x = Random.Range(posFlyEndLeft[0].position.x, posFlyEndLeft[1].position.x);
|
||||
float y = Random.Range(posFlyEndLeft[0].position.y, posFlyEndLeft[1].position.y);
|
||||
float z = Random.Range(posFlyEndLeft[0].position.z, posFlyEndLeft[1].position.z);
|
||||
posW.x = x;
|
||||
posW.y = y;
|
||||
posW.z = z;
|
||||
}
|
||||
item.transform.DOMove(posW, PlaySprayCashFlyTime)
|
||||
.SetEase(PlayCashSprayAnimationCurve)
|
||||
.OnComplete(() => ctrl.Recycle(item));
|
||||
}
|
||||
SupplyDropCashItem item2 = ctrl.GetCashItem(type);
|
||||
if (item2 != null)
|
||||
{
|
||||
Vector3 posW = gun.Point02.position;
|
||||
item2.gameObject.name = $"Cash_UP_{type}";
|
||||
item2.transform.position = posW;
|
||||
item2.PlayAni(1); // 随机播放动画
|
||||
item2.gameObject.SetActive(true);
|
||||
//item2.transform.rotation = point02.rotation;
|
||||
|
||||
if (posFlyEndRight.Length > 1)
|
||||
{
|
||||
float x = Random.Range(posFlyEndRight[0].position.x, posFlyEndRight[1].position.x);
|
||||
float y = Random.Range(posFlyEndRight[0].position.y, posFlyEndRight[1].position.y);
|
||||
float z = Random.Range(posFlyEndRight[0].position.z, posFlyEndRight[1].position.z);
|
||||
posW.x = x;
|
||||
posW.y = y;
|
||||
posW.z = z;
|
||||
}
|
||||
|
||||
item2.transform.DOMove(posW, PlaySprayCashFlyTime)
|
||||
.SetEase(PlayCashSprayAnimationCurve)
|
||||
.OnComplete(() => ctrl.Recycle(item2));
|
||||
}
|
||||
await Awaiters.Seconds(PlaySprayCashInterval);
|
||||
}
|
||||
}
|
||||
async Task PlayCashFall()
|
||||
{
|
||||
await Awaiters.Seconds(PlayCashFallStartDelay);
|
||||
float cashFallTime = 0;
|
||||
int type = 0;
|
||||
while (cashFallTime < PlayCashFallDuration)
|
||||
{
|
||||
await Awaiters.Seconds(pos_start.emissionInterval);
|
||||
cashFallTime += pos_start.emissionInterval;
|
||||
for (int i = 0; i < pos_start.emissionCount; i++)
|
||||
{
|
||||
type = UnityEngine.Random.Range(0, cashs.Count);
|
||||
SupplyDropCashItem item = ctrl.GetCashItem(type);
|
||||
if (item != null)
|
||||
{
|
||||
item.gameObject.name = $"Cash_Down_{type}";
|
||||
item.gameObject.SetActive(true);
|
||||
if (pos_start.FlyIndexStart < pos_start.FlyIndexEnd)
|
||||
{
|
||||
item.PlayAni(UnityEngine.Random.Range(pos_start.FlyIndexStart, pos_start.FlyIndexEnd + 1)); // 随机播放动画
|
||||
}
|
||||
else
|
||||
{
|
||||
item.PlayAni(pos_start.FlyIndexStart); // 随机播放动画
|
||||
}
|
||||
item.transform.position = pos_start.transform.position;
|
||||
item.transform.DOMove(pos_start.GetTargetAreaPos(),
|
||||
pos_start.flyTime)
|
||||
.SetEase(PlayCashSprayAnimationCurve)
|
||||
.OnComplete(() => ctrl.Recycle(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
await Awaiters.Seconds(PlayFallToGrabDelay);
|
||||
}
|
||||
|
||||
public GameObject InstantiateItem(int type)
|
||||
{
|
||||
return Instantiate(cashs[type], transform);
|
||||
}
|
||||
|
||||
public GameObject InstantiateNumItem()
|
||||
{
|
||||
return Instantiate(cashNum, transform);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropCashGameRoot.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropCashGameRoot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64ff7763a65b5ff43ba907adbbdc2993
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Scripts/SupplyDrop/SupplyDropCashItem.cs
Normal file
44
Assets/Scripts/SupplyDrop/SupplyDropCashItem.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropCashItem : MonoBehaviour
|
||||
{
|
||||
bool inUse = false;
|
||||
public int type = 0; // 0~4
|
||||
public Animator rootAni;
|
||||
public Animator cashAni;
|
||||
public BoxCollider boxCollider;
|
||||
public int cashCount = 0;
|
||||
|
||||
public GameObject fx_reward;
|
||||
public GameObject fx_idle;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="index">1~5</param>
|
||||
public void PlayAni(int index)
|
||||
{
|
||||
rootAni.SetTrigger($"Fly0{index}");
|
||||
cashAni.SetTrigger($"Fly0{index}");
|
||||
}
|
||||
|
||||
public void SetClick(int cashCount)
|
||||
{
|
||||
this.cashCount = cashCount;
|
||||
inUse = true;
|
||||
boxCollider.enabled = true;
|
||||
fx_idle.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
if (!inUse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fx_idle.SetActive(false);
|
||||
fx_reward.SetActive(true);
|
||||
inUse = false;
|
||||
boxCollider.enabled = false;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropCashItem.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropCashItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5623822c36190054b86d0528965f3562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Scripts/SupplyDrop/SupplyDropContentModel.cs
Normal file
19
Assets/Scripts/SupplyDrop/SupplyDropContentModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropContentModel : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public void SetTrigger(string name)
|
||||
{
|
||||
if (animator == null)
|
||||
return;
|
||||
animator.SetTrigger(name);
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (animator == null)
|
||||
return;
|
||||
animator.SetTrigger("Play");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropContentModel.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropContentModel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0b0ceb663288914a96fc60c092f91ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
312
Assets/Scripts/SupplyDrop/SupplyDropCtrl.cs
Normal file
312
Assets/Scripts/SupplyDrop/SupplyDropCtrl.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class SupplyDropCtrl : IDisposable
|
||||
{
|
||||
SupplyDropData supplyDropData;
|
||||
FishingBehaviorConf conf;
|
||||
SupplyDropModel supplyDropModel;
|
||||
SupplyDropRewardPanel supplyDropPanel;
|
||||
GameObject supplyDropGo;
|
||||
GameObject containerGo;
|
||||
GameObject fx_supplydrop_containerdisappear;
|
||||
ItemData itemData;
|
||||
ResetFishingStatusEvent resetFishing;
|
||||
Tables tables;
|
||||
public TargetAddData targetAddData;
|
||||
public Vector3 targetPos;
|
||||
|
||||
public ISupplyDropGameCtrl supplyDropGameCtrl;
|
||||
|
||||
public void InitData(int supplyDropId, SupplyDropFbx supplyDropFbx, string supplyDropPrefab, int supplyDropDropId, int fishItemId, int fishSubType, FishingBehaviorConf conf)
|
||||
{
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
supplyDropData = new SupplyDropData();
|
||||
supplyDropData.supplyDropId = supplyDropId;
|
||||
supplyDropData.fishItemID = fishItemId;
|
||||
supplyDropData.fishSubType = fishSubType;
|
||||
supplyDropData.supplyDropFbx = supplyDropFbx;
|
||||
supplyDropData.supplyDropPrefab = supplyDropPrefab;
|
||||
supplyDropData.supplyDropDropId = supplyDropDropId;
|
||||
this.conf = conf;
|
||||
}
|
||||
|
||||
public async void ShowSupplyDropModel()
|
||||
{
|
||||
string supplyDropName = supplyDropData.supplyDropPrefab;
|
||||
string airscplane = "prop_supplydrop_airscplane";
|
||||
float randX = UnityEngine.Random.value;
|
||||
float startX = UnityEngine.Random.Range(conf.supplyDropPlaneStartX[0], conf.supplyDropPlaneStartX[1]);
|
||||
float endX = UnityEngine.Random.Range(conf.supplyDropPlaneEndX[0], conf.supplyDropPlaneEndX[1]);
|
||||
float packFlyStartRandX = UnityEngine.Random.Range(0, conf.supplyDropPackFlyStartRand.x);
|
||||
float YRand = UnityEngine.Random.Range(conf.supplyDropFlyTargetRotationYRand[0], conf.supplyDropFlyTargetRotationYRand[1]);
|
||||
if (randX < 0.5f)
|
||||
{
|
||||
startX = -startX;
|
||||
endX = -endX;
|
||||
packFlyStartRandX = -packFlyStartRandX;
|
||||
YRand = -YRand;
|
||||
}
|
||||
Vector3 target = conf.supplyDropPlaneEndPos;
|
||||
target.x = endX;
|
||||
Vector3 planeRelativePos = conf.supplyDropPlaneStartPos;
|
||||
planeRelativePos.x = startX;
|
||||
Quaternion quaternion = Quaternion.LookRotation(target - planeRelativePos);
|
||||
|
||||
GameObject plane = await Addressables.InstantiateAsync(airscplane, planeRelativePos, quaternion * Quaternion.Euler(-90, 0, 0)).Task;
|
||||
if (plane != null)
|
||||
{
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_airplane"));
|
||||
plane.transform.DOMove(target, conf.supplyDropPlaneFlyTime).OnComplete(() =>
|
||||
{
|
||||
Addressables.ReleaseInstance(plane);
|
||||
}).SetEase(Ease.Linear);
|
||||
}
|
||||
//显示横幅
|
||||
ShowPanel();
|
||||
await Awaiters.Seconds(conf.supplyDropAppearDelay);
|
||||
Vector3 flyStart = new Vector3();
|
||||
flyStart.x = conf.supplyDropFlyTargetPos.x + packFlyStartRandX;
|
||||
flyStart.y = conf.supplyDropPackFlyStartRand.y;
|
||||
flyStart.z = conf.supplyDropFlyTargetPos.z + UnityEngine.Random.Range(0, conf.supplyDropPackFlyStartRand.z);
|
||||
supplyDropGo = await Addressables.InstantiateAsync(supplyDropName, flyStart, Quaternion.identity).Task;
|
||||
if (supplyDropGo != null)
|
||||
{
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_fly"));
|
||||
|
||||
supplyDropModel = supplyDropGo.GetComponent<SupplyDropModel>();
|
||||
supplyDropGo.transform.DOMove(conf.supplyDropFlyTargetPos, conf.supplyDropFlyTime).OnComplete(() =>
|
||||
{
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_drop"));
|
||||
supplyDropModel.SetTrigger("Drop");
|
||||
}).SetEase(conf.supplyDropFlyCurve);
|
||||
supplyDropGo.transform.DORotateQuaternion(Quaternion.Euler(0, YRand, 0), conf.supplyDropFlyTime);
|
||||
//supplyDropFlyTargetRotationYRand
|
||||
await Awaiters.Seconds(conf.supplyDropFlyTime);
|
||||
}
|
||||
supplyDropModel.FxSmokeDelay(conf.supplyDropFxSmokeDelay, conf.supplyDropPackIdleDelay);
|
||||
await ClaimDelay();
|
||||
}
|
||||
|
||||
async Task ShowPanel()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUINotLoading(UITypes.SupplyDropRewardPanel);
|
||||
if (go != null)
|
||||
{
|
||||
supplyDropPanel = go.GetComponent<SupplyDropRewardPanel>();
|
||||
SupplyDrop supplyDrop = tables.TbSupplyDrop[supplyDropData.supplyDropId];
|
||||
supplyDropPanel.Init(LocalizationMgr.GetText(supplyDrop.Name_l10n_key),conf.supplyDropTitleDelay, OnCloseClaim);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Awaiters.Seconds(5);
|
||||
OnCloseClaim();
|
||||
}
|
||||
}
|
||||
|
||||
async Task ClaimDelay()
|
||||
{
|
||||
//按钮出现
|
||||
if (supplyDropPanel != null)
|
||||
{
|
||||
await Awaiters.Seconds(conf.supplyDropClaimDelay);
|
||||
supplyDropPanel.ShowClaim();
|
||||
}
|
||||
}
|
||||
async Task OpenSupplyDropModel()
|
||||
{
|
||||
Item item = null;
|
||||
List<ItemData> itemdatas = GContext.container.Resolve<PlayerItemData>().AddItemByDrop(supplyDropData.supplyDropDropId, false);
|
||||
|
||||
itemData = itemdatas[0];
|
||||
item = tables.TbItem.Get(itemData.id);
|
||||
Debug.Log("OpenSupplyDrop :" + itemData.id + " " + itemData.count);
|
||||
if (item.Type == 11 && item.SubType == 1)
|
||||
{
|
||||
GContext.container.Resolve<BuffDataCenter>().SetGlobalBucffNew(item.RedirectID, true);
|
||||
}
|
||||
else if (item.Type != 14 || item.SubType == 1)
|
||||
{
|
||||
targetAddData = new TargetAddData(itemData.id, (int)itemData.curCount, (int)itemData.count);
|
||||
}
|
||||
|
||||
GContext.Publish(new EventFishingSound("audio_supplydrop_open"));
|
||||
supplyDropModel.SupplyDropOpen(conf.supplyDropOpenDelay);
|
||||
resetFishing = new ResetFishingStatusEvent();
|
||||
resetFishing.isSupplyDrop = true;
|
||||
if (supplyDropData.fishSubType == 4)
|
||||
{
|
||||
resetFishing.fishItemId = supplyDropData.fishItemID;
|
||||
}
|
||||
await ContainerDelay();
|
||||
await Awaiters.NextFrame;
|
||||
|
||||
if (item.Type != 14 || item.SubType == 1)
|
||||
{
|
||||
GContext.Publish(resetFishing);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewAirdopGameCtrl();
|
||||
}
|
||||
Dispose();
|
||||
}
|
||||
|
||||
void NewAirdopGameCtrl()
|
||||
{
|
||||
if (itemData.id == 14011)
|
||||
{
|
||||
//小玩法,钞票枪
|
||||
Debug.Log("OpenSupplyDrop:钞票枪");
|
||||
supplyDropGameCtrl = new SupplyDropGameplayCashCtrl();
|
||||
}
|
||||
else if (itemData.id == 14012)
|
||||
{
|
||||
//小玩法,卡牌
|
||||
Debug.Log("OpenSupplyDrop:卡牌");
|
||||
supplyDropGameCtrl = new SupplyDropGameplayLureCtrl();
|
||||
}
|
||||
supplyDropGameCtrl.containerModel = containerGo;
|
||||
containerGo = null;
|
||||
supplyDropGameCtrl.InitData(this, supplyDropData.supplyDropId, resetFishing);
|
||||
}
|
||||
|
||||
async Task ClaimCameraBackDelay()
|
||||
{
|
||||
ResetFishingStatusEvent resetFishingStatus = new ResetFishingStatusEvent();
|
||||
resetFishingStatus.isSupplyDrop = true;
|
||||
resetFishingStatus.playSupplyDropClaim = true;
|
||||
await Awaiters.Seconds(conf.supplyDropCameraBackDelay);
|
||||
GContext.Publish(resetFishingStatus);
|
||||
}
|
||||
|
||||
void SetLurecardsShow()
|
||||
{
|
||||
SupplyDropItemLurecards supplyDropItemLurecards = containerGo.GetComponent<SupplyDropItemLurecards>();
|
||||
var supplyDropGameplayLure = tables.TbSupplyDropGameplayLure.DataMap[supplyDropData.supplyDropId];
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
int lurecardCount = supplyDropGameplayLure.DropID.Count;
|
||||
List<int> indexs = new List<int>() { 0, 1, 2 };
|
||||
//打乱顺序
|
||||
|
||||
for (int i = 0; i < lurecardCount; i++)
|
||||
{
|
||||
ItemData itemData = playerItemData.GetItemDataOne(supplyDropGameplayLure.DropID[i]);
|
||||
int randomIndex = UnityEngine.Random.Range(0, indexs.Count);
|
||||
int j = indexs[randomIndex];
|
||||
indexs.RemoveAt(randomIndex);
|
||||
supplyDropItemLurecards.text_num[j].text = $"x{itemData.count}";
|
||||
supplyDropItemLurecards.skinned_meshes[j].material = supplyDropItemLurecards.material[i];
|
||||
}
|
||||
}
|
||||
|
||||
async Task ContainerDelay()
|
||||
{
|
||||
await Awaiters.Seconds(conf.supplyDropContainerDelay);
|
||||
float Delay = conf.supplyDropVanishDelay;
|
||||
containerGo = await Addressables.InstantiateAsync(supplyDropData.supplyDropFbx.Fbx, supplyDropModel.Content.position, Quaternion.identity).Task;
|
||||
if (containerGo != null)
|
||||
{
|
||||
if (itemData.id == 14012)
|
||||
{
|
||||
SetLurecardsShow();
|
||||
}
|
||||
SupplyDropContentModel supplyDropContentModel = containerGo.GetComponent<SupplyDropContentModel>();
|
||||
if (supplyDropContentModel != null)
|
||||
{
|
||||
supplyDropContentModel.SetTrigger("Fly");
|
||||
}
|
||||
containerGo.transform.DOMove(conf.supplyDropContainerFirstFlyRelativePos,
|
||||
conf.supplyDropContainerFirstFlyTime)
|
||||
.SetEase(conf.supplyDropContainerFirstFlyCurve).SetRelative();
|
||||
|
||||
await Awaiters.Seconds(conf.supplyDropContainerFirstFlyTime);
|
||||
Vector3 scale = Vector3.one * containerGo.transform.localScale.x * conf.supplyDropContainerFlyScale;
|
||||
containerGo.transform.DOScale(scale, conf.supplyDropContainerFlyTime).SetEase(conf.supplyDropContainerFlyCurve);
|
||||
Vector3 FlyPos = conf.supplyDropContainerFlyPos;
|
||||
containerGo.transform.DOMove(FlyPos, conf.supplyDropContainerFlyTime).SetEase(conf.supplyDropContainerFlyCurve);
|
||||
await Awaiters.Seconds(conf.supplyDropContainerFlyTime);
|
||||
if (supplyDropContentModel != null)
|
||||
{
|
||||
supplyDropContentModel.SetTrigger("Show");
|
||||
}
|
||||
if (supplyDropData.supplyDropFbx.ItemID == 14011 || supplyDropData.supplyDropFbx.ItemID == 14012)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(supplyDropData.supplyDropFbx.AudioShow))
|
||||
{
|
||||
GContext.Publish(new EventFishingSound(supplyDropData.supplyDropFbx.AudioShow));
|
||||
}
|
||||
await Awaiters.Seconds(conf.supplyDropContainerFxDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Awaiters.Seconds(conf.supplyDropContainerFxDelay);
|
||||
if (!string.IsNullOrEmpty(supplyDropData.supplyDropFbx.AudioShow))
|
||||
{
|
||||
GContext.Publish(new EventFishingSound(supplyDropData.supplyDropFbx.AudioShow));
|
||||
}
|
||||
}
|
||||
|
||||
Delay -= conf.supplyDropContainerFxDelay;
|
||||
if (!string.IsNullOrEmpty(supplyDropData.supplyDropFbx.FxShow))
|
||||
{
|
||||
fx_supplydrop_containerdisappear = await Addressables.InstantiateAsync(supplyDropData.supplyDropFbx.FxShow, containerGo.transform.position, Quaternion.identity).Task;
|
||||
}
|
||||
|
||||
targetPos = ConvertTools.WorldToScreenPoint(containerGo.transform.position, false);
|
||||
}
|
||||
if (Delay > 0)
|
||||
{
|
||||
await Awaiters.Seconds(Delay);
|
||||
}
|
||||
}
|
||||
|
||||
void OnCloseClaim()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClaimCameraBackDelay();
|
||||
OpenSupplyDropModel();
|
||||
ReleaseSupplyDropGo();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Error in OnCloseClaim: {e.Message}");
|
||||
}
|
||||
UIManager.Instance.DestroyUI(UITypes.SupplyDropRewardPanel);
|
||||
}
|
||||
|
||||
async Task ReleaseSupplyDropGo()
|
||||
{
|
||||
if (supplyDropGo != null)
|
||||
{
|
||||
await Awaiters.Seconds(conf.supplyDropPackVanishDelay);
|
||||
supplyDropModel.Hide();
|
||||
Addressables.ReleaseInstance(supplyDropGo);
|
||||
supplyDropGo = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (containerGo != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(containerGo);
|
||||
containerGo = null;
|
||||
}
|
||||
if (fx_supplydrop_containerdisappear != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_supplydrop_containerdisappear);
|
||||
fx_supplydrop_containerdisappear = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropCtrl.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa42c08ab5f9eae40bec2a2ab7a45ae7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/Scripts/SupplyDrop/SupplyDropData.cs
Normal file
12
Assets/Scripts/SupplyDrop/SupplyDropData.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
using cfg;
|
||||
|
||||
public class SupplyDropData
|
||||
{
|
||||
public int supplyDropId;
|
||||
public int fishItemID;
|
||||
public int fishSubType;
|
||||
public SupplyDropFbx supplyDropFbx;
|
||||
public string supplyDropPrefab;
|
||||
public int supplyDropDropId;
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropData.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c980a91bc2cb86642a87722a50fbaec9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
211
Assets/Scripts/SupplyDrop/SupplyDropGameplayCashCtrl.cs
Normal file
211
Assets/Scripts/SupplyDrop/SupplyDropGameplayCashCtrl.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using System.Linq;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
|
||||
public class SupplyDropGameplayCashCtrl : SupplyDropGameplayCtrl, ISupplyDropGameCtrl
|
||||
{
|
||||
SupplyDropGameplayCash supplyDropGameplayCash;
|
||||
SupplyDropCashGameRoot supplyDropCashGame;
|
||||
GrabCashPanel grabCashPanel;
|
||||
Queue<GameObject> cashPool1 = new Queue<GameObject>();
|
||||
Queue<GameObject> cashPool2 = new Queue<GameObject>();
|
||||
Queue<GameObject> cashPool3 = new Queue<GameObject>();
|
||||
Queue<GameObject> cashPool4 = new Queue<GameObject>();
|
||||
Queue<GameObject> numPool = new Queue<GameObject>();
|
||||
List<GameObject> numUserPool = new List<GameObject>();
|
||||
List<GameObject> cashUserPool = new List<GameObject>();
|
||||
float allWeight = 0f;
|
||||
List<float> weightList = new List<float>();
|
||||
List<int> dropCount = new List<int>();
|
||||
bool isCheckOver = false;
|
||||
protected override void Init(int id)
|
||||
{
|
||||
supplyDropGameplayCash = tables.TbSupplyDropGameplayCash.DataMap[id];
|
||||
SetData();
|
||||
ShowModel();
|
||||
}
|
||||
void SetData()
|
||||
{
|
||||
weightList = supplyDropGameplayCash.DropWeight;
|
||||
allWeight = weightList.Sum();
|
||||
var dropID = supplyDropGameplayCash.DropID;
|
||||
dropCount = new List<int>();
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
for (int i = 0; i < dropID.Count; i++)
|
||||
{
|
||||
ItemData itemData = playerItemData.GetItemDataOne(dropID[i]);
|
||||
if (itemData != null)
|
||||
{
|
||||
dropCount.Add((int)itemData.count);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"drop for ID {dropID[i]} not found.");
|
||||
dropCount.Add(0); // 如果没有找到数据,添加0
|
||||
}
|
||||
}
|
||||
}
|
||||
void ShowModel()
|
||||
{
|
||||
Addressables.InstantiateAsync("CashGameRoot").Completed += handle =>
|
||||
{
|
||||
if (handle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
gameModel = handle.Result;
|
||||
supplyDropCashGame = gameModel.GetComponent<SupplyDropCashGameRoot>();
|
||||
Vector3 posLocal = Camera.main.transform.InverseTransformPoint(containerModel.transform.position);
|
||||
Vector3 posW = UIManager.Instance.UI3DCamera.transform.TransformPoint(posLocal);
|
||||
supplyDropCashGame.Init(this, posW, allWeight, weightList, dropCount);
|
||||
containerModel.SetActive(false);
|
||||
ShowPanel();
|
||||
PlayAni();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async void PlayAni()
|
||||
{
|
||||
await supplyDropCashGame.IntialStage();
|
||||
grabCashPanel.SetUse();
|
||||
//加载界面 开始玩法
|
||||
await supplyDropCashGame.StartPlay();
|
||||
isCheckOver = true;
|
||||
await Awaiters.Seconds(3f);
|
||||
if (isCheckOver)
|
||||
{
|
||||
cashUserPool.Clear();
|
||||
CheckGameOver();
|
||||
}
|
||||
}
|
||||
|
||||
void CheckGameOver()
|
||||
{
|
||||
if (isCheckOver && cashUserPool.Count == 0)
|
||||
{
|
||||
isCheckOver = false;
|
||||
HideNumUserPool();
|
||||
grabCashPanel.GameOver();
|
||||
}
|
||||
}
|
||||
|
||||
void HideNumUserPool()
|
||||
{
|
||||
for (int i = 0; i < numUserPool.Count; i++)
|
||||
{
|
||||
numUserPool[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
async void ShowPanel()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUINotLoading(UITypes.GrabCashPanel);
|
||||
grabCashPanel = go.GetComponent<GrabCashPanel>();
|
||||
grabCashPanel.Init(this);
|
||||
}
|
||||
|
||||
public void Recycle(SupplyDropCashItem item, bool use = false)
|
||||
{
|
||||
if (use)
|
||||
{
|
||||
cashUserPool.Remove(item.gameObject);
|
||||
CheckGameOver();
|
||||
}
|
||||
item.transform.DOKill();
|
||||
item.gameObject.SetActive(false);
|
||||
switch (item.type)
|
||||
{
|
||||
case 0:
|
||||
cashPool1.Enqueue(item.gameObject);
|
||||
break;
|
||||
case 1:
|
||||
cashPool2.Enqueue(item.gameObject);
|
||||
break;
|
||||
case 2:
|
||||
cashPool3.Enqueue(item.gameObject);
|
||||
break;
|
||||
case 3:
|
||||
cashPool4.Enqueue(item.gameObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public SupplyDropCashItem GetCashItem(int type, bool use = false)
|
||||
{
|
||||
GameObject item = null;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
if (cashPool1.Count > 0)
|
||||
{
|
||||
item = cashPool1.Dequeue();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (cashPool2.Count > 0)
|
||||
{
|
||||
item = cashPool2.Dequeue();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (cashPool3.Count > 0)
|
||||
{
|
||||
item = cashPool3.Dequeue();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (cashPool4.Count > 0)
|
||||
{
|
||||
item = cashPool4.Dequeue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (item == null)
|
||||
item = supplyDropCashGame.InstantiateItem(type);
|
||||
if (use)
|
||||
{
|
||||
cashUserPool.Add(item);
|
||||
}
|
||||
item.transform.localScale = Vector3.one;
|
||||
return item.GetComponent<SupplyDropCashItem>();
|
||||
}
|
||||
|
||||
|
||||
public async void ShowNum(SupplyDropCashItem item)
|
||||
{
|
||||
GrabCashFloatingNum numItem = GetCashNumItem();
|
||||
string num = ConvertTools.GetNumberString(item.cashCount);
|
||||
numItem.num.text = $"+{num}";
|
||||
numItem.transform.position = item.transform.position;
|
||||
numItem.gameObject.SetActive(true);
|
||||
await Awaiters.Seconds(1);
|
||||
Recycle(numItem);
|
||||
}
|
||||
|
||||
public void Recycle(GrabCashFloatingNum item)
|
||||
{
|
||||
item.gameObject.SetActive(false);
|
||||
numUserPool.Remove(item.gameObject);
|
||||
numPool.Enqueue(item.gameObject);
|
||||
}
|
||||
public GrabCashFloatingNum GetCashNumItem()
|
||||
{
|
||||
GameObject item = null;
|
||||
if (numPool.Count > 0)
|
||||
{
|
||||
item = numPool.Dequeue();
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
item = supplyDropCashGame.InstantiateNumItem();
|
||||
numUserPool.Add(item);
|
||||
return item.GetComponent<GrabCashFloatingNum>();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayCashCtrl.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayCashCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1664b9f7da93a1040bf2d2ae3b091699
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Scripts/SupplyDrop/SupplyDropGameplayCtrl.cs
Normal file
51
Assets/Scripts/SupplyDrop/SupplyDropGameplayCtrl.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class SupplyDropGameplayCtrl : ISupplyDropGameCtrl
|
||||
{
|
||||
protected ResetFishingStatusEvent resetFishing;
|
||||
protected Tables tables;
|
||||
public SupplyDropCtrl supplyDropCtrl { get; set; }
|
||||
public GameObject containerModel { get; set; }
|
||||
public GameObject gameModel { get; set; }
|
||||
public void AddPlayerItem(ItemData selectData)
|
||||
{
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(selectData);
|
||||
Debug.Log($"SupplyDropGameplayCtrl AddPlayerItem: {selectData.id}, count: {selectData.count}, curCount: {selectData.curCount}");
|
||||
supplyDropCtrl.targetAddData = new TargetAddData(selectData.id, (int)selectData.curCount, (int)selectData.count);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UIManager.Instance.UI3DCamera.gameObject.SetActive(false);
|
||||
|
||||
GContext.Publish(resetFishing);
|
||||
Debug.Log("SupplyDropGameplayCtrl disposed.");
|
||||
if (gameModel != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(gameModel);
|
||||
}
|
||||
if (containerModel != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(containerModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitData(SupplyDropCtrl supplyDropCtrl, int supplyDropId, ResetFishingStatusEvent resetFishing)
|
||||
{
|
||||
this.supplyDropCtrl = supplyDropCtrl;
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
this.resetFishing = resetFishing;
|
||||
UIManager.Instance.UI3DCamera.gameObject.SetActive(true);
|
||||
|
||||
Init(supplyDropId);
|
||||
}
|
||||
protected virtual void Init(int id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayCtrl.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbd6e4f24a6cc1045ab6c3008988441c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/Scripts/SupplyDrop/SupplyDropGameplayLureCtrl.cs
Normal file
113
Assets/Scripts/SupplyDrop/SupplyDropGameplayLureCtrl.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class SupplyDropGameplayLureCtrl : SupplyDropGameplayCtrl, ISupplyDropGameCtrl
|
||||
{
|
||||
SupplyDropGameplayLure supplyDropGameplayLure;
|
||||
List<ItemData> lurecardItemDatas;
|
||||
SupplyDropItemLurecards supplyDropContent;
|
||||
LuckyGameRoot luckyGameRoot;
|
||||
protected override void Init(int id)
|
||||
{
|
||||
supplyDropGameplayLure = tables.TbSupplyDropGameplayLure.DataMap[id];
|
||||
SetData();
|
||||
|
||||
supplyDropContent = containerModel.GetComponent<SupplyDropItemLurecards>();
|
||||
supplyDropContent.Play();
|
||||
supplyDropContent.CardShuffle();
|
||||
supplyDropContent.transform.DOMoveZ(supplyDropContent.playZMove, supplyDropContent.playTime)
|
||||
.OnComplete(ShowModel);
|
||||
//ShowModel();
|
||||
}
|
||||
|
||||
void SetData()
|
||||
{
|
||||
if (supplyDropGameplayLure == null)
|
||||
{
|
||||
Debug.LogError("SupplyDropGameplayLure data is null");
|
||||
return;
|
||||
}
|
||||
lurecardItemDatas = new List<ItemData>();
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
int lurecardCount = supplyDropGameplayLure.DropID.Count;
|
||||
for (int i = 0; i < lurecardCount; i++)
|
||||
{
|
||||
ItemData itemData = playerItemData.GetItemDataOne(supplyDropGameplayLure.DropID[i]);
|
||||
lurecardItemDatas.Add(itemData);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowModel()
|
||||
{
|
||||
Addressables.InstantiateAsync("LuckyGameRoot").Completed += handle =>
|
||||
{
|
||||
if (handle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
gameModel = handle.Result;
|
||||
luckyGameRoot = gameModel.GetComponent<LuckyGameRoot>();
|
||||
|
||||
PlayAni();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async void PlayAni()
|
||||
{
|
||||
|
||||
List<int> indexs = new List<int>() { 0, 1, 2 };
|
||||
//打乱顺序
|
||||
|
||||
for (int i = 0; i < lurecardItemDatas.Count; i++)
|
||||
{
|
||||
ItemData itemData = lurecardItemDatas[i];
|
||||
int randomIndex = UnityEngine.Random.Range(0, indexs.Count);
|
||||
int j = indexs[randomIndex];
|
||||
indexs.RemoveAt(randomIndex);
|
||||
luckyGameRoot.lurecardItems[i].index = i;
|
||||
luckyGameRoot.lurecardItems[j].data = itemData;
|
||||
luckyGameRoot.lurecardItems[j].SetNum($"x{itemData.count}");
|
||||
luckyGameRoot.lurecardItems[j].skinned_meshe.material = supplyDropContent.material[i];
|
||||
}
|
||||
Vector3 posLocal = Camera.main.transform.InverseTransformPoint(supplyDropContent.singleCard.position);
|
||||
Vector3 posW = UIManager.Instance.UI3DCamera.transform.TransformPoint(posLocal);
|
||||
luckyGameRoot.Init(posW, supplyDropContent.singleCard.rotation);
|
||||
await luckyGameRoot.Fly();
|
||||
containerModel.SetActive(false);
|
||||
//await luckyGameRoot.PlayFlip();
|
||||
ShowPanel();
|
||||
}
|
||||
|
||||
async void ShowPanel()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUINotLoading(UITypes.Lucky3choose1Panel);
|
||||
Lucky3choose1Panel lucky3Choose1Panel = go.GetComponent<Lucky3choose1Panel>();
|
||||
lucky3Choose1Panel.Init(this);
|
||||
}
|
||||
|
||||
public async void ShowAllItem(int itemIndex)
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("supplydrop_game_choosecard"))
|
||||
{
|
||||
e.AddContent("reward_type", itemIndex + 1);
|
||||
}
|
||||
#endif
|
||||
if (luckyGameRoot != null)
|
||||
{
|
||||
await luckyGameRoot.ShowAllItem(itemIndex);
|
||||
}
|
||||
Dispose();
|
||||
UIManager.Instance.DestroyUI(UITypes.Lucky3choose1Panel);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayLureCtrl.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropGameplayLureCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf706b7961614664cb829917222761b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/SupplyDrop/SupplyDropItemCashGun.cs
Normal file
8
Assets/Scripts/SupplyDrop/SupplyDropItemCashGun.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropItemCashGun : SupplyDropContentModel
|
||||
{
|
||||
public Transform Point01;
|
||||
public Transform Point02;
|
||||
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropItemCashGun.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropItemCashGun.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67a3e1c5eda29354e994d4b60a4012d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Scripts/SupplyDrop/SupplyDropItemLurecards.cs
Normal file
24
Assets/Scripts/SupplyDrop/SupplyDropItemLurecards.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using asap.core;
|
||||
using Game;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropItemLurecards : SupplyDropContentModel
|
||||
{
|
||||
public List<TMP_Text> text_num;
|
||||
public List<SkinnedMeshRenderer> skinned_meshes;
|
||||
public List<Material> material;
|
||||
public Transform singleCard;
|
||||
public GameObject fx_card_shuffle;
|
||||
public float playZMove = 3f;
|
||||
public float playTime = 3f;
|
||||
|
||||
public void CardShuffle()
|
||||
{
|
||||
if (fx_card_shuffle)
|
||||
{
|
||||
fx_card_shuffle.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropItemLurecards.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropItemLurecards.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24ed4aad2f95f0b48936c88b9fee2109
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Scripts/SupplyDrop/SupplyDropModel.cs
Normal file
71
Assets/Scripts/SupplyDrop/SupplyDropModel.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class SupplyDropModel : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public Transform Content;
|
||||
GameObject fx_supplydrop_watersplash;
|
||||
GameObject fx_supplydrop_wateridle;
|
||||
GameObject fx_supplydrop_smoke;
|
||||
GameObject fx_supplydrop_packageopen;
|
||||
public void SetTrigger(string name)
|
||||
{
|
||||
animator.SetTrigger(name);
|
||||
}
|
||||
|
||||
public void FxSmokeDelay(float supplyDropFxSmokeDelay, float supplyDropPackIdleDelay)
|
||||
{
|
||||
SmokeDelay(supplyDropFxSmokeDelay);
|
||||
StartCoroutine(PackIdleDelay(supplyDropPackIdleDelay));
|
||||
}
|
||||
async void SmokeDelay(float supplyDropFxSmokeDelay)
|
||||
{
|
||||
fx_supplydrop_watersplash = await Addressables.InstantiateAsync("fx_supplydrop_watersplash", transform).Task;
|
||||
fx_supplydrop_wateridle = await Addressables.InstantiateAsync("fx_supplydrop_wateridle", transform).Task;
|
||||
await new WaitForSeconds(supplyDropFxSmokeDelay);
|
||||
//冒烟
|
||||
fx_supplydrop_smoke = await Addressables.InstantiateAsync("fx_supplydrop_smoke", transform).Task;
|
||||
}
|
||||
IEnumerator PackIdleDelay(float supplyDropPackIdleDelay)
|
||||
{
|
||||
yield return new WaitForSeconds(supplyDropPackIdleDelay);
|
||||
SetTrigger("Idle");
|
||||
}
|
||||
|
||||
public void SupplyDropOpen(float supplyDropOpenDelay)
|
||||
{
|
||||
SetTrigger("Open");
|
||||
//关闭冒烟
|
||||
if (fx_supplydrop_smoke != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_supplydrop_smoke);
|
||||
}
|
||||
DropOpenDelay(supplyDropOpenDelay);
|
||||
}
|
||||
async void DropOpenDelay(float supplyDropOpenDelay)
|
||||
{
|
||||
await new WaitForSeconds(supplyDropOpenDelay);
|
||||
//开光特效
|
||||
fx_supplydrop_packageopen = await Addressables.InstantiateAsync("fx_supplydrop_packageopen", transform).Task;
|
||||
}
|
||||
public void Hide()
|
||||
{
|
||||
//隐藏箱子
|
||||
gameObject.SetActive(false);
|
||||
if (fx_supplydrop_packageopen)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_supplydrop_packageopen);
|
||||
}
|
||||
if (fx_supplydrop_watersplash)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_supplydrop_watersplash);
|
||||
}
|
||||
if (fx_supplydrop_wateridle)
|
||||
{
|
||||
Addressables.ReleaseInstance(fx_supplydrop_wateridle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropModel.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropModel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c39d2b8c576785a4aaec1881fc43646e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Scripts/SupplyDrop/SupplyDropRewardPanel.cs
Normal file
44
Assets/Scripts/SupplyDrop/SupplyDropRewardPanel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SupplyDropRewardPanel : MonoBehaviour
|
||||
{
|
||||
Action OnClickClaim;
|
||||
Button btnClaim;
|
||||
GameObject title;
|
||||
GameObject receive;
|
||||
TMP_Text text_info;
|
||||
private void Awake()
|
||||
{
|
||||
title = transform.Find("root").gameObject;
|
||||
receive = transform.Find("receive").gameObject;
|
||||
btnClaim = transform.Find("receive/btn_play/btn_green").GetComponent<Button>();
|
||||
text_info = transform.Find("root/title/text_info").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btnClaim.onClick.AddListener(OnClickClaimButton);
|
||||
}
|
||||
public void Init(string name, float supplyDropTitleDelay, Action onCloseClaim)
|
||||
{
|
||||
StartCoroutine(ShowTitle(supplyDropTitleDelay));
|
||||
OnClickClaim = onCloseClaim;
|
||||
text_info.text = name;
|
||||
}
|
||||
void OnClickClaimButton()
|
||||
{
|
||||
OnClickClaim?.Invoke();
|
||||
}
|
||||
public void ShowClaim()
|
||||
{
|
||||
receive.SetActive(true);
|
||||
}
|
||||
IEnumerator ShowTitle(float supplyDropTitleDelay)
|
||||
{
|
||||
yield return new WaitForSeconds(supplyDropTitleDelay);
|
||||
title.SetActive(true);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SupplyDrop/SupplyDropRewardPanel.cs.meta
Normal file
11
Assets/Scripts/SupplyDrop/SupplyDropRewardPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fb7bb8c49905c24e8424617063c4bb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user