提交小游戏项目
This commit is contained in:
@@ -0,0 +1,462 @@
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.Game_flower;
|
||||
using DG.Tweening;
|
||||
using SGModule.Common.Extensions;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class FlowerUI : BaseUI
|
||||
{
|
||||
private FlowerUICtrl ctrl;
|
||||
private FlowerModel model;
|
||||
private FGUI.Game_flower.com_flower ui;
|
||||
|
||||
public FlowerUI(FlowerUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.FlowerUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "Game_flower";
|
||||
uiInfo.assetName = "com_flower";
|
||||
uiInfo.layerType = UILayerType.Normal;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.FlowerModel) as FlowerModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.Game_flower.com_flower;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.RefreshFlowerCleanBtn, RefreshBtnCleanPot);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.FlowelSuccess, GameSuccess);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.FlowerReset, Reset);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.FlowerRemake, Remake);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.Update101, Set101);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.FlowerBuyItem, SetItemBtn);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.FlowerFullTips, ShowFullani);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.RefreshFlowerCleanBtn, RefreshBtnCleanPot);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.FlowelSuccess, GameSuccess);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.FlowerReset, Reset);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.FlowerRemake, Remake);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, Set101);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.FlowerBuyItem, SetItemBtn);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.FlowerFullTips, ShowFullani);
|
||||
}
|
||||
#endregion
|
||||
private void ShowFullani(object a = null)
|
||||
{
|
||||
ui.t0.Play();
|
||||
}
|
||||
|
||||
private void ShowUnlockItem()
|
||||
{
|
||||
if (DataMgr.FlowerLevel.Value >= GameHelper.GetCommonModel().PropLevel[0] - 1 && !DataMgr.FlowerItemUnlock.Value[0])
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerUnlockItemUI_Open, 0);
|
||||
}
|
||||
else if (DataMgr.FlowerLevel.Value >= GameHelper.GetCommonModel().PropLevel[1] - 1 && !DataMgr.FlowerItemUnlock.Value[1])
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerUnlockItemUI_Open, 1);
|
||||
}
|
||||
else if (DataMgr.FlowerLevel.Value >= GameHelper.GetCommonModel().PropLevel[2] - 1 && !DataMgr.FlowerItemUnlock.Value[2])
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerUnlockItemUI_Open, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset(object a = null)
|
||||
{
|
||||
start_update = false;
|
||||
remain_time = GameHelper.GetCommonModel().FinishTime;
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
ui.btn_add0.visible = ui.btn_add1.visible = true;
|
||||
ui.text_level.text = (DataMgr.FlowerLevel.Value + 1).ToString();
|
||||
ShowUnlockItem();
|
||||
SetItemBtn();
|
||||
|
||||
}
|
||||
private void Remake(object a = null)
|
||||
{
|
||||
DataMgr.FlowerItem1.Value = DataMgr.FlowerItem1.Value + 1;
|
||||
CreatFlower.instance.UseCleanItem();
|
||||
remain_time += GameHelper.GetCommonModel().ExtraTime;
|
||||
start_update = true;
|
||||
SetItemBtn();
|
||||
}
|
||||
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
//Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<FlowerMatch>()));
|
||||
CreatFlower.instance.ResetGame();
|
||||
// ui.btn_tip.SetClick(TipsFunc);
|
||||
// ui.btn_clean.SetClick(CleanFunc);
|
||||
// ui.btn_refresh.SetClick(RefreshFunc);
|
||||
ui.btn_pot.SetClick(() =>
|
||||
{
|
||||
ui.group_list.visible = !ui.group_list.visible;
|
||||
});
|
||||
ui.list_pot.itemRenderer = CleanListRender;
|
||||
RefreshBtnCleanPot();
|
||||
// GameEnd();
|
||||
ui.btn_add0.SetClick(() =>
|
||||
{
|
||||
GameHelper.ShowVideoAd("flower_add0", (success) =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
AddSlotFunc(0);
|
||||
ui.btn_add0.visible = false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
ui.btn_add1.SetClick(() =>
|
||||
{
|
||||
GameHelper.ShowVideoAd("flower_add1", (success) =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
AddSlotFunc(1);
|
||||
ui.btn_add1.visible = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
HallManager.Instance.UpdateSecondEvent += Update_event;
|
||||
remain_time = GameHelper.GetCommonModel().FinishTime;
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
if (Screen.safeArea.y != 0)
|
||||
{
|
||||
ui.group_safe.y += 68;
|
||||
}
|
||||
Set101();
|
||||
ui.text_level.text = (DataMgr.FlowerLevel.Value + 1).ToString();
|
||||
SetItemBtn();
|
||||
ShowUnlockItem();
|
||||
Stop_time = -3;
|
||||
if (DataMgr.FlowerLevel.Value == 0)
|
||||
{
|
||||
ui.com_guide.visible = true;
|
||||
ui.com_guide.btn_close.SetClick(() =>
|
||||
{
|
||||
ui.com_guide.state.selectedIndex = 1;
|
||||
ui.com_guide.btn_close.SetClick(() =>
|
||||
{
|
||||
ui.com_guide.visible = false;
|
||||
CreatFlower.instance.DestoryFinger();
|
||||
});
|
||||
});
|
||||
}
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
// CreatPuzzle.instance.PuzzlenResetFunc();
|
||||
OnBackToHall();
|
||||
});
|
||||
}
|
||||
private void OnBackToHall(object obj = null)
|
||||
{
|
||||
|
||||
Debug.Log("??????????jjjjkkkkkkkk0");
|
||||
if (!GameHelper.GetVipPrivilege(Subscription.RemoveInterstitialAd.As<int>()) && GameHelper.IsGiftSwitch())
|
||||
{
|
||||
int random_ = UnityEngine.Random.Range(1, 100);
|
||||
Debug.Log($"[back hall] SaveData.GetSaveObject().is_get_removead=========={SaveData.GetSaveObject().is_get_removead} ");
|
||||
if (!SaveData.GetSaveObject().is_get_removead && random_ < GameHelper.GetCommonModel().HomeInterstitialAd)
|
||||
{
|
||||
//GameHelper.ShowInterstitial("BackHall");
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.AdcomingUI_Open);
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i = 0; i < card_item_list.Count; i++)
|
||||
// {
|
||||
// for (int j = 0; j < card_item_list[i].Count; j++)
|
||||
// {
|
||||
|
||||
// if (card_item_list[i][j] != null)
|
||||
// {
|
||||
// GameObject.Destroy(card_item_list[i][j].sheep_card);
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// SaveJson();
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerUI_Close);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.BackMainScene);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
public void Set101(object a = null)
|
||||
{
|
||||
|
||||
int coin = DataMgr.Coin.Value;
|
||||
var btnCoin = ui.btn_gold as com_gold;
|
||||
btnCoin.text_gold.text = $"{coin:N0}";
|
||||
}
|
||||
void Update_event()
|
||||
{
|
||||
|
||||
Stop_time++;
|
||||
if (Stop_time == 5)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.FlowerShowclickAni);
|
||||
}
|
||||
|
||||
if (!start_update) return;
|
||||
remain_time--;
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
if (remain_time <= 0)
|
||||
{
|
||||
if (DataMgr.FlowerLevelState.Value != 0)
|
||||
{
|
||||
start_update = false;
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerRemakeUI_Open);
|
||||
}
|
||||
else
|
||||
{
|
||||
float[] ch_array = GameHelper.GetRewardValue(2);
|
||||
var temp = new SuccessData();
|
||||
temp.IsWin = false;
|
||||
temp.ch_number = ch_array[0];
|
||||
temp.IsLevelSuccess = true;
|
||||
temp.IsH5Reward = false;
|
||||
temp.boost_array = GameHelper.GetRewardBoost(2);
|
||||
temp.level = DataMgr.FlowerLevel.Value;
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerEndUI_Open, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int remain_time;
|
||||
public static bool start_update = false;
|
||||
public static long Stop_time = 0;
|
||||
void GameSuccess(object a = null)
|
||||
{
|
||||
float[] cash_array = GameHelper.GetRewardValue(0);
|
||||
var temp = new SuccessData();
|
||||
temp.IsWin = true;
|
||||
temp.ch_number = cash_array[0];
|
||||
temp.rate = (int)cash_array[1];
|
||||
temp.IsLevelSuccess = false;
|
||||
temp.IsH5Reward = false;
|
||||
temp.boost_array = GameHelper.GetRewardBoost(0);
|
||||
// DataMgr.FlowerTimeCoinsUse.Value = false;
|
||||
DataMgr.FlowerLevel.Value = DataMgr.FlowerLevel.Value + 1;
|
||||
DOVirtual.DelayedCall(0.55f, () =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FlowerEndUI_Open, temp);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void CleanListRender(int index, GObject obj)
|
||||
{
|
||||
item_potFlower item = (item_potFlower)obj;
|
||||
item.type.selectedIndex = clean_pot_list[index][0];
|
||||
item.text_flower_number.text = "x" + clean_pot_list[index][1];
|
||||
}
|
||||
void AddSlotFunc(int index)
|
||||
{
|
||||
//Debug.Log("解锁。。。。。。。。。。" + index);
|
||||
CreatFlower.instance.AddSlost(index);
|
||||
}
|
||||
|
||||
|
||||
void SetItemBtn(object a = null)
|
||||
{
|
||||
if (DataMgr.FlowerLevel.Value < GameHelper.GetCommonModel().PropLevel[0] - 1)
|
||||
{
|
||||
ui.btn_tip.state.selectedIndex = 2;
|
||||
ui.btn_tip.SetClick(() =>
|
||||
{
|
||||
GameHelper.ShowTips("Complete up to Level " + GameHelper.GetCommonModel().PropLevel[0] + " to unlock!");
|
||||
});
|
||||
ui.btn_tip.text_unlock.SetVar("num", GameHelper.GetCommonModel().PropLevel[0].ToString()).FlushVars();
|
||||
}
|
||||
else if (DataMgr.FlowerItem0.Value > 0)
|
||||
{
|
||||
ui.btn_tip.state.selectedIndex = 1;
|
||||
ui.btn_tip.text_number.text = DataMgr.FlowerItem0.Value.ToString();
|
||||
ui.btn_tip.SetClick(() =>
|
||||
{
|
||||
// int childCount = FlowerParent.transform.childCount;
|
||||
// if (childCount <= 0)
|
||||
// {
|
||||
// GameHelper.ShowTips("Cannot Use Now");
|
||||
// return;
|
||||
// }
|
||||
TipsFunc();
|
||||
// DataMgr.FlowerItem0.Value = DataMgr.FlowerItem0.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_tip.state.selectedIndex = 0;
|
||||
ui.btn_tip.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.FlowerBuyItemUI_Open, 0);
|
||||
});
|
||||
}
|
||||
|
||||
if (DataMgr.FlowerLevel.Value < GameHelper.GetCommonModel().PropLevel[1] - 1)
|
||||
{
|
||||
ui.btn_clean.state.selectedIndex = 2;
|
||||
ui.btn_clean.SetClick(() =>
|
||||
{
|
||||
GameHelper.ShowTips("Complete up to Level " + GameHelper.GetCommonModel().PropLevel[1] + " to unlock!");
|
||||
});
|
||||
ui.btn_clean.text_unlock.SetVar("num", GameHelper.GetCommonModel().PropLevel[1].ToString()).FlushVars();
|
||||
}
|
||||
else if (DataMgr.FlowerItem1.Value > 0)
|
||||
{
|
||||
ui.btn_clean.state.selectedIndex = 1;
|
||||
ui.btn_clean.text_number.text = DataMgr.FlowerItem1.Value.ToString();
|
||||
ui.btn_clean.SetClick(() =>
|
||||
{
|
||||
// int childCount = FlowerParent.transform.childCount;
|
||||
// if (childCount <= 0)
|
||||
// {
|
||||
// GameHelper.ShowTips("Cannot Use Now");
|
||||
// return;
|
||||
// }
|
||||
CleanFunc();
|
||||
// DataMgr.FlowerItem1.Value = DataMgr.FlowerItem1.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_clean.state.selectedIndex = 0;
|
||||
ui.btn_clean.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.FlowerBuyItemUI_Open, 1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (DataMgr.FlowerLevel.Value < GameHelper.GetCommonModel().PropLevel[2] - 1)
|
||||
{
|
||||
ui.btn_refresh.state.selectedIndex = 2;
|
||||
ui.btn_refresh.SetClick(() =>
|
||||
{
|
||||
GameHelper.ShowTips("Complete up to Level " + GameHelper.GetCommonModel().PropLevel[2] + " to unlock!");
|
||||
});
|
||||
ui.btn_refresh.text_unlock.SetVar("num", GameHelper.GetCommonModel().PropLevel[2].ToString()).FlushVars();
|
||||
}
|
||||
else if (DataMgr.FlowerItem2.Value > 0)
|
||||
{
|
||||
ui.btn_refresh.state.selectedIndex = 1;
|
||||
ui.btn_refresh.text_number.text = DataMgr.FlowerItem2.Value.ToString();
|
||||
ui.btn_refresh.SetClick(() =>
|
||||
{
|
||||
// int childCount = FlowerParent.transform.childCount;
|
||||
// if (childCount <= 0)
|
||||
// {
|
||||
// GameHelper.ShowTips("Cannot Use Now");
|
||||
// return;
|
||||
// }
|
||||
RefreshFunc();
|
||||
DataMgr.FlowerItem2.Value = DataMgr.FlowerItem2.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_refresh.state.selectedIndex = 0;
|
||||
ui.btn_refresh.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.FlowerBuyItemUI_Open, 2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TipsFunc()
|
||||
{
|
||||
if (!CreatFlower.instance.CanClick) return;
|
||||
|
||||
CreatFlower.instance.UseTipsItem();
|
||||
|
||||
}
|
||||
void CleanFunc()
|
||||
{
|
||||
if (!CreatFlower.instance.CanClick) return;
|
||||
CreatFlower.instance.UseCleanItem();
|
||||
}
|
||||
void RefreshFunc()
|
||||
{
|
||||
if (!CreatFlower.instance.CanClick) return;
|
||||
CreatFlower.instance.UseRefreshItem();
|
||||
}
|
||||
List<List<int>> clean_pot_list;
|
||||
void RefreshBtnCleanPot(object a = null)
|
||||
{
|
||||
ui.btn_pot.title = CreatFlower.instance.clean_item_list.Count.ToString();
|
||||
clean_pot_list = new List<List<int>>() {
|
||||
new List<int>(){0,0},new List<int>(){1,0},new List<int>(){2,0},
|
||||
new List<int>(){3,0},new List<int>(){4,0},new List<int>(){5,0},
|
||||
new List<int>(){6,0},new List<int>(){7,0},new List<int>(){8,0},
|
||||
new List<int>(){9,0},new List<int>(){10,0},new List<int>(){11,0},
|
||||
|
||||
};
|
||||
for (int i = 0; i < CreatFlower.instance.clean_item_list.Count; i++)
|
||||
{
|
||||
clean_pot_list[CreatFlower.instance.clean_item_list[i].GetComponent<ChildItem>().type][1]++;
|
||||
}
|
||||
|
||||
clean_pot_list.RemoveAll(subList => subList[1] == 0);
|
||||
|
||||
ui.list_pot.numItems = clean_pot_list.Count;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user