174 lines
5.9 KiB
C#
174 lines
5.9 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
public class WorldBossGuide : MonoBehaviour
|
|||
|
{
|
|||
|
public Text m_CostMoney;
|
|||
|
public Text m_DugTimes;
|
|||
|
|
|||
|
public UICameraTexture m_BossModel;
|
|||
|
public UIContainerSelect m_BossList;
|
|||
|
public GameObject RewardJoin;
|
|||
|
public GameObject RewardBank;
|
|||
|
public Text Tip;
|
|||
|
|
|||
|
public void OnEnable()
|
|||
|
{
|
|||
|
var shows = new List<int>();
|
|||
|
var selects = new List<int>();
|
|||
|
var Bosss = TableManager.GetWorldBossConfig();
|
|||
|
foreach (var boss in Bosss)
|
|||
|
{
|
|||
|
if (0 == boss.Value.ISOtherServer)
|
|||
|
shows.Add(boss.Key);
|
|||
|
}
|
|||
|
if(shows.Count > 0 && selects.Count<=0)
|
|||
|
selects.Add(shows[0]);
|
|||
|
m_BossList.InitSelectContent(shows, selects, OnSelectBoss);
|
|||
|
|
|||
|
//检查是否需要出指引
|
|||
|
ShowGuide();
|
|||
|
}
|
|||
|
|
|||
|
public void OnSelectBoss(object initInfo)
|
|||
|
{
|
|||
|
int bossId = (int)initInfo;
|
|||
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(bossId, 0);
|
|||
|
if (TabBoss == null)
|
|||
|
return;
|
|||
|
m_DugTimes.text = string.Format("{0}/{1}", TabBoss.TreasureMax, TabBoss.TreasureMax);
|
|||
|
m_CostMoney.text = TabBoss.GetMoneyCountbyIndex(0).ToString();
|
|||
|
m_BossModel.gameObject.SetActive(false);
|
|||
|
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(bossId, 0);
|
|||
|
if (RoleBase != null)
|
|||
|
{
|
|||
|
Tab_CharModel charModel = TableManager.GetCharModelByID(RoleBase.CharModelID, 0);
|
|||
|
if(charModel!=null)
|
|||
|
{
|
|||
|
m_BossModel.gameObject.SetActive(true);
|
|||
|
m_BossModel.InitModelPath("", charModel,LoadAssetBundle.BUNDLE_PATH_MODEL,true);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
InitJoinReward(TabBoss.GetRewardShowbyIndex(0), RewardBank, BackRewards);
|
|||
|
InitJoinReward(TabBoss.GetRewardShowbyIndex(1), RewardJoin, JoinRewards);
|
|||
|
WorldBossData.Instance.m_CurrentShowBossId = bossId;
|
|||
|
}
|
|||
|
|
|||
|
List<GameObject> JoinRewards = new List<GameObject>();
|
|||
|
List<GameObject> BackRewards = new List<GameObject>();
|
|||
|
public void InitJoinReward(string items,GameObject cloneObj,List<GameObject> objs)
|
|||
|
{
|
|||
|
for (int i=0;i< objs.Count;i++)
|
|||
|
{
|
|||
|
objs[i].SetActive(false);
|
|||
|
}
|
|||
|
string[] itemIds = items.Split(':');
|
|||
|
for(int i=0;i<itemIds.Length;i++)
|
|||
|
{
|
|||
|
int itemID = -1;
|
|||
|
if(int.TryParse(itemIds[i],out itemID))
|
|||
|
{
|
|||
|
if (objs.Count > i)
|
|||
|
{
|
|||
|
CloneRewardItem(itemID, objs[i], cloneObj);
|
|||
|
continue;
|
|||
|
}
|
|||
|
GameObject newObj = CloneRewardItem(itemID, null, cloneObj);
|
|||
|
if(newObj!=null)
|
|||
|
objs.Add(newObj);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public GameObject CloneRewardItem(int itemId,GameObject oldItemObj,GameObject cloneObj)
|
|||
|
{
|
|||
|
if (oldItemObj == null && cloneObj == null)
|
|||
|
return null;
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
|||
|
if (commonItem == null)
|
|||
|
return null;
|
|||
|
if (oldItemObj==null)
|
|||
|
{
|
|||
|
oldItemObj = GameObject.Instantiate(cloneObj);
|
|||
|
oldItemObj.transform.SetParent(cloneObj.transform.parent);
|
|||
|
oldItemObj.transform.localPosition = Vector3.zero;
|
|||
|
oldItemObj.transform.localScale = cloneObj.transform.localScale;
|
|||
|
}
|
|||
|
if (oldItemObj == null)
|
|||
|
return null;
|
|||
|
oldItemObj.SetActive(true);
|
|||
|
Button btn = oldItemObj.GetComponentInChildren<Button>();
|
|||
|
if(btn!=null)
|
|||
|
{
|
|||
|
btn.onClick.RemoveAllListeners();
|
|||
|
btn.onClick.AddListener(delegate ()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(itemId, ItemTooltipsLogic.ShowType.Info, btn.transform.position);
|
|||
|
});
|
|||
|
}
|
|||
|
Image[] imgs = oldItemObj.GetComponentsInChildren<Image>();
|
|||
|
for(int i=0;i<imgs.Length;i++)
|
|||
|
{
|
|||
|
if(imgs[i]!=null && imgs[i].name == "Quility")
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(imgs[i], Utils.GetItemQualityFrame(commonItem));
|
|||
|
}
|
|||
|
if (imgs[i] != null && imgs[i].name == "Icon")
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(imgs[i], commonItem.Icon);
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, imgs[i].transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, imgs[i].transform);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return oldItemObj;
|
|||
|
}
|
|||
|
|
|||
|
public void Close()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.WorldBossGuide);
|
|||
|
}
|
|||
|
|
|||
|
//World指引的处理 ,临时这么解决一下
|
|||
|
public GameObject GuidePanel;
|
|||
|
public GameObject GuideObj;
|
|||
|
public Transform GuidePos;
|
|||
|
public GameObject LeftArrow;
|
|||
|
public GameObject RightArrow;
|
|||
|
private void ShowGuide()
|
|||
|
{
|
|||
|
GuideObj.transform.localPosition = new Vector3(-150, 228, 0);
|
|||
|
GuidePanel.SetActive(true);
|
|||
|
LeftArrow.SetActive(true);
|
|||
|
RightArrow.SetActive(false);
|
|||
|
Tip.text = StrDictionary.GetClientDictionaryString("#{4928}");
|
|||
|
}
|
|||
|
public void GuideLeftClick()
|
|||
|
{
|
|||
|
GuidePanel.SetActive(true);
|
|||
|
LeftArrow.SetActive(false);
|
|||
|
RightArrow.SetActive(true);
|
|||
|
Tip.text = StrDictionary.GetClientDictionaryString("#{4929}");
|
|||
|
iTween.MoveTo(GuideObj, GuidePos.position, 0.5f);
|
|||
|
}
|
|||
|
|
|||
|
public void GuideRightClick()
|
|||
|
{
|
|||
|
GCGame.Utils.EnterCopy(Games.GlobeDefine.GlobeVar.WORLDBOSS_GUIDECOPYID);
|
|||
|
GuidePanel.SetActive(false);
|
|||
|
LeftArrow.SetActive(false);
|
|||
|
RightArrow.SetActive(false);
|
|||
|
Close();
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|