public void OpenViewForNew(uint petId) { newPet = true; Singleton <PetView> .Instance.LoadPet(petId, gameObject.transform, new Vector3(-100, -15, 0)); SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(petId); name.text = spet.name; NGUITools.FindInChild <UISprite>(gameObject, "info/gradeicn").spriteName = "hslv"; gameObject.SetActive(true); close = false; SetStars((uint)spet.star); tips.text = "恭喜您获得新幻兽"; PPet pet = Singleton <PetMode> .Instance.GetPetByPetId(petId); PetVo petVo = Singleton <PetMode> .Instance.PetVos[pet.id]; NGUITools.FindInChild <UILabel>(gameObject, "info/fightvalue").text = petVo.fight.ToString(); tipsPlay.PlayReverse(); if (AfterOpenViewGuideDelegate != null) { EventDelegate.Add(tipsPlay.onFinished, AfterOpenViewGuideDelegate); AfterOpenViewGuideDelegate = null; } }
private void SetStoneInfo() { SysPet pet = currentPet; NGUITools.FindInChild <UILabel>(gameObject, "info/top/name").text = pet.name; SysItemVo itemVo = BaseDataMgr.instance.GetDataById <SysItemVo>((uint)currentPet.stone_id); NGUITools.FindInChild <UISprite>(gameObject, "info/fb/current/icn").spriteName = itemVo.icon.ToString(); NGUITools.FindInChild <UISprite>(gameObject, "info/fb/current/gradeicn").spriteName = ""; int own = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); PPet p = Singleton <PetMode> .Instance.GetPetByPetId((uint)pet.id); int need = 0; if (p != null) { need = PetLogic.GetNeedStone(p.star, true); } else { need = PetLogic.GetNeedStone((uint)pet.star, false); } NGUITools.FindInChild <UILabel>(gameObject, "info/fb/num").text = "(" + own + "/" + need + ")"; }
public void LoadPet(uint petId, Transform parent, Vector3 pos) { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(petId); pos = new Vector3(pos.x, pos.y - 20 * pet.fly, pos.z); imagePet = pet; string resId = "10004"; if (!pet.res.Equals("0")) { resId = pet.res; } if (resId == imageId) { PetImage.transform.parent = parent; PetImage.transform.localPosition = pos; } else { if (!ReferenceEquals(PetImage, null)) { PetImage.SetActive(false); } RoleDisplay.Instance.CreateModel(ModelType.Pet, resId, LoadPetImage); imageId = resId; imageParent = parent; imagePos = pos; } }
//可以召唤此宠物 public static bool CanOwn(SysPet pet) { SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>((uint)pet.id); int ownStone = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); int needStone = GetNeedStone((uint)spet.star, false); return(Singleton <PetMode> .Instance.GetPetByPetId((uint)pet.id) == null && ownStone >= needStone); }
public static int GetNeedEquip(uint petId, int num) { PPet pet = Singleton <PetMode> .Instance.GetPetByPetId(petId); SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(petId); //需要的装备id int need = PetEquipConfig[spet.type - 1][pet.grade - 1][num - 1]; return(need); }
//是否可以进化 public static bool CanEvolve(PPet pet) { if (pet.star < 5) { SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(pet.petId); int ownStone = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)spet.stone_id); int needStone = GetNeedStone(pet.star, true); return(ownStone >= needStone); } return(false); }
//获取宠物的属性信息 public static int[] GetPetProperty(int petid) { if (PetsConfig.ContainsKey(petid)) { return(PetsConfig[petid]); } else { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>((uint)petid); SetPetProperty(pet); return(PetsConfig[petid]); } }
private void SetPetsInfo(int petType) { ClearPetsInfo(); int num = 0; //先显示可以召唤的宠物数据 List <SysPet> unOwnPet = new List <SysPet>(); foreach (SysPet pet in PetLogic.SysPets) { if (petType == 0 || pet.type == petType) { if (PetLogic.CanOwn(pet)) { num++; SetPetInfo(pet, num, true); } else if (!PetLogic.IsOwn(pet)) { unOwnPet.Add(pet); } } } //再显示已经拥有的宠物 foreach (PPet pet in Singleton <PetMode> .Instance.AllPets) { SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(pet.petId); if (petType == 0 || spet.type == petType) { num++; SetPetInfo(spet, num, true); } } //已拥有和可召唤的宠物数 petNum = num; //再显示未拥有的宠物 foreach (SysPet pet in unOwnPet) { num++; SetPetInfo(pet, num, false); } SetFGTitlePos(); scrollView.ResetPosition(); SetPetPublicInfo(); }
private void SetPetInfo() { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(currentPPet.petId); NGUITools.FindInChild <UISprite>(gameObject, "info/gradeicn").spriteName = PetLogic.GetGradeIcn(currentPPet.grade); if (currentPPet != null) { NGUITools.FindInChild <UISprite>(gameObject, "info/typeicn").spriteName = PetLogic.GetTypeIcnName(pet.type); name.text = PetLogic.GetGradeDes(currentPPet.grade, pet.name); SetStars(currentPPet.star); NGUITools.FindInChild <UILabel>(gameObject, "info/levelvalue").text = currentPPet.lvl.ToString(); SysPetGrowUp petExp = BaseDataMgr.instance.GetDataById <SysPetGrowUp>(currentPPet.lvl); float exp = petExp.exp_upgrade; NGUITools.FindInChild <UISlider>(gameObject, "info/exp").value = currentPPet.exp / exp; NGUITools.FindInChild <UILabel>(gameObject, "info/exp/label").text = currentPPet.exp + "/" + exp; int stonenum = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); float need = 0f; if (currentPPet.star < 5) { need = PetLogic.GetNeedStone(currentPPet.star, true); NGUITools.FindInChild <UISlider>(gameObject, "info/stone/num").value = stonenum / need; } else { NGUITools.FindInChild <UISlider>(gameObject, "info/stone/num").value = 1; } NGUITools.FindInChild <UILabel>(gameObject, "info/stone/num/label").text = stonenum + "/" + need; //出战处理 if (currentPPet.state == 0) { FightButton.FindInChild <UILabel>("lk").text = "出战"; } else { FightButton.FindInChild <UILabel>("lk").text = "休息"; } SetPetSkill(currentPPet); SetPetEquips(currentPPet); SetPetProperty(currentPPet); } }
private void SetPetProperty(PPet pet) { PetVo petVo = Singleton <PetMode> .Instance.PetVos[pet.id]; SysPetEvolutionVo petEvo = BaseDataMgr.instance.GetDataById <SysPetEvolutionVo>(pet.star); NGUITools.FindInChild <UILabel>(propetyObj, "growvalue").text = (petEvo.grow / 10000f).ToString(); NGUITools.FindInChild <UILabel>(propetyObj, "hpvalue").text = petVo.Hp.ToString(); NGUITools.FindInChild <UILabel>(propetyObj, "attackvalue").text = petVo.AttPMax.ToString(); NGUITools.FindInChild <UILabel>(propetyObj, "pdvalue").text = petVo.DefP.ToString(); NGUITools.FindInChild <UILabel>(propetyObj, "mdvalue").text = petVo.DefM.ToString(); NGUITools.FindInChild <UILabel>(propetyObj, "decvalue").text = petVo.HurtRe.ToString(); SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(pet.petId); SysSkillBaseVo skill = BaseDataMgr.instance.GetDataById <SysSkillBaseVo>((uint)spet.unique_skill); NGUITools.FindInChild <UILabel>(propetyObj, "des").text = "天赋技能:" + skill.desc; NGUITools.FindInChild <UILabel>(gameObject, "info/fightvalue").text = petVo.fight.ToString(); }
//升阶动画 private void PlayEquips() { if (currentPPet.grade > 1) { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(currentPPet.petId); int[] equipConfigs = PetLogic.GetPetNeedEquips((uint)pet.type, (uint)currentPPet.grade - 1); for (int i = 0; i < equipObjs.Count; i++) { GameObject icn = NGUITools.FindChild(equipObjs[i], "icn"); SysEquipVo equipVo = BaseDataMgr.instance.GetDataById <SysEquipVo>((uint)equipConfigs[i]); icn.GetComponent <UISprite>().spriteName = equipVo.icon.ToString(); icn.SetActive(true); icn.GetComponent <TweenPlay>().PlayForward(); } light.SetActive(true); light.GetComponent <TweenPlay>().PlayForward(); } }
public void OpenView(uint petId) { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(petId); currentPet = pet; SetStoneInfo(); SetFBInfo(); gameObject.SetActive(true); close = false; play.PlayReverse(); Singleton <GoodsMode> .Instance.dataUpdated += DataUpdated; Singleton <CopyMode> .Instance.dataUpdated += DataUpdated; Singleton <DaemonIslandMode> .Instance.dataUpdated += DataUpdated; if (AfterOpenViewGuideDelegate != null) { EventDelegate.Add(play.onFinished, AfterOpenViewGuideDelegate); AfterOpenViewGuideDelegate = null; } }
public bool OpenViewForStone(uint stoneId, Action callback) { SysPet spet = PetLogic.GetSysPetByStoneId(stoneId); if (spet == null) { callback(); return(false); } PPet pet = Singleton <PetMode> .Instance.GetPetByPetId((uint)spet.id); if (pet != null) { callback(); return(false); } int own = Singleton <GoodsMode> .Instance.GetCountByGoodsId(stoneId); int need = PetLogic.GetNeedStone((uint)spet.star, false); if (own < need) { callback(); return(false); } OpenForStone = true; closeCallBack = callback; petId = spet.id; OpenView(); //隐藏萌宠献礼相关特效 EffectMgr.Instance.GetUIEffectGameObject(EffectId.UI_PetAnimation).SetActive(false); EffectMgr.Instance.GetUIEffectGameObject(EffectId.UI_PetLight).SetActive(false); return(true); }
private void OnPetClick(GameObject obj) { uint petId = uint.Parse(obj.name); SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(petId); if (PetLogic.CanOwn(pet)) { Singleton <PetControl> .Instance.ActiveAPet(petId); } else { PPet p = Singleton <PetMode> .Instance.GetPetByPetId(petId); if (p == null) { Singleton <PetStoneTipsView> .Instance.OpenView(petId); } else { Singleton <PetInfoView> .Instance.OpenView(petId); } } }
private static void SetPetProperty(SysPet pet) { int[] petconfig = new int[18]; int[] hp = GetProperty(pet.hp); petconfig[0] = hp[0]; petconfig[1] = hp[1]; int[] att_max = GetProperty(pet.att_max); petconfig[2] = att_max[0]; petconfig[3] = att_max[1]; int[] def_p = GetProperty(pet.def_p); petconfig[4] = def_p[0]; petconfig[5] = def_p[1]; int[] def_m = GetProperty(pet.def_m); petconfig[6] = def_m[0]; petconfig[7] = def_m[1]; int[] hurt_re = GetProperty(pet.hurt_re); petconfig[8] = hurt_re[0]; petconfig[9] = hurt_re[1]; int[] skill = GetSkill(pet.passive_skill); petconfig[10] = skill[0]; petconfig[11] = skill[1]; petconfig[12] = skill[2]; petconfig[13] = skill[3]; petconfig[14] = skill[4]; petconfig[15] = skill[5]; petconfig[16] = skill[6]; petconfig[17] = skill[7]; PetsConfig.Add(pet.id, petconfig); }
public void OpenViewForEvolve(uint uid) { newPet = false; PPet pet = Singleton <PetMode> .Instance.GetPetById(uid); Singleton <PetView> .Instance.LoadPet(pet.petId, gameObject.transform, new Vector3(-100, -15, 0)); NGUITools.FindInChild <UISprite>(gameObject, "info/gradeicn").spriteName = PetLogic.GetGradeIcn(pet.grade); SysPet sPet = BaseDataMgr.instance.GetDataById <SysPet>(pet.petId); name.text = PetLogic.GetGradeDes(pet.grade, sPet.name); tips.text = "您的幻兽进化到了" + pet.star + "星"; PetVo petVo = Singleton <PetMode> .Instance.PetVos[pet.id]; NGUITools.FindInChild <UILabel>(gameObject, "info/fightvalue").text = petVo.fight.ToString(); SetStars(pet.star); gameObject.SetActive(true); close = false; Singleton <PetView> .Instance.PetPlay(Status.Win); tipsPlay.PlayReverse(); }
//设置此宠物的技能面板信息 private void SetPetSkill(PPet pet) { int pos = 0; int[] skill1 = PetLogic.GetPetSkillInfo((int)pet.petId, 1); uint[] skill = Singleton <PetMode> .Instance.GetPetSkill(pet.id, 1); NGUITools.FindInChild <UILabel>(skillObjs[0], "name").text = PetLogic.GetSkillName(skill1[0], pos); NGUITools.FindInChild <UISprite>(skillObjs[0], "skillicn").spriteName = PetLogic.GetSkillIcn(skill1[0]); SetSkillInfo(skill, pet, 1); int[] skill2 = PetLogic.GetPetSkillInfo((int)pet.petId, 2); if (skill2[0] == skill1[0]) { pos = 1; } skill = Singleton <PetMode> .Instance.GetPetSkill(pet.id, 2); NGUITools.FindInChild <UILabel>(skillObjs[1], "name").text = PetLogic.GetSkillName(skill2[0], pos); NGUITools.FindInChild <UISprite>(skillObjs[1], "skillicn").spriteName = PetLogic.GetSkillIcn(skill2[0]); SetSkillInfo(skill, pet, 2); int[] skill3 = PetLogic.GetPetSkillInfo((int)pet.petId, 3); pos = 0; if (skill3[0] == skill1[0]) { pos++; } if (skill3[0] == skill2[0]) { pos++; } skill = Singleton <PetMode> .Instance.GetPetSkill(pet.id, 3); NGUITools.FindInChild <UILabel>(skillObjs[2], "name").text = PetLogic.GetSkillName(skill3[0], pos); NGUITools.FindInChild <UISprite>(skillObjs[2], "skillicn").spriteName = PetLogic.GetSkillIcn(skill3[0]); SetSkillInfo(skill, pet, 3); int[] skill4 = PetLogic.GetPetSkillInfo((int)pet.petId, 4); pos = 0; if (skill4[0] == skill1[0]) { pos++; } if (skill4[0] == skill2[0]) { pos++; } if (skill4[0] == skill3[0]) { pos++; } skill = Singleton <PetMode> .Instance.GetPetSkill(pet.id, 4); NGUITools.FindInChild <UILabel>(skillObjs[3], "name").text = PetLogic.GetSkillName(skill4[0], pos); NGUITools.FindInChild <UISprite>(skillObjs[3], "skillicn").spriteName = PetLogic.GetSkillIcn(skill4[0]); SetSkillInfo(skill, pet, 4); //宠物天赋技能 SysPet spet = BaseDataMgr.instance.GetDataById <SysPet>(pet.petId); SysSkillBaseVo skillVo = BaseDataMgr.instance.GetDataById <SysSkillBaseVo>((uint)spet.unique_skill + pet.star - 1); NGUITools.FindInChild <UILabel>(skillObjs[4], "name").text = skillVo.name; NGUITools.FindInChild <UILabel>(skillObjs[4], "level").text = "Lv." + skillVo.skill_lvl; NGUITools.FindInChild <UILabel>(skillObjs[4], "des").text = "说明;" + skillVo.desc; NGUITools.FindInChild <UISprite>(skillObjs[4], "skillicn").spriteName = skillVo.icon.ToString(); SetPetSkillPointInfo(); }
//设置宠物信息 private void SetPetInfo(SysPet pet, int num, bool own) { GameObject petobj; if (num > petsObj.Count) { petobj = GameObject.Instantiate(petsObj[0]) as GameObject; petsObj.Add(petobj); petobj.transform.parent = petsObj[0].transform.parent; petobj.transform.localScale = new Vector3(1, 1, 1); petobj.SetActive(false); petobj.GetComponent <UIWidgetContainer>().onClick = OnPetClick; petobj.name = pet.id.ToString(); } else { petobj = petsObj[num - 1]; petobj.name = pet.id.ToString(); } SetPetObjPos(petobj, num, own); NGUITools.FindInChild <UISprite>(petobj, "image").spriteName = pet.icon.ToString(); petobj.SetActive(true); NGUITools.FindChild(petobj, "tips").SetActive(false); //提示默认关闭 if (!own || PetLogic.CanOwn(pet)) { NGUITools.FindInChild <UILabel>(petobj, "name").text = pet.name; UIUtils.ChangeGrayShader(NGUITools.FindInChild <UISprite>(petobj, "image"), imageDepth - 1); NGUITools.FindChild(petobj, "equips").SetActive(false); NGUITools.FindChild(petobj, "level").SetActive(false); NGUITools.FindChild(petobj, "stars").SetActive(false); NGUITools.FindChild(petobj, "stone").SetActive(true); int stone = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); int need = PetLogic.GetNeedStone((uint)pet.star, false); NGUITools.FindInChild <UISprite>(petobj, "gradeicn").spriteName = ""; NGUITools.FindInChild <UISlider>(petobj, "stone").value = stone / (float)need; NGUITools.FindInChild <UILabel>(petobj, "stone/num").text = stone + "/" + need; if (PetLogic.CanOwn(pet)) { NGUITools.FindChild(petobj, "active").SetActive(true); NGUITools.FindChild(petobj, "tips").SetActive(true); NGUITools.FindChild(petobj, "gradeicn").SetActive(false); } else { NGUITools.FindChild(petobj, "gradeicn").SetActive(false); NGUITools.FindChild(petobj, "active").SetActive(false); } } else { PPet ppet = Singleton <PetMode> .Instance.GetPetByPetId((uint)pet.id); NGUITools.FindChild(petobj, "gradeicn").SetActive(true); NGUITools.FindInChild <UISprite>(petobj, "gradeicn").spriteName = PetLogic.GetGradeIcn(ppet.grade); NGUITools.FindInChild <UILabel>(petobj, "name").text = PetLogic.GetGradeDes(ppet.grade, pet.name); UIUtils.ChangeNormalShader(NGUITools.FindInChild <UISprite>(petobj, "image"), imageDepth); NGUITools.FindChild(petobj, "equips").SetActive(true); NGUITools.FindChild(petobj, "level").SetActive(true); NGUITools.FindInChild <UILabel>(petobj, "level/label").text = ppet.lvl.ToString(); NGUITools.FindChild(petobj, "stars").SetActive(true); SetStar(petobj, ppet.star); SetEquipInfo(petobj, ppet.petId); NGUITools.FindChild(petobj, "stone").SetActive(false); NGUITools.FindChild(petobj, "active").SetActive(false); //检查是否可以升阶-升星 if (PetLogic.CanUpgrade(ppet) || PetLogic.CanEvolve(ppet)) { NGUITools.FindChild(petobj, "tips").SetActive(true); } } NGUITools.FindInChild <UISprite>(petobj, "typeicn").spriteName = PetLogic.GetTypeIcnName(pet.type); }
//是否已召唤此宠物 public static bool IsOwn(SysPet pet) { return(Singleton <PetMode> .Instance.GetPetByPetId((uint)pet.id) != null); }