using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class SkillBehaviour : MonoBehaviour
|
{
|
[SerializeField] Image m_SkillIcon;
|
[SerializeField] Button m_SkillButton;
|
[SerializeField] Text m_SkillName;
|
[SerializeField] Text m_SkillDescription;
|
private int skillId = 0;
|
|
GodWeaponEffectConfig godWeaponEffectConfig = null;
|
|
public event Action<int> onClick;
|
|
private void Awake()
|
{
|
m_SkillButton.onClick.AddListener(OnSkillButton);
|
}
|
|
public void Display(int _skillId)
|
{
|
var config = SkillConfig.Get(_skillId);
|
godWeaponEffectConfig = null;
|
skillId = 0;
|
if (config != null)
|
{
|
skillId = _skillId;
|
m_SkillIcon.SetSprite(config.IconName);
|
}
|
}
|
|
public void DisplayGodWeaponEffect(GodWeaponEffectConfig config)
|
{
|
godWeaponEffectConfig = config;
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
m_SkillIcon.SetSprite(_model.GetEffectSkillIcon(config.type, config.level));
|
if (m_SkillName != null)
|
{
|
m_SkillName.text = config.skillName;
|
}
|
if (m_SkillDescription != null)
|
{
|
m_SkillDescription.text = string.Empty;
|
if (ActivateShow.activateType == ActivateShow.ActivateFunc.GodWeaponEffect)
|
{
|
DisplayGodWeaponEffectProperty(config);
|
}
|
}
|
}
|
|
void DisplayGodWeaponEffectProperty(GodWeaponEffectConfig config)
|
{
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
Dictionary<int, int> dict;
|
if (_model.TryGetEffectProperty(config.type, config.level, out dict))
|
{
|
var sb = new StringBuilder();
|
foreach (var property in dict.Keys)
|
{
|
var propertyConfig = PlayerPropertyConfig.Get(property);
|
if (propertyConfig != null)
|
{
|
sb.Append(propertyConfig.Name);
|
sb.Append(StringUtility.Contact("+", UIHelper.ReplaceLargeNum(
|
UIHelper.ReplacePercentage(dict[property], propertyConfig.ISPercentage,
|
UIHelper.GetPropertyDecimalCount(property))),
|
propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
sb.Append("\n");
|
}
|
}
|
m_SkillDescription.text = sb.ToString();
|
m_SkillDescription.color = UIHelper.GetUIColor(TextColType.DarkGreen);
|
}
|
}
|
|
public void DisplayNewGot(int _skillId)
|
{
|
var config = SkillConfig.Get(_skillId);
|
godWeaponEffectConfig = null;
|
skillId = 0;
|
if (config != null)
|
{
|
skillId = _skillId;
|
m_SkillIcon.SetSprite(config.IconName);
|
m_SkillName.text = config.SkillName;
|
m_SkillDescription.text = config.Description;
|
m_SkillDescription.color = UIHelper.GetUIColor(TextColType.LightYellow);
|
}
|
}
|
|
private void OnSkillButton()
|
{
|
if (skillId != 0)
|
{
|
switch (ActivateShow.activateType)
|
{
|
case ActivateShow.ActivateFunc.Realm:
|
break;
|
case ActivateShow.ActivateFunc.GodWeapon:
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
var _dict = _model.godWeaponSkillDict[ActivateShow.godWeaponType];
|
var _lv = 0;
|
foreach (var _key in _dict.Keys)
|
{
|
if (skillId == _dict[_key])
|
{
|
_lv = _key;
|
break;
|
}
|
}
|
var config = GodWeaponConfig.GetConfig(ActivateShow.godWeaponType, _lv);
|
SkillDetails.ShowSkillDetails(config.SkillID, SkillDetails.SkillSourceType.GodWeaponSkill, 0, config.Name, string.Empty);
|
break;
|
}
|
|
if (onClick != null)
|
{
|
onClick(skillId);
|
}
|
}
|
|
if (godWeaponEffectConfig != null)
|
{
|
switch (ActivateShow.activateType)
|
{
|
case ActivateShow.ActivateFunc.GodWeapon:
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
if (godWeaponEffectConfig != null)
|
{
|
var stage = 0;
|
if (_model.TryGetGodWeaponStage(ActivateShow.godWeaponType, godWeaponEffectConfig.level, out stage))
|
{
|
SkillDetails.ShowGodWeaponEffectSkill(ActivateShow.godWeaponType, stage);
|
}
|
}
|
break;
|
}
|
}
|
}
|
}
|
}
|