fix:1、添加arrow的游戏代码,和相关的周边功能
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ArrowSettingCtrl : BaseCtrl
|
||||
{
|
||||
public static ArrowSettingCtrl Instance { get; private set; }
|
||||
|
||||
private ArrowSettingModel 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: a719660d4b2e0254583b70941f0eede5
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ArrowSettingModel : 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: 9bbfb75ed03e0fc43a081b175504f450
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,256 @@
|
||||
using IgnoreOPS;
|
||||
using FairyGUI;
|
||||
using FGUI.ZM_Setting_07;
|
||||
using IgnoreOPS;
|
||||
using UnityEngine;
|
||||
using btn_head = FGUI.ZM_Common_01.btn_head;
|
||||
|
||||
// using FGUI.G006_menu;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ArrowSettingUI : BaseUI
|
||||
{
|
||||
private ArrowSettingUICtrl ctrl;
|
||||
private ArrowSettingModel model;
|
||||
private int _selectIndex = -1;
|
||||
|
||||
private const int TotalItem = 8;
|
||||
|
||||
private com_arrow_setting ui;
|
||||
|
||||
public ArrowSettingUI(ArrowSettingUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.ArrowSettingUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Setting_07";
|
||||
uiInfo.assetName = "com_arrow_setting";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.ArrowSettingModel) as ArrowSettingModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
// WebviewManager.ShezhiACT(true);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.StopArrowTouch, true);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_arrow_setting;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.StopArrowTouch, false);
|
||||
|
||||
// if (Screen.safeArea.y != 0)
|
||||
// {
|
||||
// ui.title.y += Screen.safeArea.y;
|
||||
// }
|
||||
// WebviewManager.ShezhiACT(false);
|
||||
_selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
|
||||
GetSliderValueByScale((float)args);
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
private void GetSliderValueByScale(float speed)
|
||||
{
|
||||
float validScale = Mathf.Clamp(speed, 1200f, 1700f);
|
||||
float ratio = (validScale - 1200f) / (1700f - 1200f);
|
||||
float sliderVal = ratio * 100f;
|
||||
|
||||
ui.speed_slide.value = Mathf.Clamp(sliderVal, 0f, 100f);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
// CommonHelper.FadeIn(ui);
|
||||
ui.show.Play();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
SetVersion();
|
||||
SetUID();
|
||||
|
||||
var namStr = GameHelper.GetUserName();
|
||||
ui.edit_name.input.text = namStr;
|
||||
|
||||
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("http://captainsroll.com/"); });
|
||||
|
||||
ui.btn_us.SetClick(() => { GameHelper.OpenEmail(); });
|
||||
|
||||
ui.btn_revive.SetClick(() =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.reset_game, false);
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
ui.level_text.SetVar("lv",GameHelper.GetLevel().ToString()).FlushVars();
|
||||
|
||||
ui.speed_slide.onChanged.Add(SetSlideValue);
|
||||
|
||||
ui.btn_music.on_off.selectedIndex =
|
||||
model.IsOpenMusic ? 0 : 1;
|
||||
ui.btn_sound.on_off.selectedIndex =
|
||||
GRoot.inst.soundVolume > 0 ? 0 : 1;
|
||||
|
||||
ui.btn_music.SetClick(SetMusic);
|
||||
ui.btn_sound.SetClick(SetSound);
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
ui.hide.Play(UpdateUserInfo);
|
||||
|
||||
});
|
||||
if (GameHelper.IsGiftSwitch())
|
||||
{
|
||||
// ui.btn_restore.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_us.visible = true;
|
||||
}
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// if (success)
|
||||
// {
|
||||
// GameHelper.ShowTips("Restore Purchases Success!");
|
||||
// // SaveData.GetSaveObject().is_get_packreward = success;
|
||||
// SaveData.GetSaveObject().have_slot = success;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Debug.Log("[barry] restore failed: " + success);
|
||||
// GameHelper.ShowTips("There are no recoverable transactions");
|
||||
// }
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
private void SetSlideValue()
|
||||
{
|
||||
var sliderValue = (float)ui.speed_slide.value;
|
||||
// 先把滑块值钳位在 0~100 内
|
||||
float val = Mathf.Clamp(sliderValue, 0f, 100f);
|
||||
|
||||
// 线性映射:0→0.6,100→1.5
|
||||
float ratio = val / 100f;
|
||||
float speed = 1200f + ratio * (1700f - 1200f);
|
||||
|
||||
|
||||
speed = Mathf.Clamp(speed, 1200f, 1700f);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UpdateSpeed, speed);
|
||||
}
|
||||
|
||||
private void SetMusic()
|
||||
{
|
||||
model.IsOpenMusic = !model.IsOpenMusic;
|
||||
|
||||
ui.btn_music.on_off.selectedIndex = model.IsOpenMusic
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
||||
private void SetSound()
|
||||
{
|
||||
var sound = GRoot.inst.soundVolume;
|
||||
sound = sound > 0 ? 0 : 1;
|
||||
|
||||
GRoot.inst.soundVolume = sound;
|
||||
PlayerPrefs.SetFloat("soundVolume", sound);
|
||||
ui.btn_sound.on_off.selectedIndex = sound > 0
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
private void SetVersion()
|
||||
{
|
||||
// Debug.Log($"SetVersion====== {Application.version}");
|
||||
ui.text_version.SetVar("count", Application.version).FlushVars();
|
||||
}
|
||||
|
||||
private void SetUID()
|
||||
{
|
||||
ui.text_uid.SetVar("UID", GameHelper.GetLoginModel().Uid.ToString()).FlushVars();
|
||||
}
|
||||
|
||||
private void SetAvatar()
|
||||
{
|
||||
if (_selectIndex != -1 && _selectIndex != DataMgr.PlayerAvatarId.Value)
|
||||
{
|
||||
DataMgr.PlayerAvatarId.Value = _selectIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UpdateUserInfo()
|
||||
{
|
||||
SaveName();
|
||||
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
private void SaveName()
|
||||
{
|
||||
var name = ui.edit_name.input.text;
|
||||
|
||||
if (string.IsNullOrEmpty(name) || name.IsNullOrWhiteSpace())
|
||||
{
|
||||
GameHelper.ShowTips("The input cannot be null", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.Equals(DataMgr.PlayerName)) return;
|
||||
|
||||
// GameHelper.ShowTips("Name changed successfully");
|
||||
DataMgr.PlayerName.Value = name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f70e08a1fa35f7e4296d5b0f093cba6e
|
||||
timeCreated: 1676360265
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ArrowSettingUICtrl : BaseUICtrl
|
||||
{
|
||||
private ArrowSettingUI ui;
|
||||
private ArrowSettingModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.ArrowSettingUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.ArrowSettingUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new ArrowSettingUI(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: c878a49cee89b2047b83b09db20d1c12
|
||||
timeCreated: 1676360266
|
||||
Reference in New Issue
Block a user