提交项目
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using BingoBrain.Core;
|
||||
using BingoBrain.HotFix;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class SomsionCtrl : BaseCtrl
|
||||
{
|
||||
public static SomsionCtrl Instance { get; private set; }
|
||||
|
||||
private SomsionModel model;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
model = ModuleBoardk.GetModel(ModelConst.SomsionModel) as SomsionModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
ctrlDispatcher.AddListener(CtrlMsg.GameNewDays, RestEventDayMissionsProgress);
|
||||
gameDispatcher.AddListener(BingoInfo.ShowGameOver, AddBingGoNum);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
ctrlDispatcher.RemoveListener(CtrlMsg.GameNewDays, RestEventDayMissionsProgress);
|
||||
gameDispatcher.RemoveListener(BingoInfo.ShowGameOver, AddBingGoNum);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 重置刷新任务
|
||||
/// </summary>
|
||||
public void RestEventDayMissionsProgress(object obj)
|
||||
{
|
||||
SetActiveMissionsLst();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置一次活跃任务
|
||||
/// </summary>
|
||||
protected void SetActiveMissionsLst()
|
||||
{
|
||||
PreferencesMgr.Instance.ActiveMissions.Clear();
|
||||
var dataList = GameHelper.GetConfig<TaskListModel>().GetDataList();
|
||||
// dataList.Select(item => new Task(item.id, item.taskNum))
|
||||
// .ToList()
|
||||
// .ForEach(task =>
|
||||
// {
|
||||
// task.InitData();
|
||||
// PreferencesMgr.Instance.ActiveMissions.Add(task);
|
||||
// });
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
var item = dataList[i];
|
||||
var task = new Task(item.id, item.taskNum);
|
||||
task.InitData();
|
||||
PreferencesMgr.Instance.ActiveMissions.Add(task);
|
||||
}
|
||||
|
||||
PreferencesMgr.Instance.SaveActiveMissions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存日常任务数据 累加
|
||||
/// </summary>
|
||||
/// <param name="id">任务的id </param>
|
||||
/// <param name="value">值</param>
|
||||
public void AddTaskVal(int id, int value = 1)
|
||||
{
|
||||
// var task = PreferencesMgr.Instance.ActiveMissions.Find((e) => e.Id == id);
|
||||
Task task = null; // 假设 TaskType 是任务的类型
|
||||
for (int i = 0; i < PreferencesMgr.Instance.ActiveMissions.Count; i++)
|
||||
{
|
||||
if (PreferencesMgr.Instance.ActiveMissions[i].Id == id)
|
||||
{
|
||||
task = PreferencesMgr.Instance.ActiveMissions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (value > 0 && task is { IsReward: false })
|
||||
{
|
||||
task.Progress += value;
|
||||
task.Progress = Mathf.Clamp(task.Progress, 0, task.MaxProgress);
|
||||
PreferencesMgr.Instance.SaveActiveMissions();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddBingGoNum(object o)
|
||||
{
|
||||
Instance.AddTaskVal(1);
|
||||
Instance.AddTaskVal(2);
|
||||
Instance.AddTaskVal(3);
|
||||
Instance.AddTaskVal(4);
|
||||
Instance.AddTaskVal(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61e7c714180e435b93795a8573f8a86c
|
||||
timeCreated: 1679628744
|
||||
@@ -0,0 +1,33 @@
|
||||
using BingoBrain.Core;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class SomsionModel : BaseModel
|
||||
{
|
||||
public string GetNextReTimeStr
|
||||
{
|
||||
get
|
||||
{
|
||||
var str = $"{nameof(Reset)} in: {GameHelper.GetInterval(GameHelper.GetTomorrowCountTime())}";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnReset()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e200a8519b9c45cbaae93196ade7c678
|
||||
timeCreated: 1679628745
|
||||
@@ -0,0 +1,193 @@
|
||||
using FairyGUI;
|
||||
using BingoBrain.Core;
|
||||
using BingoBrain.HotFix;
|
||||
using FGUI.JTask;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using DontConfuse;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class SomsionUI : BaseUI
|
||||
{
|
||||
private SomsionUICtrl ctrl;
|
||||
private SomsionModel model;
|
||||
private com_task ui;
|
||||
|
||||
public SomsionUI(SomsionUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SomsionUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "JTask";
|
||||
uiInfo.assetName = "com_task";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = true;
|
||||
uiInfo.isNeedCloseAnim = true;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = ModuleBoardk.GetModel(ModelConst.SomsionModel) as SomsionModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
ui?.FadeOut();
|
||||
WebviewManager.Instance.SetDarkThough(true);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_task;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
WebviewManager.Instance.SetDarkThough(false);
|
||||
Audio.Instance.PlayDynamicEffect("pop_open");
|
||||
ui.list_task.itemRenderer = ItemRenderer;
|
||||
ui.list_task.numItems = PreferencesMgr.Instance.ActiveMissions.Count;
|
||||
ui.closeButton.SetClick(() =>
|
||||
{
|
||||
Audio.Instance.PlayDynamicEffect("button");
|
||||
CtrlCloseUI();
|
||||
});
|
||||
RefreshTime();
|
||||
Hall.Instance.UpdateSecondEvent += RefreshTime;
|
||||
|
||||
}
|
||||
|
||||
private void RefreshTime()
|
||||
{
|
||||
ui.text_time.text = model.GetNextReTimeStr;
|
||||
}
|
||||
|
||||
internal void ItemRenderer(int index, GObject item)
|
||||
{
|
||||
|
||||
com_Singletask _Singletask = item as com_Singletask;
|
||||
if (GameHelper.IsGiftSwitch()) _Singletask.gift.selectedIndex = 1;
|
||||
Task task = PreferencesMgr.Instance.ActiveMissions[index];
|
||||
Debug.Log(JsonConvert.SerializeObject(PreferencesMgr.Instance.ActiveMissions));
|
||||
TaskList taskVO = GameHelper.GetConfig<TaskListModel>().GetData(task.Id);
|
||||
_Singletask.text_taskname.text = taskVO.taskName.Replace("%s", taskVO.taskNum.ToString());
|
||||
string val = string.Empty;
|
||||
if (task.RewardId == 101)
|
||||
{
|
||||
val = GameHelper.GetNoDecimalUnitStr(task.RewardSum);
|
||||
}
|
||||
|
||||
if (task.RewardId == 102)
|
||||
{
|
||||
val = $"{(decimal)task.RewardSum:N}";
|
||||
}
|
||||
|
||||
_Singletask.text_num.text = val;
|
||||
switch (taskVO.rewardID)
|
||||
{
|
||||
case 101:
|
||||
_Singletask.cont_currency.selectedIndex = com_Singletask.Currency_coin;
|
||||
break;
|
||||
case 102:
|
||||
_Singletask.cont_currency.selectedIndex = com_Singletask.Currency_diam;
|
||||
break;
|
||||
}
|
||||
|
||||
// TextureHelper.GetItemIcon(taskVO.rewardID, tx => { _Singletask.loader_reward.texture = tx; });
|
||||
_Singletask.cont_collect.selectedIndex = com_Singletask.Collect_none;
|
||||
_Singletask.text_progress.text = task.Progress + "/" + task.MaxProgress;
|
||||
if (task.IsReward)
|
||||
{
|
||||
_Singletask.com_task_pb.TweenValue(task.MaxProgress, 0.3f);
|
||||
_Singletask.com_task_pb.max = task.MaxProgress;
|
||||
_Singletask.btn_task.cont_button.selectedIndex = btn_task.Button_done;
|
||||
_Singletask.cont_collect.selectedIndex = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Singletask.com_task_pb.max = task.MaxProgress;
|
||||
if (task.Progress >= task.MaxProgress)
|
||||
{
|
||||
_Singletask.btn_task.cont_button.selectedIndex = btn_task.Button_collect;
|
||||
_Singletask.cont_collect.selectedIndex = com_Singletask.Collect_collect;
|
||||
|
||||
_Singletask.com_task_pb.TweenValue(task.MaxProgress, 0.3f);
|
||||
_Singletask.btn_task.SetClick(() => { OnClickTaskBtn(_Singletask, task); });
|
||||
}
|
||||
else
|
||||
{
|
||||
_Singletask.btn_task.cont_button.selectedIndex = btn_task.Button_num;
|
||||
|
||||
// _Singletask.btn_task.text_num.text = task.Progress + "/" + task.MaxProgress;
|
||||
|
||||
|
||||
_Singletask.com_task_pb.TweenValue(task.Progress, 0.3f);
|
||||
_Singletask.btn_task.SetClick(OnClickGoPlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickTaskBtn(com_Singletask singletask, Task task)
|
||||
{
|
||||
Audio.Instance.PlayDynamicEffect("button");
|
||||
if (task.IsReward)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (task.Progress < task.MaxProgress)
|
||||
{
|
||||
OnClickGoPlay();
|
||||
return;
|
||||
}
|
||||
|
||||
// 领取奖励
|
||||
if (task.IsMulti)
|
||||
{
|
||||
GameHelper.GetRewardExtra(task.RewardId, (decimal)task.RewardSum, task.cont_index, isSuccess =>
|
||||
{
|
||||
if (!isSuccess)
|
||||
{
|
||||
gameDispatcher.Dispatch(BingoInfo.ShowGameOver);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.GetRewardOnly(task.RewardId, (decimal)task.RewardSum, RewardOrigin.DailyTask);
|
||||
}
|
||||
|
||||
if (!PreferencesMgr.Instance.FinishTaskList.Contains(task.Id))
|
||||
{
|
||||
PreferencesMgr.Instance.FinishTaskList.Add(task.Id);
|
||||
PreferencesMgr.Instance.SaveFinishTaskList();
|
||||
}
|
||||
|
||||
singletask.btn_task.onClick.Clear();
|
||||
task.IsReward = true;
|
||||
singletask.cont_collect.selectedIndex = com_Singletask.Collect_none;
|
||||
singletask.btn_task.cont_button.selectedIndex = btn_task.Button_done;
|
||||
PreferencesMgr.Instance.SaveActiveMissions();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
ui?.FadeIn();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnClickGoPlay()
|
||||
{
|
||||
CtrlCloseUI();
|
||||
GameDispatcher.Instance.Dispatch(BingoInfo.MainTab,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3046afbf3af94b15a73fbcf09e63fb52
|
||||
timeCreated: 1679628744
|
||||
@@ -0,0 +1,71 @@
|
||||
using BingoBrain.Core;
|
||||
using BingoBrain.HotFix;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class SomsionUICtrl : BaseUICtrl
|
||||
{
|
||||
private SomsionUI ui;
|
||||
private SomsionModel model;
|
||||
|
||||
private uint openUIMsg = SkinInfo.MissionUI_Open;
|
||||
private uint closeUIMsg = SkinInfo.MissionUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new SomsionUI(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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0b88fd872e144eab9dfb72032f55cc8
|
||||
timeCreated: 1679628745
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace BingoBrain
|
||||
{
|
||||
// [System.Serializable]
|
||||
public class Task
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int MaxProgress { get; set; }
|
||||
public int Progress { get; set; }
|
||||
public bool IsReward { get; set; }
|
||||
public int RewardId { get; set; }
|
||||
public float RewardSum { get; set; }
|
||||
public bool IsMulti { get; set; }
|
||||
public int cont_index { get; set; }
|
||||
|
||||
public Task(int id, int maxProgress)
|
||||
{
|
||||
Id = id;
|
||||
Progress = 0;
|
||||
IsReward = false;
|
||||
MaxProgress = maxProgress;
|
||||
}
|
||||
|
||||
public void InitData()
|
||||
{
|
||||
TaskList taskListVO = GameHelper.GetConfig<TaskListModel>().GetData(Id);
|
||||
RewardId = taskListVO.rewardID;
|
||||
IsMulti = taskListVO.isMulti;
|
||||
cont_index = taskListVO.cont_index;
|
||||
if (!PreferencesMgr.Instance.FinishTaskList.Contains(Id))
|
||||
{
|
||||
RewardSum = taskListVO.rewardFirst;
|
||||
}
|
||||
else
|
||||
{
|
||||
RewardSum = taskListVO.reward[GameHelper.GetDynamicIndex(RewardId)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f34cc6b8f034fae86d5a5cc47068305
|
||||
timeCreated: 1679628744
|
||||
Reference in New Issue
Block a user