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 PetMainAttrWnd : MonoBehaviour { public GameObject SleepPet; public GameObject CallPet; public GameObject HelpBtn; public GameObject FightBtn; public GameObject BaseAttrWnd; //基础属性 public GameObject DetailAttrWnd; //详细属性 public Toggle BaseAttrToggle; public Toggle DetailAttrToggle; public InitAptitudeStart baseAptitudeStart; public InitAptitudeStart detailAptitudeStart; //弹出框 public GameObject PopWnd; public GameObject FightSet; public UIContainerBase FightSetting; public GameObject ChangePetName; //基础属性 public Text grow; //成长 public Text attack;//攻击 public Text blood; //气血 public Text physical; //物理防御 public Text cultivation; //修为 public Text magic; //法术防御 public Text sawy; //悟性 public Text nature; //性格 public Text style; //类型 public GameObject expObj; public Text exp; //经验值 public Slider expSlider; public GameObject liftObj; public Text lift; //寿命值 public Slider liftSlider; //详细属性 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 Text detailattack;//攻击 public Text detailblood; //气血 public Text detailphysical; //物理防御 public Text detailmagic; //法术防御 public GameObject[] skillIcons = new GameObject[8]; public void ClearInfo(bool state) { detailphysical.gameObject.SetActive(state); detailblood.gameObject.SetActive(state); detailattack.gameObject.SetActive(state); detailmagic.gameObject.SetActive(state); magic.gameObject.SetActive(state); cultivation.gameObject.SetActive(state); physical.gameObject.SetActive(state); blood.gameObject.SetActive(state); attack.gameObject.SetActive(state); grow.gameObject.SetActive(state); nature.gameObject.SetActive(state); style.gameObject.SetActive(state); sawy.gameObject.SetActive(state); exp.gameObject.SetActive(state); lift.gameObject.SetActive(state); Boneatitude.gameObject.SetActive(state); Forceatitude.gameObject.SetActive(state); Poweratitude.gameObject.SetActive(state); Smartatitude.gameObject.SetActive(state); Agileatitude.gameObject.SetActive(state); bone.gameObject.SetActive(state); force.gameObject.SetActive(state); power.gameObject.SetActive(state); smart.gameObject.SetActive(state); agile.gameObject.SetActive(state); hit.gameObject.SetActive(state); avoid.gameObject.SetActive(state); baseAptitudeStart.ClearInfo(state); detailAptitudeStart.ClearInfo(state); expObj.gameObject.SetActive(state); liftObj.gameObject.SetActive(state); for (int i = 0; i < skillIcons.Length; i++) { AddStudySkill(null, -1, i); } } public void Awake() { Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.UPDATA_PET_CALLFIGHTINFO, UpdateCallBtn); Hashtable calbackMoveparam2 = new Hashtable(); calbackMoveparam2["name"] = "MainAttr"; MessageEventCallBack fun2 = UpdateFelllowAttr; calbackMoveparam2.Add("callFun", fun2); Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdatePetInfo, calbackMoveparam2); } public void OnDestroy() { Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdatePetInfo, "MainAttr"); Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.UPDATA_PET_CALLFIGHTINFO, UpdateCallBtn); } public void UpdateCallBtn(object obj) { Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId); if (pet == null) return; if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level>=70) { HelpBtn.SetActive(false); CallPet.SetActive(false); FightBtn.SetActive(((!pet.Called) && (!pet.Helped))); } else { HelpBtn.SetActive(((!pet.Called) && (!pet.Helped))); CallPet.SetActive(((!pet.Called) && (!pet.Helped))); FightBtn.SetActive(false); } if (FightSet != null && FightSet.activeInHierarchy) { OnClick_FightPetReSet(); } if (pet.Attached) FightBtn.SetActive(false); SleepPet.SetActive(pet.Called || pet.Helped || pet.Attached); } public void UpdateFelllowAttr(Hashtable addparam, Hashtable sendparam) { if (sendparam.ContainsKey("guid") == false) return; ulong fellowGuid = (ulong)sendparam["guid"]; if(fellowGuid== PetMainWnd.CurrentSelectFellowId) { OPenBaseAttrWnd(false); OPenDetailWnd(false); } } public void OnSelectPet() { if (GameManager.gameManager.PlayerDataPool.FellowContainer==null) return; Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId); if (pet == null) return; BaseAttrToggle.isOn = true; DetailAttrToggle.isOn = false; OPenBaseAttrWnd(); UpdateCallBtn(null); 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 OnClick_ChangePetName() { if (PopWnd == null) return; if (FightSet == null) return; PopWnd.SetActive(true); ChangePetName.SetActive(true); InputField input = ChangePetName.GetComponentInChildren(); if (input != null) { input.text = ""; } } public void OnClick_ChangeNameCancel() { if (PopWnd == null) return; if (FightSet == null) return; PopWnd.SetActive(false); ChangePetName.SetActive(false); } public void OnClick_ChangeNameOK() { if (PopWnd == null) return; if (FightSet == null) return; if (ChangePetName == null) return; InputField input = ChangePetName.GetComponentInChildren(); if (input == null) return; CG_FELLOW_CHANGE_NAME send = (CG_FELLOW_CHANGE_NAME)PacketDistributed.CreatePacket(MessageID.PACKET_CG_FELLOW_CHANGE_NAME); send.Fellowguid = PetMainWnd.CurrentSelectFellowId; send.Name = input.text; send.SendPacket(); PopWnd.SetActive(false); ChangePetName.SetActive(false); } public void OnClickBaseAttr() { OPenBaseAttrWnd(); } public void OnClickDetailAttr() { OPenDetailWnd(); } // 显示宠物技能图标 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