262 lines
6.3 KiB
C#
262 lines
6.3 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-01-11
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "LevelDetailBox.View" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G.UI
|
|
{
|
|
using System.Collections;
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
using Text = TMPro.TextMeshProUGUI;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
partial class LevelDetailBox
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
[KUIFlag]
|
|
Button _btnClose;
|
|
[KUIFlag]
|
|
Text _tmpName;
|
|
[KUIFlag]
|
|
Image _imgFigure;
|
|
//[KUIFlag]
|
|
//KUIList __kungfuMoves;
|
|
[KUIFlag]
|
|
KUIList __listDrops;
|
|
|
|
[KUIFlag]
|
|
Button _btnStart;
|
|
[KUIFlag]
|
|
Text _tmpStart;
|
|
[KUIFlag]
|
|
Text _tmpReqCV;
|
|
[KUIFlag]
|
|
Button _btnSweep;
|
|
[KUIFlag]
|
|
Text _tmpSweepInfo;
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
#endregion
|
|
|
|
#region Field
|
|
|
|
private SmartCostWidget _smartCostWidget;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void InitView()
|
|
{
|
|
SetViewData();
|
|
|
|
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
|
|
_btnStart.onClick.AddListener(this.OnStartBtnClick);
|
|
_btnSweep.onClick.AddListener(this.OnSweepBtnClick);
|
|
|
|
_smartCostWidget = _btnSweep.gameObject.AddComponent<SmartCostWidget>();
|
|
|
|
__listDrops.AddTemplate<EquipmentWidget>(true);
|
|
//__kungfuMoves.AddTemplate<KUIWidget>(true);
|
|
}
|
|
|
|
public void RefreshView()
|
|
{
|
|
if (this.data is ItemLevel levelItem)
|
|
{
|
|
_tmpName.text = levelItem.name;
|
|
if (PlayerProxy.Instance.combatValue >= levelItem.requireCV)
|
|
_tmpReqCV.color = Color.white;
|
|
else
|
|
_tmpReqCV.color = Color.red;
|
|
_tmpReqCV.text = "需求战力" + levelItem.requireCV.ToString();
|
|
|
|
if (!string.IsNullOrEmpty(levelItem.figure))
|
|
{
|
|
StartCoroutine(SetFigure(levelItem.chapter.atlas, levelItem.figure));
|
|
}
|
|
else
|
|
{
|
|
_imgFigure.overrideSprite = null;
|
|
}
|
|
|
|
__listDrops.Clear();
|
|
if (levelItem.drop != null)
|
|
{
|
|
int count = Mathf.Min(levelItem.drop.Length, 5);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
var item = __listDrops.GetItem();
|
|
item.SetData(ItemProxy.Instance.GetStaticItem<ItemProp>(levelItem.drop[i]));
|
|
}
|
|
}
|
|
|
|
//if (!levelItem.isCompleted)
|
|
//{
|
|
// if (levelItem.kungfuMoves != null && levelItem.kungfuMoves.Length > 0)
|
|
// {
|
|
// __kungfuMoves.gameObject.SetActive(true);
|
|
// __kungfuMoves.Clear();
|
|
// foreach (var moves in levelItem.kungfuMoves)
|
|
// {
|
|
// var movesItem = ItemProxy.Instance.GetStaticItem<ItemMoves>(moves);
|
|
// var item = __kungfuMoves.GetItem();
|
|
// AssetProxy.Instance.SetSprite(item.Find<Image>("_imgIcon"), movesItem.icon);
|
|
// item.Find<Text>("Name/_tmpName").text = movesItem.name;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// __kungfuMoves.gameObject.SetActive(false);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// __kungfuMoves.gameObject.SetActive(false);
|
|
//}
|
|
|
|
if (FunctionProxy.Instance.GetFunctionUnlock(FunctionProxy.FunctionId.Vip))
|
|
{
|
|
_btnSweep.gameObject.SetActive(true);
|
|
|
|
var amount = TimeProxy.Instance.GetTimeInfo2(TimeProxy.扫荡关卡);
|
|
_tmpSweepInfo.text = $"今日次数:{amount.remain}/{amount.max}";
|
|
|
|
_smartCostWidget.SetAdTicket(MoneyProxy.Instance.GetMoney(Item.Id.kAdTicket));
|
|
}
|
|
else
|
|
{
|
|
_btnSweep.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private IEnumerator SetFigure(string atlas, string figure)
|
|
{
|
|
var handle = AssetProxy.Instance.TryGetGlobalAssetAsync<UnityEngine.U2D.SpriteAtlas>(atlas);
|
|
yield return handle;
|
|
if (handle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
|
|
{
|
|
_imgFigure.gameObject.SetActive(true);
|
|
_imgFigure.overrideSprite = handle.Result.GetSprite(figure);
|
|
_imgFigure.SetNativeSize();
|
|
}
|
|
else
|
|
{
|
|
_imgFigure.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void OnCloseBtnClick()
|
|
{
|
|
CloseWindow(this);
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnStartBtnClick()
|
|
{
|
|
if (this.data is ItemLevel levelItem)
|
|
{
|
|
int result = LevelProxy.Instance.StartLevel(levelItem.id);
|
|
if (result == 1)
|
|
{
|
|
ToastBox.ShowText("背包物品已满,请清理背包后继续");
|
|
PostNotification(GlobalDefine.EVENT_EQUIPMENT_FULL);
|
|
PostNotification(GlobalDefine.EVENT_MAIN_WINDOW_PAGE, "1", "3");
|
|
}
|
|
else if (result == 2)
|
|
{
|
|
AdMoneyBox.ShowAdMoney(Item.Id.kEnergy, true);
|
|
}
|
|
CloseWindow(this);
|
|
}
|
|
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private void OnSweepBtnClick()
|
|
{
|
|
if (this.data is ItemLevel levelItem)
|
|
{
|
|
SweepLevel(levelItem);
|
|
}
|
|
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="levelItem"></param>
|
|
void SweepLevel(ItemLevel levelItem)
|
|
{
|
|
if (levelItem.type == 1 && levelItem.isCompleted)
|
|
{
|
|
int amount = TimeProxy.Instance.GetTimes(TimeProxy.扫荡关卡);
|
|
if (amount <= 0)
|
|
{
|
|
ToastBox.ShowText("扫荡次数不足");
|
|
#if !UNITY_EDITOR
|
|
return;
|
|
#endif
|
|
}
|
|
|
|
int result = LevelProxy.Instance.SweepLevel(levelItem.id);
|
|
if (result == 0)
|
|
{
|
|
CloseWindow(this);
|
|
}
|
|
else if (result == 1)
|
|
{
|
|
ToastBox.ShowText("背包物品已满,请清理背包后继续");
|
|
PostNotification(GlobalDefine.EVENT_EQUIPMENT_FULL);
|
|
OpenWindow<EquipmentSellBox>();
|
|
//PostNotification(GlobalDefine.EVENT_MAIN_WINDOW_PAGE, 3, "");
|
|
}
|
|
else
|
|
{
|
|
AdMoneyBox.ShowAdMoney(Item.Id.kEnergy, true);
|
|
CloseWindow(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var prevLevelItem = ItemProxy.Instance.GetStaticItem<ItemLevel>(levelItem.id - 1);
|
|
if (prevLevelItem != null)
|
|
{
|
|
MessageBox.ShowMessage("扫荡提示", "通关后解锁扫荡功能,继续扫荡前一关?",
|
|
() =>
|
|
{
|
|
SweepLevel(prevLevelItem);
|
|
},
|
|
() =>
|
|
{
|
|
});
|
|
}
|
|
//ToastBox.ShowText("通关后解锁扫荡功能");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|