Example #1
0
    private string MarkTaskComplete(string s)
    {
        currentTask.isComplete = true;
        if (!s.Equals("nul", StringComparison.InvariantCultureIgnoreCase) && !s.Equals("win", StringComparison.InvariantCultureIgnoreCase))
        {
            Debug.Log("NOT NUL");
            string[] parts = s.Split(new string[] { ">>" }, StringSplitOptions.None);
            s = parts[1];
            string[] rtask  = parts[0].Split(':');
            GameTask remove = GameTask.findGameTaskByID(rtask[1]);
            Debug.Log("PARTS");
            Debug.Log(remove);
            Debug.Log(parts[0]);
            GameTask t = ParseTask(s);
            if (remove == null) // try finding by name
            {
                foreach (var T in tasks)
                {
                    if (T.name.StartsWith(rtask[0], StringComparison.InvariantCultureIgnoreCase))
                    {
                        remove = T;
                        break;
                    }
                }
            }

            if (remove != null)
            {
                tasks.Remove(remove);
                tasks.Add(t);
            }
            else
            {
                foreach (var tas in tasks)
                {
                    if (tas.name.Equals(currentTask.name))
                    {
                        Debug.Log("TASK MATCH -- " + tas);
                        tas.isComplete = true;
                        break;
                    }
                }
            }
        }
        else
        {
            foreach (var tas in tasks)
            {
                if (tas.name.Equals(currentTask.name))
                {
                    Debug.Log("TASK MATCH -- " + tas);
                    tas.isComplete = true;
                    break;
                }
            }
        } // test with GR1, CL, Funk station (fix wiring)

        if (playerData == null)
        {
            Debug.Log("NULL DATA");
            playerData = PlayerData.FindLocalPlayer();
            //playerData = PlayerData.FindLocalPlayer();
        }
        if (playerData == null)
        {
            return("ERR--no player data found");
        }

        playerData.ReloadTaskListScene(tasks);
        if (s.Equals("win", StringComparison.InvariantCultureIgnoreCase))
        {
            StartCoroutine(Delay(.5f, OpenWinPanel));
        }
        //*/
        return("");
    }