Beispiel #1
0
 void OnClickPetShow(uint iid)
 {
     _curPetIid  = iid;
     _curPetData = PetModel.getInstance().GetPetDataByIid(iid);
     RefreshPetListCon();
     RefreshPetTrainCon();
     RefreshPetUpgrade();
 }
Beispiel #2
0
        public void Refresh()
        {
            PetData pd = PetModel.getInstance().GetPetDataByIid(_petiid);

            _rankTxt.text  = pd.rank.ToString();
            _levelTxt.text = "Lv." + pd.level.ToString();

            bool b = PetModel.getInstance().GetCanUpgrade(_petiid);

            _canUpgradeHint.gameObject.SetActive(b);

            b = PetModel.getInstance().IsHungry(_petiid);
            _hungryHint.gameObject.SetActive(b);
        }
Beispiel #3
0
        void RefreshAllPetsShow()
        {
            Dictionary <uint, PetData> allpet = PetModel.getInstance().Allpets;
            var etor = allpet.GetEnumerator();

            while (etor.MoveNext())
            {
                uint    iid = etor.Current.Key;
                PetShow ps  = null;
                if (!_petShows.TryGetValue(iid, out ps))
                {
                    ps             = new PetShow(_petShowGrid, _petShowPrefab, etor.Current.Key, OnClickPetShow);
                    _petShows[iid] = ps;
                }
                ps.Refresh();
            }
        }
Beispiel #4
0
        override public void init()
        {
            #region --右侧功能区初始化
            _petListCon    = transform.FindChild("petListCon");
            _petTrainCon   = transform.FindChild("petTrainCon");
            _petUpgradeCon = transform.FindChild("petUpgradeCon");
            #endregion

            #region --左侧列表初始化

            _petListBtn = transform.FindChild("leftList/scroll_view/container/petListBtn");
            BaseButton b_petListBtn = new BaseButton(_petListBtn, 0, 0);
            b_petListBtn.onClick = OnClickPetListBtn;

            _petTrainBtn = transform.FindChild("leftList/scroll_view/container/petTrainBtn");
            BaseButton b_petTrainBtn = new BaseButton(_petTrainBtn, 0, 0);
            b_petTrainBtn.onClick = OnClickPetTrainBtn;

            _petUpgradeBtn = transform.FindChild("leftList/scroll_view/container/petUpgradeBtn");
            BaseButton b_petUpgradeBtn = new BaseButton(_petUpgradeBtn, 0, 0);
            b_petUpgradeBtn.onClick = OnClickPetUpgradeBtn;

            #endregion

            #region --中间宠物展示初始化
            _petShowPrefab            = Resources.Load("prefab/pet_show") as GameObject;
            _petShowGrid              = transform.FindChild("petList/scroll_view/grid").GetComponent <GridLayoutGroup>();
            _petShowContentSizeFitter = _petShowGrid.GetComponent <ContentSizeFitter>();
            #endregion

            #region --宠物列表Container初始化
            _petListNameTxt  = transform.FindChild("petListCon/nametxt").GetComponent <Text>();
            _petListLevelTxt = transform.FindChild("petListCon/leveltxt").GetComponent <Text>();
            _hungrySlider    = transform.FindChild("petListCon/hungrySlider").GetComponent <Slider>();
            _hungrySliderTxt = transform.FindChild("petListCon/hungrySlider/hungryValTxt").GetComponent <Text>();
            _expSlider       = transform.FindChild("petListCon/expSlider").GetComponent <Slider>();
            _expSliderTxt    = transform.FindChild("petListCon/expSlider/expValTxt").GetComponent <Text>();
            _petListAtt      = transform.FindChild("petListCon/pet_att/petatts").gameObject;
            _hungryAutoUse   = transform.FindChild("petListCon/hungryAutoUse").GetComponent <Toggle>();
            _feedBtn         = transform.FindChild("petListCon/feedBtn").GetComponent <Button>();
            _recyleBtn       = transform.FindChild("petListCon/recyleBtn").GetComponent <Button>();
            _changeNameBtn   = transform.FindChild("petListCon/changeNameBtn").GetComponent <Button>();
            _useBtn          = transform.FindChild("petListCon/useBtn").GetComponent <Button>();
            #endregion

            #region --宠物培养Container初始化
            _petTrainNameTxt  = transform.FindChild("petTrainCon/nametxt").GetComponent <Text>();
            _petTrainLevelTxt = transform.FindChild("petTrainCon/leveltxt").GetComponent <Text>();
            _petTrainAtt      = transform.FindChild("petTrainCon/pet_att/petatts").gameObject;
            _blessSlider      = transform.FindChild("petTrainCon/blessBar").GetComponent <Slider>();
            _blessSliderTxt   = transform.FindChild("petTrainCon/blessBar/blessVal").GetComponent <Text>();
            _costGoldTxt      = transform.FindChild("petTrainCon/costGoldVal").GetComponent <Text>();
            _costBlessTxt     = transform.FindChild("petTrainCon/costBlessVal").GetComponent <Text>();
            _blessLeftTxt     = transform.FindChild("petTrainCon/blessLeftVal").GetComponent <Text>();
            _diamondAutoUse   = transform.FindChild("petTrainCon/diamondAutoUse").GetComponent <Toggle>();
            _blessBtn         = transform.FindChild("petTrainCon/blessBtn").GetComponent <Button>();
            #endregion

            #region --宠物进阶Container初始化
            _pet3DShowImg      = transform.FindChild("petUpgradeCon/showbg").gameObject;
            _pet3DShowPoint    = transform.FindChild("petUpgradeCon/showbg/showPoint").gameObject;
            _petUpgrdeSuccTxt  = transform.FindChild("petUpgradeCon/showbg/upgradeRateBg/successRate").GetComponent <Text>();
            _peticon           = transform.FindChild("petUpgradeCon/petbg/peticon").GetComponent <Image>();
            _crystalSlider     = transform.FindChild("petUpgradeCon/crystalSlider").GetComponent <Slider>();
            _petUpgradeGlodTxt = transform.FindChild("petUpgradeCon/gldval").GetComponent <Text>();
            _crystalCostTxt    = transform.FindChild("petUpgradeCon/crystalVal").GetComponent <Text>();
            _crystalLeftTxt    = transform.FindChild("petUpgradeCon/crystalLeftBg/crystalLeftVal").GetComponent <Text>();
            _upgradeBtn        = transform.FindChild("petUpgradeCon/upgradeBtn").GetComponent <Text>();

            EventTriggerListener.Get(_pet3DShowImg).onDrag = OnDragPet3D;
            #endregion

            //!--关闭按钮
            _closeBtn = transform.FindChild("closeBtn");
            BaseButton b_closeBtn = new BaseButton(_closeBtn, 0, 0);
            b_closeBtn.onClick = OnClose;

            //TODO 测试用代码
            PetModel.getInstance().DummyData();
        }