213 lines
6.7 KiB
C#
213 lines
6.7 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-03-28
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "TitleStudyWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public class TitleStudyWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
GameObject __goStudyCost;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnStudy;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpStudy;
|
|||
|
[KUIFlag]
|
|||
|
KUIList _listStar0;
|
|||
|
[KUIFlag]
|
|||
|
KUIList _listStar1;
|
|||
|
[KUIFlag]
|
|||
|
KUIList _listStar2;
|
|||
|
[KUIFlag]
|
|||
|
KUIList _listStar3;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAttribute0;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAttribute1;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAttribute2;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAttribute3;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpCombatValue;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpTitleName;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _goChaRoot;
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
CostWidget _priceItem;
|
|||
|
ChaWidget _chaWidget;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
var title = SwordProxy.Instance.GetStudyTitle();
|
|||
|
if (title != null)
|
|||
|
{
|
|||
|
var stars = SwordProxy.Instance.GetStudyStar();
|
|||
|
|
|||
|
for (int i = 0; i < 10; i++)
|
|||
|
{
|
|||
|
var widget = _listStar0.transform.GetChild(i);
|
|||
|
widget.GetComponent<StarWidget>().SetGray(i >= stars[0]);
|
|||
|
|
|||
|
widget = _listStar1.transform.GetChild(i);
|
|||
|
widget.GetComponent<StarWidget>().SetGray(i >= stars[1]);
|
|||
|
|
|||
|
widget = _listStar2.transform.GetChild(i);
|
|||
|
widget.GetComponent<StarWidget>().SetGray(i >= stars[2]);
|
|||
|
|
|||
|
widget = _listStar3.transform.GetChild(i);
|
|||
|
widget.GetComponent<StarWidget>().SetGray(i >= stars[3]);
|
|||
|
}
|
|||
|
|
|||
|
var results = F.ListPool<CombatAttribute>.Get();
|
|||
|
|
|||
|
CombatAttribute.Convert(title.attributes, results);
|
|||
|
var ca = results[0];
|
|||
|
ca.value = ca.value * title.studyAdd[stars[0]] / 100;
|
|||
|
_tmpAttribute0.text = ca.ToString();
|
|||
|
ca = results[1];
|
|||
|
ca.value = ca.value * title.studyAdd[stars[1]] / 100;
|
|||
|
_tmpAttribute1.text = ca.ToString();
|
|||
|
ca = results[2];
|
|||
|
ca.value = ca.value * title.studyAdd[stars[2]] / 100;
|
|||
|
_tmpAttribute2.text = ca.ToString();
|
|||
|
ca = results[3];
|
|||
|
ca.value = ca.value * title.studyAdd[stars[3]] / 100;
|
|||
|
_tmpAttribute3.text = ca.ToString();
|
|||
|
|
|||
|
F.ListPool<CombatAttribute>.Release(results);
|
|||
|
|
|||
|
bool full = true;
|
|||
|
for (int i = 0; i < stars.Length; i++)
|
|||
|
{
|
|||
|
if (stars[i] < 10)
|
|||
|
{
|
|||
|
full = false;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (full)
|
|||
|
{
|
|||
|
__goStudyCost.SetActive(false);
|
|||
|
_tmpStudy.text = "突破";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
__goStudyCost.SetActive(true);
|
|||
|
_priceItem.SetAndCheckPrice(title.studyCost[0], title.studyCost[1]);
|
|||
|
_tmpStudy.text = "修炼";
|
|||
|
}
|
|||
|
_tmpTitleName.text = title.name;
|
|||
|
_tmpCombatValue.text = SwordProxy.Instance.GetStudyCombatValue().ToString();
|
|||
|
|
|||
|
_chaWidget.Show("cha_01_skin_1_w2_ui", "", null);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnStudyBtnClick()
|
|||
|
{
|
|||
|
var title = SwordProxy.Instance.GetStudyTitle();
|
|||
|
if (title != null)
|
|||
|
{
|
|||
|
var stars = SwordProxy.Instance.GetStudyStar();
|
|||
|
bool full = true;
|
|||
|
for (int i = 0; i < stars.Length; i++)
|
|||
|
{
|
|||
|
if (stars[i] < 10)
|
|||
|
{
|
|||
|
full = false;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (full)
|
|||
|
{
|
|||
|
if (SwordProxy.Instance.StudyTitle() == 3)
|
|||
|
{
|
|||
|
ToastBox.ShowEffect("UI_fx_Breach02");
|
|||
|
Refresh();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ToastBox.ShowText("突破失败,请先提升境界");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (MoneyProxy.Instance.CheckMoney(title.studyCost[0], title.studyCost[1]))
|
|||
|
{
|
|||
|
int result = SwordProxy.Instance.StudyTitle();
|
|||
|
MoneyProxy.Instance.CostMoney(title.studyCost[0], title.studyCost[1]);
|
|||
|
|
|||
|
PostNotification(GlobalDefine.EVENT_MONEY_CHANGED);
|
|||
|
if (result == 1)
|
|||
|
ToastBox.ShowEffect("UI_fx_Practice");
|
|||
|
else if (result == 2)
|
|||
|
ToastBox.ShowEffect("UI_fx_Level04");
|
|||
|
Refresh();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AdMoneyBox.ShowAdMoney(title.studyCost[0], true);
|
|||
|
}
|
|||
|
}
|
|||
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_listStar0.AddTemplate<StarWidget>(true);
|
|||
|
_listStar1.AddTemplate<StarWidget>(true);
|
|||
|
_listStar2.AddTemplate<StarWidget>(true);
|
|||
|
_listStar3.AddTemplate<StarWidget>(true);
|
|||
|
|
|||
|
for (int i = 0; i < 10; i++)
|
|||
|
{
|
|||
|
_listStar0.GetItem();
|
|||
|
_listStar1.GetItem();
|
|||
|
_listStar2.GetItem();
|
|||
|
_listStar3.GetItem();
|
|||
|
}
|
|||
|
|
|||
|
_chaWidget = _goChaRoot.AddComponent<ChaWidget>();
|
|||
|
|
|||
|
_priceItem = __goStudyCost.AddComponent<CostWidget>();
|
|||
|
_btnStudy.onClick.AddListener(this.OnStudyBtnClick);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|