//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, September 21, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using TableConfig;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
|
public class DungenWHYJ : MonoBehaviour
|
{
|
|
[SerializeField] Button m_WHYJButton;
|
[SerializeField] GameObject m_Container_WHYJ;
|
[SerializeField] Transform m_Horizontal;
|
DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
public void Init()
|
{
|
model.dungeonFightStageChangeEevent -= dungeonFightStageChangeEevent;
|
model.dungeonFightStageChangeEevent += dungeonFightStageChangeEevent;
|
model.updateMissionEvent -= updateMissionEvent;
|
model.updateMissionEvent += updateMissionEvent;
|
if (model.dungeonFightStage == DungeonFightStage.Prepare)
|
{
|
m_Container_WHYJ.SetActive(true);
|
}
|
else
|
{
|
m_Container_WHYJ.SetActive(false);
|
}
|
SetTranItemCell();
|
}
|
|
private void updateMissionEvent()
|
{
|
SetTranItemCell();
|
}
|
|
private void Start()
|
{
|
m_WHYJButton.AddListener(OnClickButton);
|
}
|
private void OnEnable()
|
{
|
|
}
|
private void OnDisable()
|
{
|
|
}
|
|
private void dungeonFightStageChangeEevent(DungeonFightStage obj)
|
{
|
if (obj == DungeonFightStage.Prepare)
|
{
|
if (!m_Container_WHYJ.activeSelf)
|
{
|
m_Container_WHYJ.SetActive(true);
|
}
|
}
|
else if(obj == DungeonFightStage.Normal)
|
{
|
if (m_Container_WHYJ.activeSelf)
|
{
|
m_Container_WHYJ.SetActive(false);
|
}
|
}
|
}
|
|
private void SetTranItemCell()
|
{
|
int lineID = model.mission.lineID;
|
var WHYJConfig = Config.Instance.Get<WHYJRewardConfig>(lineID+1);
|
int[] RewardList = ConfigParse.GetMultipleStr<int>(WHYJConfig.Reward);
|
int[] QuantityList = ConfigParse.GetMultipleStr<int>(WHYJConfig.Quantity);
|
for (int i = 0; i < m_Horizontal.childCount; i++)
|
{
|
if (i < RewardList.Length)
|
{
|
m_Horizontal.GetChild(i).gameObject.SetActive(true);
|
ItemCell ItemCell = m_Horizontal.GetChild(i).GetComponent<ItemCell>();
|
ItemCellModel cellModel = new ItemCellModel(RewardList[i], true, (ulong)QuantityList[i], 0);
|
ItemCell.Init(cellModel);
|
}
|
else
|
{
|
m_Horizontal.GetChild(i).gameObject.SetActive(false);
|
}
|
|
}
|
|
}
|
private void OnClickButton()
|
{
|
m_Container_WHYJ.SetActive(!m_Container_WHYJ.activeSelf);
|
}
|
}
|
|
}
|