Exemple #1
0
        //初始化所有成就数据
        private void InitAchievementDic()
        {
            dicAchievementData = new Dictionary <uint, AchievementData>();
            listCategory       = new List <uint>();
            listCategory.Add(0);
            int length = AchievementXML.Count;

            for (int i = 0; i < length; i++)
            {
                AchievementData data = new AchievementData();

                data.id        = AchievementXML[i].getUint("achievement_id");
                data.category  = AchievementXML[i].getUint("category");
                data.name      = AchievementXML[i].getString("name");
                data.type      = AchievementXML[i].getUint("type");
                data.bndyb     = AchievementXML[i].getUint("bndyb");
                data.point     = AchievementXML[i].getUint("point");
                data.condition = AchievementXML[i].getUint("param1");
                data.value     = AchievementXML[i].getUint("param2");
                data.desc      = AchievementXML[i].getString("desc");
                data.degree    = 0;

                if (!listCategory.Contains(data.category))
                {
                    listCategory.Add(data.category);
                }

                dicAchievementData[data.id] = data;
            }
        }
        private void InitAchievementDic()
        {
            this.dicAchievementData = new Dictionary <uint, AchievementData>();
            this.listCategory       = new List <uint>();
            this.listCategory.Add(0u);
            int count = this.AchievementXML.Count;

            for (int i = 0; i < count; i++)
            {
                AchievementData achievementData = new AchievementData();
                achievementData.id        = this.AchievementXML[i].getUint("achievement_id");
                achievementData.category  = this.AchievementXML[i].getUint("category");
                achievementData.name      = this.AchievementXML[i].getString("name");
                achievementData.type      = this.AchievementXML[i].getUint("type");
                achievementData.bndyb     = this.AchievementXML[i].getUint("bndyb");
                achievementData.point     = this.AchievementXML[i].getUint("point");
                achievementData.condition = this.AchievementXML[i].getUint("param1");
                achievementData.value     = this.AchievementXML[i].getUint("param2");
                achievementData.desc      = this.AchievementXML[i].getString("desc");
                achievementData.degree    = 0u;
                bool flag = !this.listCategory.Contains(achievementData.category);
                if (flag)
                {
                    this.listCategory.Add(achievementData.category);
                }
                this.dicAchievementData[achievementData.id] = achievementData;
            }
        }
        public List <AchievementData> GetAchievenementDataByType(uint category)
        {
            List <AchievementData> list  = new List <AchievementData>();
            List <AchievementData> list2 = new List <AchievementData>();
            List <AchievementData> list3 = new List <AchievementData>();
            List <AchievementData> list4 = new List <AchievementData>();

            foreach (uint current in this.dicAchievementData.Keys)
            {
                AchievementData achievementData = this.dicAchievementData[current];
                bool            flag            = category == 0u || achievementData.category == category;
                if (flag)
                {
                    switch (achievementData.state)
                    {
                    case AchievementState.UNREACHED:
                        list4.Add(achievementData);
                        break;

                    case AchievementState.REACHED:
                        list2.Add(achievementData);
                        break;

                    case AchievementState.RECEIVED:
                        list3.Add(achievementData);
                        break;
                    }
                }
            }
            list.AddRange(list2);
            list.AddRange(list4);
            list.AddRange(list3);
            return(list);
        }
        public AchievementData GetAchievementDataByID(uint id)
        {
            AchievementData result = null;
            bool            flag   = this.dicAchievementData.ContainsKey(id);

            if (flag)
            {
                result = this.dicAchievementData[id];
            }
            return(result);
        }
Exemple #5
0
        //更具成就ID获取成就信息
        public AchievementData GetAchievementDataByID(uint id)
        {
            AchievementData data = null;

            if (dicAchievementData.ContainsKey(id))
            {
                data = dicAchievementData[id];
            }

            return(data);
        }
