127 lines
3.2 KiB
C#
127 lines
3.2 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-06-10
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "EquipmentUpgradeWidget" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static G.PlayerProxy;
|
|
|
|
namespace G.UI
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class EquipmentUpgradeWidget : KUIWidget
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
[KUIFlag]
|
|
Button _btnUpgrade;
|
|
[KUIFlag]
|
|
Button _btnOneKeyUpgrade;
|
|
[KUIFlag]
|
|
KUIList __goExtraAttributes;
|
|
[KUIFlag]
|
|
GameObject __goUpgradeCost;
|
|
[KUIFlag]
|
|
GameObject __goOnekeyUpgradeCost;
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
private CostWidget _upgradeCost;
|
|
private CostWidget _onekeyUpgradeCost;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
public override void Refresh()
|
|
{
|
|
if (this.data is EquipmentSlotInfo equipmentSlot)
|
|
{
|
|
bool enough = PlayerProxy.Instance.GetUpgradeEquipmentSlotCost(equipmentSlot.id, false, out int costId, out int cost);
|
|
_upgradeCost.SetPrice(costId, cost, enough);
|
|
|
|
SetExtra(equipmentSlot.equipment.extraAttributes, equipmentSlot.upgradeAttributes);
|
|
}
|
|
}
|
|
|
|
private void SetExtra(List<CombatAttribute> attributes, List<CombatAttribute> attributes2)
|
|
{
|
|
if (attributes != null && attributes.Count > 0)
|
|
{
|
|
__goExtraAttributes.gameObject.SetActive(true);
|
|
__goExtraAttributes.Clear();
|
|
for (int i = 0; i < attributes.Count; i++)
|
|
{
|
|
var at = __goExtraAttributes.GetItem<EquipmentAttributeItem>();
|
|
at.SetData(attributes[i].ToString());
|
|
if (i < attributes2.Count)
|
|
{
|
|
var at2 = __goExtraAttributes.GetItem<EquipmentAttributeItem>();
|
|
at2.SetData("<color=#349652>强化+" + attributes2[i].value + "</color>");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
__goExtraAttributes.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void OnUpgradeBtnClick()
|
|
{
|
|
if (this.data is EquipmentSlotInfo equipmentSlot)
|
|
{
|
|
if (PlayerProxy.Instance.UpgradeEquipmentSlot(equipmentSlot.id, false, true))
|
|
{
|
|
Refresh();
|
|
}
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnOneKeyUpgradeBtnClick()
|
|
{
|
|
if (this.data is EquipmentSlotInfo equipmentSlot)
|
|
{
|
|
if (PlayerProxy.Instance.UpgradeEquipmentSlot(equipmentSlot.id, true, true))
|
|
{
|
|
Refresh();
|
|
}
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private void Awake()
|
|
{
|
|
SetViewData();
|
|
|
|
__goExtraAttributes.AddTemplate<EquipmentAttributeItem>(true);
|
|
_upgradeCost = __goUpgradeCost.AddComponent<CostWidget>();
|
|
_onekeyUpgradeCost = __goOnekeyUpgradeCost.AddComponent<CostWidget>();
|
|
_btnUpgrade.onClick.AddListener(this.OnUpgradeBtnClick);
|
|
_btnOneKeyUpgrade.onClick.AddListener(this.OnOneKeyUpgradeBtnClick);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|