//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, November 02, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
using LitJson;
|
|
namespace vnxbqy.UI
|
{
|
|
public class BossIntroduceBehaviour : MonoBehaviour
|
{
|
[SerializeField] protected FindPreciousType m_FindPreciousType = FindPreciousType.WorldBoss;
|
[SerializeField] Transform m_ContainerReward;
|
[SerializeField] Transform m_ContainerBossInfo;
|
|
[SerializeField] Button m_ViewBossInfo;
|
[SerializeField] Button m_ViewReward;
|
|
[SerializeField] Text m_BossName;
|
[SerializeField] Text m_BossLevel;
|
[SerializeField] RawImage m_BossPortrait;
|
[SerializeField] BossAbilityBehaviour m_BossAbility;
|
[SerializeField] FindPreciousRewardPreviewGroup m_UndoubtedlyRewardGroup;
|
[SerializeField] FindPreciousRewardPreviewGroup m_UnusualRewardGroup;
|
[SerializeField] TextEx m_FightPower;
|
|
ViewType m_ViewType = ViewType.Reward;
|
|
float confirmDelay = 0.3f;
|
float confirmTimer = 0f;
|
int tempBossId = 0;
|
protected int bossId = 0;
|
|
public void Display(int _bossId, bool _immediately)
|
{
|
if (_immediately)
|
{
|
tempBossId = bossId = _bossId;
|
Draw();
|
}
|
else
|
{
|
tempBossId = _bossId;
|
confirmTimer = 0f;
|
}
|
}
|
|
public void Dispose()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
|
private void LateUpdate()
|
{
|
if (tempBossId != bossId)
|
{
|
confirmTimer += Time.deltaTime;
|
if (confirmTimer > confirmDelay)
|
{
|
bossId = tempBossId;
|
Draw();
|
}
|
}
|
}
|
|
private void Draw()
|
{
|
switch (m_ViewType)
|
{
|
case ViewType.BossInfo:
|
DrawBossInfo();
|
break;
|
case ViewType.Reward:
|
DrawReward();
|
break;
|
}
|
}
|
|
private void DrawBossInfo()
|
{
|
m_ViewType = ViewType.BossInfo;
|
m_ContainerReward.SetActive(false);
|
m_ContainerBossInfo.SetActive(true);
|
|
var config = NPCConfig.Get(bossId);
|
m_BossName.text = config.charName;
|
m_BossLevel.text = Language.Get("Z1024", config.NPCLV);
|
UI3DModelExhibition.Instance.ShowNPC(bossId, config.UIModeLOffset, config.UIModelRotation, m_BossPortrait);
|
m_BossAbility.Display(bossId);
|
}
|
|
protected virtual void DrawReward()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
m_ViewType = ViewType.Reward;
|
m_ContainerReward.SetActive(true);
|
m_ContainerBossInfo.SetActive(false);
|
|
if (m_FightPower != null)
|
{
|
var config = NPCExConfig.Get(bossId);
|
m_FightPower.text = UIHelper.ReplaceLargeNum(config.SuppressFightPower);
|
m_FightPower.colorType = PlayerDatas.Instance.baseData.FightPoint >= (ulong)config.SuppressFightPower ? TextColType.Green : TextColType.Red;
|
|
}
|
int[] undoubtedlyRewards = null;
|
int[] unusualRewards = null;
|
int undoubtedlyNewDropId = 0;
|
int unusualNewDropId = 0;
|
|
var jobStr = PlayerDatas.Instance.baseData.Job.ToString();
|
switch (m_FindPreciousType)
|
{
|
case FindPreciousType.WorldBoss:
|
undoubtedlyRewards = LitJson.JsonMapper.ToObject<int[]>(LitJson.JsonMapper.ToObject(WorldBossConfig.Get(bossId).RareItemID)[jobStr].ToJson());
|
undoubtedlyNewDropId = WorldBossConfig.Get(bossId).NewItemId;
|
break;
|
case FindPreciousType.BossHome:
|
undoubtedlyRewards = LitJson.JsonMapper.ToObject<int[]>(LitJson.JsonMapper.ToObject(BossHomeConfig.Get(bossId).RareItemID)[jobStr].ToJson());
|
undoubtedlyNewDropId = BossHomeConfig.Get(bossId).NewItemId;
|
break;
|
case FindPreciousType.ElderGodArea:
|
undoubtedlyRewards = ElderGodAreaConfig.Get(bossId).RareItemID;
|
undoubtedlyNewDropId = ElderGodAreaConfig.Get(bossId).NewItemId;
|
break;
|
case FindPreciousType.PersonalBoss:
|
var personalBossConfig = PersonalBossConfig.Get(bossId);
|
undoubtedlyRewards = personalBossConfig.MustItemID;
|
unusualRewards = LitJson.JsonMapper.ToObject<int[]>(LitJson.JsonMapper.ToObject(personalBossConfig.RareItemID)[jobStr].ToJson());
|
unusualNewDropId = personalBossConfig.NewItemId;
|
break;
|
case FindPreciousType.DemonJar:
|
var demonJarConfig = DemonJarConfig.Get(bossId);
|
|
undoubtedlyRewards = demonJarConfig.MustItemID;
|
unusualRewards = LitJson.JsonMapper.ToObject<int[]>(LitJson.JsonMapper.ToObject(demonJarConfig.RareItemID)[jobStr].ToJson());
|
unusualNewDropId = demonJarConfig.NewItemId;
|
break;
|
case FindPreciousType.CrossServerBoss:
|
undoubtedlyRewards = LitJson.JsonMapper.ToObject<int[]>(LitJson.JsonMapper.ToObject(CrossServerBossConfig.Get(bossId).RareItemID)[jobStr].ToJson());
|
undoubtedlyNewDropId = CrossServerBossConfig.Get(bossId).NewItemId;
|
break;
|
}
|
|
if (m_UndoubtedlyRewardGroup != null)
|
{
|
if (undoubtedlyRewards != null && undoubtedlyRewards.Length > 0)
|
{
|
m_UndoubtedlyRewardGroup.SetActive(true);
|
m_UndoubtedlyRewardGroup.Display(undoubtedlyNewDropId, undoubtedlyRewards);
|
}
|
else
|
{
|
m_UndoubtedlyRewardGroup.SetActive(false);
|
}
|
}
|
|
if (m_UnusualRewardGroup != null)
|
{
|
if (unusualRewards != null && unusualRewards.Length > 0)
|
{
|
m_UnusualRewardGroup.SetActive(true);
|
m_UnusualRewardGroup.Display(unusualNewDropId, unusualRewards);
|
}
|
else
|
{
|
m_UnusualRewardGroup.SetActive(false);
|
}
|
}
|
|
}
|
|
private void Awake()
|
{
|
m_ViewBossInfo.AddListener(DrawBossInfo);
|
m_ViewReward.AddListener(DrawReward);
|
}
|
|
public enum ViewType
|
{
|
BossInfo,
|
Reward,
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
|
}
|
|
}
|
|
}
|
|
|
|