371 lines
12 KiB
C#
371 lines
12 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using GCGame;
|
|
|
|
public class WorldBoss : MonoBehaviour
|
|
{
|
|
public Text m_LeaveBloodRate;
|
|
public Text m_CostMoney;
|
|
public Text m_TextDesc;
|
|
public UICameraTexture m_BossModel;
|
|
public UIContainerSelect m_BossList;
|
|
public GameObject RewardJoin;
|
|
public GameObject RewardBank;
|
|
|
|
public Toggle EnterCopy_Check;
|
|
public GameObject EnterCopyMessageTip;
|
|
public GameObject EnterCopyBtn;
|
|
public Text EnterCopyTip;
|
|
public UITagPanel _TagPanel;
|
|
private int m_FirstShowBossID = -1;
|
|
|
|
private void Awake()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.WorldBossInfo,Init);
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.WorldBossDugTimes, DugTimes);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.WorldBossInfo, Init);
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.WorldBossDugTimes, DugTimes);
|
|
}
|
|
|
|
public void SetFirstSelectBossId(int bossID)
|
|
{
|
|
m_FirstShowBossID = bossID;
|
|
}
|
|
|
|
public void ForBidClick()
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{49032}"));
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
WorldBossData.Instance.SendAskData();
|
|
}
|
|
|
|
public void DugTimes(object Times)
|
|
{
|
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(WorldBossData.Instance.m_CurrentShowBossId, 0);
|
|
if (TabBoss == null)
|
|
return;
|
|
WorldBossData.BossInfo bossInfo = WorldBossData.Instance.GetBossInfo(WorldBossData.Instance.m_CurrentShowBossId);
|
|
if (bossInfo == null)
|
|
return;
|
|
int count = bossInfo.m_DugUseTimes;
|
|
if (count >= TabBoss.getMoneyCountCount())
|
|
count = TabBoss.getMoneyCountCount() - 1;
|
|
m_CostMoney.text = TabBoss.GetMoneyCountbyIndex(count).ToString();
|
|
m_FirstShowBossID = -1;
|
|
}
|
|
|
|
public void ShowPage(int index)
|
|
{
|
|
if (_TagPanel)
|
|
_TagPanel.ShowPage(index);
|
|
}
|
|
|
|
private int ShowPageIndex = 0;
|
|
public void TagShowPageMain(int page)
|
|
{
|
|
ShowPageIndex = page;
|
|
Init(null);
|
|
}
|
|
|
|
public void Init(object par)
|
|
{
|
|
var shows = new List<int>();
|
|
var selects = new List<int>();
|
|
var Bosss = TableManager.GetWorldBossConfig();
|
|
foreach (var boss in Bosss)
|
|
{
|
|
if (ShowPageIndex == boss.Value.ISOtherServer)
|
|
{
|
|
shows.Add(boss.Key);
|
|
if(boss.Key == m_FirstShowBossID)
|
|
selects.Add(boss.Key);
|
|
}
|
|
}
|
|
|
|
if(shows.Count > 0 && selects.Count<=0)
|
|
selects.Add(shows[0]);
|
|
m_BossList.InitSelectContent(shows, selects, OnSelectBoss);
|
|
|
|
if(ShowPageIndex == 0)
|
|
{
|
|
m_TextDesc.text = StrDictionary.GetClientDictionaryString("#{49057}");
|
|
}
|
|
else
|
|
{
|
|
m_TextDesc.text = StrDictionary.GetClientDictionaryString("#{49058}");
|
|
}
|
|
}
|
|
|
|
private void ClearBossInfo(Tab_WorldBossConfig TabBoss)
|
|
{
|
|
m_LeaveBloodRate.text = "0%";
|
|
int count = 0;
|
|
if (count >= TabBoss.getMoneyCountCount())
|
|
count = TabBoss.getMoneyCountCount() - 1;
|
|
m_CostMoney.text = TabBoss.GetMoneyCountbyIndex(count).ToString();
|
|
m_BossModel.gameObject.SetActive(false);
|
|
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(TabBoss.Id, 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 = TabBoss.Id;
|
|
EnterCopyBtn.SetActive(false);
|
|
}
|
|
|
|
public void OnSelectBoss(object initInfo)
|
|
{
|
|
int bossId = (int)initInfo;
|
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(bossId, 0);
|
|
if (TabBoss == null)
|
|
return;
|
|
WorldBossData.BossInfo bossInfo = WorldBossData.Instance.GetBossInfo(bossId);
|
|
if (bossInfo == null)
|
|
{
|
|
ClearBossInfo(TabBoss);
|
|
return;
|
|
}
|
|
m_LeaveBloodRate.text = string.Format("{0}%", bossInfo.m_LeaveBloodRate);
|
|
int count = bossInfo.m_DugUseTimes;
|
|
if (count >= TabBoss.getMoneyCountCount())
|
|
count = TabBoss.getMoneyCountCount() - 1;
|
|
m_CostMoney.text = TabBoss.GetMoneyCountbyIndex(count).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;
|
|
EnterCopyBtn.SetActive(!bossInfo.m_Killed);
|
|
}
|
|
|
|
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 OpenBank_Click()
|
|
{
|
|
UIManager.ShowUI(UIInfo.WorldBossRank);
|
|
}
|
|
|
|
public void Dug_Click()
|
|
{
|
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(WorldBossData.Instance.m_CurrentShowBossId, 0);
|
|
if (TabBoss == null)
|
|
{
|
|
return;
|
|
}
|
|
if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < TabBoss.Level)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1949}"));
|
|
return;
|
|
}
|
|
WorldBossData.BossInfo info = WorldBossData.Instance.GetBossInfo(WorldBossData.Instance.m_CurrentShowBossId);
|
|
if (info == null)
|
|
return;
|
|
if(info.m_DugLeaveTimes <= 0)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1950}"));
|
|
return;
|
|
}
|
|
int BossId = WorldBossData.Instance.m_CurrentShowBossId;
|
|
if (info.m_DugLeaveTimes >= 1)
|
|
{
|
|
|
|
int count = TabBoss.getMoneyCountCount();
|
|
int AllMoney = 0;
|
|
int OneMoney = TabBoss.GetMoneyCountbyIndex(info.m_DugUseTimes);
|
|
for (int i = info.m_DugUseTimes; i < count; i++)
|
|
{
|
|
AllMoney += TabBoss.GetMoneyCountbyIndex(i);
|
|
}
|
|
|
|
MessageBoxLogic.OpenOKCancelBoxWithBtnName(StrDictionary.GetClientDictionaryString("#{1951}", AllMoney, OneMoney), "", StrDictionary.GetClientDictionaryString("#{49034}"), StrDictionary.GetClientDictionaryString("#{49033}"), delegate ()
|
|
{
|
|
WorldBossData.Instance.SendAskDug(BossId, 1);
|
|
}, delegate ()
|
|
{
|
|
WorldBossData.Instance.SendAskDug(BossId, 0);
|
|
}, TextAnchor.MiddleCenter,-1,MessageBoxLogic.PASSWORD.INVALID,0,0,false,true);
|
|
}
|
|
}
|
|
|
|
public void JoinKill_Boss()
|
|
{
|
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(WorldBossData.Instance.m_CurrentShowBossId, 0);
|
|
if (TabBoss == null)
|
|
{
|
|
return;
|
|
}
|
|
Tab_Fuben fuben = TableManager.GetFubenByID(TabBoss.FubenID, 0);
|
|
if (fuben == null)
|
|
{
|
|
return;
|
|
}
|
|
Tab_RoleBaseAttr roleBase = TableManager.GetRoleBaseAttrByID(TabBoss.Id, 0);
|
|
if (roleBase == null)
|
|
return;
|
|
if(PlayerPrefs.HasKey("WorldBossEnterCopy"))
|
|
{
|
|
int date = PlayerPrefs.GetInt("WorldBossEnterCopy");
|
|
if(System.DateTime.Now.Year*1000+System.DateTime.Now.DayOfYear == date)
|
|
{
|
|
GCGame.Utils.EnterCopy(TabBoss.FubenID);
|
|
return;
|
|
}
|
|
}
|
|
|
|
string Tip = StrDictionary.GetClientDictionaryString("#{1955}", roleBase.Name);
|
|
Tab_SceneClass sceneClass = TableManager.GetSceneClassByID(fuben.GetSceneIdbyIndex(0), 0);
|
|
if (sceneClass != null)
|
|
{
|
|
Tip = (sceneClass.PVPRule == 0 ? StrDictionary.GetClientDictionaryString("#{1955}",roleBase.Name) : StrDictionary.GetClientDictionaryString("#{1956}",roleBase.Name));
|
|
}
|
|
EnterCopyTip.text = Tip;
|
|
EnterCopyMessageTip.SetActive(true);
|
|
|
|
}
|
|
|
|
public void EnterCopySet(bool isOn)
|
|
{
|
|
if(isOn)
|
|
{
|
|
PlayerPrefs.SetInt("WorldBossEnterCopy",System.DateTime.Now.Year*1000+System.DateTime.Now.DayOfYear);
|
|
}
|
|
else
|
|
{
|
|
PlayerPrefs.DeleteKey("WorldBossEnterCopy");
|
|
}
|
|
}
|
|
|
|
public void EnterCopyNo()
|
|
{
|
|
EnterCopyMessageTip.SetActive(false);
|
|
}
|
|
|
|
public void EnterCopyOK()
|
|
{
|
|
EnterCopyMessageTip.SetActive(false);
|
|
Tab_WorldBossConfig TabBoss = TableManager.GetWorldBossConfigByID(WorldBossData.Instance.m_CurrentShowBossId, 0);
|
|
if (TabBoss == null)
|
|
{
|
|
return;
|
|
}
|
|
Tab_Fuben fuben = TableManager.GetFubenByID(TabBoss.FubenID, 0);
|
|
if (fuben == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GCGame.Utils.EnterCopy(TabBoss.FubenID);
|
|
return;
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
UIManager.CloseUI(UIInfo.WorldBoss);
|
|
}
|
|
|
|
public void OpenDescrip()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(40);
|
|
}
|
|
} |