Ejemplo n.º 1
0
    IEnumerator CheckTasks()
    {
        yield return(new WaitForSeconds(2f));

        GameObject win = GameObject.Find("Distribution Window");

        Destroy(win);


        Task[] tasks = taskCreator.tasks;

        SetWinNum(tasks.Length);

        District[] districts = distMan.districts;
        string     winOrLose = "";
        string     goal      = "";
        int        taskNum   = 0;

        foreach (Task task in tasks)
        {
            District currDist = null;

            foreach (District district in districts)
            {
                if (district.name.Equals(task.GetDistrict(), StringComparison.InvariantCultureIgnoreCase))
                {
                    currDist = district;
                }
            }

            //print(task.GetDistrict() + " = " + currDist.name + "?");
            //print(task.GetGoal() + " " + task.GetScore() + ", " + currDist.name + ": " + currDist.GetResource(task.GetResource()));
            //if (task.GetResource().Contains("Power")) {
            goal = task.GetGoal().Trim();
            //print("(" + goal + ") equals 'Allocate'? " + (goal == "Allocate"));
            //print("(" + goal + ") equals 'Don't Allocate'? " + (goal == "Don't Allocate"));

            if (task.GetGoal().Equals("Don't Allocate"))
            {
                if (task.GetScore() >= currDist.GetResource(task.GetResource()))
                {
                    winOrLose = "Win";
                }

                else
                {
                    winOrLose = "Lose";
                }
            }

            else if (task.GetGoal().Equals("Allocate"))
            {
                if (task.GetScore() <= currDist.GetResource(task.GetResource()))
                {
                    winOrLose = "Win";
                }

                else
                {
                    winOrLose = "Lose";
                }
            }

            if (winOrLose.Equals("Win"))
            {
                Blink blink = GameObject.Find(currDist.name.ToUpper() + " Menu Bar Background").GetComponent <Blink>();
                blink.BlinkWin();
                if (!arbeauOff)
                {
                    taskCreator.SpawnArbeauWinLose(taskNum, winOrLose);
                }
            }

            else if (winOrLose.Equals("Lose"))
            {
                foreach (District district in distMan.districts)
                {
                    if (currDist.name.Equals(district.name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (district.GetUnrest() >= 5)
                        {
                            district.CloseDistrict();
                            //print(district.name + "is closed");
                            Blink blink = GameObject.Find(currDist.name.ToUpper() + " Menu Bar Background").GetComponent <Blink>();
                            blink.SetClose();

                            int closeIndex;
                            closeMap.TryGetValue(currDist.name, out closeIndex);

                            taskCreator.SpawnArbeauClose(closeIndex);

                            closedCnt++;
                            print("closedCnt: " + closedCnt);
                        }

                        else
                        {
                            Blink blink = GameObject.Find(currDist.name.ToUpper() + " Menu Bar Background").GetComponent <Blink>();
                            blink.BlinkLose();
                            if (!arbeauOff)
                            {
                                taskCreator.SpawnArbeauWinLose(taskNum, winOrLose);
                            }
                        }

                        district.IncrementUnrest();
                    }
                }
            }


            winOrLose = "";

            taskNum++;
            //}
        }
        //print("increment round");
        round++;
    }