569 lines
18 KiB
C#
569 lines
18 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using GCGame;
|
|||
|
using System;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class ItemGetPathPopRoot : UIControllerBase<ItemGetPathPopRoot>
|
|||
|
{
|
|||
|
// 获得路径数据结构
|
|||
|
public class GetPathData
|
|||
|
{
|
|||
|
public int pathType; // 获得路径类型
|
|||
|
public string info; // 具体数据含义,更具路径类型而定
|
|||
|
public int itemID;
|
|||
|
// 因为两个获取表 MissionItemGetPath 和 ItemGetPath 的一些需求不一致
|
|||
|
// 所以标记下,特殊处理。
|
|||
|
public int tabType = 0; // 0-itemGetPath;1-missionItemGetPath
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
// 取消自动选择
|
|||
|
pathScoll.AutoSelect = false;
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
HideAllGetPath();
|
|||
|
|
|||
|
if (_ClickCallBack != null)
|
|||
|
{
|
|||
|
_ClickCallBack();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void HideAllGetPath()
|
|||
|
{
|
|||
|
//for (int index = 0; index < _PathObjs.Length; ++index)
|
|||
|
//{
|
|||
|
// _PathObjs[index].SetActive(false);
|
|||
|
//}
|
|||
|
pathScoll.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public UISubScollMenu pathScoll;
|
|||
|
|
|||
|
public void CloseWindow()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.ItemGetPathPop);
|
|||
|
}
|
|||
|
|
|||
|
#region show
|
|||
|
|
|||
|
public delegate void ClickCallBack();
|
|||
|
public static ClickCallBack _ClickCallBack;
|
|||
|
public static void Show(int itemID, Vector2 showPos, ClickCallBack clickCallBack = null)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("DataID", itemID);
|
|||
|
hash.Add("ShowPos", showPos);
|
|||
|
_ClickCallBack = clickCallBack;
|
|||
|
UIManager.ShowUI(UIInfo.ItemGetPathPop, ItemGetPathPopRoot.ShowUIOver, hash);
|
|||
|
}
|
|||
|
|
|||
|
static void ShowUIOver(bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
Hashtable hash = param as Hashtable;
|
|||
|
if (ItemGetPathPopRoot.Instance() != null)
|
|||
|
{
|
|||
|
ItemGetPathPopRoot.Instance().ShowInner((int)hash["DataID"], (Vector2)hash["ShowPos"]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void ShowInner(int itemID, Vector2 showPos)
|
|||
|
{
|
|||
|
ShowItemGetPath(itemID, showPos);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region
|
|||
|
|
|||
|
public RectTransform _AnchorTrans;
|
|||
|
//public GameObject[] _PathObjs;
|
|||
|
//public Text[] _ShowTexts;
|
|||
|
|
|||
|
private Tab_ItemGetPath _ItemPathTab;
|
|||
|
|
|||
|
private void ShowItemGetPath(int itemID, Vector2 showPos)
|
|||
|
{
|
|||
|
_ItemPathTab = TableManager.GetItemGetPathByID(itemID, 0);
|
|||
|
if (_ItemPathTab == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("没有配置这个物品");
|
|||
|
UIManager.CloseUI(UIInfo.ItemGetPathPop);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
pathScoll.gameObject.SetActive(true);
|
|||
|
SetPos(showPos);
|
|||
|
|
|||
|
pathScoll.Clear();
|
|||
|
List<GetPathData> pathList = new List<GetPathData>();
|
|||
|
for (int i = 0; i < _ItemPathTab.getItemPathCount(); ++i)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(_ItemPathTab.GetItemPathbyIndex(i)))
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
if("-1" == _ItemPathTab.GetItemPathbyIndex(i))
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
switch (i)
|
|||
|
{
|
|||
|
case 0:
|
|||
|
case 4:
|
|||
|
case 5:
|
|||
|
case 7:
|
|||
|
case 10:
|
|||
|
{
|
|||
|
// 以上为只会有一种情况的路径
|
|||
|
GetPathData pathType = new GetPathData();
|
|||
|
pathType.pathType = i;
|
|||
|
pathType.info = _ItemPathTab.GetItemPathbyIndex(i).Trim('"');
|
|||
|
pathType.itemID = _ItemPathTab.Id;
|
|||
|
pathScoll.PushMenu(pathType);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
case 2:
|
|||
|
case 3:
|
|||
|
case 6:
|
|||
|
case 8:
|
|||
|
case 11:
|
|||
|
{
|
|||
|
// 多种情况的路径
|
|||
|
// 类别
|
|||
|
GetPathData classMenu = new GetPathData();
|
|||
|
classMenu.pathType = i;
|
|||
|
classMenu.info = "";
|
|||
|
classMenu.itemID = _ItemPathTab.Id;
|
|||
|
|
|||
|
|
|||
|
// 详细
|
|||
|
string infoRaw = _ItemPathTab.GetItemPathbyIndex(i).Trim('"');
|
|||
|
string[] infos = infoRaw.Split('|');
|
|||
|
GetPathData[] detailItem = new GetPathData[infos.Length];
|
|||
|
for (int j = 0; j < infos.Length; ++j)
|
|||
|
{
|
|||
|
GetPathData item = new GetPathData();
|
|||
|
item.pathType = i;
|
|||
|
item.info = infos[j];
|
|||
|
item.itemID = _ItemPathTab.Id;
|
|||
|
|
|||
|
detailItem[j] = item;
|
|||
|
}
|
|||
|
|
|||
|
pathScoll.PushMenu(classMenu, detailItem);
|
|||
|
}
|
|||
|
break;
|
|||
|
// 运营活动的特殊处理一下,会出现类似的活动,需要先判断。
|
|||
|
case 9:
|
|||
|
{
|
|||
|
// 多种情况的路径
|
|||
|
// 类别
|
|||
|
GetPathData classMenu = new GetPathData();
|
|||
|
classMenu.pathType = i;
|
|||
|
classMenu.info = "";
|
|||
|
classMenu.itemID = _ItemPathTab.Id;
|
|||
|
|
|||
|
// 详细
|
|||
|
string infoRaw = _ItemPathTab.GetItemPathbyIndex(i).Trim('"');
|
|||
|
string[] infos = infoRaw.Split('|');
|
|||
|
List<GetPathData> detailItem = new List<GetPathData>();
|
|||
|
|
|||
|
for (int j = 0; j < infos.Length; ++j)
|
|||
|
{
|
|||
|
if (IsMarketingActActive(infos[j]))
|
|||
|
{
|
|||
|
GetPathData item = new GetPathData();
|
|||
|
item.pathType = i;
|
|||
|
item.info = infos[j];
|
|||
|
item.itemID = _ItemPathTab.Id;
|
|||
|
|
|||
|
detailItem.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
pathScoll.PushMenu(classMenu, detailItem.ToArray());
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static bool IsMarketingActActive(string info)
|
|||
|
{
|
|||
|
// 活动特殊处理,必须用‘,’区分入口和ID
|
|||
|
string[] infos = info.Split(';');
|
|||
|
if (infos.Length < 2)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Config error !!!");
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
if (infos[0] == "-1")
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
int actID = string.IsNullOrEmpty(infos[1]) ? -1 : Convert.ToInt32(infos[1]);
|
|||
|
if (GlobalData.IsMarketingActActive(actID))
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
private void SetPos(Vector2 pos)
|
|||
|
{
|
|||
|
_AnchorTrans.position = pos;
|
|||
|
|
|||
|
float newY;
|
|||
|
float newX;
|
|||
|
|
|||
|
// 优先在右显示
|
|||
|
if (Screen.width - _AnchorTrans.anchoredPosition.x >= _AnchorTrans.rect.width)
|
|||
|
{
|
|||
|
newX = _AnchorTrans.anchoredPosition.x + _AnchorTrans.rect.width / 2;
|
|||
|
}
|
|||
|
else if (_AnchorTrans.anchoredPosition.x >= _AnchorTrans.rect.width)
|
|||
|
{
|
|||
|
newX = _AnchorTrans.anchoredPosition.x - _AnchorTrans.rect.width / 2;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newX = Screen.width - _AnchorTrans.rect.width / 2;
|
|||
|
}
|
|||
|
|
|||
|
if (Screen.height - _AnchorTrans.anchoredPosition.y < _AnchorTrans.rect.height / 2)
|
|||
|
{
|
|||
|
newY = Screen.height - _AnchorTrans.rect.height / 2;
|
|||
|
}
|
|||
|
else if (_AnchorTrans.anchoredPosition.y <= _AnchorTrans.rect.height / 2)
|
|||
|
{
|
|||
|
newY = _AnchorTrans.rect.height / 2;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newY = _AnchorTrans.anchoredPosition.y;
|
|||
|
}
|
|||
|
|
|||
|
_AnchorTrans.anchoredPosition = new Vector2(newX, newY);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemPathClick(object menuData)
|
|||
|
{
|
|||
|
GetPathData data = menuData as GetPathData;
|
|||
|
// 10类型仅做展示,不做跳转,甚至不能关闭这个界面
|
|||
|
if (data == null)
|
|||
|
{
|
|||
|
CloseWindow();
|
|||
|
}
|
|||
|
else if(data.pathType == 10)
|
|||
|
{
|
|||
|
// do nothing
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GoGetPath(data, CloseWindow);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void GoGetPath(GetPathData data, Action onClick = null)
|
|||
|
{
|
|||
|
switch (data.pathType)
|
|||
|
{
|
|||
|
case 0://元宝商城
|
|||
|
int goodID = Convert.ToInt32(data.info);
|
|||
|
var shopItemTab = TableManager.GetYuanBaoShopByID(goodID, 0);
|
|||
|
YuanBaoShopLogic.OpenShopForItem(shopItemTab.ItemID);
|
|||
|
break;
|
|||
|
case 1://系统商店
|
|||
|
if (string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
int shopID = Convert.ToInt32(data.info);
|
|||
|
|
|||
|
if (shopID > 0 && shopID < 4)
|
|||
|
{
|
|||
|
SysShopController.ShowShopForItem(shopID, data.itemID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
YuanBaoShopLogic.OpenShopForJiFenItem(shopID, data.itemID);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 2://NPC商店
|
|||
|
if (string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
int NPCId = Convert.ToInt32(data.info);
|
|||
|
SysShopController._SelectedItem = data.itemID;
|
|||
|
UIManager.ClosePopUI();
|
|||
|
FindNpc(NPCId);
|
|||
|
break;
|
|||
|
case 3://怪物掉落
|
|||
|
if (string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
break;
|
|||
|
case 4://交易市场
|
|||
|
Market.ShowMarket(data.itemID);
|
|||
|
break;
|
|||
|
case 5://玩家商店
|
|||
|
if(data.tabType == 0)
|
|||
|
{
|
|||
|
Market.ShowMarket(data.itemID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if(!string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
string[] param = data.info.Split(',');
|
|||
|
if(param.Length == 2)
|
|||
|
{
|
|||
|
int classType = Convert.ToInt32(param[0]);
|
|||
|
int subClassType = Convert.ToInt32(param[1]);
|
|||
|
Market.ShowPlayerShopMarket(classType, subClassType);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case 6://活动
|
|||
|
if (string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
UIManager.ShowUI(UIInfo.Activity);
|
|||
|
break;
|
|||
|
case 7://百晓生
|
|||
|
//UIManager.ShowUI(UIInfo.Activity);
|
|||
|
int helpID = int.Parse(data.info);
|
|||
|
var helpRecord = TableManager.GetChatHelperByID(helpID, 0);
|
|||
|
ChatHelperRoot.ShowChatHelperStr(helpRecord.KeyWord);
|
|||
|
break;
|
|||
|
case 8:
|
|||
|
if (string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
ShowUI(data.info);
|
|||
|
break;
|
|||
|
case 9:
|
|||
|
if(string.IsNullOrEmpty(data.info))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
string[] actInfo = data.info.Split(';');
|
|||
|
|
|||
|
if(actInfo.Length < 2)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Config error");
|
|||
|
}
|
|||
|
GotoOperationalAct(Convert.ToInt32(actInfo[0]), Convert.ToInt32(actInfo[1]));
|
|||
|
break;
|
|||
|
case 11:
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.Boss, delegate (bool bSuccess, object param)
|
|||
|
{
|
|||
|
BossUI worldBoss = UIManager.GetUIComponent<BossUI>(UIInfo.Boss);
|
|||
|
if (worldBoss != null)
|
|||
|
{
|
|||
|
int bossType = Convert.ToInt32((string)param);
|
|||
|
worldBoss.ShowPage(bossType);
|
|||
|
}
|
|||
|
}, data.info);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if (onClick != null)
|
|||
|
{
|
|||
|
onClick();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void FindNPCStr(string npcIDStr)
|
|||
|
{
|
|||
|
int npcID = int.Parse(npcIDStr);
|
|||
|
FindNpc(npcID);
|
|||
|
}
|
|||
|
|
|||
|
// 前往NPC商店
|
|||
|
private static void FindNpc(int npcID)
|
|||
|
{
|
|||
|
Tab_AutoSearch sceneNpc = TableManager.GetAutoSearchByID(npcID, 0);
|
|||
|
if (sceneNpc == null)
|
|||
|
return;
|
|||
|
AutoSearchPoint point = new AutoSearchPoint(sceneNpc.DstSceneID, sceneNpc.X, sceneNpc.Z);
|
|||
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|||
|
{
|
|||
|
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(sceneNpc.DataId, 0);
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|||
|
if (role != null)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = role.Name;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
private enum UICLASSTYPE
|
|||
|
{
|
|||
|
MARRY = 0, //结婚副本
|
|||
|
COPY = 1, //活动界面副本
|
|||
|
}
|
|||
|
|
|||
|
private enum UISUBCLASSTYPE
|
|||
|
{
|
|||
|
ADVANCECOPY = 0, //进阶副本
|
|||
|
MAINMISSION = 1, //主线副本
|
|||
|
EQUIP = 2, //装备副本
|
|||
|
}
|
|||
|
|
|||
|
// 副本UI跳转
|
|||
|
public static void ShowUI(string info)
|
|||
|
{
|
|||
|
int _ClassType = -1;
|
|||
|
int _SubClass = -1;
|
|||
|
int _SubSubClass = -1;
|
|||
|
|
|||
|
int _OptParam = string.IsNullOrEmpty(info) ? -1 : Convert.ToInt32(info);
|
|||
|
|
|||
|
if (_OptParam == -1)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
_SubSubClass = _OptParam % 10 - 1;
|
|||
|
_SubClass = (_OptParam / 10) % 10;
|
|||
|
_ClassType = _OptParam / 100;
|
|||
|
|
|||
|
switch (_ClassType)
|
|||
|
{
|
|||
|
case (int)UICLASSTYPE.MARRY:
|
|||
|
{
|
|||
|
if (!GameManager.gameManager.PlayerDataPool.IsMarried)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData("#{47012}");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.MarryRoot, delegate (bool bSucess, object param)
|
|||
|
{
|
|||
|
if (bSucess)
|
|||
|
{
|
|||
|
MarryRoot.Instance.OnMenuItemClick(MarryRoot.MarryMenuItemType.Copy);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
break;
|
|||
|
case (int)UICLASSTYPE.COPY:
|
|||
|
{
|
|||
|
Hashtable tempParam = new Hashtable();
|
|||
|
tempParam["_SubClass"] = _SubClass;
|
|||
|
tempParam["_SubSubClass"] = _SubSubClass;
|
|||
|
UIManager.ShowUI(UIInfo.CopyScenePanelCtr, delegate (bool bSucess, object param)
|
|||
|
{
|
|||
|
if (bSucess)
|
|||
|
{
|
|||
|
int sc = (int)((Hashtable)param)["_SubClass"];
|
|||
|
int ssc = (int)((Hashtable)param)["_SubSubClass"];
|
|||
|
CopyScenePanelCtr.Instance.OnMenuItemClick(sc, ssc);
|
|||
|
}
|
|||
|
}, tempParam);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 运营活动跳转
|
|||
|
// enhanceID 入口ID
|
|||
|
// actID 活动ID
|
|||
|
public static void GotoOperationalAct(int enhanceID, int actID)
|
|||
|
{
|
|||
|
switch (enhanceID)
|
|||
|
{
|
|||
|
case -2:
|
|||
|
YuanBaoShopLogic.OpenChargePage();
|
|||
|
break;
|
|||
|
// vip
|
|||
|
case -1:
|
|||
|
YuanBaoShopLogic.OpenVipPage();
|
|||
|
break;
|
|||
|
case 0:
|
|||
|
// 福利大厅 有分页
|
|||
|
UIManager.ShowUI(UIInfo.WelfareRoot,
|
|||
|
(bool bSuccess, object param) =>
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
// 等级礼包NodeID = 203
|
|||
|
WelfareRootCtr.Instance.OpenWith(actID);
|
|||
|
}
|
|||
|
}); break;
|
|||
|
case 1:
|
|||
|
// 进阶特惠 有分页
|
|||
|
MarketingWinRootCS.OpenWithAct = actID;
|
|||
|
if (MarketingActsRoot.Instance() != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowActById(enhanceID, actID);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
// 开服活动 有分页
|
|||
|
OpenServiceRootCS.OpenWithAct = actID;
|
|||
|
if (MarketingActsRoot.Instance() != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowActById(enhanceID, actID);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 6:
|
|||
|
// 每日首冲/累充 有分页
|
|||
|
DailyRechargeRoot.OpenWithAct = actID;
|
|||
|
if (MarketingActsRoot.Instance() != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowActById(enhanceID, actID);
|
|||
|
}
|
|||
|
break;
|
|||
|
case 17:
|
|||
|
// 节日活动 有分页
|
|||
|
NewYearPage.OpenWithAct = actID;
|
|||
|
if (MarketingActsRoot.Instance() != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowActById(enhanceID, actID);
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
// 其他无分页活动
|
|||
|
if (MarketingActsRoot.Instance() != null)
|
|||
|
{
|
|||
|
MarketingActsRoot.Instance().ShowActById(enhanceID, actID);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|