aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/FinalMission/QuestViewer.cs
blob: 2a943e59a9e157c01b1661f119662360d1222ee1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ShiftUI;

namespace ShiftOS.FinalMission
{
    public partial class QuestViewer : Form
    {
        public QuestViewer()
        {
            InitializeComponent();
        }

        private void QuestViewer_Load(object sender, EventArgs e)
        {
            SetupList();
            StartQuestCheckThread();
            var tmr = new ShiftUI.Timer();
            tmr.Interval = 500;
            tmr.Tick += (object s, EventArgs a) =>
            {
                SetupList();
            };
            tmr.Start();
        }

        public void SetupList()
        {
            lbobjectives.Items.Clear();
            foreach(var itm in EndGameHandler.ThingsToDo)
            {
                lbobjectives.Items.Add(itm.Key);
            }
        }

        public void StartQuestCheckThread()
        {
            var t = new Thread(new ThreadStart(new Action(() => {
                //Start checkloop.
                while(true)
                {
                    CheckObjective(EndGameHandler.CurrentObjective);
                }
            })));
            t.Start();
        }

        public void CheckObjective(string obj)
        {
            if(EndGameHandler.ThingsToDo[obj] == true)
            {
                EndGameHandler.GoToNextObjective();
            }
        }
    }
}