218 lines
6.9 KiB
C#
218 lines
6.9 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
|
|
public class GuideStepAreaClickHold : GuideStepAreaClick
|
|
{
|
|
private bool _HoldUI = false;
|
|
|
|
private List<int> _GuideItemIDs = new List<int>();
|
|
|
|
protected override void InitGuideUIGO()
|
|
{
|
|
if (UIPath == GUIDE_UI_PATH.BackPack)
|
|
{
|
|
_GuideItemIDs.Clear();
|
|
var itemIdStrs = PathParam.Split(',');
|
|
foreach (var itemIDStr in itemIdStrs)
|
|
{
|
|
int tempID;
|
|
if (int.TryParse(itemIDStr, out tempID))
|
|
{
|
|
_GuideItemIDs.Add(tempID);
|
|
}
|
|
}
|
|
|
|
var backItems = GameManager.gameManager.PlayerDataPool.BackPack.GetList();
|
|
foreach (var backItem in backItems)
|
|
{
|
|
if (!backItem.IsValid())
|
|
continue;
|
|
|
|
foreach (var itemID in _GuideItemIDs)
|
|
{
|
|
if (backItem.DataID == itemID)
|
|
{
|
|
_HoldUI = true;
|
|
break;
|
|
}
|
|
|
|
if (_HoldUI)
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (!_HoldUI)
|
|
{
|
|
LogModule.DebugLog("背包中没有这个物品");
|
|
FinishGuideStep();
|
|
}
|
|
else
|
|
{
|
|
StartCoroutine(InitGuideUIGOLater());
|
|
}
|
|
_TryGetUIGOTimes = 0;
|
|
}
|
|
else if (UIPath == GUIDE_UI_PATH.EquipToolTip)
|
|
{
|
|
_HoldUI = true;
|
|
StartCoroutine(InitGuideUIGOLater());
|
|
}
|
|
else if (UIPath == GUIDE_UI_PATH.ItemToolTip)
|
|
{
|
|
_HoldUI = true;
|
|
StartCoroutine(InitGuideUIGOLater());
|
|
}
|
|
else if (UIPath == GUIDE_UI_PATH.Path)
|
|
{
|
|
_HoldUI = true;
|
|
StartCoroutine(InitGuideUIGOLater());
|
|
}
|
|
}
|
|
|
|
private int _TryGetUIGOTimes = 0;
|
|
private const int _TryGetUIGOMaxTimes = 10;
|
|
private IEnumerator InitGuideUIGOLater()
|
|
{
|
|
if (!_HoldUI)
|
|
yield break;
|
|
while (_TryGetUIGOTimes < _TryGetUIGOMaxTimes)
|
|
{
|
|
switch (UIPath)
|
|
{
|
|
case GUIDE_UI_PATH.BackPack:
|
|
if (BackPackLogic.Instance())
|
|
{
|
|
BackPackLogic.Instance()._ItemsContainer.ForeachActiveItem<CommonItemBackPackItem>(
|
|
(backPackItem) =>
|
|
{
|
|
foreach (var itemID in _GuideItemIDs)
|
|
{
|
|
if (backPackItem._ItemBackPack.GameItem == null)
|
|
break;
|
|
|
|
if (!backPackItem._ItemBackPack.GameItem.IsValid())
|
|
break;
|
|
|
|
if (backPackItem._ItemBackPack.GameItem.DataID != itemID)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!backPackItem._ItemSlot._ItemImg.enabled)
|
|
break;
|
|
|
|
//if (backPackItem._ItemBackPack.GameItem.DataID == itemID)
|
|
{
|
|
_GuideUIGO = backPackItem.gameObject;
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
break;
|
|
case GUIDE_UI_PATH.EquipToolTip:
|
|
if (EquipTooltipsLogic.Instance())
|
|
{
|
|
int btnIdx = int.Parse(PathParam);
|
|
if (EquipTooltipsLogic.Instance()._PopMenu.SubBtns.Count > btnIdx)
|
|
{
|
|
int menuIdx = 0;
|
|
foreach (var keyValue in EquipTooltipsLogic.Instance()._PopMenu.SubBtns)
|
|
{
|
|
if (menuIdx == btnIdx)
|
|
{
|
|
_GuideUIGO = keyValue.Key.gameObject;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
++menuIdx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
case GUIDE_UI_PATH.ItemToolTip:
|
|
if (ItemTooltipsLogic.Instance())
|
|
{
|
|
int btnIdx = int.Parse(PathParam);
|
|
if (ItemTooltipsLogic.Instance()._PopMenu.SubBtns.Count > btnIdx)
|
|
{
|
|
int menuIdx = 0;
|
|
foreach (var keyValue in ItemTooltipsLogic.Instance()._PopMenu.SubBtns)
|
|
{
|
|
if (menuIdx == btnIdx)
|
|
{
|
|
_GuideUIGO = keyValue.Key.gameObject;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
++menuIdx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
case GUIDE_UI_PATH.Path:
|
|
_GuideUIGO = GameObject.Find(PathParam);
|
|
break;
|
|
}
|
|
|
|
if (_GuideUIGO == null)
|
|
{
|
|
_TryGetUIGOTimes++;
|
|
yield return new WaitForSeconds(0.2f);
|
|
}
|
|
else
|
|
{
|
|
ShowGuide();
|
|
yield break;
|
|
}
|
|
}
|
|
_HoldUI = false;
|
|
FinishGuideStep();
|
|
}
|
|
|
|
protected override void ShowGuide()
|
|
{
|
|
if (_GuideUIGO == null && !_HoldUI)
|
|
{
|
|
FinishGuideStep();
|
|
return;
|
|
}
|
|
|
|
if (_CopyGuideGO != null)
|
|
return;
|
|
|
|
if (_HoldUI)
|
|
{
|
|
GuideLogic.Instance()._GuideInfo.gameObject.SetActive(false);
|
|
GuideLogic.Instance()._NewFuncInfo.gameObject.SetActive(false);
|
|
if (GuideType == GUIDE_OPT_TYPE.ForceOpt)
|
|
{
|
|
GuideLogic.Instance().SetForceBackActive(true);
|
|
}
|
|
else if (GuideType == GUIDE_OPT_TYPE.ClickClose)
|
|
{
|
|
GuideLogic.Instance().SetClickBack();
|
|
}
|
|
else
|
|
{
|
|
GuideLogic.Instance().SetForceBackActive(false);
|
|
}
|
|
}
|
|
|
|
if (_GuideUIGO == null)
|
|
return;
|
|
|
|
base.ShowGuide();
|
|
}
|
|
}
|