提交小游戏项目
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class MenuCtrl : BaseCtrl
|
||||
{
|
||||
public static MenuCtrl Instance { get; private set; }
|
||||
|
||||
private MenuModel 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: f454d607f8ad454fb11ae4756ed84dfd
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
using System.Linq;
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class MenuModel : BaseModel
|
||||
{
|
||||
public bool IsOpenMusic
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenBGM; }
|
||||
set { AudioManager.Instance.IsOpenBGM = value; }
|
||||
}
|
||||
|
||||
public bool IsOpenEffect
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenEffect; }
|
||||
set { AudioManager.Instance.IsOpenEffect = value; }
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
public string LangIdKey = "LangIdKey";
|
||||
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,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1ea9acdf2dc4281b6ce4ce36ecf131e
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
|
||||
// using FGUI.G006_menu;
|
||||
|
||||
using UnityEngine;
|
||||
using FGUI.ZM_Setting_07;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Net;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
|
||||
{
|
||||
public class MenuUI : BaseUI
|
||||
{
|
||||
private MenuUICtrl ctrl;
|
||||
private MenuModel model;
|
||||
private FGUI.ZM_Setting_07.com_setting ui;
|
||||
private int selectIndex = -1;
|
||||
|
||||
private int total_item;
|
||||
|
||||
public MenuUI(MenuUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.MenuUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Setting_07";
|
||||
uiInfo.assetName = "com_setting";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.MenuModel) as MenuModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
CommonHelper.FadeOut(ui);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Setting_07.com_setting;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
total_item = 8;
|
||||
selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
var namStr = GameHelper.GetUserName();
|
||||
// com_Person.edit_name.input.text = namStr;
|
||||
// com_Person.btn_update.SetClick(UpdateUserInfo);
|
||||
// com_Person.edit_name.btn_amend.SetClick(SaveName);
|
||||
|
||||
ui.btn_back.SetClick(OnCloseView);
|
||||
ui.btn_music.SetClick(OnClickSetMusic);
|
||||
ui.btn_sound.SetClick(OnClickSoundBtn);
|
||||
ui.btn_us.SetClick(() =>
|
||||
{
|
||||
GameHelper.OpenEmail();
|
||||
});
|
||||
|
||||
ui.btn_privacy.menus.selectedIndex = btn_menu.Menus_privacy;
|
||||
ui.btn_terms.menus.selectedIndex = btn_menu.Menus_terms;
|
||||
ui.btn_official.menus.selectedIndex = btn_menu.Menus_official;
|
||||
ui.btn_us.menus.selectedIndex = 4;
|
||||
ui.btn_record.menus.selectedIndex = 5;
|
||||
ui.btn_restore.menus.selectedIndex = 6;
|
||||
ui.btn_privacy.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0); });
|
||||
ui.btn_terms.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1); });
|
||||
ui.btn_official.SetClick(() => { OpenBrowser.OpenURL("https://www.beanherofuzz.com/"); });
|
||||
ui.btn_language.SetClick(() => {
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LanguageViewUI_Open);
|
||||
});
|
||||
SetUID();
|
||||
SetVersion();
|
||||
RefreshMusicUI();
|
||||
|
||||
if (GameHelper.IsGiftSwitch())
|
||||
{
|
||||
ui.gift.selectedIndex = 1;
|
||||
}
|
||||
else ui.gift.selectedIndex = 0;
|
||||
// ui.btn_restore.SetClick(() =>
|
||||
// {
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
||||
// if (success)
|
||||
// {
|
||||
// Debug.Log("[barry] restore success: " + success);
|
||||
// GameHelper.ShowTips("Restore Purchases Success!");
|
||||
// SaveData.GetSaveObject().have_slot = success;
|
||||
// DataMgr.VipLevel.Value = 3;
|
||||
// DataMgr.VipExpirationTime.Value =
|
||||
// ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowTips("There are no recoverable transactions");
|
||||
// }
|
||||
// });
|
||||
// CtrlCloseUI();
|
||||
// });
|
||||
|
||||
// com_Person.list.itemRenderer = UpdateItem;
|
||||
// com_Person.list.numItems = total_item;
|
||||
}
|
||||
|
||||
// private void UpdateItem(int index, GObject items)
|
||||
// {
|
||||
// var currentIndex = index + 1;
|
||||
// var head = items as btn_item_head;
|
||||
// var imgHead = head.head as btn_head;
|
||||
|
||||
// TextureHelper.SetAvatarToLoader(currentIndex, imgHead.load_avatar);
|
||||
// head.head_select.selectedIndex = selectIndex == currentIndex
|
||||
// ? btn_item_head.Head_select_select
|
||||
// : btn_item_head.Head_select_none;
|
||||
|
||||
// head.SetClick(() =>
|
||||
// {
|
||||
// selectIndex = currentIndex;
|
||||
// com_Person.list.numItems = total_item;
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
private void UpdateUserInfo()
|
||||
{
|
||||
if (selectIndex != -1)
|
||||
{
|
||||
DataMgr.PlayerAvatarId.Value = selectIndex;
|
||||
}
|
||||
|
||||
SaveName();
|
||||
|
||||
OnCloseView();
|
||||
|
||||
}
|
||||
|
||||
private void SaveName()
|
||||
{
|
||||
// var name = com_Person.edit_name.input.text;
|
||||
|
||||
// if (string.IsNullOrEmpty(name) || name.IsNullOrWhiteSpace())
|
||||
// {
|
||||
// GameHelper.ShowTips("The input cannot be null", true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // if (name.Equals(GameHelper.GetPlayerInviteCode()))
|
||||
// // {
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// if (name.Equals(DataMgr.PlayerName.Value)) return;
|
||||
|
||||
// GameHelper.ShowTips($"Name changed successfully");
|
||||
// DataMgr.PlayerName.Value = name;
|
||||
}
|
||||
|
||||
private void SetVersion()
|
||||
{
|
||||
// ui.text_version.SetVar("Version", Application.version.ToString()).FlushVars();
|
||||
ui.text_version.text = "Version:" + Application.version;
|
||||
}
|
||||
|
||||
private void SetUID()
|
||||
{
|
||||
ui.text_uid.text = $"UID:{GameHelper.GetLoginModel().Uid}";
|
||||
}
|
||||
|
||||
public override void OnSwitchLanguage()
|
||||
{
|
||||
base.OnSwitchLanguage();
|
||||
|
||||
SetVersion();
|
||||
|
||||
SetUID();
|
||||
}
|
||||
private void CloseMenu(Action action = null)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
action?.Invoke();
|
||||
}
|
||||
private void OnCloseView()
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
private void OnClickSetMusic()
|
||||
{
|
||||
model.IsOpenMusic = !model.IsOpenMusic;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void OnClickSoundBtn()
|
||||
{
|
||||
model.IsOpenEffect = !model.IsOpenEffect;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void RefreshMusicUI()
|
||||
{
|
||||
ui.btn_music.music_on_off.selectedIndex =
|
||||
model.IsOpenMusic ? 0 : 1;
|
||||
ui.btn_sound.music_on_off.selectedIndex =
|
||||
model.IsOpenEffect ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dee91b0289945b88b3c9216e12a7758
|
||||
timeCreated: 1676360265
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public class MenuUICtrl : BaseUICtrl
|
||||
{
|
||||
private MenuUI ui;
|
||||
private MenuModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.MenuUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.MenuUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new MenuUI(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,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bee553769448494792af2ea30744bfe1
|
||||
timeCreated: 1676360266
|
||||
Reference in New Issue
Block a user