//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, December 18, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
public class GatherSoulGenerateBossWin : Window
|
{
|
[SerializeField] Text m_Label;
|
[SerializeField] Toggle m_AutoGenerate;
|
[SerializeField] Button m_Confirm;
|
[SerializeField] Button m_Cancel;
|
[SerializeField] Button m_Close;
|
|
GatherSoulDungeonModel model {
|
get { return ModelCenter.Instance.GetModel<GatherSoulDungeonModel>(); }
|
}
|
|
bool autoGenerate = false;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.onClick.AddListener(CloseClick);
|
m_Cancel.onClick.AddListener(CloseClick);
|
m_Confirm.onClick.AddListener(Confirm);
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.missionHelpUpdate += MissionHelpUpdate;
|
m_AutoGenerate.isOn = model.mission.isAuto == 1;
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.missionHelpUpdate -= MissionHelpUpdate;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
DisplayLabel();
|
}
|
|
void DisplayLabel()
|
{
|
var mission = model.mission;
|
if (mission.hasRefreshBoss == 1)
|
{
|
m_Label.text = Language.Get("GatherSoulAreadyGenerateBoss");
|
}
|
else
|
{
|
m_Label.text = Language.Get("GatherSoulGenerateBoss", model.generateBossCost);
|
}
|
}
|
|
private void Confirm()
|
{
|
var mission = model.mission;
|
if (mission.hasRefreshBoss == 1)
|
{
|
if (m_AutoGenerate.isOn == (mission.isAuto == 1))
|
{
|
CloseClick();
|
}
|
else
|
{
|
if (m_AutoGenerate.isOn)
|
{
|
var weelCount = model.dungeonWeelCount - mission.wheel;
|
ConfirmCost(weelCount);
|
}
|
else
|
{
|
CA508_tagCMDoFBAction pak = new CA508_tagCMDoFBAction();
|
pak.ActionType = 2;
|
pak.ActionInfo = 2;
|
GameNetSystem.Instance.SendInfo(pak);
|
CloseClick();
|
}
|
}
|
}
|
else
|
{
|
var weelCount = m_AutoGenerate.isOn ? (model.dungeonWeelCount - mission.wheel + 1) : 1;
|
ConfirmCost(weelCount);
|
}
|
}
|
|
void ConfirmCost(int weelCount)
|
{
|
var cost = weelCount * model.generateBossCost;
|
if (weelCount == 0)
|
{
|
CloseClick();
|
return;
|
}
|
if (UIHelper.GetMoneyCnt(1) >= (ulong)cost)
|
{
|
CA508_tagCMDoFBAction pak = new CA508_tagCMDoFBAction();
|
pak.ActionType = 2;
|
pak.ActionInfo = m_AutoGenerate.isOn ? (uint)1 : 0;
|
GameNetSystem.Instance.SendInfo(pak);
|
CloseClick();
|
}
|
else
|
{
|
CloseClick();
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
}
|
}
|
|
private void MissionHelpUpdate()
|
{
|
DisplayLabel();
|
}
|
}
|
|
}
|
|
|
|
|