Files
JJBB/Assets/Project/Script/GUI/Pet/OtherPetInfoWnd.cs
2024-08-23 15:49:34 +08:00

193 lines
6.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Lifetime;
using Games.GlobeDefine;
using Games.LogicObj;
using Games.SkillModle;
using GCGame;
using GCGame.Table;
using Module.Log;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Games.MountModule;
using Games.Fellow;
using Games.Events;
public class OtherPetInfoWnd : MonoBehaviour
{
public Text Title;
public Text petName; //宠物名称
public Text petLevel; //宠物等级
public Text totlePower; //总战力
//基础属性
public Text Summ; //总评语
public Text grow; //成长
public Text attack;//攻击
public Text blood; //气血
public Text physical; //物理防御
public Text cultivation; //修为
public Text magic; //法术防御
public Text sawy; //悟性
public Text level; //携带等级
//详细属性
public Text Boneatitude; //根骨资质
public Text Forceatitude; //精力资质
public Text Poweratitude; //力量资质
public Text Smartatitude; //智力资质
public Text Agileatitude; //敏捷资质
public Text bone; //根骨
public Text force; //精力
public Text power; //力量
public Text smart; //智力
public Text agile; //敏捷
public Text hit; //命中
public Text avoid; //闪避
public GameObject[] skillIcons = new GameObject[8];
public InitAptitudeStart baseAptitudeStart;
public UICameraTexture modelTexture; //模型展示的RenderTexture
public Image PetQuilityIcon;
public void AddStudySkill(Fellow fellow, int id, int index)
{
if (index > skillIcons.Length)
return;
GameObject skillHas = skillIcons[index];
if (skillHas == null)
return;
Transform child = skillHas.transform.Find("Child");
Tab_FellowSkill skillInfo = TableManager.GetFellowSkillByID(id, 0);
if (skillInfo == null)
{
if (child != null)
child.gameObject.SetActive(false);
return;
}
if (fellow.IsHaveSkillId(id) == false)
{
if (child != null)
child.gameObject.SetActive(false);
return;
}
child.gameObject.SetActive(true);
Transform skillIcon = skillHas.transform.Find("Child/Icon");
Transform level = skillHas.transform.Find("Child/Level");
Button Btn = skillHas.GetComponentInChildren<Button>();
if (skillIcon != null)
{
Image icon = skillIcon.gameObject.GetComponent<Image>();
if (icon != null)
{
LoadAssetBundle.Instance.SetImageSprite(icon, skillInfo.SkillIcon);
}
}
if (level != null)
{
Text levelText = level.gameObject.GetComponent<Text>();
if (levelText != null)
{
levelText.text = "Lv." + skillInfo.Level.ToString();
}
}
if (Btn != null)
{
Btn.onClick.RemoveAllListeners();
Btn.onClick.AddListener(delegate ()
{
OnClickSkillIcon(skillInfo, Btn.transform);
});
}
}
public void OnClickSkillIcon(Tab_FellowSkill skill,Transform pos)
{
FellowSkillTooltip.ShowSkillToolTips(skill.Id,pos.position);
}
//基础属性
public void OPenBaseAttrWnd(Fellow pet,string Name ="")
{
if(Name!="")
{
Title.text = StrDictionary.GetClientDictionaryString("#{20155}", Name);
}
else
{
Title.text = StrDictionary.GetClientDictionaryString("#{20156}");
}
petName.text = pet.Name;
petLevel.text = string.Format("Lv.{0}", pet.Level);
totlePower.text = pet.CombatValue.ToString();
Summ.text = pet.Summ;
grow.text = pet.grow.ToString();
attack.text = pet.attack.ToString();
blood.text = pet.blood.ToString();
physical.text = pet.physical.ToString();
cultivation.text = pet.cultivation.ToString();
magic.text = pet.magic.ToString();
sawy.text = (pet.sawy * 1.0f / 100.0f).ToString();
Tab_FellowBase petBase = TableManager.GetFellowBaseByID(pet.DataId, 0);
if (petBase != null)
{
level.text = petBase.CarryLevel.ToString();
}
Tab_PromoteCultivation atitudeData = TableManager.GetPromoteCultivationByID(pet.cultivation, 0);
if (atitudeData != null)
{
float addRate = atitudeData.AddAptitudePer * 1.0f / 100.0f;
Boneatitude.text = string.Format("{0}(<color=#feff88ff>+{1}%</color>)", pet.Boneatitude, addRate);
Forceatitude.text = string.Format("{0}(<color=#feff88ff>+{1}%</color>)", pet.Forceatitude, addRate);
Poweratitude.text = string.Format("{0}(<color=#feff88ff>+{1}%</color>)", pet.Poweratitude, addRate);
Smartatitude.text = string.Format("{0}(<color=#feff88ff>+{1}%</color>)", pet.Smartatitude, addRate);
Agileatitude.text = string.Format("{0}(<color=#feff88ff>+{1}%</color>)", pet.Agileatitude, addRate);
}
bone.text = pet.bone.ToString();
force.text = pet.force.ToString();
power.text = pet.power.ToString();
smart.text = pet.smart.ToString();
agile.text = pet.agile.ToString();
hit.text = pet.hit.ToString();
avoid.text = pet.avoid.ToString();
if (baseAptitudeStart != null)
{
baseAptitudeStart.InitStart(pet.AptitudeTotle);
}
var modelTab = pet.CharModel();
if (modelTab != null)
{
modelTexture.InitModelPath(modelTab.ResPath,modelTab, LoadAssetBundle.BUNDLE_PATH_PET, true);
}
if (PetQuilityIcon != null)
{
LoadAssetBundle.Instance.SetImageSprite(PetQuilityIcon, Utils.GetFellowQuilityIcon(pet.Quality));
}
for (int i = 0; i < skillIcons.Length; i++)
{
if (i == 0)
{
AddStudySkill(pet, pet.GY_skillid, i);
continue;
}
if (i == 1)
{
AddStudySkill(pet, pet.MW_skillid, i);
continue;
}
AddStudySkill(pet, pet.GetOwnSkillId(i - 2), i);
}
}
public void Close()
{
UIManager.CloseUI(UIInfo.OtherPetInfoWndPath);
}
}