You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
297 lines
9.0 KiB
297 lines
9.0 KiB
using UnityEngine;
|
|
using LzFramework.UI;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
using LzFramework.FSM.Msg;
|
|
|
|
namespace DisComputer
|
|
{
|
|
public class MainMenuView : TTUIPage
|
|
{
|
|
public MainMenuView() : base(UIType.Fixed, UIMode.DoNothing, UICollider.None)
|
|
{
|
|
uiPath = "UIPrefabs/MainMenuView";
|
|
}
|
|
|
|
//左边操作栏
|
|
private GameObject leftPartGo;
|
|
|
|
//选择按钮
|
|
private Button select_btn;
|
|
//旋转按钮
|
|
private Button rotation_btn;
|
|
//电脑零件按钮
|
|
private Button lingJian_btn;
|
|
//工具箱
|
|
private Button toolBox_btn;
|
|
//专注物体按钮
|
|
private Button focuseModel_btn;
|
|
//退出专注模式
|
|
private Button quit_btn;
|
|
//提示按钮
|
|
private Button tip_btn;
|
|
|
|
|
|
//进度条展示控制器
|
|
private ProgressStater progressStater;
|
|
|
|
|
|
public override void Awake(GameObject go)
|
|
{
|
|
GameObject select_go = transform.Find("LeftTop/select_btn").gameObject;
|
|
select_btn = select_go.GetComponent<Button>();
|
|
select_btn.onClick.AddListener(OnClickSelect);
|
|
|
|
GameObject rotation_go = transform.Find("LeftTop/rotation_btn").gameObject;
|
|
rotation_btn = rotation_go.GetComponent<Button>();
|
|
rotation_btn.onClick.AddListener(OnClickRotation);
|
|
|
|
GameObject lingJian_go = transform.Find("LeftTop/lingJian_btn").gameObject;
|
|
lingJian_btn = lingJian_go.GetComponent<Button>();
|
|
lingJian_btn.onClick.AddListener(OnClickLingJian);
|
|
|
|
|
|
GameObject toolBox_go = transform.Find("LeftTop/toolBox_btn").gameObject;
|
|
toolBox_btn = toolBox_go.GetComponent<Button>();
|
|
toolBox_btn.onClick.AddListener(OnClickToolBox);
|
|
|
|
GameObject focuseModel_go = transform.Find("OperationPart/focuseModel_btn").gameObject;
|
|
focuseModel_btn = focuseModel_go.GetComponent<Button>();
|
|
focuseModel_btn.onClick.AddListener(OnClickFocuseModel);
|
|
|
|
GameObject quit_go = transform.Find("OperationPart/quit_btn").gameObject;
|
|
quit_btn = quit_go.GetComponent<Button>();
|
|
quit_btn.onClick.AddListener(OnClickQuitFocusMode);
|
|
quit_btn.gameObject.SetActive(false);
|
|
|
|
GameObject tip_go = transform.Find("OperationPart/tip_btn").gameObject;
|
|
tip_btn = tip_go.GetComponent<Button>();
|
|
tip_btn.onClick.AddListener(OnClickTip);
|
|
tip_btn.gameObject.SetActive(false);
|
|
|
|
GameObject tempProgressGo = transform.Find("ProgressPart").gameObject;
|
|
progressStater = tempProgressGo.GetComponent<ProgressStater>();
|
|
progressStater.InitScale();
|
|
|
|
|
|
|
|
leftPartGo = transform.Find("LeftTop").gameObject;
|
|
|
|
InitMsg();
|
|
}
|
|
|
|
public override void Active()
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
}
|
|
|
|
|
|
public override void Hide()
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
public override void Refresh()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#region logicl
|
|
|
|
/// <summary>
|
|
/// 注册消息
|
|
/// </summary>
|
|
void InitMsg()
|
|
{
|
|
MessageDispatcher.AddListener(MsgName.MainViewGrowthBar,OnRecGrowthProgress);
|
|
MessageDispatcher.AddListener(MsgName.MainViewClearBar,OnRecClearProgress);
|
|
|
|
MessageDispatcher.AddListener(MsgName.MainViewQuitFocuseMode, OnRecExitFocuseMode);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退出专注模式
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
void OnRecExitFocuseMode(IMessage message)
|
|
{
|
|
quit_btn.gameObject.SetActive(false);
|
|
focuseModel_btn.gameObject.SetActive(true);
|
|
tip_btn.gameObject.SetActive(false);
|
|
progressStater.OnHide();
|
|
TTUIPage.ClosePage<SparePartsView>();
|
|
TTUIPage.ClosePage<ToolBoxView>();
|
|
float moveX = leftPartGo.transform.localPosition.x - 74;
|
|
leftPartGo.transform.DOLocalMoveX(moveX, 0.2f).SetEase(Ease.OutQuart);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 接收进度消息
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
void OnRecGrowthProgress(IMessage message)
|
|
{
|
|
progressStater.GrouwthProgress();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置进度
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
void OnRecClearProgress(IMessage message)
|
|
{
|
|
progressStater.ClearProgress();
|
|
}
|
|
|
|
|
|
|
|
#region **************** onclick *****************
|
|
|
|
/// <summary>
|
|
/// 点击选择
|
|
/// </summary>
|
|
private void OnClickSelect()
|
|
{
|
|
Debug.LogFormat("点击选择按钮");
|
|
UIAnimator.Singleton.BtnShakeAct(select_btn.transform, 1.2f, 0.2f);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击旋转
|
|
/// </summary>
|
|
private void OnClickRotation()
|
|
{
|
|
Debug.LogFormat("点击旋转按钮");
|
|
UIAnimator.Singleton.BtnShakeAct(rotation_btn.transform, 1.2f, 0.2f);
|
|
ModelControl.Instance.RewindTargetRoatation();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击工具箱
|
|
/// </summary>
|
|
private void OnClickToolBox()
|
|
{
|
|
if (UIAnimator.Singleton.CoolInterval(0.50f))
|
|
return;
|
|
|
|
Debug.LogFormat("点击工具按钮");
|
|
UIAnimator.Singleton.BtnShakeAct(toolBox_btn.transform, 1.2f, 0.2f);
|
|
TTUIPage.ShowPage<ToolBoxView>();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击零件
|
|
/// </summary>
|
|
private void OnClickLingJian()
|
|
{
|
|
Debug.LogFormat("点击组装零件按钮");
|
|
if (UIAnimator.Singleton.CoolInterval(0.50f))
|
|
return;
|
|
|
|
UIAnimator.Singleton.BtnShakeAct(lingJian_btn.transform, 1.2f, 0.2f);
|
|
TTUIPage.ShowPage<SparePartsView>();
|
|
MessageContainer.SendMessage(GameConfig.GetItemInfos, this, MsgName.SparePartsViewShowSpare,0.02f);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击专注
|
|
/// </summary>
|
|
private void OnClickFocuseModel()
|
|
{
|
|
if (GameDataConfig.Instance.pcId == -1)
|
|
return;
|
|
|
|
GamePCLighter.Instance.HideLight();
|
|
|
|
Debug.LogFormat(">>>>>>>>>>>> PC ID {0}",GameDataConfig.Instance.pcId);
|
|
MainControl.Instance.SetGameState(MainState.Active);
|
|
MessageContainer.SendMessage("test", this, MsgName.ModelControlShowCenter);
|
|
focuseModel_btn.gameObject.SetActive(false);
|
|
quit_btn.gameObject.SetActive(true);
|
|
tip_btn.gameObject.SetActive(true);
|
|
|
|
|
|
float moveX = leftPartGo.transform.localPosition.x + 74;
|
|
leftPartGo.transform.DOLocalMoveX(moveX, 0.2f).SetEase(Ease.OutQuart);
|
|
|
|
if(GameConfig.state == GameState.Unload)
|
|
{
|
|
if(GameConfig.curProgressIndex == -1)
|
|
{
|
|
PcControl.Instance.ReadyUnloadNextStep(0);
|
|
}
|
|
else
|
|
{
|
|
PcControl.Instance.SetNextSpareType();
|
|
}
|
|
|
|
TTUIPage.ShowPage<ToolBoxView>();
|
|
}
|
|
else
|
|
{
|
|
if (GameConfig.curProgressIndex == -1)
|
|
{
|
|
PcControl.Instance.ReadyLoadNextStep(0);
|
|
}else
|
|
{
|
|
PcControl.Instance.SetNextSpareType();
|
|
}
|
|
|
|
TTUIPage.ShowPage<SparePartsView>();
|
|
}
|
|
|
|
|
|
|
|
progressStater.OnShow();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击退出专注模式
|
|
/// </summary>
|
|
private void OnClickQuitFocusMode()
|
|
{
|
|
|
|
//聚焦模式无法退出
|
|
if (MouseControl.Instance.isFocuseState)
|
|
{
|
|
MessageContainer.SendMessage("当前处于工作状态,无法退出!稍后再试", this, MsgName.TipViewShowPoint);
|
|
return;
|
|
}
|
|
|
|
|
|
MainControl.Instance.SetGameState(MainState.Idle);
|
|
//恢复相机视距
|
|
MouseControl.Instance.RewindCameraField();
|
|
|
|
quit_btn.gameObject.SetActive(false);
|
|
focuseModel_btn.gameObject.SetActive(true);
|
|
tip_btn.gameObject.SetActive(false);
|
|
progressStater.OnHide();
|
|
TTUIPage.ClosePage<SparePartsView>();
|
|
TTUIPage.ClosePage<ToolBoxView>();
|
|
MessageContainer.SendMessage("quit", this,MsgName.ModelControlShowDesktop);
|
|
|
|
|
|
float moveX = leftPartGo.transform.localPosition.x - 74;
|
|
leftPartGo.transform.DOLocalMoveX(moveX, 0.2f).SetEase(Ease.OutQuart);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击提示
|
|
/// </summary>
|
|
private void OnClickTip()
|
|
{
|
|
MessageContainer.SendMessage("quit",this,MsgName.TipViewShowOperation);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|