Exemple #6
0
        //显示成就页面
        private void OnShowAchievementPage(uint showType, int pageIndex)
        {
            List <AchievementData> listData = achModel.GetAchievenementDataByType(showType);
            int curIndex = maxNum * pageIndex;

            if (curIndex >= listData.Count)
            {
                return;
            }

            OnShowSelect(showType, pageIndex);
            ClearContainer();

            for (int i = 0; i < maxNum; i++)
            {
                int index = curIndex + i;
                if (index >= listData.Count)
                {
                    return;
                }
                GameObject clone = (GameObject)GameObject.Instantiate(tempPage);

                AchievementData data = listData[index];

                clone.name = data.id.ToString();

                Text textPoint = clone.transform.FindChild("Image_point/text_point").GetComponent <Text>();
                Text textTitle = clone.transform.FindChild("text_1").GetComponent <Text>();
                Text textDesc  = clone.transform.FindChild("text_state").GetComponent <Text>();

                textPoint.text = data.point.ToString();
                textTitle.text = data.name;
                textDesc.text  = data.desc;

                OnRefreshPageState(clone, data);

                clone.transform.SetParent(conPage, false);
                clone.SetActive(true);

                dicPage[data.id] = clone;
            }

            //初始化容器位置
            RectTransform rect   = conPage.GetComponent <RectTransform>();
            Vector2       newPos = new Vector2(rect.anchoredPosition.x, 0);

            rect.anchoredPosition = newPos;
            scrollPage.StopMovement();
        }
Exemple #7
0
        public void OnRefreshPageEvent(GameEvent e)
        {
            List <uint> listAchievementChange = this.achModel.listAchievementChange;

            foreach (uint current in listAchievementChange)
            {
                bool flag = this.dicPage.ContainsKey(current);
                if (flag)
                {
                    GameObject      page = this.dicPage[current];
                    AchievementData achievementDataByID = this.achModel.GetAchievementDataByID(current);
                    this.OnRefreshPageState(page, achievementDataByID);
                }
            }
            this.achModel.listAchievementChange.Clear();
        }
Exemple #8
0
        private void SortPage(GameObject page, AchievementData data)
        {
            switch (data.state)
            {
            case AchievementState.REACHED:
                page.transform.SetAsFirstSibling();
                break;

            case AchievementState.RECEIVED:
                page.transform.SetAsLastSibling();
                this.ClearContainer();
                this.scrollPage.StopMovement();
                this.OnPointChange();
                this.OnShowAchievementPage(this.selectType, this.pageIndex);
                break;
            }
        }
Exemple #9
0
        //刷新成就面板事件
        public void OnRefreshPageEvent(GameEvent e)
        {
            //成就的变化
            List <uint> list = achModel.listAchievementChange;

            foreach (uint id in list)
            {
                if (dicPage.ContainsKey(id))
                {
                    GameObject      tempPage = dicPage[id];
                    AchievementData data     = achModel.GetAchievementDataByID(id);

                    OnRefreshPageState(tempPage, data);
                }
            }

            achModel.listAchievementChange.Clear();
        }
Exemple #10
0
        //领取奖励
        private void OnShowGetPrize(GameEvent e)
        {
            uint            id   = achModel.GetAchievementID;
            AchievementData data = achModel.GetAchievementDataByID(id);

            uint bndyb = data.bndyb;

            if (bndyb > 0)
            {
                flytxt.instance.fly(ContMgr.getCont("a3_honor_getbz") + bndyb);
            }
            if (dicPage.ContainsKey(id))
            {
                GameObject page = dicPage[id];

                OnRefreshPageState(page, data);
                SortPage(page, data);
            }
        }
