866 lines
28 KiB
C#
866 lines
28 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using GCGame.Table;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
using Games.Item;
|
|
using Module.Log;
|
|
|
|
public class StroyCopySceneRootCtrl : MonoBehaviour
|
|
{
|
|
|
|
private static StroyCopySceneRootCtrl Instance;
|
|
public static StroyCopySceneRootCtrl GteInstance()
|
|
{
|
|
return Instance;
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
IEnumerator RefreshBossInfoItemState()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
for (int index = 0; index < _ItemPrefabList.Count; index++)
|
|
{
|
|
_ItemPrefabList[index].GetComponent<BossInfoItem>().SetItemState();
|
|
yield return null;
|
|
}
|
|
ReqRemainTimes();
|
|
yield break;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public enum CopySceneType
|
|
{
|
|
INVALID = -1,
|
|
NORMAL = 0, //普通模式
|
|
HERO = 1, //英雄模式
|
|
}
|
|
|
|
//全部的剧情副本
|
|
public Dictionary<int, List<Tab_StroyCopy>> m_AllStoryCopy = new Dictionary<int, List<Tab_StroyCopy>>();
|
|
//选择的副本类型
|
|
public CopySceneType m_SelectedCopySceneType = CopySceneType.HERO;
|
|
//人物最高可以参加的副本等级
|
|
public int m_CanJoinLevel;
|
|
|
|
//记录父类位置
|
|
public Transform m_Parent;
|
|
public Transform m_ReawrdItemParent;
|
|
//副本Item预设体
|
|
public GameObject m_BossInfoItem;
|
|
|
|
//副本剩余次数
|
|
public Text m_CopySceneReaminText;
|
|
|
|
//奖励物品
|
|
public GameObject m_RewardItem;
|
|
public List<GameObject> m_RewardList;
|
|
|
|
//副本限制信息
|
|
//public Text m_LimitInfoText;
|
|
|
|
//帮助信息
|
|
public Text m_HelpText;
|
|
|
|
//等级预设
|
|
public GameObject levelItemPrefab;
|
|
public Text selectButtonDesc; //当前等级描述
|
|
private bool IsShowLevelItemPanel = false;
|
|
public Transform levelItemParent;
|
|
public GameObject selectButtonMarkBGoBJ;
|
|
|
|
//public Button joinButton;
|
|
|
|
//public Text _perfectCombatValue;
|
|
|
|
public DiffcultySelect _Select;
|
|
|
|
|
|
public GameObject _SingleBtn;
|
|
public GameObject _TeamBtn;
|
|
|
|
//设置副本剩余次数 服务器同步
|
|
private int remainChallengeTimes = 0;
|
|
public void SetMyCopySceneRemainCount(int count)
|
|
{
|
|
remainChallengeTimes = count;
|
|
m_CopySceneReaminText.text = count.ToString();
|
|
|
|
for (int index = 0; index < _ItemPrefabList.Count; index++)
|
|
{
|
|
_ItemPrefabList[index].GetComponent<BossInfoItem>().SetRemainChallengeTimes(count);
|
|
if (_ItemPrefabList[index].GetComponent<BossInfoItem>()._CopySceneId == m_SelectedCopySceneId)
|
|
{
|
|
_ItemPrefabList[index].GetComponent<BossInfoItem>().OnItemClick();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private int lastIndex = 1;
|
|
public void SetSelectedType(int m_Index)
|
|
{
|
|
if (lastIndex == m_Index)
|
|
{
|
|
return;
|
|
}
|
|
lastIndex = m_Index;
|
|
switch (m_Index)
|
|
{
|
|
case (int)CopySceneType.NORMAL:
|
|
m_SelectedCopySceneType = CopySceneType.NORMAL;
|
|
break;
|
|
case (int)CopySceneType.HERO:
|
|
m_SelectedCopySceneType = CopySceneType.HERO;
|
|
break;
|
|
default:
|
|
m_SelectedCopySceneType = CopySceneType.INVALID;
|
|
break;
|
|
}
|
|
RefreshBossItemInfo(m_SelectedCopySceneType);
|
|
SwitchDropDesc();
|
|
}
|
|
|
|
private void RefreshChallengeBtnState()
|
|
{
|
|
Tab_StroyCopy stroyCopy = TableManager.GetStroyCopyByID(m_SelectedCopySceneId, 0);
|
|
if (stroyCopy == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var mainPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;//人物等级
|
|
var _IsLock = true;
|
|
if (mainPlayerLevel >= stroyCopy.Level && GameManager.gameManager.MissionManager.IsMissionHaveDone(stroyCopy.LimitMissionId))
|
|
{
|
|
_IsLock = false;
|
|
}
|
|
|
|
if (_IsLock)
|
|
{
|
|
_TeamBtn.SetActive(false);
|
|
_SingleBtn.SetActive(false);
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42504}"));
|
|
//m_LimitInfoText.text = string.Format("<color=#7c8194>{0}</color>", StrDictionary.GetClientDictionaryString("#{42504}"));
|
|
//joinButton.interactable = false;
|
|
}
|
|
//else
|
|
//{
|
|
// m_LimitInfoText.text = string.Format("<color=#5f433b>{0}</color>", StrDictionary.GetClientDictionaryString("#{42503}"));
|
|
// joinButton.interactable = true;
|
|
//}
|
|
}
|
|
|
|
private int m_SelectedCopySceneId = -1;
|
|
private CopySceneType lastHardType = CopySceneType.INVALID;
|
|
public void InitMyBossInfo(int m_Id, bool _IsLock)
|
|
{
|
|
StartCoroutine(CreateRew(m_Id));
|
|
}
|
|
|
|
IEnumerator CreateRew(int m_Id)
|
|
{
|
|
yield return null;
|
|
if (m_SelectedCopySceneId == m_Id)
|
|
{
|
|
yield break;
|
|
}
|
|
m_SelectedCopySceneId = m_Id;
|
|
lastHardType = m_SelectedCopySceneType;
|
|
Tab_StroyCopy stroyCopy = TableManager.GetStroyCopyByID(m_Id, 0);
|
|
string[] m_itemId = null;
|
|
if (stroyCopy == null)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
_SingleBtn.SetActive(stroyCopy.CanSingle == 1);
|
|
_TeamBtn.SetActive(stroyCopy.CanTeam == 1);
|
|
|
|
m_itemId = stroyCopy.GetHeroDropbyIndex(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession).Split('|');
|
|
//_perfectCombatValue.text = stroyCopy.HeroPower.ToString();
|
|
|
|
var needCreateCount = m_itemId.Length - m_RewardList.Count;
|
|
|
|
if (needCreateCount >= 0)
|
|
{
|
|
for (int index = 0; index < needCreateCount; index++)
|
|
{
|
|
GameObject m_ItemPrefab = GameObject.Instantiate(m_RewardItem);
|
|
m_ItemPrefab.transform.SetParent(m_ReawrdItemParent);
|
|
m_ItemPrefab.transform.localScale = Vector3.one;
|
|
m_ItemPrefab.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|
m_ItemPrefab.transform.localPosition = Vector3.zero;
|
|
|
|
m_RewardList.Add(m_ItemPrefab);
|
|
}
|
|
|
|
//活动奖励
|
|
for (int index = 0; index < m_itemId.Length; index++)
|
|
{
|
|
m_RewardList[index].SetActive(true);
|
|
m_RewardList[index].GetComponent<CopySceneRewardItem>().InitItem(int.Parse(m_itemId[index]), -1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int index = m_RewardList.Count - Mathf.Abs(needCreateCount); index < m_RewardList.Count; index++)
|
|
{
|
|
m_RewardList[index].SetActive(false);
|
|
}
|
|
|
|
//活动奖励
|
|
for (int index = 0; index < m_itemId.Length; index++)
|
|
{
|
|
m_RewardList[index].GetComponent<CopySceneRewardItem>().InitItem(int.Parse(m_itemId[index]), -1);
|
|
}
|
|
}
|
|
|
|
//活动奖励
|
|
for (int index = 0; index < m_itemId.Length; index++)
|
|
{
|
|
m_RewardList[index].GetComponent<CopySceneRewardItem>().InitItem(int.Parse(m_itemId[index]), -1);
|
|
}
|
|
|
|
//这边重新加一次判断
|
|
RefreshChallengeBtnState();
|
|
SetItemMarkIcon(m_Id);
|
|
|
|
yield break;
|
|
}
|
|
|
|
public void MyHelpButtonClick()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(16);
|
|
}
|
|
|
|
public bool JudgeMyTeamInfo(int minCount)
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam() &&
|
|
GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() >= minCount)
|
|
{
|
|
if (!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{9004}"));
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|
{
|
|
if (!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{9004}"));
|
|
return false;
|
|
}else
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{65200}"), null, delegate ()
|
|
{
|
|
UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}, delegate ()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
});
|
|
return false;
|
|
}
|
|
}else
|
|
{
|
|
if (minCount == 1)
|
|
return true;
|
|
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{65200}"), null, delegate ()
|
|
{
|
|
UIManager.ShowUI(UIInfo.TeamCreateRoot, delegate (bool bSucess, object param)
|
|
{
|
|
if (bSucess)
|
|
{
|
|
var hash = new Hashtable();
|
|
var copyTab = TableManager.GetStroyCopyByID(m_SelectedCopySceneId, 0);
|
|
if (copyTab == null)
|
|
{
|
|
return;
|
|
}
|
|
hash["index"] = copyTab.HeroTeamTargetId;
|
|
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, hash);
|
|
}
|
|
});
|
|
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}, delegate ()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
});
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void MyJoinButtonClick()
|
|
{
|
|
Tab_StroyCopy stroyCopy = TableManager.GetStroyCopyByID(m_SelectedCopySceneId, 0);
|
|
if (stroyCopy == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int copySceneId = -1;
|
|
var fuben = TableManager.GetFubenByID(stroyCopy.HeroFubenId, 0);
|
|
if(fuben == null)
|
|
{
|
|
return;
|
|
}
|
|
if (JudgeMyTeamInfo(fuben.PlayerDemandMin)) //符合客户端的参加条件
|
|
{
|
|
copySceneId = stroyCopy.HeroFubenId;
|
|
}
|
|
else
|
|
{
|
|
copySceneId = -1;
|
|
}
|
|
if (copySceneId != -1)
|
|
{
|
|
MessageBoxLogic.ShowEnterCopySceneEnsureMessageBox(copySceneId, 1, (int)m_SelectedCopySceneType);
|
|
}
|
|
}
|
|
|
|
public void OnSingleBtn()
|
|
{
|
|
var stroyCopy = TableManager.GetStroyCopyByID(m_SelectedCopySceneId, 0);
|
|
if (stroyCopy == null) return;
|
|
var copySceneId = stroyCopy.HeroFubenId;
|
|
MessageBoxLogic.ShowEnterCopySceneEnsureMessageBox(copySceneId, 1, (int)m_SelectedCopySceneType, false);
|
|
}
|
|
|
|
public void OnTeamBtn()
|
|
{
|
|
var stroyCopy = TableManager.GetStroyCopyByID(m_SelectedCopySceneId, 0);
|
|
if (stroyCopy == null) return;
|
|
var copySceneId = stroyCopy.HeroFubenId;
|
|
|
|
var fuben = TableManager.GetFubenByID(stroyCopy.HeroFubenId, 0);
|
|
if (fuben == null)
|
|
{
|
|
return;
|
|
}
|
|
if (!JudgeMyTeamInfo(fuben.PlayerDemandMin))
|
|
return;
|
|
|
|
MessageBoxLogic.ShowEnterCopySceneEnsureMessageBox(copySceneId, 1, (int)m_SelectedCopySceneType, true);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
SortLevelList();
|
|
HideLevelPanel();
|
|
StartCoroutine(CreateItemPrefab());
|
|
InitAddTimeItem();
|
|
|
|
RefreshItemCount();
|
|
RefreshChallengeBtnState();
|
|
}
|
|
|
|
void HideLevelPanel()
|
|
{
|
|
selectButtonMarkBGoBJ.gameObject.SetActive(IsShowLevelItemPanel);
|
|
}
|
|
|
|
public enum LevelType
|
|
{
|
|
Invalid = -1,
|
|
level0,
|
|
level1,
|
|
level2,
|
|
level3,
|
|
level4,
|
|
level5,
|
|
level6,
|
|
}
|
|
LevelType canJoinType = LevelType.Invalid;
|
|
IEnumerator InitSelectButtonDesc()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
int mainPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|
bool hasUnLockType = false;
|
|
int maxLevel = -1;
|
|
foreach (var info in TableManager.GetStroyCopy().Values)
|
|
{
|
|
if (info.Level <= mainPlayerLevel && GameManager.gameManager.MissionManager.IsMissionHaveDone(info.LimitMissionId))
|
|
{
|
|
hasUnLockType = true;
|
|
maxLevel = info.Level;
|
|
}
|
|
}
|
|
|
|
if (!hasUnLockType)
|
|
{
|
|
canJoinType = LevelType.level0;
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42616}");
|
|
}
|
|
else
|
|
{
|
|
foreach(var tab in TableManager.GetStroyCopy().Values)
|
|
{
|
|
if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= tab.MinLevel
|
|
&& GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level <= tab.MaxLevel)
|
|
{
|
|
canJoinType = (LevelType)tab.EnumType;
|
|
}
|
|
}
|
|
}
|
|
yield return StartCoroutine(SetSelectedType(canJoinType));
|
|
|
|
yield break;
|
|
}
|
|
|
|
private List<GameObject> _ItemPrefabList = new List<GameObject>(); //全部预设
|
|
private Dictionary<int, RectTransform> _EveryTypeFirstItemDic = new Dictionary<int, RectTransform>();
|
|
IEnumerator CreateItemPrefab()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
if (_ItemPrefabList.Count <= 0)
|
|
{
|
|
foreach (var info in TableManager.GetStroyCopy())
|
|
{
|
|
var infoItemPrefab = Instantiate(m_BossInfoItem);
|
|
infoItemPrefab.transform.SetParent(m_Parent);
|
|
infoItemPrefab.transform.localPosition = Vector3.zero;
|
|
infoItemPrefab.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|
infoItemPrefab.transform.localScale = Vector3.one;
|
|
|
|
infoItemPrefab.GetComponent<BossInfoItem>().InitMyItem(info.Key, m_SelectedCopySceneType);
|
|
_ItemPrefabList.Add(infoItemPrefab);
|
|
|
|
if (!_EveryTypeFirstItemDic.ContainsKey(info.Value.EnumType))
|
|
{
|
|
_EveryTypeFirstItemDic.Add(info.Value.EnumType, infoItemPrefab.GetComponent<RectTransform>());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//if (m_SelectedCopySceneType == CopySceneType.INVALID)
|
|
// SetSelectedType(0);
|
|
//else
|
|
// SetSelectedType((int)m_SelectedCopySceneType);
|
|
SetSelectedType(1);
|
|
|
|
//初始化当前可以进行的分段描述
|
|
yield return StartCoroutine(InitSelectButtonDesc());
|
|
|
|
yield return StartCoroutine(RefreshBossInfoItemState());
|
|
//获取每个等级分段对应的区域
|
|
GetAnchoredPosAreaDis();
|
|
|
|
ShowLeftOrRightIcon();
|
|
yield break;
|
|
}
|
|
|
|
|
|
private bool _sorted;
|
|
List<int> typeList = new List<int>();
|
|
private List<GameObject> levelItemPrefabList = new List<GameObject>();
|
|
public void SortLevelList()
|
|
{
|
|
if (_sorted)
|
|
return;
|
|
_sorted = true;
|
|
var copySceneDic = TableManager.GetStroyCopy().Values;
|
|
foreach (var tab in copySceneDic)
|
|
{
|
|
if (!typeList.Contains(tab.EnumType))
|
|
{
|
|
typeList.Add(tab.EnumType);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnSelectButtonClick()
|
|
{
|
|
selectButtonMarkBGoBJ.gameObject.SetActive(!IsShowLevelItemPanel);
|
|
IsShowLevelItemPanel = !IsShowLevelItemPanel;
|
|
if (!IsShowLevelItemPanel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (levelItemPrefabList.Count == 0)
|
|
{
|
|
for (int index = 0; index < typeList.Count; index++)
|
|
{
|
|
GameObject levelItem = GameObject.Instantiate(levelItemPrefab);
|
|
levelItem.transform.SetParent(levelItemParent);
|
|
levelItem.transform.localPosition = Vector3.zero;
|
|
levelItem.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|
levelItem.transform.localScale = Vector3.one;
|
|
|
|
levelItem.GetComponent<CopySceneLevelItem>().InitItem((LevelType)typeList[index]);
|
|
levelItemPrefabList.Add(levelItem);
|
|
}
|
|
}
|
|
|
|
if (_CurType != LevelType.Invalid)
|
|
{
|
|
for (int index = 0; index < levelItemPrefabList.Count; index++)
|
|
{
|
|
levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().markIcon.gameObject.SetActive(
|
|
_CurType == levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().type ? true : false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int index = 0; index < levelItemPrefabList.Count; index++)
|
|
{
|
|
levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().markIcon.gameObject.SetActive(
|
|
canJoinType == levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().type ? true : false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private LevelType _CurShowType = LevelType.Invalid;
|
|
private void SetSelectButtonDesc(LevelType type)
|
|
{
|
|
//if(_CurShowType == type)
|
|
//{
|
|
// return;
|
|
//}
|
|
_CurShowType = type;
|
|
if (_CurShowType == LevelType.level0)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42616}");// "等级:<color=#FC4747FF>30-49</color>";
|
|
}
|
|
else if (_CurShowType == LevelType.level1)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42617}");// "等级:<color=#FC4747FF>50-69</color>";
|
|
}
|
|
else if (_CurShowType == LevelType.level2)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42618}");// "等级:<color=#FC4747FF>70-89</color>";
|
|
}
|
|
else if (_CurShowType == LevelType.level3)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42619}");// "等级:<color=#FC4747FF>90-109</color>";
|
|
}
|
|
else if (_CurShowType == LevelType.level4)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42620}");// "等级:<color=#FC4747FF>110-129</color>";
|
|
}
|
|
else if (_CurShowType == LevelType.level5)
|
|
{
|
|
selectButtonDesc.text = StrDictionary.GetClientDictionaryString("#{42621}");// "等级:<color=#FC4747FF>130-150</color>";
|
|
}
|
|
}
|
|
|
|
public void OnLevelItemClick(LevelType type)
|
|
{
|
|
StartCoroutine(SetSelectedType(type));
|
|
}
|
|
|
|
private LevelType _CurType = LevelType.Invalid;
|
|
IEnumerator SetSelectedType(LevelType type)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
_CurType = type;
|
|
IsShowLevelItemPanel = false;
|
|
HideLevelPanel();
|
|
|
|
yield return StartCoroutine(ShowCurTypeFirstBossInfo());
|
|
|
|
SetLevelItemMarkIcon();
|
|
SetSelectButtonDesc(_CurType);
|
|
|
|
ReqRemainTimes();
|
|
|
|
yield break;
|
|
}
|
|
|
|
private void ReqRemainTimes()
|
|
{
|
|
//向服务器请求剧情副本的次数
|
|
CG_REQ_SEND_PACKET Packet = (CG_REQ_SEND_PACKET)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SEND_PACKET);
|
|
Packet.SetReqType((int)CG_REQ_SEND_PACKET.REQ_TYPE.REQ_TYPE_STORY_FB_INFO);
|
|
Packet.SendPacket();
|
|
}
|
|
|
|
private GameObject _CurNeedShowItemObj = null;
|
|
IEnumerator ShowCurTypeFirstBossInfo()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
if (_outSetFubenId != -1)
|
|
{
|
|
for (int index = 0; index < _ItemPrefabList.Count; index++)
|
|
{
|
|
var bossInfoItem = _ItemPrefabList[index].GetComponent<BossInfoItem>();
|
|
var stroyTab = TableManager.GetStroyCopyByID(bossInfoItem._CopySceneId, 0);
|
|
if (stroyTab != null)
|
|
{
|
|
if (_outSetFubenId == (_type == 0 ? stroyTab.EasyFubenId : stroyTab.HeroFubenId))
|
|
{
|
|
bossInfoItem.OnItemClick();
|
|
_CurNeedShowItemObj = bossInfoItem.gameObject;
|
|
|
|
_outSetFubenId = -1;
|
|
_type = -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (_EveryTypeFirstItemDic.ContainsKey((int)_CurType))
|
|
{
|
|
_EveryTypeFirstItemDic[(int)_CurType].gameObject.GetComponent<BossInfoItem>().OnItemClick();
|
|
_CurNeedShowItemObj = _EveryTypeFirstItemDic[(int)_CurType].gameObject;
|
|
}
|
|
|
|
if(_CurNeedShowItemObj == null)
|
|
{
|
|
_EveryTypeFirstItemDic[(int)LevelType.level0].gameObject.GetComponent<BossInfoItem>().OnItemClick();
|
|
_CurNeedShowItemObj = _EveryTypeFirstItemDic[(int)LevelType.level0].gameObject;
|
|
}
|
|
|
|
if (_CurNeedShowItemObj == null)
|
|
{
|
|
LogModule.ErrorLog("副本不足!副本不足!副本不足!让你们加几次了!");
|
|
}
|
|
|
|
yield return StartCoroutine(PositionItem());
|
|
|
|
yield break;
|
|
}
|
|
|
|
public RectTransform _ScorllRectTransform;
|
|
public RectTransform _ContainerObjTransform;
|
|
|
|
IEnumerator PositionItem()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
{
|
|
float _ContainerMinX = -_ContainerObjTransform.sizeDelta.x;
|
|
float _ContainerFixX = -_CurNeedShowItemObj.GetComponent<RectTransform>().anchoredPosition.x
|
|
+ _ContainerObjTransform.GetComponent<GridLayoutGroup>().padding.left;
|
|
float _ContanierPosX = Mathf.Clamp(_ContainerFixX, _ContainerMinX, 0);
|
|
_ContainerObjTransform.anchoredPosition = new Vector2(_ContanierPosX, 0);
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
private int _outSetFubenId = -1;
|
|
private int _type = -1;
|
|
public void SetOutSetFubenId(int _fubenId, int type)
|
|
{
|
|
_outSetFubenId = _fubenId;
|
|
_type = type;
|
|
}
|
|
|
|
public void RefreshBossItemInfo(CopySceneType type)
|
|
{
|
|
for (int index = 0; index < _ItemPrefabList.Count; index++)
|
|
{
|
|
var bossInfoItem = _ItemPrefabList[index].GetComponent<BossInfoItem>();
|
|
bossInfoItem.RefreshBossItemInfo(type);
|
|
if (bossInfoItem._CopySceneId == m_SelectedCopySceneId)
|
|
{
|
|
bossInfoItem.OnItemClick(); //刷新奖励
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetItemMarkIcon(int _CopyId)
|
|
{
|
|
for (int index = 0; index < _ItemPrefabList.Count; index++)
|
|
{
|
|
_ItemPrefabList[index].gameObject.GetComponent<BossInfoItem>().markIcon.gameObject.SetActive(
|
|
_ItemPrefabList[index].gameObject.GetComponent<BossInfoItem>()._CopySceneId == _CopyId ? true : false);
|
|
}
|
|
}
|
|
|
|
public void SetLevelItemMarkIcon()
|
|
{
|
|
for (int index = 0; index < levelItemPrefabList.Count; index++)
|
|
{
|
|
levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().markIcon.gameObject.SetActive(
|
|
levelItemPrefabList[index].GetComponent<CopySceneLevelItem>().type == _CurType ? true : false);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
IsShowLevelItemPanel = false;
|
|
lastIndex = -1;
|
|
}
|
|
|
|
private LevelType _CurDragLevelType = LevelType.level0;
|
|
|
|
// 极值 类型
|
|
private Dictionary<int, float> _DisToLevelTypeDic = new Dictionary<int, float>();
|
|
public void GetAnchoredPosAreaDis()
|
|
{
|
|
//获取最大类型枚举值
|
|
int _MaxLevel = 0;
|
|
foreach (var info in _EveryTypeFirstItemDic)
|
|
{
|
|
if (info.Key > _MaxLevel)
|
|
{
|
|
_MaxLevel = info.Key;
|
|
}
|
|
}
|
|
|
|
foreach (var item in _EveryTypeFirstItemDic)
|
|
{
|
|
if (item.Key < _MaxLevel)
|
|
{
|
|
if (!_DisToLevelTypeDic.ContainsKey(item.Key))
|
|
{
|
|
float _maxDis = _EveryTypeFirstItemDic[item.Key + 1].anchoredPosition.x - _ScorllRectTransform.rect.width / 2;
|
|
_DisToLevelTypeDic.Add(item.Key, _maxDis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
float _maxDis = _ContainerObjTransform.rect.width;
|
|
if (!_DisToLevelTypeDic.ContainsKey(_MaxLevel))
|
|
_DisToLevelTypeDic.Add(_MaxLevel, _maxDis);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetNeedShowLevelDesc()
|
|
{
|
|
float _CurDis = Mathf.Abs(_ContainerObjTransform.localPosition.x);
|
|
foreach (var info in _DisToLevelTypeDic)
|
|
{
|
|
if (_CurDis < info.Value)
|
|
{
|
|
_CurType = (LevelType)info.Key;
|
|
break;
|
|
}
|
|
}
|
|
SetSelectButtonDesc(_CurType);
|
|
}
|
|
|
|
public void OnScrollDrag()
|
|
{
|
|
SetNeedShowLevelDesc();
|
|
ShowLeftOrRightIcon();
|
|
}
|
|
|
|
private float? _ItemPrefabWidth = null;
|
|
private float? _ItemPaddingWidth = null;
|
|
private float? _MarkIconHideOrShowDis = null;
|
|
private float? _ContainerWidth = null;
|
|
public void GetItemWodthAndPaddingWidth()
|
|
{
|
|
_ItemPrefabWidth = _ContainerObjTransform.gameObject.GetComponent<GridLayoutGroup>().cellSize.x;
|
|
_ItemPaddingWidth = _ContainerObjTransform.gameObject.GetComponent<GridLayoutGroup>().spacing.x;
|
|
_MarkIconHideOrShowDis = _ItemPrefabWidth +_ItemPaddingWidth;
|
|
_ContainerWidth = _ContainerObjTransform.rect.width;
|
|
}
|
|
|
|
public GameObject _LeftIcon;
|
|
public GameObject _RightIcon;
|
|
private void ShowLeftOrRightIcon()
|
|
{
|
|
if (_MarkIconHideOrShowDis == null || _ContainerWidth == null
|
|
|| _MarkIconHideOrShowDis == 0 || _ContainerWidth == 0)
|
|
{
|
|
GetItemWodthAndPaddingWidth();
|
|
}
|
|
//left
|
|
if (Mathf.Abs(_ContainerObjTransform.localPosition.x) > _MarkIconHideOrShowDis)
|
|
{
|
|
if (!_LeftIcon.activeInHierarchy) _LeftIcon.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
if (_LeftIcon.activeInHierarchy) _LeftIcon.SetActive(false);
|
|
}
|
|
|
|
//right
|
|
if (_ContainerWidth - Mathf.Abs(_ContainerObjTransform.localPosition.x) - _ScorllRectTransform.rect.width > _MarkIconHideOrShowDis)
|
|
{
|
|
if (!_RightIcon.activeInHierarchy) _RightIcon.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
if (_RightIcon.activeInHierarchy) _RightIcon.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public Image _ItemIcon;
|
|
public Image _ItemQuality;
|
|
public Text _ItemCount;
|
|
public GameObject _ItemGetBtn;
|
|
private const int _ItemId = 860; //固定
|
|
public void InitAddTimeItem()
|
|
{
|
|
var commonItem = TableManager.GetCommonItemByID(_ItemId, 0);
|
|
if (commonItem == null)
|
|
{
|
|
LogModule.ErrorLog("commonitem 860 is null");
|
|
return;
|
|
}
|
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|
if (commonItem.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, _ItemIcon.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, _ItemIcon.transform);
|
|
}
|
|
|
|
RefreshItemCount();
|
|
}
|
|
|
|
public void OnItemGetBtn()
|
|
{
|
|
ItemTooltipsLogic.ShowItemTooltip(_ItemId, ItemTooltipsLogic.ShowType.GetPath, _ItemIcon.gameObject.transform.position);
|
|
}
|
|
|
|
public void RefreshItemCount()
|
|
{
|
|
var _BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|
if(_BackPack != null)
|
|
{
|
|
var count = _BackPack.GetItemCountByDataId(_ItemId);
|
|
_ItemGetBtn.SetActive(count <= 0);
|
|
if (count > 0)
|
|
_ItemCount.text = "<color=#FFFFFFFF>" + count.ToString() + "</color>";
|
|
else
|
|
_ItemCount.text = "<color=#FF3434FF>" + count.ToString() + "</color>";
|
|
}
|
|
}
|
|
|
|
public GameObject _NormalDesc;
|
|
public GameObject _HeroDesc;
|
|
public void SwitchDropDesc()
|
|
{
|
|
_NormalDesc.SetActive(lastIndex == (int)CopySceneType.NORMAL);
|
|
_HeroDesc.SetActive(lastIndex == (int)CopySceneType.HERO);
|
|
}
|
|
|
|
public void OnItemIconClick()
|
|
{
|
|
var _BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|
if (_BackPack.GetItemCountByDataId(_ItemId) > 0)
|
|
ItemTooltipsLogic.ShowItemTooltip(_ItemId, ItemTooltipsLogic.ShowType.Info, _ItemIcon.transform.position);
|
|
else
|
|
ItemTooltipsLogic.ShowItemTooltip(_ItemId, ItemTooltipsLogic.ShowType.GetPath, transform.position);
|
|
}
|
|
}
|