备份CatanBuilding瘦身独立工程
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user