ball 项目提交
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class RewardAniCtrl : BaseCtrl
|
||||
{
|
||||
public static RewardAniCtrl Instance { get; private set; }
|
||||
|
||||
private RewardAniModel model;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14c240eb0c71404f96bf61b0a7883f09
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class RewardAniModel : BaseModel
|
||||
{
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
// protected override void OnReset()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 读取数据
|
||||
|
||||
// protected override void OnReadData()
|
||||
// {
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 本地存储
|
||||
|
||||
|
||||
|
||||
// protected override void WriteLocalStorage()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class RewardAniData : IDisposable
|
||||
{
|
||||
public float CoinSum;
|
||||
|
||||
public float AddCoinSum;
|
||||
|
||||
public int RewardId;
|
||||
public Vector2 target;
|
||||
public Vector2 origin;
|
||||
public Vector2 center;
|
||||
|
||||
public event Action<float> UpdataCb;
|
||||
public event Action EndEventCb;
|
||||
public event Action UICloseEventCb;
|
||||
|
||||
private float coinAddTime = 0.45f;
|
||||
|
||||
|
||||
public bool IsPlayAudio;
|
||||
|
||||
public RewardAniData(int id, float sum, Vector2 starPot = default, Vector2 tar = default)
|
||||
{
|
||||
RewardId = id;
|
||||
CoinSum = sum;
|
||||
origin = starPot;
|
||||
target = tar;
|
||||
AddCoinSum = CoinSum;
|
||||
}
|
||||
|
||||
public void Updata()
|
||||
{
|
||||
float val = CoinSum * Time.deltaTime / coinAddTime;
|
||||
if (AddCoinSum >= val)
|
||||
{
|
||||
AddCoinSum -= val;
|
||||
UpdataCb?.Invoke(val);
|
||||
}
|
||||
else if (AddCoinSum > 0)
|
||||
{
|
||||
UpdataCb?.Invoke(AddCoinSum);
|
||||
AddCoinSum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndEvent();
|
||||
}
|
||||
}
|
||||
|
||||
public void EndEvent()
|
||||
{
|
||||
EndEventCb?.Invoke();
|
||||
EndEventCb = null;
|
||||
}
|
||||
|
||||
public void UICloseEvent()
|
||||
{
|
||||
UICloseEventCb?.Invoke();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UpdataCb = null;
|
||||
EndEventCb = null;
|
||||
UICloseEventCb = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0da355b99aee4e25ad73771052d52516
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,291 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using DG.Tweening;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
using FGUI.ZM_Coins_101;
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class RewardAniUI : BaseUI
|
||||
{
|
||||
private RewardAniUICtrl ctrl;
|
||||
private RewardAniModel model;
|
||||
private FGUI.ZM_Coins_101.com_coinFly ui;
|
||||
|
||||
public RewardDisplayData data;
|
||||
|
||||
|
||||
private bool isUpdate = false;
|
||||
|
||||
|
||||
private int completeSum = 0;
|
||||
|
||||
|
||||
private float toSizeAniTime = 0.4f;
|
||||
|
||||
|
||||
private float moveAniTime = 0.5f;
|
||||
|
||||
|
||||
private float showAniTime = 0.1f;
|
||||
|
||||
|
||||
private bool isRiseUI;
|
||||
|
||||
private Action CloseCb;
|
||||
|
||||
private List<Tween> tweenList = new List<Tween>();
|
||||
|
||||
private Tween closeTween;
|
||||
|
||||
public RewardAniUI(RewardAniUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.RewardAniUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Coins_101";
|
||||
uiInfo.assetName = "com_coinFly";
|
||||
uiInfo.layerType = UILayerType.Animation;
|
||||
uiInfo.isTickUpdate = true;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
if (!isUpdate)
|
||||
{
|
||||
if (isRiseUI)
|
||||
{
|
||||
if (data.rewardSingleData.id == 101 || data.rewardSingleData.id == 102)
|
||||
{
|
||||
GameHelper.OnRiseUIRecover(data.rewardSingleData.id, UILayerType.Normal);
|
||||
isRiseUI = false;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data?.Update();
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.RewardAniModel) as RewardAniModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
foreach (var tween in tweenList)
|
||||
{
|
||||
if (tween is { active: true })
|
||||
{
|
||||
tween.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
tweenList.Clear();
|
||||
|
||||
data?.EndEvent();
|
||||
|
||||
DOVirtual.DelayedCall(Time.deltaTime, delegate
|
||||
{
|
||||
data?.UICloseEvent();
|
||||
data?.Dispose();
|
||||
});
|
||||
CloseCb?.Invoke();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_coinFly;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (args is RewardDisplayData displayModel)
|
||||
{
|
||||
data = displayModel;
|
||||
}
|
||||
|
||||
ui.com_coins.visible = false;
|
||||
ui.text_Add.visible = false;
|
||||
|
||||
InitView(data);
|
||||
}
|
||||
|
||||
private void InitView(RewardDisplayData data)
|
||||
{
|
||||
if (data.isPlayAudio)
|
||||
{
|
||||
AudioManager.Instance.PlayDynamicEffect(data.audioName);
|
||||
}
|
||||
|
||||
if (data.isNeedFly)
|
||||
{
|
||||
var comFly = UIPackage.CreateObject("ZM_Coins_101", "com_coinFly").asCom as com_coinFly;
|
||||
|
||||
var comFlyCurrency = comFly.com_coins;
|
||||
comFlyCurrency.visible = true;
|
||||
if (!data.isSingle)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("+");
|
||||
if (data.rewardSingleData.id == 102 || data.rewardSingleData.id == 106)
|
||||
{
|
||||
}
|
||||
|
||||
sb.Append(GameHelper.GetNumStr(data.rewardSingleData.GetTotalValue(), 2));
|
||||
comFly.text_Add.SetText(sb.ToString());
|
||||
comFly.text_Add.position = data.rewardSingleData.startPosition;
|
||||
// comFly.fx_addSum.Play();
|
||||
}
|
||||
|
||||
comFlyCurrency.cont_coin.selectedIndex =
|
||||
!data.isSingle ? com_coins.Coin_more : com_coins.Coin_single;
|
||||
comFlyCurrency.position = data.rewardSingleData.startPosition;
|
||||
data.rewardSingleData.startPosition.x -= 150;
|
||||
data.rewardSingleData.startPosition.y -= 136;
|
||||
data.rewardSingleData.endPosition.x -= 150;
|
||||
data.rewardSingleData.endPosition.y -= 136;
|
||||
|
||||
float val = 0f;
|
||||
|
||||
comFly.fx_enter.position = comFlyCurrency.position;
|
||||
|
||||
|
||||
foreach (var o in comFlyCurrency.GetChildren())
|
||||
{
|
||||
var item = (FGUI.ZM_Coins_101.com_coin)o;
|
||||
if (!item.visible)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
item.visible = false;
|
||||
//item.icon.texture = TextureHelper.GetItemIcon(data.rewardSingleData.id);
|
||||
TextureHelper.GetItemIcon(data.rewardSingleData.id, spr => { item.icon.texture = spr; });
|
||||
float def = val;
|
||||
var tween = DOVirtual.DelayedCall(0.05f, () =>
|
||||
{
|
||||
item.visible = true;
|
||||
|
||||
Vector2 tar = new Vector2(
|
||||
Random.Range(0, item.parent.size.x / (!data.isSingle ? 1 : 2)),
|
||||
Random.Range(0, item.parent.size.y / (!data.isSingle ? 1 : 2)));
|
||||
item.size = Vector2.zero;
|
||||
item.position = new Vector2(item.parent.width / 2, item.parent.height / 2);
|
||||
if (!data.isSingle)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
toSizeAniTime = 0.2f;
|
||||
}
|
||||
|
||||
item.TweenMove(tar, toSizeAniTime + def);
|
||||
var moveTween = DOTween.To(() => item.size, (e) => item.size = e, Vector2.one,
|
||||
toSizeAniTime + def);
|
||||
tweenList.Add(moveTween);
|
||||
|
||||
item.icon.visible = true;
|
||||
var delayTween = DOVirtual.DelayedCall(toSizeAniTime + def, () =>
|
||||
{
|
||||
var moveTime = moveAniTime;
|
||||
var moveTween2 = DOTween.To(() => item.icon.alpha, (e) => { item.icon.alpha = e; },
|
||||
0.6f,
|
||||
moveTime);
|
||||
tweenList.Add(moveTween2);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
item.TweenMove(data.rewardSingleData.endPosition -
|
||||
(Vector2)item.parent.position +
|
||||
item.parent.size / 2, moveTime);
|
||||
}
|
||||
|
||||
|
||||
var delayTween2 = DOVirtual.DelayedCall(moveTime, () =>
|
||||
{
|
||||
item.icon.visible = false;
|
||||
completeSum++;
|
||||
var fxPlayData = FxPlayData.Get(Fx_Type.fx_ui_jinbi_click, 1,
|
||||
item.LocalToRoot(Vector2.zero, GRoot.inst));
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.PlayUIFX, fxPlayData);
|
||||
|
||||
if (!isUpdate)
|
||||
{
|
||||
isUpdate = true;
|
||||
}
|
||||
|
||||
if (data.isSingle)
|
||||
{
|
||||
if (closeTween is { active: true })
|
||||
{
|
||||
closeTween.Kill();
|
||||
}
|
||||
|
||||
closeTween = DOVirtual.DelayedCall(2f, CtrlCloseUI);
|
||||
tweenList.Add(closeTween);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (completeSum >= comFly.numChildren)
|
||||
{
|
||||
if (closeTween is { active: true })
|
||||
{
|
||||
closeTween.Kill();
|
||||
}
|
||||
|
||||
closeTween = DOVirtual.DelayedCall(2f, CtrlCloseUI);
|
||||
tweenList.Add(closeTween);
|
||||
}
|
||||
}
|
||||
});
|
||||
tweenList.Add(delayTween2);
|
||||
});
|
||||
tweenList.Add(delayTween);
|
||||
});
|
||||
tweenList.Add(tween);
|
||||
val += 0.02f;
|
||||
}
|
||||
|
||||
ui.AddChild(comFly);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2108e5e1b03943e6b17e9b03fc7f0fa0
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class RewardAniUICtrl : BaseUICtrl
|
||||
{
|
||||
private RewardAniModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.RewardAniUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.RewardAniUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
private Queue<RewardAniUI> removeList = new Queue<RewardAniUI>();
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (removeList.Count > 0)
|
||||
{
|
||||
DOVirtual.DelayedCall(3f, () =>
|
||||
{
|
||||
if (removeList.Count > 0)
|
||||
{
|
||||
var tmpUI = removeList.Peek();
|
||||
tmpUI?.CtrlCloseUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var rewardAniUI = new RewardAniUI(this);
|
||||
rewardAniUI.Open(args);
|
||||
removeList.Enqueue(rewardAniUI);
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (removeList.Count > 0)
|
||||
{
|
||||
var tmpUI = removeList.Dequeue();
|
||||
if (tmpUI != null && !tmpUI.isClose)
|
||||
{
|
||||
tmpUI.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4381e765f7004f68975536de233a02da
|
||||
timeCreated: 1671086538
|
||||
Reference in New Issue
Block a user