Exemple #11
0
        //通过类型选取相应的成就, 如果是0, 则返回全部成就信息
        public List <AchievementData> GetAchievenementDataByType(uint category)
        {
            //if (category == 0)
            //    return dicAchievementData.Values.ToList<AchievementData>();

            List <AchievementData> listData = new List <AchievementData>();

            List <AchievementData> listReached   = new List <AchievementData>();
            List <AchievementData> listReceiced  = new List <AchievementData>();
            List <AchievementData> listUnreached = new List <AchievementData>();

            foreach (uint key in dicAchievementData.Keys)
            {
                AchievementData data = dicAchievementData[key];

                if (category == 0 || data.category == category)
                {
                    switch (data.state)
                    {
                    case AchievementState.UNREACHED:
                        listUnreached.Add(data);
                        break;

                    case AchievementState.REACHED:
                        listReached.Add(data);
                        break;

                    case AchievementState.RECEIVED:
                        listReceiced.Add(data);
                        break;

                    default:
                        break;
                    }
                }
            }
            listData.AddRange(listReached);
            listData.AddRange(listUnreached);
            listData.AddRange(listReceiced);

            return(listData);
        }
Exemple #12
0
        private void OnShowGetPrize(GameEvent e)
        {
            uint            getAchievementID    = this.achModel.GetAchievementID;
            AchievementData achievementDataByID = this.achModel.GetAchievementDataByID(getAchievementID);
            uint            bndyb = achievementDataByID.bndyb;
            bool            flag  = bndyb > 0u;

            if (flag)
            {
                flytxt.instance.fly("获得绑定钻石 :" + bndyb, 0, default(Color), null);
            }
            bool flag2 = this.dicPage.ContainsKey(getAchievementID);

            if (flag2)
            {
                GameObject page = this.dicPage[getAchievementID];
                this.OnRefreshPageState(page, achievementDataByID);
                this.SortPage(page, achievementDataByID);
            }
        }
Exemple #13
0
        private void OnShowAchievementPage(uint showType, int pageIndex)
        {
            List <AchievementData> achievenementDataByType = this.achModel.GetAchievenementDataByType(showType);
            int  num  = this.maxNum * pageIndex;
            bool flag = num >= achievenementDataByType.Count;

            if (!flag)
            {
                this.OnShowSelect(showType, pageIndex);
                this.ClearContainer();
                for (int i = 0; i < this.maxNum; i++)
                {
                    int  num2  = num + i;
                    bool flag2 = num2 >= achievenementDataByType.Count;
                    if (flag2)
                    {
                        return;
                    }
                    GameObject      gameObject      = UnityEngine.Object.Instantiate <GameObject>(this.tempPage);
                    AchievementData achievementData = achievenementDataByType[num2];
                    gameObject.name = achievementData.id.ToString();
                    Text component  = gameObject.transform.FindChild("Image_point/text_point").GetComponent <Text>();
                    Text component2 = gameObject.transform.FindChild("text_1").GetComponent <Text>();
                    Text component3 = gameObject.transform.FindChild("text_state").GetComponent <Text>();
                    component.text  = achievementData.point.ToString();
                    component2.text = achievementData.name;
                    component3.text = achievementData.desc;
                    this.OnRefreshPageState(gameObject, achievementData);
                    gameObject.transform.SetParent(this.conPage, false);
                    gameObject.SetActive(true);
                    this.dicPage[achievementData.id] = gameObject;
                }
                RectTransform component4       = this.conPage.GetComponent <RectTransform>();
                Vector2       anchoredPosition = new Vector2(component4.anchoredPosition.x, 0f);
                component4.anchoredPosition = anchoredPosition;
                this.scrollPage.StopMovement();
            }
        }
