コード例 #1
0
        public override void onShowed()
        {
            A3_PetProxy.getInstance().GetPets();
            petmodel.OnExpChange += OnExpChange;
            //petmodel.OnStarvationChange += OnStarvationChange;
            // petmodel.OnAutoFeedChange += OnAutoFeedChange;
            petmodel.OnAutoFeedChange -= OnAutoBuyChange;
            petmodel.OnLevelChange    += OnLevelChange;
            petmodel.OnStageChange    += OnStageChange;

            OnExpChange();
            OnStarvationChange();
            OnAutoFeedChange();
            OnAutoBuyChange();
            OnLevelChange();
            OnStageChange();
            OnPetItemChange(null);

            BagProxy.getInstance().addEventListener(BagProxy.EVENT_ITEM_CHANGE, OnPetItemChange);

            //if (petmodel.Starvation < 20)
            //{
            //    String hint = ContMgr.getCont("pet_hungry");
            //    flytxt.instance.fly(hint);
            //}
        }
コード例 #2
0
        public void OpenPet()
        {
            var dt = transform.FindChild("tab/pet");

            if (dt)
            {
                dt.gameObject.SetActive(true);
            }
            A3_PetProxy.getInstance().GetPets();
        }
コード例 #3
0
 private void OnAutoBuyToggleChange(bool isOn)
 {
     if (isOn)
     {
         A3_PetProxy.getInstance().SetAutoBuy(1);
     }
     else
     {
         A3_PetProxy.getInstance().SetAutoBuy(0);
     }
 }
コード例 #4
0
        override public void onClosed()
        {
            // 军团buff另加。监听事件EVENT_REMOVE
            A3_LegionProxy.getInstance().removeEventListener(A3_LegionProxy.EVENT_QUIT, Quit);
            // A3_LegionProxy.getInstance().removeEventListener(A3_LegionProxy.EVENT_REMOVE, Quit);
            A3_LegionProxy.getInstance().removeEventListener(A3_LegionProxy.EVENT_CREATE, Join);
            A3_LegionProxy.getInstance().removeEventListener(A3_LegionProxy.EVENT_DELETECLAN, Deleteclan);
            //宠物buff另加。监听事件
            //A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_GET_PET, OpenPet);//得到宠物
            A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.CHANGE_PET, changePet);            //更换宠物
            A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_HAVE_PET, closePet);         //饲料到期
            A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_GET_LAST_TIME, get_pettime); //购买饲料

            BattleProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_GET_LAST_TIME, reshbuff);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public override void onClosed()
 {
     A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_GET_LAST_TIME, getlastTime);
     //A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_GET_PET, getPet);
     A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_SHOW_PET, showPet);
     A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_FEED_PET, feedPet);
     A3_PetProxy.getInstance().removeEventListener(A3_PetProxy.EVENT_HAVE_PET, havePet);
     UIClient.instance.removeEventListener(UI_EVENT.ON_MONEY_CHANGE, onMoneyChange);
     A3_PetModel.showbuy = false;
     petgo.canshow       = false;
     petgo.disposeAvatar();
     InterfaceMgr.getInstance().changeState(InterfaceMgr.STATE_NORMAL);
     GRMap.GAME_CAMERA.SetActive(true);
     if (openEveryLogin)
     {
         welfareProxy.getInstance()._isShowEveryDataLogin = false;
         welfareProxy.getInstance().sendWelfare(welfareProxy.ActiveType.selfWelfareInfo);
         openEveryLogin = false;
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        private void OnStage(GameObject go)
        {
            uint costnum = currentStage.getUint("crystal");

            A3_PetProxy.getInstance().Stage((int)costnum);
        }
コード例 #9
0
        private void OnOnekey(GameObject go)
        {
            Toggle toggle = getComponentByPath <Toggle>("exp_con/toggle");

            A3_PetProxy.getInstance().OneKeyBless(toggle.isOn);
        }
コード例 #10
0
        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);    //发送换宠物
            };
        }
コード例 #11
0
 public A3_PetModel() : base()
 {
     A3_PetProxy.getInstance().addEventListener(A3_PetProxy.EVENT_USE_PETFEED, OnMonitorFeed);
 }