| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Tuesday, September 12, 2017 |
| | | //-------------------------------------------------------- |
| | | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using TableConfig; |
| | | using Snxxz.UI; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | public class DungeonSweepWin : Window |
| | | { |
| | | [SerializeField] ItemBehaviour m_DungeonTicket; |
| | | [SerializeField] ItemBehaviour m_SweepCost; |
| | | [SerializeField] Button m_Cancel; |
| | | [SerializeField] Button m_Confirm; |
| | | [SerializeField] Button m_Close; |
| | | |
| | | DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } } |
| | | PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } } |
| | | GetItemPathModel getItemPathModel { get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); } } |
| | | |
| | | #region Built-in |
| | | protected override void BindController() |
| | | { |
| | | } |
| | | |
| | | protected override void AddListeners() |
| | | { |
| | | m_Confirm.AddListener(ConfirmSweepResult); |
| | | m_Cancel.AddListener(CloseClick); |
| | | m_Close.AddListener(CloseClick); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | DisplayTicket(); |
| | | DisplaySweepCost(); |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | } |
| | | |
| | | protected override void OnAfterClose() |
| | | { |
| | | } |
| | | #endregion |
| | | |
| | | private void DisplayTicket() |
| | | { |
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId); |
| | | if (tickets.id > 0) |
| | | { |
| | | m_DungeonTicket.SetItem(tickets); |
| | | m_DungeonTicket.gameObject.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | m_DungeonTicket.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | private void DisplaySweepCost() |
| | | { |
| | | var cost = model.GetSweepCost(model.currentDungeon); |
| | | m_SweepCost.SetItem(cost); |
| | | } |
| | | |
| | | private void ConfirmSweepResult() |
| | | { |
| | | var error = 0; |
| | | if (TestSweep(out error)) |
| | | { |
| | | model.SweepDungeon(model.currentDungeon); |
| | | } |
| | | else |
| | | { |
| | | switch (error) |
| | | { |
| | | case 1: |
| | | DesignDebug.Log("副本评级不足"); |
| | | break; |
| | | case 2: |
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId); |
| | | getItemPathModel.SetChinItemModel(tickets.id); |
| | | break; |
| | | case 3: |
| | | var cost = model.GetSweepCost(model.currentDungeon); |
| | | var itemOwn = playerPack.GetItemCountByID(PackType.rptItem, cost.id); |
| | | var moneyNeed = GeneralConfig.Instance.autoBuyItemPrices[0] * (cost.count - itemOwn); |
| | | ConfirmCancel.ShowPopConfirm( |
| | | Language.Get("Mail101"), |
| | | Language.Get("MultipleSweep_Text3", cost.count - itemOwn, moneyNeed), |
| | | (bool _ok) => |
| | | { |
| | | if (_ok) |
| | | { |
| | | var moneyOwn = PlayerDatas.Instance.baseData.Gold + PlayerDatas.Instance.baseData.GoldPaper; |
| | | if (moneyNeed > moneyOwn) |
| | | { |
| | | WindowCenter.Instance.Open<RechargeTipWin>(); |
| | | } |
| | | else |
| | | { |
| | | model.SweepDungeon(model.currentDungeon); |
| | | } |
| | | } |
| | | } |
| | | ); |
| | | |
| | | break; |
| | | case 4: |
| | | WindowCenter.Instance.Open<DungeonBuyTimesWin>(); |
| | | break; |
| | | case 5: |
| | | SysNotifyMgr.Instance.ShowTip("SweepFB_1"); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool TestSweep(out int error) |
| | | { |
| | | var dataMapId = model.GetDungeonDataIdByMapId(PlayerDatas.Instance.baseData.MapID); |
| | | if (dataMapId == model.currentDungeon.mapId) |
| | | { |
| | | error = 5; |
| | | return false; |
| | | } |
| | | |
| | | var grade = model.GetDungeonGrade(model.currentDungeon); |
| | | if (grade <= 0) |
| | | { |
| | | error = 1; |
| | | return false; |
| | | } |
| | | |
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId); |
| | | var ticketsOwn = playerPack.GetItemCountByID(PackType.rptItem, tickets.id); |
| | | if (ticketsOwn < tickets.count) |
| | | { |
| | | error = 2; |
| | | return false; |
| | | } |
| | | |
| | | var cost = model.GetSweepCost(model.currentDungeon); |
| | | var itemOwn = playerPack.GetItemCountByID(PackType.rptItem, cost.id); |
| | | if (itemOwn < cost.count) |
| | | { |
| | | error = 3; |
| | | return false; |
| | | } |
| | | |
| | | var enterTimes = model.GetDungeonEnterTimes(model.currentDungeon.mapId); |
| | | var totalTimes = model.GetDungeonTotalTimes(model.currentDungeon.mapId); |
| | | var surplusTimes = totalTimes - enterTimes; |
| | | if (surplusTimes <= 0) |
| | | { |
| | | error = 4; |
| | | return false; |
| | | } |
| | | |
| | | error = 0; |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, September 12, 2017
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | | using Snxxz.UI;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class DungeonSweepWin : Window
|
| | | {
|
| | | [SerializeField] ItemBehaviour m_DungeonTicket;
|
| | | [SerializeField] ItemBehaviour m_SweepCost;
|
| | | [SerializeField] Button m_Cancel;
|
| | | [SerializeField] Button m_Confirm;
|
| | | [SerializeField] Button m_Close;
|
| | |
|
| | | DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | | PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
| | | GetItemPathModel getItemPathModel { get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); } }
|
| | |
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | m_Confirm.AddListener(ConfirmSweepResult);
|
| | | m_Cancel.AddListener(CloseClick);
|
| | | m_Close.AddListener(CloseClick);
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | DisplayTicket();
|
| | | DisplaySweepCost();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | | #endregion
|
| | |
|
| | | private void DisplayTicket()
|
| | | {
|
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
|
| | | if (tickets.id > 0)
|
| | | {
|
| | | m_DungeonTicket.SetItem(tickets);
|
| | | m_DungeonTicket.gameObject.SetActive(true);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_DungeonTicket.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | private void DisplaySweepCost()
|
| | | {
|
| | | var cost = model.GetSweepCost(model.currentDungeon);
|
| | | m_SweepCost.SetItem(cost);
|
| | | }
|
| | |
|
| | | private void ConfirmSweepResult()
|
| | | {
|
| | | var error = 0;
|
| | | if (TestSweep(out error))
|
| | | {
|
| | | model.SweepDungeon(model.currentDungeon);
|
| | | }
|
| | | else
|
| | | {
|
| | | switch (error)
|
| | | {
|
| | | case 1:
|
| | | DebugEx.Log("副本评级不足");
|
| | | break;
|
| | | case 2:
|
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
|
| | | getItemPathModel.SetChinItemModel(tickets.id);
|
| | | break;
|
| | | case 3:
|
| | | var cost = model.GetSweepCost(model.currentDungeon);
|
| | | var itemOwn = playerPack.GetItemCountByID(PackType.rptItem, cost.id);
|
| | | var moneyNeed = GeneralConfig.Instance.autoBuyItemPrices[0] * (cost.count - itemOwn);
|
| | | ConfirmCancel.ShowPopConfirm(
|
| | | Language.Get("Mail101"),
|
| | | Language.Get("MultipleSweep_Text3", cost.count - itemOwn, moneyNeed),
|
| | | (bool _ok) =>
|
| | | {
|
| | | if (_ok)
|
| | | {
|
| | | var moneyOwn = PlayerDatas.Instance.baseData.Gold + PlayerDatas.Instance.baseData.GoldPaper;
|
| | | if (moneyNeed > moneyOwn)
|
| | | {
|
| | | WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | }
|
| | | else
|
| | | {
|
| | | model.SweepDungeon(model.currentDungeon);
|
| | | }
|
| | | }
|
| | | }
|
| | | );
|
| | |
|
| | | break;
|
| | | case 4:
|
| | | WindowCenter.Instance.Open<DungeonBuyTimesWin>();
|
| | | break;
|
| | | case 5:
|
| | | SysNotifyMgr.Instance.ShowTip("SweepFB_1");
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private bool TestSweep(out int error)
|
| | | {
|
| | | var dataMapId = model.GetDungeonDataIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
| | | if (dataMapId == model.currentDungeon.mapId)
|
| | | {
|
| | | error = 5;
|
| | | return false;
|
| | | }
|
| | |
|
| | | var grade = model.GetDungeonGrade(model.currentDungeon);
|
| | | if (grade <= 0)
|
| | | {
|
| | | error = 1;
|
| | | return false;
|
| | | }
|
| | |
|
| | | var tickets = model.GetDungeonTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
|
| | | var ticketsOwn = playerPack.GetItemCountByID(PackType.rptItem, tickets.id);
|
| | | if (ticketsOwn < tickets.count)
|
| | | {
|
| | | error = 2;
|
| | | return false;
|
| | | }
|
| | |
|
| | | var cost = model.GetSweepCost(model.currentDungeon);
|
| | | var itemOwn = playerPack.GetItemCountByID(PackType.rptItem, cost.id);
|
| | | if (itemOwn < cost.count)
|
| | | {
|
| | | error = 3;
|
| | | return false;
|
| | | }
|
| | |
|
| | | var enterTimes = model.GetDungeonEnterTimes(model.currentDungeon.mapId);
|
| | | var totalTimes = model.GetDungeonTotalTimes(model.currentDungeon.mapId);
|
| | | var surplusTimes = totalTimes - enterTimes;
|
| | | if (surplusTimes <= 0)
|
| | | {
|
| | | error = 4;
|
| | | return false;
|
| | | }
|
| | |
|
| | | error = 0;
|
| | | return true;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|