Пример #1
0
 private void RefreshProgress()
 {
     progressRoot.SetActive(false);
     completeRoot.SetActive(false);
     if (gotRoot != null)
     {
         gotRoot.SetActive(false);
     }
     if (taskInfo.isFinished)
     {
         if (taskInfo.isGetReward)
         {
             if (gotRoot != null)
             {
                 gotRoot.SetActive(true);
             }
         }
         else
         {
             completeRoot.SetActive(true);
         }
     }
     else
     {
         TaskConditionInfo conditionData = taskInfo.GetFirstCondition();
         int maxCount = conditionData.maxCount;
         progressRoot.SetActive(true);
         int   curCount = maxCount == 1 ? 0 : conditionData.value;
         float scale    = curCount / (maxCount + 0.0f);
         if (progressTran != null)
         {
             progressTran.localScale = new Vector3(scale, progressTran.localScale.y);
         }
         textProgress.text = string.Format(Localization.Get("common.value/max"), curCount, maxCount);
     }
 }
Пример #2
0
    //读取常规任务配置
    public void ReadTaskMainData()
    {
        string text = ResourceLoadManager.Instance.GetConfigText(name1);

        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name1);
            return;
        }
        taskMainConfig.Clear();

        //读取以及处理XML文本的类
        XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_TASK_MAIN, text);
        //解析xml的过程
        XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes;

        foreach (XmlElement xe in nodelist)
        {
            XmlNode comment = xe.SelectSingleNode(GlobalConst.CONFIG_SWITCH_COLUMN);
            if (comment != null && comment.InnerText == GlobalConst.CONFIG_SWITCH)
            {
                continue;
            }

            TaskConfig config = new TaskConfig();
            foreach (XmlElement xel in xe)
            {
                uint value;
                if (xel.Name == "id")
                {
                    uint.TryParse(xel.InnerText, out value);
                    config.id = value;
                }
                else if (xel.Name == "type")
                {
                    uint.TryParse(xel.InnerText, out value);
                    config.type = value;
                }
                else if (xel.Name == "icon")
                {
                    config.icon = xel.InnerText;
                }
                else if (xel.Name == "title")
                {
                    config.title = xel.InnerText;
                }
                else if (xel.Name == "desc")
                {
                    config.desc = xel.InnerText;
                }
                else if (xel.Name == "award_tips")
                {
                    config.award_tips = xel.InnerText;
                }
                else if (xel.Name == "award_id")
                {
                    uint.TryParse(xel.InnerText, out value);
                    config.award_id = value;
                }
                else if (xel.Name == "condition_id1")
                {
                    uint.TryParse(xel.InnerText, out value);
                }
                else if (xel.Name == "condition_value1")
                {
                    uint.TryParse(xel.InnerText, out value);
                }
                else if (xel.Name == "precondition_value1")
                {
                    uint.TryParse(xel.InnerText, out value);
                    if (config.precondition.Count <= 0)
                    {
                        TaskConditionInfo tc = new TaskConditionInfo();
                        tc.condition_value = value;
                        config.precondition.Add(tc);
                    }
                    else
                    {
                        config.precondition[0].condition_value = value;
                    }
                }

                else if (xel.Name == "precondition_id1")
                {
                    uint.TryParse(xel.InnerText, out value);

                    if (config.precondition.Count <= 0)
                    {
                        TaskConditionInfo tc = new TaskConditionInfo();
                        tc.condition_id = value;
                        config.precondition.Add(tc);
                    }
                    else
                    {
                        config.precondition[0].condition_id = value;
                    }
                }
                else if (xel.Name == "show_process")
                {
                    uint.TryParse(xel.InnerText, out value);
                    config.show_process = value;
                }
                else if (xel.Name == "link")
                {
                    if (xel.InnerText.Contains(":"))
                    {
                        string[] entirety = xel.InnerText.Split(':');
                        config.link.Add(uint.Parse(entirety[0]));
                        config.link.Add(uint.Parse(entirety[1]));
                    }
                    else
                    {
                        config.link.Add(uint.Parse(xel.InnerText));
                    }
                }
            }
            if (!taskMainConfig.ContainsKey(config.id))
            {
                taskMainConfig.Add(config.id, config);
            }
        }
    }