//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, December 21, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
using System;
|
|
namespace Snxxz.UI
|
{
|
|
public class DemonJarBriefInfoBehaviour : FindPreciousBossBriefInfoBehaviour
|
{
|
[SerializeField] ItemBehaviour m_ItemBehaviour;
|
[SerializeField] Text m_Participant;
|
[SerializeField] Transform m_Attention;
|
|
DemonJarModel model { get { return ModelCenter.Instance.GetModel<DemonJarModel>(); } }
|
|
protected override int selectedBossId {
|
get { return model.selectedBoss; }
|
set { model.selectedBoss = value; }
|
}
|
|
protected override InteractorableState interactorableState {
|
get {
|
var selected = selectedBossId == bossId;
|
var dieOrLocked = !model.IsBossUnLocked(bossId) || !findPreciousModel.IsBossAlive(bossId);
|
|
if (!dieOrLocked)
|
{
|
return selected ? InteractorableState.NormalSelected : InteractorableState.NormalUnSelected;
|
}
|
else
|
{
|
return selected ? InteractorableState.DieOrLockedSelected : InteractorableState.DieOrLockedUnSelected;
|
}
|
}
|
set {
|
base.interactorableState = value;
|
}
|
}
|
|
protected override bool isRebornRightNow {
|
get {
|
return model.IsBossUnLocked(bossId) && base.isRebornRightNow;
|
}
|
}
|
|
protected override bool isUnLocked {
|
get {
|
return model.IsBossUnLocked(bossId);
|
}
|
}
|
|
public override void Display(object _data)
|
{
|
base.Display(_data);
|
|
var config = DemonJarConfig.Get(bossId);
|
var npcConfig = NPCConfig.Get(bossId);
|
|
m_Attention.gameObject.SetActive(findPreciousModel.IsBossSubscribed(bossId));
|
m_ItemBehaviour.gameObject.SetActive(config.SpecialItemMark > 0);
|
if (config.SpecialItemMark > 0)
|
{
|
m_ItemBehaviour.showCount = false;
|
m_ItemBehaviour.SetItem(config.SpecialItemMark, 1);
|
}
|
|
m_Participant.gameObject.SetActive(isUnLocked && findPreciousModel.IsBossAlive(bossId));
|
|
DrawBossBaseInfo(config.PortraitID, npcConfig.charName, npcConfig.NPCLV, npcConfig.ClientRealm);
|
UpdateBossRebornCoolDown(isUnLocked);
|
UpdateBossPortrait(interactorableState);
|
UpdateBossParticipant(bossId);
|
OnSelected(bossId);
|
|
model.bossSelectedEvent -= OnSelected;
|
model.participantChangeEvent -= UpdateBossParticipant;
|
model.bossSelectedEvent += OnSelected;
|
model.participantChangeEvent += UpdateBossParticipant;
|
}
|
|
public override void Dispose()
|
{
|
base.Dispose();
|
model.bossSelectedEvent -= OnSelected;
|
model.participantChangeEvent -= UpdateBossParticipant;
|
}
|
|
private void OnSelected(int _bossId)
|
{
|
UpdateBossNameLevelFont(interactorableState);
|
}
|
|
protected override void OnSubscribe(int _bossId)
|
{
|
base.OnSubscribe(_bossId);
|
if (bossId != _bossId)
|
{
|
return;
|
}
|
|
m_Attention.gameObject.SetActive(findPreciousModel.IsBossSubscribed(bossId));
|
}
|
|
protected override void OnBossInfoUpdate(int _bossId)
|
{
|
base.OnBossInfoUpdate(_bossId);
|
var unLocked = model.IsBossUnLocked(bossId);
|
m_Participant.gameObject.SetActive(unLocked && findPreciousModel.IsBossAlive(bossId));
|
}
|
|
private void UpdateBossParticipant(int _bossId)
|
{
|
if (bossId != _bossId)
|
{
|
return;
|
}
|
|
DemonJarBossData bossData;
|
model.TryGetBossData(bossId, out bossData);
|
m_Participant.text = Language.Get("FindPrecious_8", bossData.participant);
|
}
|
|
}
|
|
}
|
|
|
|