141 lines
4.3 KiB
C#
141 lines
4.3 KiB
C#
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"));
|
|
}
|
|
}
|
|
}
|