备份CatanBuilding瘦身独立工程
This commit is contained in:
769
Assets/Scripts/UI/Washing/EventWashingPanel.cs
Normal file
769
Assets/Scripts/UI/Washing/EventWashingPanel.cs
Normal file
@@ -0,0 +1,769 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
|
||||
public class EventWashingPanel : BasePanel
|
||||
{
|
||||
#region 生命周期
|
||||
protected override void Start()
|
||||
{
|
||||
// 标题
|
||||
InitTitle();
|
||||
|
||||
// 箭头
|
||||
InitArraw();
|
||||
|
||||
// 电池
|
||||
InitBattery();
|
||||
|
||||
// 奖励
|
||||
InitReward();
|
||||
|
||||
// 手指
|
||||
InitFinger();
|
||||
|
||||
//// 瞄准准心
|
||||
//InitAim();
|
||||
// 手势跟踪
|
||||
InitGestureFollow();
|
||||
|
||||
// 关闭按钮
|
||||
btn_close = transform.Find("root/Btn_close").GetComponent<Button>();
|
||||
|
||||
// 所有游戏结束
|
||||
InitGameOver();
|
||||
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
||||
{
|
||||
txt_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(m_DataManager.RemainingTime));
|
||||
}).AddTo(this);
|
||||
|
||||
m_OperationCDTimer = m_MaximumAllowableTimeWithoutOperation;
|
||||
m_State = 0;
|
||||
|
||||
m_IsGuiding = false;
|
||||
|
||||
base.Start();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (m_IsGuiding == true) return;
|
||||
if (Input.anyKey || Input.anyKeyDown)
|
||||
{
|
||||
m_OperationCDTimer = m_MaximumAllowableTimeWithoutOperation;
|
||||
m_State = 0;
|
||||
StopTimeoutHandling();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OperationCDTimer -= Time.deltaTime;
|
||||
}
|
||||
if (m_OperationCDTimer < 0 && m_State == 0)
|
||||
{
|
||||
m_State = 1;
|
||||
TimeoutHandling();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (m_DataManager != null && electricityConsumption != null)
|
||||
{
|
||||
electricityConsumption.SetPercentage(m_DataManager.WashingData.Energy);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
btn_introduction.onClick.RemoveAllListeners();
|
||||
btn_preview.onClick.RemoveAllListeners();
|
||||
btn_close.onClick.RemoveAllListeners();
|
||||
btn_left.onClick.RemoveAllListeners();
|
||||
btn_right.onClick.RemoveAllListeners();
|
||||
btn_game_over.onClick.RemoveAllListeners();
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新手引导
|
||||
bool m_IsGuiding = false;
|
||||
public bool InitGuidance()
|
||||
{
|
||||
m_IsGuiding = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventWashingPanel");
|
||||
if (m_IsGuiding)
|
||||
{
|
||||
m_OperationCDTimer = m_MaximumAllowableTimeWithoutOperation;
|
||||
m_State = 0;
|
||||
StopTimeoutHandling();
|
||||
}
|
||||
return m_IsGuiding;
|
||||
}
|
||||
public void CompleteGuidance()
|
||||
{
|
||||
m_IsGuiding = false;
|
||||
m_OperationCDTimer = m_MaximumAllowableTimeWithoutOperation;
|
||||
m_State = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据相关
|
||||
private EventWashingDataManager m_DataManager;
|
||||
public void SetDataManager(EventWashingDataManager dataManager)
|
||||
{
|
||||
m_DataManager = dataManager;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 展示模式
|
||||
private void HideAllExceptBtnClose()
|
||||
{
|
||||
// 隐藏标题栏
|
||||
if (obj_title != null)
|
||||
{
|
||||
obj_title.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏奖励栏
|
||||
if (obj_reward != null)
|
||||
{
|
||||
obj_reward.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏箭头栏
|
||||
if (obj_viewpoint != null)
|
||||
{
|
||||
obj_viewpoint.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
//// 隐藏电池栏
|
||||
//if (obj_battery != null)
|
||||
//{
|
||||
// obj_battery.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
// 隐藏手指
|
||||
if (finger != null)
|
||||
{
|
||||
finger.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏准心
|
||||
//if (aim != null)
|
||||
//{
|
||||
// aim.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
// 隐藏电量消耗
|
||||
if (electricityConsumption != null)
|
||||
{
|
||||
electricityConsumption.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏手势
|
||||
if (gestureFollow != null)
|
||||
{
|
||||
gestureFollow.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏结束语
|
||||
if (conclusion_welldone != null)
|
||||
{
|
||||
conclusion_welldone.gameObject.SetActive(false);
|
||||
}
|
||||
if (conclusion_good != null)
|
||||
{
|
||||
conclusion_good.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏所有游戏结束展示
|
||||
if (obj_game_over != null)
|
||||
{
|
||||
obj_game_over.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 显示关闭按钮
|
||||
if (btn_close != null)
|
||||
{
|
||||
btn_close.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowForRemove()
|
||||
{
|
||||
m_FunctionType = 0;
|
||||
|
||||
m_IsGuiding = false;
|
||||
|
||||
HideAllExceptBtnClose();
|
||||
|
||||
// 显示标题栏
|
||||
SetTitleVisible(true);
|
||||
// 显示奖励
|
||||
SetRewardVisible(true);
|
||||
// 显示电池
|
||||
SetBatteryVisible(true);
|
||||
//// 显示手势跟随
|
||||
//SetGestureFollowVisible(true);
|
||||
//// 显示准心
|
||||
//SetAimVisible(true);
|
||||
// 显示电量消耗
|
||||
SetElectricityConsumptionVisible(true);
|
||||
|
||||
SetTitleInfo();
|
||||
SetBatteryInfo();
|
||||
SetRewardInfo();
|
||||
|
||||
// 手势跟踪
|
||||
InitGestureFollow();
|
||||
SetGestureFollowVisible(false);
|
||||
}
|
||||
|
||||
public void ShowForCleaning()
|
||||
{
|
||||
m_FunctionType = 0;
|
||||
|
||||
m_IsGuiding = false;
|
||||
|
||||
HideAllExceptBtnClose();
|
||||
|
||||
// 显示标题栏
|
||||
SetTitleVisible(true);
|
||||
// 显示奖励
|
||||
SetRewardVisible(true);
|
||||
// 显示电池
|
||||
SetBatteryVisible(true);
|
||||
// 显示手势跟随
|
||||
//SetGestureFollowVisible(true);
|
||||
//// 显示准心
|
||||
//SetAimVisible(true);
|
||||
// 关闭笔刷填充进度
|
||||
ResetBrushChannelCounterFillAndInverse(false, false);
|
||||
// 显示电量消耗
|
||||
SetElectricityConsumptionVisible(true);
|
||||
|
||||
SetTitleInfo();
|
||||
SetBatteryInfo();
|
||||
SetRewardInfo();
|
||||
|
||||
// 手势跟踪
|
||||
InitGestureFollow();
|
||||
SetGestureFollowVisible(false);
|
||||
|
||||
//InitGuidance();
|
||||
}
|
||||
|
||||
public void ShowForPainting()
|
||||
{
|
||||
m_FunctionType = 1;
|
||||
|
||||
m_IsGuiding = false;
|
||||
|
||||
HideAllExceptBtnClose();
|
||||
|
||||
// 显示标题栏
|
||||
SetTitleVisible(true);
|
||||
// 显示奖励
|
||||
SetRewardVisible(true);
|
||||
// 显示电池
|
||||
SetBatteryVisible(true);
|
||||
//// 显示手势跟随
|
||||
//SetGestureFollowVisible(false);
|
||||
//// 显示准心
|
||||
//SetAimVisible(true);
|
||||
// 关闭笔刷填充进度
|
||||
ResetBrushChannelCounterFillAndInverse(false, false);
|
||||
// 显示箭头
|
||||
SetArrowVisible(true);
|
||||
// 显示电量消耗
|
||||
SetElectricityConsumptionVisible(true);
|
||||
|
||||
SetTitleInfo();
|
||||
SetBatteryInfo();
|
||||
SetRewardInfo();
|
||||
|
||||
// 手势跟踪
|
||||
InitGestureFollow();
|
||||
SetGestureFollowVisible(false);
|
||||
|
||||
//InitGuidance();
|
||||
}
|
||||
|
||||
public void ShowForAllGameOver()
|
||||
{
|
||||
m_IsGuiding = false;
|
||||
|
||||
// 隐藏标题栏
|
||||
if (obj_title != null)
|
||||
{
|
||||
obj_title.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏奖励栏
|
||||
if (obj_reward != null)
|
||||
{
|
||||
obj_reward.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏箭头栏
|
||||
if (obj_viewpoint != null)
|
||||
{
|
||||
obj_viewpoint.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏电池栏
|
||||
SetBatteryVisible(false);
|
||||
|
||||
// 隐藏手指
|
||||
if (finger != null)
|
||||
{
|
||||
finger.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏准心
|
||||
//if (aim != null)
|
||||
//{
|
||||
// aim.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
//// 隐藏电量消耗
|
||||
//if (electricityConsumption != null)
|
||||
//{
|
||||
// electricityConsumption.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
// 隐藏手势
|
||||
if (gestureFollow != null)
|
||||
{
|
||||
gestureFollow.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏结束语
|
||||
if (conclusion_welldone != null)
|
||||
{
|
||||
conclusion_welldone.gameObject.SetActive(false);
|
||||
}
|
||||
if (conclusion_good != null)
|
||||
{
|
||||
conclusion_good.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 显示关闭按钮
|
||||
if (btn_close != null)
|
||||
{
|
||||
btn_close.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 显示游戏结束
|
||||
if (obj_game_over != null)
|
||||
{
|
||||
obj_game_over.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// 隐藏完成所有游戏文字提示
|
||||
if (obj_text_final != null)
|
||||
{
|
||||
obj_text_final.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
SetGestureFollowVisible(false);
|
||||
}
|
||||
|
||||
public void ShowForShipOver()
|
||||
{
|
||||
m_IsGuiding = false;
|
||||
|
||||
// 隐藏标题栏
|
||||
if (obj_title != null)
|
||||
{
|
||||
obj_title.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏奖励栏
|
||||
if (obj_reward != null)
|
||||
{
|
||||
obj_reward.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏箭头栏
|
||||
if (obj_viewpoint != null)
|
||||
{
|
||||
obj_viewpoint.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏电池栏
|
||||
SetBatteryVisible(false);
|
||||
|
||||
// 隐藏手指
|
||||
if (finger != null)
|
||||
{
|
||||
finger.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏准心
|
||||
//if (aim != null)
|
||||
//{
|
||||
// aim.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
//// 隐藏电量消耗
|
||||
//if (electricityConsumption != null)
|
||||
//{
|
||||
// electricityConsumption.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
// 隐藏手势
|
||||
if (gestureFollow != null)
|
||||
{
|
||||
gestureFollow.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 隐藏结束语
|
||||
if (conclusion_welldone != null)
|
||||
{
|
||||
conclusion_welldone.gameObject.SetActive(false);
|
||||
}
|
||||
if (conclusion_good != null)
|
||||
{
|
||||
conclusion_good.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 显示关闭按钮
|
||||
if (btn_close != null)
|
||||
{
|
||||
btn_close.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 显示游戏结束
|
||||
if (obj_game_over != null)
|
||||
{
|
||||
obj_game_over.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// 隐藏完成所有游戏文字提示
|
||||
if (obj_text_final != null)
|
||||
{
|
||||
obj_text_final.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// 手势跟踪
|
||||
InitGestureFollow();
|
||||
SetGestureFollowVisible(false);
|
||||
|
||||
//InitGuidance();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 结束语
|
||||
public EventWashingConclusion conclusion_welldone;
|
||||
public EventWashingConclusion conclusion_good;
|
||||
public void StartConclusion()
|
||||
{
|
||||
if (m_DataManager == null) return;
|
||||
EventWashingStep step = m_DataManager.GetCurrentEventStep();
|
||||
if (step.ShowID == 0)
|
||||
conclusion_welldone.StartConclusion();
|
||||
else if (step.ShowID == 1)
|
||||
conclusion_good.StartConclusion();
|
||||
}
|
||||
public void ResetConclusion(bool isVisible)
|
||||
{
|
||||
//conclusion_welldone.ResetConclusion();
|
||||
//conclusion_welldone.gameObject.SetActive(isVisible);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 当前操作进度
|
||||
public BrushChannelCounterFill brushChannelCounterFillPercentage;
|
||||
public void ResetBrushChannelCounterFillAndInverse(bool inverse, bool enabled = true)
|
||||
{
|
||||
if (brushChannelCounterFillPercentage != null)
|
||||
{
|
||||
brushChannelCounterFillPercentage.Inverse = inverse;
|
||||
brushChannelCounterFillPercentage.enabled = enabled;
|
||||
}
|
||||
}
|
||||
public float GetFillOmitPercentage()
|
||||
{
|
||||
if (brushChannelCounterFillPercentage != null)
|
||||
{
|
||||
return BrushChannelCounterFill.OmitPercentage;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
public void StartCountingFill()
|
||||
{
|
||||
if (brushChannelCounterFillPercentage != null)
|
||||
{
|
||||
brushChannelCounterFillPercentage.StartCounting();
|
||||
}
|
||||
}
|
||||
|
||||
public void StopCountingFill()
|
||||
{
|
||||
if (brushChannelCounterFillPercentage != null)
|
||||
{
|
||||
brushChannelCounterFillPercentage.StopCounting();
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetBrushChannelCounterData()
|
||||
{
|
||||
if (brushChannelCounterFillPercentage != null)
|
||||
{
|
||||
brushChannelCounterFillPercentage.ResetData();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 手指
|
||||
public EventWashingFinger finger;
|
||||
private void InitFinger()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetFingerVisible(bool isVisible)
|
||||
{
|
||||
finger.gameObject.SetActive(isVisible);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 手势
|
||||
public EventWashingGestureFollow gestureFollow;
|
||||
public float m_GestureMoveSpeed = 60f;
|
||||
public Transform m_GestureInitTransform = null;
|
||||
protected void InitGestureFollow()
|
||||
{
|
||||
if (m_GestureInitTransform == null) return;
|
||||
gestureFollow.transform.position = m_GestureInitTransform.position;
|
||||
gestureFollow.transform.rotation = m_GestureInitTransform.rotation;
|
||||
gestureFollow.transform.localScale = m_GestureInitTransform.localScale;
|
||||
}
|
||||
public void SetGestureFollowPosition(Vector3 position)
|
||||
{
|
||||
gestureFollow.SetFollowPosition(position, m_GestureMoveSpeed);
|
||||
}
|
||||
public void SetGestureFollowVisible(bool isVisible)
|
||||
{
|
||||
gestureFollow.gameObject.SetActive(isVisible);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 标题
|
||||
GameObject obj_title;
|
||||
TMP_Text txt_title_name;
|
||||
TMP_Text txt_time;
|
||||
Button btn_introduction;
|
||||
Button btn_preview;
|
||||
|
||||
private void InitTitle()
|
||||
{
|
||||
// 标题
|
||||
obj_title = transform.Find("root/title").gameObject;
|
||||
txt_title_name = transform.Find("root/title/Txt_titleName").GetComponent<TMP_Text>();
|
||||
txt_time = transform.Find("root/title/Txt_time").GetComponent<TMP_Text>();
|
||||
btn_introduction = transform.Find("root/title/Btn_questionmark").GetComponent<Button>();
|
||||
btn_introduction.onClick.AddListener(OnBtnQuestionmark);
|
||||
btn_preview = transform.Find("root/title/Btn_preview").GetComponent<Button>();
|
||||
//btn_preview.onClick.AddListener(OnBtnPreview);
|
||||
}
|
||||
public void SetTitleVisible(bool isVisible)
|
||||
{
|
||||
obj_title.SetActive(isVisible);
|
||||
}
|
||||
private async void OnBtnQuestionmark()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(m_DataManager.GetCurrentInfoPopupPanel());
|
||||
UIManager.Instance.HideUI(UITypes.EventWashingPanel);
|
||||
}
|
||||
public void SetBtnPreviewClickListener(UnityAction listener)
|
||||
{
|
||||
btn_preview.onClick.RemoveAllListeners();
|
||||
if (listener != null)
|
||||
btn_preview.onClick.AddListener(listener);
|
||||
}
|
||||
|
||||
public void SetTitleInfo()
|
||||
{
|
||||
txt_title_name.text = LocalizationMgr.GetFormatTextValue("UI_EventWashingPanel_1", m_DataManager.GetShipName());
|
||||
|
||||
txt_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(m_DataManager.RemainingTime));
|
||||
//Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
||||
//{
|
||||
// txt_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(m_DataManager.RemainingTime));
|
||||
//}).AddTo(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 奖励
|
||||
// 奖励
|
||||
GameObject obj_reward;
|
||||
Image img_icon_tool;
|
||||
Image img_reward_progress;
|
||||
TMP_Text txt_step_name;
|
||||
public RewardItemNew rewardItem;
|
||||
private void InitReward()
|
||||
{
|
||||
// 奖励
|
||||
obj_reward = transform.Find("root/reward").gameObject;
|
||||
img_icon_tool = transform.Find("root/reward/bg_reward/icon_tool").GetComponent<Image>();
|
||||
img_reward_progress = transform.Find("root/reward/bg_reward/bg_bar/Img_bar").GetComponent<Image>();
|
||||
txt_step_name = transform.Find("root/reward/bg_reward/Txt_stepName").GetComponent<TMP_Text>();
|
||||
|
||||
// 奖励进度
|
||||
img_reward_progress.fillAmount = 0f;
|
||||
}
|
||||
|
||||
public void SetRewardVisible(bool isVisible)
|
||||
{
|
||||
obj_reward.SetActive(isVisible);
|
||||
}
|
||||
|
||||
public void UpdateSingleProgress(float ratio)
|
||||
{
|
||||
img_reward_progress.fillAmount = ratio;
|
||||
}
|
||||
|
||||
public void SetRewardInfo()
|
||||
{
|
||||
EventWashingStep washingStep = m_DataManager.GetCurrentEventStep();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(img_icon_tool, washingStep.Icon, BasePanel.PanelName);
|
||||
|
||||
txt_step_name.text = LocalizationMgr.GetText(washingStep.Name_l10n_key);
|
||||
|
||||
if (string.IsNullOrEmpty(washingStep.GiftIcon))
|
||||
{
|
||||
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(washingStep.DropID, 0);
|
||||
rewardItem.SetRewardPopupData(itemData);
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardItem.SetDropIcon(washingStep.GiftIcon, washingStep.DropID);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 箭头
|
||||
// 箭头
|
||||
GameObject obj_viewpoint;
|
||||
Button btn_left;
|
||||
Button btn_right;
|
||||
|
||||
private void InitArraw()
|
||||
{
|
||||
// 箭头
|
||||
obj_viewpoint = transform.Find("root/viewpoint").gameObject;
|
||||
btn_left = transform.Find("root/viewpoint/left").GetComponent<Button>();
|
||||
btn_right = transform.Find("root/viewpoint/right").GetComponent<Button>();
|
||||
}
|
||||
// 设置箭头显示状态
|
||||
public void SetArrowVisible(bool isVisible)
|
||||
{
|
||||
obj_viewpoint.SetActive(isVisible);
|
||||
}
|
||||
|
||||
public void SetBtnArrayClickListener(UnityAction left, UnityAction right)
|
||||
{
|
||||
btn_left.onClick.RemoveAllListeners();
|
||||
if (left != null)
|
||||
btn_left.onClick.AddListener(left);
|
||||
|
||||
btn_right.onClick.RemoveAllListeners();
|
||||
if (right != null)
|
||||
btn_right.onClick.AddListener(right);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 电池
|
||||
public EventWashingBatteryLevel electricityConsumption; // 电量消耗
|
||||
private void InitBattery()
|
||||
{
|
||||
|
||||
}
|
||||
// 设置电池显示状态
|
||||
public void SetBatteryVisible(bool isVisible)
|
||||
{
|
||||
electricityConsumption.gameObject.SetActive(isVisible);
|
||||
}
|
||||
// 设置电量消耗显示状态
|
||||
public void SetElectricityConsumptionVisible(bool isVisible)
|
||||
{
|
||||
//electricityConsumption.gameObject.SetActive(isVisible);
|
||||
}
|
||||
public void SetBatteryInfo()
|
||||
{
|
||||
electricityConsumption.UpdateToken(m_DataManager.GetToken());
|
||||
}
|
||||
public void SetEnergyShortage()
|
||||
{
|
||||
electricityConsumption.SetEnergyShortage();
|
||||
}
|
||||
public void SetEnergyEnough()
|
||||
{
|
||||
electricityConsumption.SetEnergyEnough();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关闭按钮
|
||||
// 关闭按钮
|
||||
Button btn_close;
|
||||
public void SetBtnCloseClickListener(UnityAction listener)
|
||||
{
|
||||
btn_close.onClick.RemoveAllListeners();
|
||||
btn_game_over.onClick.RemoveAllListeners();
|
||||
if (listener != null)
|
||||
{
|
||||
btn_close.onClick.AddListener(listener);
|
||||
btn_game_over.onClick.AddListener(listener);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 长时间不操作检测
|
||||
[Tooltip("最长允许无操作时间")]
|
||||
[SerializeField]
|
||||
private float m_MaximumAllowableTimeWithoutOperation = 5f;
|
||||
private float m_OperationCDTimer;
|
||||
private int m_State = 0;
|
||||
private int m_FunctionType = 0;
|
||||
|
||||
private void TimeoutHandling()
|
||||
{
|
||||
if (finger == null) return;
|
||||
SetFingerVisible(true);
|
||||
if (m_FunctionType == 1) finger.PlayAnimationForPainting();
|
||||
else finger.PlayAnimationDefault();
|
||||
}
|
||||
private void StopTimeoutHandling()
|
||||
{
|
||||
if (finger == null) return;
|
||||
finger.SetAnimationEnabled(false);
|
||||
SetFingerVisible(false);
|
||||
}
|
||||
|
||||
public void ContinuousOperation()
|
||||
{
|
||||
m_OperationCDTimer = m_MaximumAllowableTimeWithoutOperation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 游戏结束
|
||||
Button btn_game_over;
|
||||
GameObject obj_game_over;
|
||||
GameObject obj_text_final;
|
||||
private void InitGameOver()
|
||||
{
|
||||
obj_game_over = transform.Find("root/Obj_finished").gameObject;
|
||||
btn_game_over = transform.Find("root/Obj_finished/Btn_confirm/btn_green").GetComponent<Button>();
|
||||
obj_text_final = transform.Find("root/Obj_finished/text_final").gameObject;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user