换皮
This commit is contained in:
@@ -2,12 +2,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.Common_01;
|
||||
using FGUI.Turntable_11;
|
||||
using IgnoreOPS;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -17,15 +15,16 @@ namespace ChillConnect
|
||||
{
|
||||
private WheelViewUICtrl ctrl;
|
||||
private WheelViewModel model;
|
||||
private readonly int[] vidieWeight = new int[12];
|
||||
private readonly int[] vidieWeight = new int[8];
|
||||
private TurntableModel turntableData;
|
||||
|
||||
private List<com_coin> ItemList = new();
|
||||
private bool isClickSpin;
|
||||
private bool isClickAbleWatchAD = true;
|
||||
|
||||
private SkeletonAnimation normalAnim;
|
||||
// private SkeletonAnimation turnAnim;
|
||||
private SkeletonAnimation awardAnim;
|
||||
// private SkeletonAnimation awardAnim;
|
||||
private Action closeCallback;
|
||||
|
||||
|
||||
@@ -68,10 +67,6 @@ namespace ChillConnect
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
// if (Screen.safeArea.y != 0)
|
||||
// {
|
||||
// // ui..y += Screen.safeArea.y;
|
||||
// }
|
||||
|
||||
LoadLastCheckDate();
|
||||
|
||||
@@ -87,15 +82,14 @@ namespace ChillConnect
|
||||
ItemList.Add(disc.award6);
|
||||
ItemList.Add(disc.award7);
|
||||
ItemList.Add(disc.award8);
|
||||
ItemList.Add(disc.award9);
|
||||
ItemList.Add(disc.award10);
|
||||
ItemList.Add(disc.award11);
|
||||
ItemList.Add(disc.award12);
|
||||
|
||||
HallManager.Instance.UpdateSecondEvent += UpdateTime;
|
||||
|
||||
turntableData = ConfigSystem.GetConfig<TurntableModel>();
|
||||
|
||||
|
||||
normalAnim = FXManager.Instance.SetFx<SkeletonAnimation>(ui.light_parent, Fx_Type.fx_wheel, ref closeCallback);
|
||||
|
||||
UpdateTime();
|
||||
|
||||
refreshData();
|
||||
@@ -146,14 +140,16 @@ namespace ChillConnect
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
normalAnim.state.SetAnimation(0, "zhuanpan_zhizhen_idle", true);
|
||||
for (var i = 0; i < ItemList.Count; i++)
|
||||
{
|
||||
vidieWeight[i] = turntableData.DataList[i].weight;
|
||||
}
|
||||
ui.disc.rotation = 0;
|
||||
ui.btn_spin.SetClick(SpineAnim);
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
ui.spin.touchable = false;
|
||||
ui.close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
@@ -170,52 +166,24 @@ namespace ChillConnect
|
||||
var id = turntable.wheel_item;
|
||||
var quantity = turntable.quantity;
|
||||
|
||||
item.text_num.text = "x" + (id == 0 ? GameHelper.Get101Str((decimal)quantity) : quantity.ToString());
|
||||
if (!GameHelper.IsGiftSwitch() && id == 102)
|
||||
{
|
||||
id = 101;
|
||||
quantity *= 10;
|
||||
}
|
||||
|
||||
setItemUrl(item.item_icon, id, (int)quantity);
|
||||
item.text_num.text = id == 102 ? GameHelper.Get102Str((decimal)quantity) : GameHelper.Get101Str((decimal)quantity);
|
||||
item.status.selectedIndex = id == 102 ? com_coin.Status_b : com_coin.Status_a;
|
||||
}
|
||||
|
||||
|
||||
var times = DataMgr.ThisDayWatchSlyderVideoNum.Value;
|
||||
var limits = GameHelper.GetCommonModel().wheelTimes[0];
|
||||
ui.text_spin.SetVar("times", times.ToString()).FlushVars();
|
||||
ui.text_spin.SetVar("limits", limits.ToString()).FlushVars();
|
||||
ui.spin.text_spintimes.SetVar("times", times.ToString()).FlushVars();
|
||||
ui.spin.text_spintimes.SetVar("limits", limits.ToString()).FlushVars();
|
||||
|
||||
}
|
||||
|
||||
public string GetIndex(int quantity)
|
||||
{
|
||||
// 验证输入是否为有效数值
|
||||
if (quantity < 0)
|
||||
{
|
||||
throw new ArgumentException("Quantity must be a non-negative integer.");
|
||||
}
|
||||
|
||||
// 使用 switch 表达式明确处理边界条件
|
||||
return quantity switch
|
||||
{
|
||||
<= 80 => "1",
|
||||
> 80 and <= 150 => "2",
|
||||
> 150 => "3",
|
||||
};
|
||||
}
|
||||
|
||||
void setItemUrl(GLoader loader, int urltype, int quantity)
|
||||
{
|
||||
if (urltype == 0)
|
||||
{
|
||||
string idx = GetIndex(quantity);
|
||||
|
||||
loader.url = $"ui://Turntable_11/spin_gold{idx}";
|
||||
}
|
||||
else if (urltype == 1) loader.url = "ui://Common_01/spin_remove";
|
||||
else if (urltype == 2) loader.url = "ui://Common_01/spin_undo";
|
||||
else if (urltype == 3) loader.url = "ui://Common_01/spin_refresh";
|
||||
// if(urltype > 0) loader.SetScale(0.7f, 0.7f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
@@ -268,160 +236,72 @@ namespace ChillConnect
|
||||
}
|
||||
}
|
||||
|
||||
void hideAllLight()
|
||||
{
|
||||
for (int i = 0; i < ItemList.Count; i++)
|
||||
{
|
||||
ItemList[i].light.visible = false;
|
||||
ItemList[i].light1.visible = false;
|
||||
ItemList[i].light_anim.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Spin()
|
||||
{
|
||||
// normalAnim.SetActive(false);
|
||||
|
||||
if (awardAnim != null)
|
||||
{
|
||||
// 停止之前的动画并释放资源
|
||||
awardAnim.state.ClearTracks();
|
||||
awardAnim = null;
|
||||
}
|
||||
|
||||
hideAllLight();
|
||||
|
||||
ui.disc.rotation = 0;
|
||||
normalAnim.state.SetAnimation(0, "zhuanpan_zhizhen_run", true);
|
||||
isClickSpin = true;
|
||||
ui.btn_close.touchable = false;
|
||||
ui.btn_close.grayed = false;
|
||||
ui.close.touchable = false;
|
||||
ui.close.grayed = false;
|
||||
|
||||
ui.btn_spin.touchable = false;
|
||||
|
||||
var index = CommonHelper.GetIndexByChanceList(vidieWeight);
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.wheel_spin);
|
||||
var data = turntableData.DataList[index];
|
||||
Debug.Log("spin index=== : " + index);
|
||||
int allNum = ItemList.Count * 6 + index;
|
||||
int itemCount = ItemList.Count;
|
||||
float[] timess = (float[])ReceivePlanes(allNum);
|
||||
var angle = 3600 - (data.Seq - 1) * 45;
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.wheel_spin);
|
||||
DOTween.To(() => ui.disc.rotation, e => ui.disc.rotation = e, angle, turnTime)
|
||||
.SetEase(Ease.OutQuad);
|
||||
|
||||
float totalTimes = timess.Last();
|
||||
for (int i = 0; i < allNum; i++)
|
||||
{
|
||||
int currentIndex = i % itemCount;
|
||||
float time = timess[i];
|
||||
|
||||
DOVirtual.DelayedCall(time, () =>
|
||||
{
|
||||
int selectI = currentIndex + 1;
|
||||
if (currentIndex + 1 > itemCount - 1)
|
||||
{
|
||||
selectI = 0;
|
||||
}
|
||||
ItemList[selectI].light.visible = true;
|
||||
ItemList[selectI].light1.visible = true;
|
||||
|
||||
ItemList[currentIndex].light.visible = false;
|
||||
ItemList[currentIndex].light1.visible = false;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ResultTween = DOVirtual.DelayedCall(totalTimes, () => ReceivePlane(data, index));
|
||||
ResultTween = DOVirtual.DelayedCall(turnTime, () => ReceivePlane(data));
|
||||
|
||||
}
|
||||
|
||||
private Array ReceivePlanes(int nums)
|
||||
private void ReceivePlane(Turntable vo)
|
||||
{
|
||||
float start = 0.25f;
|
||||
float end = 0.06f;
|
||||
float delta = 0.02f;
|
||||
float lastDelta = 0.1f;
|
||||
|
||||
float delay = start;
|
||||
float[] sum = new float[nums];
|
||||
for (int i = 0; i < nums; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
sum[i] = delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
sum[i] = sum[i - 1] + delay;
|
||||
}
|
||||
|
||||
if (delay > end)
|
||||
{
|
||||
delay -= delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = end;
|
||||
}
|
||||
|
||||
//后8个间隔变慢
|
||||
if (i >= nums - 8)
|
||||
{
|
||||
sum[i] += lastDelta;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private void ReceivePlane(Turntable vo, int index)
|
||||
{
|
||||
ItemList[index].light1.visible = false;
|
||||
|
||||
ItemList[index].light_anim.visible = true;
|
||||
awardAnim = FXManager.Instance.SetFx<SkeletonAnimation>(ItemList[index].light_anim, Fx_Type.fx_wheel, ref closeCallback);
|
||||
awardAnim.state.SetAnimation(0, "animation", true);
|
||||
normalAnim.state.SetAnimation(0, "zhuanpan_win", true);
|
||||
|
||||
DOVirtual.DelayedCall(1.5f, () =>
|
||||
{
|
||||
isClickSpin = false;
|
||||
ResultTween = null;
|
||||
ui.btn_close.touchable = true;
|
||||
ui.btn_close.grayed = false;
|
||||
ui.close.touchable = true;
|
||||
ui.close.grayed = false;
|
||||
|
||||
ui.btn_spin.cont_spin.selectedIndex = btn_go1.Spin_grey;
|
||||
ui.btn_spin.cont_spin.selectedIndex = 1;
|
||||
|
||||
ui.btn_spin.cont_state.selectedIndex = btn_go1.State_Video;
|
||||
ui.btn_spin.cont_state.selectedIndex = 1;
|
||||
|
||||
var id = vo.wheel_item;
|
||||
var quantity = vo.quantity;
|
||||
Debug.Log($"barry ReceivePlane===: {id} {quantity}");
|
||||
if (id == 0)
|
||||
{
|
||||
var startPoint = GameHelper.GetUICenterPosition(ItemList[index]);
|
||||
var endPoint = GameHelper.GetUICenterPosition(ui.point);
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(101, (decimal)quantity, RewardOrigin.LuckyWheel, index)
|
||||
{
|
||||
startPosition = startPoint,
|
||||
endPosition = new Vector2(endPoint.x - 150, endPoint.y - 136),
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.Dialog |
|
||||
RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
|
||||
});
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
}
|
||||
else
|
||||
if (!GameHelper.IsGiftSwitch() && id == 102)
|
||||
{
|
||||
GameHelper.AddItemNumber(id - 1, (int)quantity);
|
||||
GameHelper.ShowTips("Successfully received");
|
||||
id = 101;
|
||||
quantity *= 10;
|
||||
}
|
||||
|
||||
var endPoint = GameHelper.GetUICenterPosition(ui.point);
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(id, (decimal)quantity, RewardOrigin.LuckyWheel)
|
||||
{
|
||||
endPosition = new Vector2(endPoint.x - 150, endPoint.y - 136),
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
normalAnim.state.SetAnimation(0, "zhuanpan_zhizhen_idle", true);
|
||||
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
|
||||
DataMgr.NextOpenWheelStampTime.Value =
|
||||
GameHelper.GetNowTime() + GameHelper.GetCommonModel().wheelTimes[1];
|
||||
DataMgr.ThisDayWatchSlyderVideoNum.Value++;
|
||||
DataMgr.ThisDayWatchSlyderVideoNum.Value = DataMgr.ThisDayWatchSlyderVideoNum.Value + 1;
|
||||
|
||||
UpdateTime();
|
||||
refreshData();
|
||||
@@ -435,11 +315,10 @@ namespace ChillConnect
|
||||
DateTime currentTime = DateTime.Now;
|
||||
|
||||
|
||||
ui.btn_spin.cont_state.selectedIndex = btn_go1.State_Limit;
|
||||
ui.btn_spin.cont_state.selectedIndex = 2;
|
||||
ui.btn_spin.touchable = false;
|
||||
ui.btn_spin.enabled = false;
|
||||
ui.btn_spin.cont_spin.selectedIndex = btn_go1.Spin_grey;
|
||||
ui.btn_spin.img_saveingpot.visible = false;
|
||||
ui.btn_spin.cont_spin.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -447,24 +326,15 @@ namespace ChillConnect
|
||||
{
|
||||
ui.btn_spin.touchable = true;
|
||||
ui.btn_spin.enabled = true;
|
||||
ui.btn_spin.cont_spin.selectedIndex = btn_go1.Spin_none;
|
||||
ui.btn_spin.cont_state.selectedIndex = btn_go1.State_None;
|
||||
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1)
|
||||
{
|
||||
ui.btn_spin.img_saveingpot.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_spin.img_saveingpot.visible = false;
|
||||
}
|
||||
ui.btn_spin.cont_spin.selectedIndex = 0;
|
||||
ui.btn_spin.cont_state.selectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_spin.touchable = false;
|
||||
ui.btn_spin.enabled = false;
|
||||
ui.btn_spin.cont_spin.selectedIndex = btn_go1.Spin_grey;
|
||||
ui.btn_spin.cont_state.selectedIndex = btn_go1.State_Video;
|
||||
ui.btn_spin.img_saveingpot.visible = false;
|
||||
ui.btn_spin.cont_spin.selectedIndex = 1;
|
||||
ui.btn_spin.cont_state.selectedIndex = 1;
|
||||
}
|
||||
|
||||
ui.btn_spin.text_time.text = model.NextOpenWheelTimeStr;
|
||||
|
||||
Reference in New Issue
Block a user