123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class UAVSkillInfo : MonoBehaviour {
- public Text titleTxt;
- public Image icon;
- public Text descTxt;
- void Awake()
- {
- titleTxt.text = Language.GetStr ("PowerTip", "extraPower");
- }
- public void SetData(Equipment equipment)
- {
- UAVData uavData = UAVManager.GetInstance ().GetDataByEquipId (equipment.GetData().id);
- string desc = "";
- for(int i=0; i<uavData.powers.Length; i++)
- {
- int powerId = uavData.powers [i];
- PowerData powerData = PowerDataManager.GetInstance ().GetData (powerId);
- if(powerData.effect == Power.PowerEffect.Heal.GetHashCode())
- {
- desc += GetHealDesc (powerData);
- }
- if(powerData.buff > 0)
- {
- desc += GetBuffDesc (powerData.buff);
- }
- desc += "\n" + Language.GetStr ("PowerTip", "coolDown").Replace("%SEC%", powerData.cd.ToString());
- icon.sprite = Power.GetIcon (powerData);
- if(i < uavData.powers.Length - 1)
- desc += "\n\n";
- }
- descTxt.text = desc;
- }
- private string GetTarget(PowerData powerData)
- {
- if (powerData.target == Power.TargetRange.Self.GetHashCode ())
- return Language.GetStr ("PowerTip", "tarSelf");
- return "";
- }
- private string GetValue(PowerData powerData)
- {
- if (powerData.value_type == Power.ValueType.Percent.GetHashCode ()) {
- return powerData.value + "%";
- }
- else if(powerData.value_type == Power.ValueType.Constant.GetHashCode()) {
- return powerData.value.ToString ();
- }
- return "";
- }
- private string GetHealDesc(PowerData powerData)
- {
- string str = Language.GetStr ("PowerTip", "heal");
- str = str.Replace ("%TAR%", GetTarget(powerData));
- str = str.Replace ("%NUM%", GetValue(powerData));
- return str;
- }
- private string GetBuffTarget(BuffData buffData)
- {
- if (buffData.target == Buff.TargetType.Launcher.GetHashCode())
- return Language.GetStr ("PowerTip", "tarSelf");
- return "";
- }
- private string GetBuffValue(BuffData buffData, int index)
- {
- if (buffData.value_type[index] == ConfigValue.ValueType.Percentage.GetHashCode ())
- return buffData.value[index] + "%";
- return "";
- }
- private string GetBuffDesc(int buffId)
- {
- BuffData buffData = BuffManager.GetInstance ().GetData (buffId);
- string str = "";
- for(int i=0; i<buffData.buff_type.Length; i++)
- {
- int buffType = buffData.buff_type [i];
- if(buffType == Buff.BuffType.SpeedUp.GetHashCode())
- {
- str += Language.GetStr ("PowerTip", "speedUp");
- str = str.Replace ("%TAR%", GetBuffTarget(buffData));
- str = str.Replace ("%NUM%", GetBuffValue(buffData, i));
- }
- str += ", " + Language.GetStr ("PowerTip", "duration").Replace ("%SEC%", buffData.duration.ToString());
- if(i < buffData.buff_type.Length - 1)
- str += "\n";
- }
- return str;
- }
- }
|