Beispiel #1
0
        private void GetMissionData()
        {
            dynamic resp = Post("/mission", "");
            if (resp != null && resp.errorCode == 0)
            {
                LogInfo("刷新任务信息");
                var scenario = new MojoMissionScenario
                {
                    Name = resp.data.cur_scenario.name,
                    Order = resp.data.cur_scenario.order,
                    ScenarioId = resp.data.cur_scenario.scenario_id,
                    Unlock = resp.data.cur_scenario.unlock
                };

                var groups = new List<MojoMissionTaskGroup>();
                MojoMissionTaskGroup curGroup = null;
                foreach (var g in resp.data.task_groups)
                {
                    var new_g = new MojoMissionTaskGroup
                    {
                        Level = g.level,
                        Name = g.name,
                        Order = g.order,
                        ScenarioId = g.scenario_id,
                        TaskGroupId = g.task_group_id,
                        Unlock = g.unlock
                    };
                    groups.Add(new_g);

                    if (new_g.TaskGroupId == (string)resp.data.cur_task_group.task_group_id)
                    {
                        curGroup = new_g;
                    }
                }

                var tasks = new List<MojoMissionTask>();
                foreach (var t in resp.data.tasks)
                {
                    var new_t = new MojoMissionTask
                    {
                        Status = t.status,
                        Unlock = t.unlock,
                        Count = t.count,
                        EP = t.ep,
                        Id = t.id,
                        Level = t.level,
                        Name = t.name,
                        ScenarioId = t.scenario_id,
                        SumCount = t.sum_count,
                        TaskGroupId = t.task_group_id,
                        TaskId = t.task_id
                    };
                    tasks.Add(new_t);
                }

                SGLL.Data.MissionData = new MojoMissionData
                {
                    Tasks = tasks,
                    TaskGroups = groups,
                    CurTaskGroup = curGroup,
                    CurScenario = scenario
                };
            }
            SGLL.CallStatusUpdate(this, ChangedType.Mission);
        }
Beispiel #2
0
        public void Display()
        {
            DisplayStartStop();

            if (UpCall.Data != null && UpCall.Data.MissionData != null)
            {
                var md = UpCall.Data.MissionData;
                this.labelScenario.Text = md.CurScenario == null ? "--" : md.CurScenario.Name;

                // show groups
                if (md.CurScenario != null && (scenario == null || scenario.ScenarioId != md.CurScenario.ScenarioId))
                {
                    listViewEx1.Items.Clear();
                    scenario = md.CurScenario;
                }
                if (md.TaskGroups != null)
                {
                    var gi = listViewEx1.Items.Count == 0;
                    for (int i = 0; i < md.TaskGroups.Count; i++)
                    {
                        var g = md.TaskGroups[i];
                        if (gi)
                        {
                            ListViewItem lvi = listViewEx1.Items.Add(g.Name);
                            lvi.SubItems.Add(g.Level.ToString());
                        }
                        else
                            listViewEx1.Items[i].SubItems[1].Text = g.Level.ToString();

                        if (md.CurTaskGroup != null && md.CurTaskGroup.TaskGroupId == g.TaskGroupId)
                        {
                            listViewEx1.Items[i].BackColor = Color.LightGreen;
                        }
                        else
                            listViewEx1.Items[i].BackColor = Color.White;
                    }
                }

                // show tasks
                if (md.CurTaskGroup != null && (group == null || group.TaskGroupId != md.CurTaskGroup.TaskGroupId))
                {
                    listViewEx2.Items.Clear();
                    group = md.CurTaskGroup;
                }
                if (md.Tasks != null)
                {
                    var ti = listViewEx2.Items.Count == 0;
                    for (int i = 0; i < md.Tasks.Count; i++)
                    {
                        var t = md.Tasks[i];
                        ListViewItem lvi = null;
                        if (ti)
                        {
                            lvi = listViewEx2.Items.Add(t.Name);
                            lvi.SubItems.Add(t.EP.ToString());
                            lvi.SubItems.Add("");
                            ProgressBar pb = new ProgressBar();
                            pb.Maximum = t.SumCount;
                            pb.Value = t.Count;
                            listViewEx2.AddEmbeddedControl(pb, 2, i);
                        }
                        else
                        {
                            lvi = listViewEx2.Items[i];
                            lvi.SubItems[1].Text = t.EP.ToString();
                            ProgressBar pb = (ProgressBar)listViewEx2.GetEmbeddedControl(2, i);
                            if (pb != null && pb.Value != t.Count)
                            {
                                pb.Maximum = t.SumCount;
                                pb.Value = t.Count;
                            }
                        }
                    }
                }
            }
        }