public override bool Initialize(params object[] p) { moduleHome.HideOthers(PET_OBJECT_NAME); if (base.Initialize()) { SelectPet = null; PetInfo defaultPet = null; if (p.Length > 0) { defaultPet = modulePet.GetPet((int)p[0]); if (defaultPet != null) { OnSelectChange(defaultPet, null); } } petSelectModule.Initalize(Module_Pet.GetAllPet(), defaultPet); talkButton?.onClick.AddListener(OnTease); fightButton?.onClick.AddListener(OnPetFight); restButton?.onClick.AddListener(RestButton); skillButton?.onClick.AddListener(() => { if (SelectPet == null) { Logger.LogError("检测到bug。SelectPet为空!"); return; } moduleGlobal.UpdateSkillTip(SelectPet.GetSkill(), SelectPet.AdditiveLevel, SelectPet.Mood); }); } return(true); }
private void _ME(ModuleEvent <Module_Pet> e) { if (!Root.activeInHierarchy) { return; } switch (e.moduleEvent) { case Module_Pet.PetStatusChange: RefreshButtonState(); RefreshAttribute(); RefreshDescColor(); PlayPetFightAction(); break; case Module_Pet.PetGradeChange: var p = e.param1 as PetInfo; if ((p?.ID ?? -1) == SelectPet?.ID) { RefreshStar(); RefreshModule(); RefreshAttribute(); RefreshSkill(); } break; case Module_Pet.ResponseStatus: ResponseChageStatus(e.msg as ScPetStatus); break; case Module_Pet.ResponseTease: ResponseTease(e.msg as ScPetTease); break; case Module_Pet.MoodChange: RefreshMood(); break; case Module_Pet.PetListChange: petSelectModule.ResetDataSource(Module_Pet.GetAllPet()); RefreshButtonState(); break; case Module_Pet.EventGetNewPet: var pet = e.param1 as PetInfo; if (null == pet) { break; } petSelectModule.SetItem(pet); if (null != SelectPet && SelectPet.ID == pet.ID) { SelectPet = pet; } Refresh(); RefreshHintCompose(SelectPet); PlayUnlockEffect(); break; default: Refresh(); break; } petSelectModule?._ME(e); }