Exemple #14
0
        //刷新指定成就的状态
        private void OnRefreshPageState(GameObject page, AchievementData data)
        {
            //TODO 刷新指定的page
            Text       textDrgee   = page.transform.FindChild("text_state/text_plan").GetComponent <Text>();
            Slider     sliderState = page.transform.FindChild("expbar/slider").GetComponent <Slider>();
            BaseButton btnGet      = new BaseButton(page.transform.FindChild("btn_get"));
            Transform  conPrize    = page.transform.FindChild("con_prize");
            Text       numtext     = null;
            var        numtra      = page.transform.FindChild("con_prize/panel_0/icon/Text");

            if (numtra != null)
            {
                numtext = numtra.GetComponent <Text>();
            }

            switch (data.state)
            {
            case AchievementState.UNREACHED:
                btnGet.gameObject.SetActive(false);
                conPrize.GetChild(0).gameObject.SetActive(true);
                conPrize.GetChild(1).gameObject.SetActive(false);
                if (data.bndyb == 0)
                {
                    numtext.transform.parent.gameObject.SetActive(false);
                    conPrize.GetComponent <Image>().enabled = false;
                }
                numtext.text = data.bndyb.ToString();
                break;

            case AchievementState.REACHED:
                btnGet.gameObject.SetActive(true);
                btnGet.onClick = OnGetPrzieClick;
                conPrize.GetChild(0).gameObject.SetActive(true);
                conPrize.GetChild(1).gameObject.SetActive(false);
                if (data.bndyb == 0)
                {
                    numtext.transform.parent.gameObject.SetActive(false);
                    conPrize.GetComponent <Image>().enabled = false;
                }
                numtext.text = data.bndyb.ToString();
                break;

            case AchievementState.RECEIVED:
                btnGet.gameObject.SetActive(false);
                conPrize.GetChild(0).gameObject.SetActive(false);
                conPrize.GetChild(1).gameObject.SetActive(true);
                if (data.bndyb == 0)
                {
                    numtext.transform.parent.gameObject.SetActive(false);
                }
                numtext.text = "";
                break;

            default:
                break;
            }

            textDrgee.text = "(" + (data.degree > data.condition ? data.condition : data.degree) + "/" + data.condition + ")";

            sliderState.maxValue = data.condition;
            sliderState.value    = data.degree;
        }
Exemple #15
0
        private void OnRefreshPageState(GameObject page, AchievementData data)
        {
            Text       component  = page.transform.FindChild("text_state/text_plan").GetComponent <Text>();
            Slider     component2 = page.transform.FindChild("expbar/slider").GetComponent <Slider>();
            BaseButton baseButton = new BaseButton(page.transform.FindChild("btn_get"), 1, 1);
            Transform  transform  = page.transform.FindChild("con_prize");
            Text       text       = null;
            Transform  transform2 = page.transform.FindChild("con_prize/panel_0/icon/Text");
            bool       flag       = transform2 != null;

            if (flag)
            {
                text = transform2.GetComponent <Text>();
            }
            switch (data.state)
            {
            case AchievementState.UNREACHED:
            {
                baseButton.gameObject.SetActive(false);
                transform.GetChild(0).gameObject.SetActive(true);
                transform.GetChild(1).gameObject.SetActive(false);
                bool flag2 = data.bndyb == 0u;
                if (flag2)
                {
                    text.transform.parent.gameObject.SetActive(false);
                    transform.GetComponent <Image>().enabled = false;
                }
                text.text = data.bndyb.ToString();
                break;
            }

            case AchievementState.REACHED:
            {
                baseButton.gameObject.SetActive(true);
                baseButton.onClick = new Action <GameObject>(this.OnGetPrzieClick);
                transform.GetChild(0).gameObject.SetActive(true);
                transform.GetChild(1).gameObject.SetActive(false);
                bool flag3 = data.bndyb == 0u;
                if (flag3)
                {
                    text.transform.parent.gameObject.SetActive(false);
                    transform.GetComponent <Image>().enabled = false;
                }
                text.text = data.bndyb.ToString();
                break;
            }

            case AchievementState.RECEIVED:
            {
                baseButton.gameObject.SetActive(false);
                transform.GetChild(0).gameObject.SetActive(false);
                transform.GetChild(1).gameObject.SetActive(true);
                bool flag4 = data.bndyb == 0u;
                if (flag4)
                {
                    text.transform.parent.gameObject.SetActive(false);
                }
                text.text = "";
                break;
            }
            }
            component.text = string.Concat(new object[]
            {
                "(",
                (data.degree > data.condition) ? data.condition : data.degree,
                "/",
                data.condition,
                ")"
            });
            component2.maxValue = data.condition;
            component2.value    = data.degree;
        }