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"); }
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 OnSyncAutoBuy(Variant data) { A3_PetModel instance = ModelBase <A3_PetModel> .getInstance(); bool flag = data["auto_buy_feeds"] == 0; if (flag) { instance.Auto_buy = false; } else { instance.Auto_buy = true; } int itemNumByTpid = ModelBase <a3_BagModel> .getInstance().getItemNumByTpid(instance.GetFeedItemTpid()); bool flag2 = instance.Auto_buy && itemNumByTpid <= 0; if (flag2) { ModelBase <A3_PetModel> .getInstance().AutoBuy(); } }