private void OnSwitch(TabControl t) { int index = t.getSeletedIndex(); if (current != null) { current.onClose(); current.gameObject.SetActive(false); } if (index == 0) { if (A3_PetModel.getInstance().hasPet()) { if (pet == null) { GameObject prefab = GAMEAPI.ABLayer_LoadNow_GameObject("uilayer_a3_pet_skin"); GameObject panel = GameObject.Instantiate(prefab) as GameObject; //pet = new a3_pet_skin(panel.transform); //pet.setPerent(con); //pet.gameObject.SetActive(false); } if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.PET)) { current = pet; } } else { flytxt.instance.fly(ContMgr.getCont("no_get_pet")); current = null; } } else if (index == 1) { if (wing == null) {//TODO GameObject prefab = GAMEAPI.ABLayer_LoadNow_GameObject("uilayer_a3_wing_skin"); GameObject panel = GameObject.Instantiate(prefab) as GameObject; //wing = new a3_wing_skin(panel.transform); // wing.setPerent(con); //wing.gameObject.SetActive(false); } if (FunctionOpenMgr.instance.Check(FunctionOpenMgr.PET_SWING)) { current = wing; } } if (current != null) { current.onShowed(); current.visiable = true; if (!current.__mainTrans.gameObject.activeSelf) { current.__mainTrans.gameObject.SetActive(true); } } }
private void OnBless(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); cpet.Tpid = data["id"]; cpet.Level = data["level"]; cpet.Exp = data["exp"]; }
private void OnSyncStarvation(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); cpet.Starvation = data["starvation"]; if (a3_pet_skin.instan != null) { a3_pet_skin.instan.OnStarvationChange(); } }
private void OnStage(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); cpet.Tpid = data["id"]; cpet.Stage = data["stage"]; cpet.Level = 1; cpet.Exp = 0; flytxt.instance.fly(ContMgr.getCont("petmodel_upok")); }
private void OnAutoPlayUpgrade(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); cpet.Tpid = data["id"]; cpet.Exp = data["exp"]; if (data.ContainsKey("level")) { cpet.Level = data["level"]; } }
private void OnSyncAutoFeed(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); if (data["auto_feed"] == 0) { cpet.Auto_feed = false; } else { cpet.Auto_feed = true; } //debug.Log(cpet.Auto_feed + "::::::::" + a3_pet_skin.instan.autofeed.isOn); }
public void ChangePetAvatar(int petID, int petStage) { if (petID == m_petID && petStage == m_petStage) { return; } m_petID = petID; m_petStage = petStage; if (m_myPetBird != null) { GameObject.Destroy(m_myPetBird.gameObject); m_myPetBird = null; } Transform stop = m_curModel.FindChild("birdstop"); string petava = A3_PetModel.getInstance().GetPetAvatar(m_petID, 0); if (petava == "") { return; } GameObject birdPrefab = GAMEAPI.ABModel_LoadNow_GameObject("profession_" + petava); GameObject pathPrefab = GAMEAPI.ABModel_LoadNow_GameObject("profession_birdpath"); if (birdPrefab == null || pathPrefab == null) { return; } GameObject bird = GameObject.Instantiate(birdPrefab, stop.position, Quaternion.identity) as GameObject; GameObject path = GameObject.Instantiate(pathPrefab, stop.position, Quaternion.identity) as GameObject; if (bird == null || path == null) { return; } path.transform.parent = stop; bird.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); m_myPetBird = bird.AddComponent <PetBird>(); m_myPetBird.Path = path; }
private void OnOneKeyBless(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); if (data.ContainsKey("multi_res")) { int res = data["multi_res"]; if (res < 0) { Globle.err_output(res); } } cpet.Tpid = data["id"]; cpet.Level = data["level"]; cpet.Exp = data["exp"]; }
private void Getpet(Variant data) { if (!PlayerModel.getInstance().havePet) { PlayerModel.getInstance().havePet = true;//刷新palyermodel里面数据是否有pet } debug.Log(data.dump()); A3_PetModel.getInstance().petId = data["pet"]["id_arr"]._arr; A3_PetModel.curPetid = (uint)data["pet"]["id"]._int; A3_PetModel.getInstance().Tpid = (uint)data["pet"]["id"]._int; dispatchEvent(GameEvent.Create(EVENT_GET_PET, this, data)); if (SelfRole._inst != null) { SelfRole.OnPetHaveChange(data); } }
public override void init() { instan = this; petmodel = A3_PetModel.getInstance(); feedid = petmodel.GetFeedItemTpid(); levelid = petmodel.GetLevelItemTpid(); stageid = petmodel.GetStageItemTpid(); currentLevel = petmodel.CurrentLevelConf(); currentStage = petmodel.CurrentStageConf(); stagestep = currentStage.getUint("crystal_step"); BaseButton upBtn = new BaseButton(getTransformByPath("exp_con/upgrade")); upBtn.onClick = OnUpgrade; BaseButton onekeyBtn = new BaseButton(getTransformByPath("exp_con/onekey")); onekeyBtn.onClick = OnOnekey; BaseButton feedBtn = new BaseButton(getTransformByPath("lampoil")); feedBtn.onClick = OnFeed; BaseButton stageBtn = new BaseButton(getTransformByPath("stage_con/improve")); stageBtn.onClick = OnStage; BaseButton helpBtn = new BaseButton(getTransformByPath("title/help")); helpBtn.onClick = OnHelp; BaseButton close_btn = new BaseButton(getTransformByPath("close")); close_btn.onClick = onclose; autofeed = getComponentByPath <Toggle>("light_hint/toggle"); autofeed.onValueChanged.AddListener(OnAutoFeedToggleChange); autobuy = getComponentByPath <Toggle>("light_hint/toggle2"); autobuy.onValueChanged.AddListener(OnAutoBuyToggleChange); prefab = getGameObjectByPath("att/a3_pet_att"); }
public override void onShowed() { A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_GET_LAST_TIME, getlastTime); //A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_GET_PET, getPet); A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_SHOW_PET, showPet); A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_FEED_PET, feedPet); A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_HAVE_PET, havePet); toback = false; UIClient.instance.addEventListener(UI_EVENT.ON_MONEY_CHANGE, onMoneyChange); refreshMoney(); refreshGold(); refreshGift(); petgo.createAvatar(); petgo.creatPetAvatar(petid); petgo.canshow = true; if (A3_PetModel.showbuy) { getGameObjectByPath("buyshow").SetActive(true); } InterfaceMgr.getInstance().changeState(InterfaceMgr.STATE_FUNCTIONBAR); GRMap.GAME_CAMERA.SetActive(false); List <int> lst = new List <int>(); lst.Clear(); for (int i = 0; i < A3_PetModel.getInstance().petId.Count; i++) { lst.Add(A3_PetModel.getInstance().petId[i]); } if (lst.Contains(petid)) { chosenpetBtnOnClick(transform.FindChild("scoll/cont/" + petid + "/icon_bg/icon").gameObject, false); } else { chosenpetBtnOnClick(transform.FindChild("scoll/cont/" + petid + "/lock").gameObject, true); } UiEventCenter.getInstance().onWinOpen(uiName); }
void getPet(GameEvent e)//修改宠物是否可用 { A3_PetModel.getInstance().petId = e.data["pet"]["id_arr"]._arr; for (int i = 0; i < A3_PetModel.getInstance().petId.Count; i++) { int petGo = A3_PetModel.getInstance().petId[i]; string str = ""; str = XMLMgr.instance.GetSXML("newpet.pet", "pet_id==" + petGo).getString("mod"); //switch (petGo) //{ // case 2: str = "eagle"; break; // case 5: str ="yingwu"; break; // case 3: str = "yaque"; break; // default: // break; //} transform.FindChild("scoll/cont/" + petGo + "/lock").gameObject.SetActive(false); transform.FindChild("scoll/cont/" + petGo + "/lock/image_lock").gameObject.SetActive(false); } }
private void OnSyncAutoBuy(Variant data) { A3_PetModel cpet = A3_PetModel.getInstance(); if (data["auto_buy_feeds"] == 0) { cpet.Auto_buy = false; } else { cpet.Auto_buy = true; } int num = a3_BagModel.getInstance().getItemNumByTpid(cpet.GetFeedItemTpid()); if (cpet.Auto_buy && num <= 0) { A3_PetModel.getInstance().AutoBuy(); } //debug.Log(cpet.Auto_buy + "::::::::" + a3_pet_skin.instan.autobuy.isOn); }
private void OnFeed(GameObject go) { int havenum = a3_BagModel.getInstance().getItemNumByTpid(feedid); if (havenum > 0) { if (havenum == 1) { if (A3_PetModel.getInstance().Auto_buy == false) { //String hint = ContMgr.getCont("pet_no_feed"); // if (flytxt.instance != null) // flytxt.instance.fly(hint); } } A3_PetProxy.getInstance().Feed(); } else { a3_store.itm_tpid = feedid; InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_STORE); } }
private void OnGetPets(Variant data) { if (data.ContainsKey("pet")) { Variant spet = data["pet"]; A3_PetModel cpet = A3_PetModel.getInstance(); cpet.Tpid = spet["id"]; //cpet.Stage = spet["stage"]; //cpet.Level = spet["level"]; //cpet.Exp = spet["exp"]; //if (spet.ContainsKey("starvation")) cpet.Starvation = spet["starvation"]; //if (spet.ContainsKey("auto_feed")) //{ // if (spet["auto_feed"] == 0) { cpet.Auto_feed = false; } // else { cpet.Auto_feed = true; } //} //if (spet.ContainsKey("auto_buy_feeds")) //{ // if (spet["auto_buy_feeds"] == 0) { cpet.Auto_buy = false; } // else { cpet.Auto_buy = true; } //} } }
public override void init() { #region 初始化汉字 getComponentByPath <Text>("timeBuy/buyIt/Text").text = ContMgr.getCont("a3_new_pet_00"); getComponentByPath <Text>("timeBuy/use/Text").text = ContMgr.getCont("a3_new_pet_0000"); getComponentByPath <Text>("help/descTxt").text = ContMgr.getCont("a3_new_pet_11") + "\n" + ContMgr.getCont("a3_new_pet_1212") + "\n" + ContMgr.getCont("a3_new_pet_1313") + "\n" + ContMgr.getCont("a3_new_pet_1414"); getComponentByPath <Text>("help/btn/Text").text = ContMgr.getCont("a3_new_pet_22"); getComponentByPath <Text>("buyshow/scollBuy/content/buy0/free").text = ContMgr.getCont("a3_new_pet_33"); getComponentByPath <Text>("buyshow/scollBuy/content/buy0/image/buy").text = ContMgr.getCont("a3_new_pet_44"); getComponentByPath <Text>("buyshow/scollBuy/content/buy1/1").text = ContMgr.getCont("a3_new_pet_55"); getComponentByPath <Text>("buyshow/scollBuy/content/buy1/image/buy").text = ContMgr.getCont("a3_new_pet_66"); getComponentByPath <Text>("buyshow/scollBuy/content/buy2/3").text = ContMgr.getCont("a3_new_pet_77"); getComponentByPath <Text>("buyshow/scollBuy/content/buy2/image/buy").text = ContMgr.getCont("a3_new_pet_88"); getComponentByPath <Text>("zdsq/info").text = ContMgr.getCont("a3_new_pet_99"); getComponentByPath <Text>("lxjy/info").text = ContMgr.getCont("a3_new_pet_1010"); getComponentByPath <Text>("lxjy/info2").text = ContMgr.getCont("a3_new_pet_1111"); getComponentByPath <Text>("buyshow/scollBuy/content/buy3/image/buy").text = ContMgr.getCont("a3_new_pet_89"); #endregion instance = this; pet_name = getComponentByPath <Text>("pet_name/Text"); usepet_btn = getGameObjectByPath("timeBuy/use"); zdsq = getGameObjectByPath("zdsq"); lxjy = getGameObjectByPath("lxjy"); new BaseButton(getTransformByPath("btn_zdsq")).onClick = (GameObject go) => { zdsq.SetActive(true); }; new BaseButton(getTransformByPath("btn_lxjy")).onClick = (GameObject go) => { lxjy.SetActive(true); }; BaseButton lxjyclose = new BaseButton(getTransformByPath("lxjy/close")); BaseButton lxjyclose1 = new BaseButton(getTransformByPath("lxjy/close1")); lxjyclose.onClick = lxjyclose1.onClick = (GameObject go) => { lxjy.SetActive(false); }; BaseButton zdsqclose = new BaseButton(getTransformByPath("zdsq/close")); BaseButton zdsqclose1 = new BaseButton(getTransformByPath("zdsq/close1")); zdsqclose.onClick = zdsqclose1.onClick = (GameObject go) => { zdsq.SetActive(false); }; //if (PlayerModel.getInstance().last_time == -1) //{ // lastTime = -1; // getGameObjectByPath("timeBuy/buyIt").SetActive(false); //} if (PlayerModel.getInstance().last_time <= 0) { lastTime = 0; usepet_btn.SetActive(false); } else if (PlayerModel.getInstance().last_time > 0) { usepet_btn.SetActive(true); lastTime = PlayerModel.getInstance().last_time - muNetCleint.instance.CurServerTimeStamp;//当前饲料剩余时间 } first = PlayerModel.getInstance().first; debug.Log("first:" + first.ToString() + " last_time:" + lastTime); petgo = new petGO(); timeGo = transform.FindChild("timeBuy/Text").GetComponent <Text>(); sliderGo = getGameObjectByPath("timeBuy/expbar/slider"); if (first) { getGameObjectByPath("buyshow/scollBuy/content/buy0").SetActive(true); } else { getGameObjectByPath("buyshow/scollBuy/content/buy0").SetActive(false); } //A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_GET_LAST_TIME, getlastTime); A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_GET_PET, getPet); //A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_SHOW_PET, showPet); //A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_FEED_PET, feedPet); //A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_HAVE_PET, havePet); //if (lastTime <= -1) //{ // lastTime = -1; // getGameObjectByPath("timeBuy/buyIt").SetActive(false); //} #region button new BaseButton(getTransformByPath("title/btn_close")).onClick = (GameObject go) => { InterfaceMgr.getInstance().close(InterfaceMgr.A3_NEW_PET); }; BaseButton touchClose = new BaseButton(getTransformByPath("buyshow/touchClose")); touchClose.onClick = close; new BaseButton(getTransformByPath("showSth/help")).onClick = (GameObject go) => { getGameObjectByPath("help").SetActive(true); }; new BaseButton(getTransformByPath("help/btn")).onClick = (GameObject go) => { getGameObjectByPath("help").SetActive(false); }; //金币钻石绑钻按钮 new BaseButton(getTransformByPath("top/jingbi/Image")).onClick = (GameObject go) => { InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_EXCHANGE); if (a3_exchange.Instance != null) { a3_exchange.Instance.transform.SetAsLastSibling(); } }; new BaseButton(getTransformByPath("top/zuanshi/Image")).onClick = (GameObject go) => { toback = true; InterfaceMgr.getInstance().close(this.uiName); InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_RECHARGE); }; new BaseButton(getTransformByPath("top/bangzuan/Image")).onClick = (GameObject go) => { InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_HONOR); if (a3_honor.instan != null) { a3_honor.instan.transform.SetAsLastSibling(); } }; //=============== //购买饲料 new BaseButton(getTransformByPath("timeBuy/buyIt")).onClick = (GameObject go) => { //if (all <= -1) //{ // flytxt.instance.fly(ContMgr.getCont("a3_new_pet_long")); //} //else getGameObjectByPath("buyshow").SetActive(true); }; //免费一天-----1\2\永久 new BaseButton(getTransformByPath("buyshow/scollBuy/content/buy0/image")).onClick = (GameObject go) => { A3_PetProxy.getInstance().SendTime(1); getGameObjectByPath("buyshow").SetActive(false); getGameObjectByPath("buyshow/scollBuy/content/buy0").SetActive(false); }; new BaseButton(getTransformByPath("buyshow/scollBuy/content/buy1/image")).onClick = (GameObject go) => { A3_PetProxy.getInstance().SendTime(2); getGameObjectByPath("buyshow").SetActive(false); }; new BaseButton(getTransformByPath("buyshow/scollBuy/content/buy2/image")).onClick = (GameObject go) => { A3_PetProxy.getInstance().SendTime(3); getGameObjectByPath("buyshow").SetActive(false); }; new BaseButton(getTransformByPath("buyshow/scollBuy/content/buy3/image")).onClick = (GameObject go) => { getGameObjectByPath("buyshow").SetActive(false); A3_PetProxy.getInstance().SendTime(4); List <SXML> buyList = XMLMgr.instance.GetSXMLList("newpet.buy.b", "id==" + 4); int zuan = buyList[0].getInt("zuan"); //if (zuan <= PlayerModel.getInstance().gold) // getGameObjectByPath("timeBuy/buyIt").SetActive(false); }; //=============== #endregion iconTemp = getGameObjectByPath("icon_temp"); xml = XMLMgr.instance.GetSXML("newpet"); list = xml.GetNodeList("pet"); petNum = list.Count; cont = getTransformByPath("scoll/cont"); sizeY = cont.GetComponent <GridLayoutGroup>().cellSize.y; cont.GetComponent <RectTransform>().sizeDelta = new Vector2(130f, sizeY * petNum); transform.FindChild("ig_bg_bg").gameObject.SetActive(false); getEventTrigerByPath("rotate").onDrag = OnDrag; #region 宠物icon按钮 A3_PetModel petmodel = A3_PetModel.getInstance(); getTransformByPath("shuxing/exp/Text").GetComponent <Text>().text = ContMgr.getCont("a3_new_pet_1") + list[0].getInt("exp") + "%"; getTransformByPath("shuxing/gold/Text").GetComponent <Text>().text = ContMgr.getCont("a3_new_pet_2") + list[0].getInt("gold") + "%"; getTransformByPath("shuxing/equip/Text").GetComponent <Text>().text = ContMgr.getCont("a3_new_pet_3") + list[0].getInt("arm") + "%"; getTransformByPath("shuxing/mate/Text").GetComponent <Text>().text = ContMgr.getCont("a3_new_pet_4") + list[0].getInt("mat") + "%"; foreach (var item in list) { goIcon = Instantiate(iconTemp) as GameObject; goIcon.transform.SetParent(getTransformByPath("scoll/cont")); goIcon.name = item.getString("pet_id"); goIcon.SetActive(true); goIcon.transform.localScale = Vector3.one; String str = "scoll/cont/" + goIcon.name + "/icon_bg/icon"; transform.FindChild("scoll/cont/" + list[0].getString("pet_id") + "/icon_bg/image_on").gameObject.SetActive(true); string names = item.getString("mod"); // if (names == "jiexi") // names = "yingwu"; getTransformByPath(str).GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite("icon_pet_" + names); new BaseButton(transform.FindChild("scoll/cont/" + goIcon.name + "/icon_bg/icon")).onClick = (GameObject go) => { chosenpetBtnOnClick(go, false); }; new BaseButton(transform.FindChild("scoll/cont/" + goIcon.name + "/lock")).onClick = (GameObject go) => { chosenpetBtnOnClick(go, true); }; } timeSet(lastTime); CancelInvoke("time"); InvokeRepeating("time", 0, 1); if (A3_PetModel.curPetid != 0) { transform.FindChild("scoll/cont/" + A3_PetModel.curPetid + "/icon_bg/yuxuan_on").gameObject.SetActive(true); } #endregion getPet0(); if (a3_everydayLogin.instans != null && a3_everydayLogin.instans.open) { InterfaceMgr.getInstance().close(InterfaceMgr.A3_EVERYDAYLOGIN); openEveryLogin = true; } new BaseButton(usepet_btn.transform).onClick = (GameObject go) => { if (A3_PetModel.curPetid == old_petid) { flytxt.instance.fly(ContMgr.getCont("pet_this_old")); return; } for (int i = 0; i < getTransformByPath("scoll/cont").childCount; i++) { if (int.Parse(getTransformByPath("scoll/cont").GetChild(i).gameObject.name) == petid) { getTransformByPath("scoll/cont").GetChild(i).FindChild("icon_bg/yuxuan_on").gameObject.SetActive(true); } else { getTransformByPath("scoll/cont").GetChild(i).FindChild("icon_bg/yuxuan_on").gameObject.SetActive(false); } } A3_PetProxy.getInstance().SendPetId(petid); //发送换宠物 }; }