ball 项目提交
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class GetTaskRewardCtrl : BaseCtrl
|
||||
{
|
||||
public static GetTaskRewardCtrl Instance { get; private set; }
|
||||
|
||||
private GetTaskRewardModel model;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
//model = ModuleManager.Instance..GetModel(ModelConst.GetTaskRewardModel) as GetTaskRewardModel;
|
||||
}
|
||||
|
||||
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,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87ee97ded9a294cd39e08c80f08dd72d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class GetTaskRewardModel : 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ecff54cb7d2546328d5e92f9f89abad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,276 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Spine.Unity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.LG_Common;
|
||||
using FGUI.ZM_Common_01;
|
||||
using IgnoreOPS;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class GetTaskRewardUI : BaseUI
|
||||
{
|
||||
private GetTaskRewardUICtrl ctrl;
|
||||
private GetTaskRewardModel model;
|
||||
private FGUI.ZM_Tasks_13.com_task_reward ui;
|
||||
|
||||
public GetTaskRewardUI(GetTaskRewardUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.GetTaskRewardUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Tasks_13";
|
||||
uiInfo.assetName = "com_task_reward";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.GetTaskRewardModel) as GetTaskRewardModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
closeCallback?.Invoke();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Tasks_13.com_task_reward;
|
||||
}
|
||||
private Action closeCallback;
|
||||
private int rewardNum;
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
if (args == null) return;
|
||||
var data = (ScrollItemData)args;
|
||||
weightList = data.weight;
|
||||
boostList = data.Boost;
|
||||
|
||||
rewardNum = data.rewards;
|
||||
rate = GetRandomBoost();
|
||||
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(baseUI.GetChild("bg_parent") as GGraph, Fx_Type.fx_win, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "out", true);
|
||||
|
||||
InitView();
|
||||
// Debug.Log(args);
|
||||
int number = data.rewards;
|
||||
ui.text_award.text = number.ToString();
|
||||
|
||||
((btn_claim3)ui.btn_claim).title = number.ToString();
|
||||
|
||||
ui.btn_claim.SetClick(() =>
|
||||
{
|
||||
GameHelper.addInterAdnumber();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetTaskReward, rewardNum);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GetTaskRewardUI_Close);
|
||||
});
|
||||
if (SaveData.GetSaveObject().LargeRewardNum < ConfigSystem.GetCommonConf().FreeClaims)
|
||||
{
|
||||
(ui.btn_mult as FGUI.ZM_Common_01.btn_claim4).state.selectedIndex = 1;
|
||||
}
|
||||
ui.btn_mult.SetClick(() =>
|
||||
{
|
||||
|
||||
if (SaveData.GetSaveObject().LargeRewardNum < ConfigSystem.GetCommonConf().FreeClaims)
|
||||
{
|
||||
StartScroll();
|
||||
SaveData.GetSaveObject().LargeRewardNum++;
|
||||
SaveData.SaveDataFunc();
|
||||
ui.btn_claim.touchable = ui.btn_mult.touchable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("TaskReward", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
StartScroll();
|
||||
ui.btn_claim.touchable = ui.btn_mult.touchable = false;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.GetTaskReward, true);
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GetTaskRewardUI_Close);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (AudioManager.Instance.IsOpenEffect)
|
||||
{
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.Victoriously);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t0.Play(Scroll);
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t1.Play(() =>
|
||||
{
|
||||
rate_idnex++;
|
||||
ui.btn_mult.title = "" + rewardNum * boostList[rate_idnex % 5];
|
||||
});
|
||||
ui.btn_mult.title = "" + rewardNum * boostList[rate_idnex];
|
||||
|
||||
list_1 = new List<item_wheel>() { ((wheel_)ui.wheel.GetChild("wheel_")).item_0, ((wheel_)ui.wheel.GetChild("wheel_")).item_1, (ui.wheel.GetChild("wheel_") as wheel_).item_2, (ui.wheel.GetChild("wheel_") as wheel_).item_3, (ui.wheel.GetChild("wheel_") as wheel_).item_4, (ui.wheel.GetChild("wheel_") as wheel_).item_5, (ui.wheel.GetChild("wheel_") as wheel_).item_6, (ui.wheel.GetChild("wheel_") as wheel_).item_7, };
|
||||
// list_1[2].img_light.visible = true;
|
||||
|
||||
for (int i = 0; i < list_1.Count; i++)
|
||||
{
|
||||
list_1[i].type.selectedIndex = (i + scroll_number) % 3;
|
||||
list_1[i].text_rate.text = "X" + boostList[i % boostList.Length];
|
||||
}
|
||||
}
|
||||
|
||||
List<item_wheel> list_1;
|
||||
private int rate_idnex = 3;
|
||||
private int scroll_number;
|
||||
List<int> rate_list = new List<int>();
|
||||
private int scroll_type = 1;
|
||||
private int rate;
|
||||
private int[] boostList;
|
||||
private void StartScroll()
|
||||
{
|
||||
ui.btn_mult.SetClick(() => { });
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t0.timeScale = 5.0f;
|
||||
scroll_type = 2;
|
||||
}
|
||||
private void Scroll()
|
||||
{
|
||||
if (scroll_type == 1)
|
||||
{
|
||||
scroll_number++;
|
||||
rate_list.Clear();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
rate_list.Add(boostList[(scroll_number + i) % boostList.Length]);
|
||||
}
|
||||
for (int i = 0; i < list_1.Count; i++)
|
||||
{
|
||||
list_1[i].type.selectedIndex = (i + scroll_number) % 3;
|
||||
list_1[i].text_rate.text = "X" + rate_list[i];
|
||||
}
|
||||
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t1.Play(() =>
|
||||
{
|
||||
rate_idnex++;
|
||||
ui.btn_mult.title = GameHelper.Get101Str((decimal)rewardNum * boostList[rate_idnex % boostList.Length]);
|
||||
});
|
||||
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t0.Play(Scroll);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
scroll_number++;
|
||||
|
||||
rate_list.Clear();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
rate_list.Add(boostList[(scroll_number + i) % boostList.Length]);
|
||||
}
|
||||
|
||||
// bool need_return = false;
|
||||
|
||||
if (((wheel_)ui.wheel.GetChild("wheel_")).t0.timeScale < 2f && list_1[4].text_rate.text == ("X" + rate))
|
||||
{
|
||||
Debug.Log($"开始领取2---------------{rewardNum} {rate}");
|
||||
//开始领取
|
||||
int reward = rewardNum * rate;
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetTaskReward, reward);
|
||||
|
||||
CtrlCloseUI();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < list_1.Count; i++)
|
||||
{
|
||||
list_1[i].type.selectedIndex = (i + scroll_number) % 3;
|
||||
list_1[i].text_rate.text = "X" + rate_list[i];
|
||||
}
|
||||
|
||||
// if (need_return)
|
||||
// {
|
||||
// (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale = 0;
|
||||
// return;
|
||||
// }
|
||||
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t1.Play(() =>
|
||||
{
|
||||
rate_idnex++;
|
||||
ui.btn_mult.title = GameHelper.Get101Str((decimal)rewardNum * boostList[rate_idnex % boostList.Length]);
|
||||
});
|
||||
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t0.Play(Scroll);
|
||||
((wheel_)ui.wheel.GetChild("wheel_")).t0.timeScale = ((wheel_)ui.wheel.GetChild("wheel_")).t0.timeScale - 0.3f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int[] weightList;
|
||||
public int GetRandomBoost()
|
||||
{
|
||||
int rate_all = 0;
|
||||
for (int i = 0; i < weightList.Length; i++)
|
||||
{
|
||||
rate_all += weightList[i];
|
||||
}
|
||||
|
||||
var videoRewardRate = 0;
|
||||
int random_ = Random.Range(0, rate_all);
|
||||
int int_ = 0;
|
||||
for (int i = 0; i < weightList.Length; i++)
|
||||
{
|
||||
int_ += weightList[i];
|
||||
if (random_ < int_)
|
||||
{
|
||||
return boostList[i];
|
||||
}
|
||||
}
|
||||
|
||||
return videoRewardRate;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68d77870ef81f4afaabf33d1c0470495
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class GetTaskRewardUICtrl : BaseUICtrl
|
||||
{
|
||||
private GetTaskRewardUI ui;
|
||||
private GetTaskRewardModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.GetTaskRewardUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.GetTaskRewardUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.GetTaskRewardModel) as GetTaskRewardModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new GetTaskRewardUI(this);
|
||||
ui.Open(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (ui != null && !ui.isClose)
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
ui = null;
|
||||
}
|
||||
#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,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89cba9dc9d404422291d75698d7fcb60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user