Files
JJBB/Assets/Project/Script/GUI/LevelCombatTips/LevelCombatTipRoot.cs
2024-08-23 15:49:34 +08:00

214 lines
5.8 KiB
C#

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GCGame.Table;
using System;
using Games.GlobeDefine;
public class LevelCombatTipRoot : UIControllerBase<LevelCombatTipRoot>
{
private void Start()
{
SetInstance(this);
}
private void OnDestroy()
{
SetInstance(null);
}
public void Close()
{
UIManager.CloseUI(UIInfo.LevelCombatTipRoot);
}
#region func
public static void GotoFun(Tab_LevelCombatTipItem tabItem, bool closeUI = false)
{
if (tabItem.BtnGoFunc == "OpenUI")
{
OpenUI(tabItem.BtnGoParam);
}
else if (tabItem.BtnGoFunc == "Monster")
{
GotoMonster(tabItem.BtnGoParam);
}
else if (tabItem.BtnGoFunc == "Active")
{
GotoActive(tabItem.BtnGoParam);
}
if (closeUI)
{
if (LevelCombatTipRoot.Instance())
{
LevelCombatTipRoot.Instance().Close();
}
}
}
private static void OpenUI(string funcParam)
{
if (UIPathData.m_DicUIName.ContainsKey(funcParam))
{
UIManager.ShowUI(UIPathData.m_DicUIName[funcParam]);
}
else if (funcParam.Contains("AdvanceMountPanel"))
{
var splits = funcParam.Split('/');
int advType = int.Parse(splits[1]);
UIManager.ShowUI(UIInfo.AdvanceMountPanel, delegate (bool bSucess, object param)
{
if (bSucess)
{
AdvanceMountPanelCtr.Instance.SetAdvanceType(advType);
}
});
}
else if (funcParam.Contains("MeridiaSoul"))
{
var splits = funcParam.Split('/');
int showPage = int.Parse(splits[1]);
UIManager.ShowUI(UIInfo.MeridiaSoulWnd, delegate (bool bSucess, object param)
{
if (bSucess)
{
MeridiaSoulMain.Instance._TagPanel.ShowPage(showPage);
}
});
}
else if (funcParam.Contains("EquipEnhanceRoot"))
{
var splits = funcParam.Split('/');
int showPage = int.Parse(splits[1]);
UIManager.ShowUI(UIInfo.EquipEnhance, delegate (bool bSucess, object param)
{
if (bSucess)
{
EquipEnhanceRoot.Instance().TryOpen(showPage);
}
});
}
else if (funcParam.Contains("CopyScenePanelCtr"))
{
var splits = funcParam.Split('/');
int showPage = int.Parse(splits[1]);
UIManager.ShowUI(UIInfo.CopyScenePanelCtr, delegate (bool bSucess, object param)
{
if (bSucess)
{
CopyScenePanelCtr.Instance.OnMenuItemClick(showPage);
}
});
}
}
private static void GotoMonster(string funcParam)
{
var splitStrs = funcParam.Split(';');
int sceneID = int.Parse(splitStrs[0]);
int posX = int.Parse(splitStrs[1]);
int posZ = int.Parse(splitStrs[2]);
//接受任务后自动寻路
Vector3 targetPos = new Vector3();
targetPos.x = posX;
targetPos.z = posZ;
int nTargetScene = sceneID;
AutoSearchPoint point = new AutoSearchPoint(nTargetScene, targetPos.x, targetPos.z);
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
{
GameManager.gameManager.AutoSearch.BuildPath(point);
GameManager.gameManager.AutoSearch.Path.finishCallBack = (object param) => { ChatFrameLogic.Instance().OnDoAutoFightClick(); };
if (LevelCombatTipRoot.Instance())
{
LevelCombatTipRoot.Instance().Close();
}
}
}
private static void GotoActive(string funcParam)
{
int activeBaseID = int.Parse(funcParam);
ActivityController.ClickActive(activeBaseID);
}
#endregion
#region tip state
public enum BtnState
{
Go,
Going,
Disable,
Done,
}
public static BtnState GetBtnState(Tab_LevelCombatTipItem tabItem)
{
if (tabItem.BtnGoFunc == "OpenUI")
{
return BtnState.Go;
}
else if (tabItem.BtnGoFunc == "Monster")
{
return BtnState.Go;
}
else if (tabItem.BtnGoFunc == "Active")
{
return GetActiveState(tabItem);
}
return BtnState.Disable;
}
private static BtnState GetActiveState(Tab_LevelCombatTipItem tabItem)
{
int activeBaseID = int.Parse(tabItem.BtnGoParam);
if (!ActivityController.IsTodayOpen(activeBaseID))
{
return BtnState.Disable;
}
if (ActivityController.GetActivityTimeState(activeBaseID) == (int)ActivityController.ActivityTimeType.IsGoing)
{
if (!ActivityController.IsLevelEnough(activeBaseID))
{
return BtnState.Disable;
}
else if ((!ActivityController.IsCompleted(activeBaseID)))
{
//判断是否有当前任务在身上
if (ActivityItem.IsHaveThisTypeMission(activeBaseID))
{
return BtnState.Going;
}
else
{
return BtnState.Go;
}
}
else
{
return BtnState.Done;
}
}
else if (ActivityController.GetActivityTimeState(activeBaseID) == (int)ActivityController.ActivityTimeType.WillOpen)
{
return BtnState.Disable;
}
else
{
return BtnState.Disable;
}
}
#endregion
}