提交小游戏项目
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class PuzzleCtrl : BaseCtrl
|
||||
{
|
||||
public static PuzzleCtrl Instance { get; private set; }
|
||||
|
||||
private PuzzleModel model;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
//model = ModuleManager.Instance..GetModel(ModelConst.PuzzleModel) as PuzzleModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c9e5478ace624ae5a76cbc95c80c2f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class PuzzleModel : BaseModel
|
||||
{
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f46c19630678446e955e092fe4759f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,334 @@
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using SGModule.Common.Extensions;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class PuzzleUI : BaseUI
|
||||
{
|
||||
private PuzzleUICtrl ctrl;
|
||||
private PuzzleModel model;
|
||||
private FGUI.Game_puzzle.com_puzzle ui;
|
||||
|
||||
public PuzzleUI(PuzzleUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.PuzzleUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "Game_puzzle";
|
||||
uiInfo.assetName = "com_puzzle";
|
||||
uiInfo.layerType = UILayerType.Normal;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PuzzleModel) as PuzzleModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= UpdateSec;
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.Game_puzzle.com_puzzle;
|
||||
}
|
||||
|
||||
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.PuzzleSuccess, PuzzleSuccessFunc);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.PuzzleTimeStart, TimeStart);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.PuzzleBuyItem, SetItemBtn);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.PuzzleAddTime, AddTime);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.PuzzleReset, PuzzleResetFunc);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.Update101, Set101);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.PuzzleSuccess, PuzzleSuccessFunc);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.PuzzleTimeStart, TimeStart);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.PuzzleBuyItem, SetItemBtn);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.PuzzleAddTime, AddTime);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.PuzzleReset, PuzzleResetFunc);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, Set101);
|
||||
}
|
||||
#endregion
|
||||
List<JigsawPuzzle> puzzleList = ConfigSystem.GetConfig<JigsawPuzzle>();
|
||||
private void PuzzleResetFunc(object a = null)
|
||||
{
|
||||
Debug.Log("ui里的reset");
|
||||
JigsawPuzzle PuzzleData;
|
||||
|
||||
if (puzzle_level < puzzleList.Count)
|
||||
{
|
||||
PuzzleData = puzzleList[puzzle_level];
|
||||
}
|
||||
else PuzzleData = puzzleList[puzzleList.Count - 1];
|
||||
|
||||
// CreatPuzzle.instance.CreatPuzzleItem(PuzzleData.Type, PuzzleData.ResourceImage, PuzzleData.Pieces, puzzle_level);
|
||||
CreatPuzzle.instance.CreatPuzzleItem(PuzzleData.Type, "2", PuzzleData.Pieces, puzzle_level);
|
||||
Debug.Log("chongzhiguanka");
|
||||
DataMgr.PuzzleTimeCoinsUse.Value = false;
|
||||
is_time_begin = false;
|
||||
remain_time = PuzzleData.PlayTime;
|
||||
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
ui.t0.Play();
|
||||
HallManager.Instance.UpdateSecondEvent -= UpdateSec;
|
||||
ui.text_level.SetVar("level", (DataMgr.PuzzleLevel.Value + 1).ToString()).FlushVars();
|
||||
}
|
||||
|
||||
private void PuzzleSuccessFunc(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);
|
||||
temp.level = puzzle_level + 1;
|
||||
DataMgr.PuzzleTimeCoinsUse.Value = false;
|
||||
puzzle_level += 1;
|
||||
DataMgr.PuzzleLevel.Value = DataMgr.PuzzleLevel.Value + 1;
|
||||
HallManager.Instance.UpdateSecondEvent -= UpdateSec;
|
||||
DOVirtual.DelayedCall(0.55f, () =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PuzzleEndUI_Open, temp);
|
||||
});
|
||||
|
||||
// puzzle_level += 1;
|
||||
// DataMgr.PuzzleLevel.Value = DataMgr.PuzzleLevel.Value + 1;
|
||||
// JigsawPuzzle PuzzleData = puzzleList[puzzle_level];
|
||||
// CreatPuzzle.instance.CreatPuzzleItem(PuzzleData.Type, PuzzleData.ResourceImage, PuzzleData.Pieces, puzzle_level);
|
||||
// Debug.Log("chongzhiguanka");
|
||||
// is_time_begin = false;
|
||||
// remain_time = PuzzleData.PlayTime;
|
||||
// ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
// HallManager.Instance.UpdateSecondEvent -= UpdateSec;
|
||||
}
|
||||
void AddTime(object a = null)
|
||||
{
|
||||
remain_time += 15;
|
||||
HallManager.Instance.UpdateSecondEvent += UpdateSec;
|
||||
}
|
||||
private bool is_time_begin = false;
|
||||
void TimeStart(object a = null)
|
||||
{
|
||||
if (!is_time_begin)
|
||||
{
|
||||
is_time_begin = true;
|
||||
HallManager.Instance.UpdateSecondEvent += UpdateSec;
|
||||
}
|
||||
}
|
||||
void UpdateSec()
|
||||
{
|
||||
remain_time -= 1;
|
||||
if (remain_time <= 0)
|
||||
{
|
||||
remain_time = 0;
|
||||
HallManager.Instance.UpdateSecondEvent -= UpdateSec;
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.PuzzleBuyItemUI_Open, 3);
|
||||
}
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
}
|
||||
private int remain_time;
|
||||
private int puzzle_level = 0;
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
puzzle_level = DataMgr.PuzzleLevel.Value;
|
||||
DataMgr.PuzzleTimeCoinsUse.Value = true;
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.PuzzleBuyItemUI_Open, 3); //zhushi
|
||||
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<JigsawPuzzle>()));
|
||||
|
||||
JigsawPuzzle PuzzleData;
|
||||
if (puzzle_level < puzzleList.Count)
|
||||
{
|
||||
PuzzleData = puzzleList[puzzle_level];
|
||||
}
|
||||
else PuzzleData = puzzleList[puzzleList.Count - 1];
|
||||
// CreatPuzzle.instance.CreatPuzzleItem(PuzzleData.Type, PuzzleData.ResourceImage, PuzzleData.Pieces, puzzle_level);
|
||||
CreatPuzzle.instance.CreatPuzzleItem(PuzzleData.Type,"1", PuzzleData.Pieces, puzzle_level);
|
||||
remain_time = PuzzleData.PlayTime;
|
||||
ui.text_time.text = CommonHelper.TimeFormat(remain_time, CountDownType.Minute);
|
||||
ui.t0.Play();
|
||||
SetItemBtn();
|
||||
UpdataAvatar();
|
||||
Set101();
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CreatPuzzle.instance.PuzzlenResetFunc();
|
||||
OnBackToHall();
|
||||
});
|
||||
if (Screen.safeArea.y != 0)
|
||||
{
|
||||
ui.btn_gold.y += Screen.safeArea.y;
|
||||
}
|
||||
ui.text_level.SetVar("level", (DataMgr.PuzzleLevel.Value + 1).ToString()).FlushVars();
|
||||
}
|
||||
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.PuzzleUI_Close);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.BackMainScene);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
void SetItemBtn(object a = null)
|
||||
{
|
||||
if (DataMgr.PuzzleItem0.Value > 0)
|
||||
{
|
||||
ui.btn_item0.state.selectedIndex = 1;
|
||||
ui.btn_item0.text_number.text = DataMgr.PuzzleItem0.Value.ToString();
|
||||
ui.btn_item0.SetClick(() =>
|
||||
{
|
||||
int childCount = puzzleParent.transform.childCount;
|
||||
if (childCount <= 0)
|
||||
{
|
||||
GameHelper.ShowTips("Cannot Use Now");
|
||||
return;
|
||||
}
|
||||
UseProp(3);
|
||||
DataMgr.PuzzleItem0.Value = DataMgr.PuzzleItem0.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_item0.state.selectedIndex = 0;
|
||||
ui.btn_item0.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.PuzzleBuyItemUI_Open, 0);
|
||||
});
|
||||
}
|
||||
if (DataMgr.PuzzleItem1.Value > 0)
|
||||
{
|
||||
ui.btn_item1.state.selectedIndex = 1;
|
||||
ui.btn_item1.text_number.text = DataMgr.PuzzleItem1.Value.ToString();
|
||||
ui.btn_item1.SetClick(() =>
|
||||
{
|
||||
int childCount = puzzleParent.transform.childCount;
|
||||
if (childCount <= 0)
|
||||
{
|
||||
GameHelper.ShowTips("Cannot Use Now");
|
||||
return;
|
||||
}
|
||||
UseProp(1);
|
||||
DataMgr.PuzzleItem1.Value = DataMgr.PuzzleItem1.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_item1.state.selectedIndex = 0;
|
||||
ui.btn_item1.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.PuzzleBuyItemUI_Open, 1);
|
||||
});
|
||||
}
|
||||
if (DataMgr.PuzzleItem2.Value > 0)
|
||||
{
|
||||
ui.btn_item2.state.selectedIndex = 1;
|
||||
ui.btn_item2.text_number.text = DataMgr.PuzzleItem2.Value.ToString();
|
||||
ui.btn_item2.SetClick(() =>
|
||||
{
|
||||
int childCount = puzzleParent.transform.childCount;
|
||||
if (childCount <= 0)
|
||||
{
|
||||
GameHelper.ShowTips("Cannot Use Now");
|
||||
return;
|
||||
}
|
||||
UseProp(3);
|
||||
DataMgr.PuzzleItem2.Value = DataMgr.PuzzleItem2.Value - 1;
|
||||
SetItemBtn();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_item2.state.selectedIndex = 0;
|
||||
ui.btn_item2.SetClick(() =>
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.PuzzleBuyItemUI_Open, 2);
|
||||
});
|
||||
}
|
||||
}
|
||||
GameObject puzzleParent = GameObject.Find("puzzle_parent");
|
||||
void UseProp(int numbers)
|
||||
{
|
||||
|
||||
CreatPuzzle.instance.FlyLastN(numbers);
|
||||
}
|
||||
private void UpdataAvatar(object obj = null)
|
||||
{
|
||||
var headId = DataMgr.PlayerAvatarId.Value;
|
||||
Debug.Log("qqqqqqqqqqqqqqqqqqqqqqq" + headId);
|
||||
}
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 988683279bf734f5a8175232d22c5fa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class PuzzleUICtrl : BaseUICtrl
|
||||
{
|
||||
private PuzzleUI ui;
|
||||
private PuzzleModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.PuzzleUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.PuzzleUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PuzzleModel) as PuzzleModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new PuzzleUI(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: e269f3c6c0d764af5a805d32d11f5715
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user