Ejemplo n.º 1
0
    void LateUpdate()
    {
        if (Automator.Enabled())
        {
            if (!controller.Paralyzed)
            {
                string action = Automator.Step();
                controller.PerformAction(action);
            }
            return;
        }

        if (!created)
        {
            if (!client.Calling)
            {
                client.Create(GenerateMessage());
                created = true;
            }
        }
        else
        {
            if (client.HasAction)
            {
                lastAction = client.GetAction();
                controller.PerformAction(lastAction);
            }
            if (!client.Calling)
            {
                client.Step(GenerateMessage());
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        rewardText.text = "Reward: " + Reward.Get();

        if (task.Success())
        {
            task.Reset();

            if (task.Done(Trials.GetSuccess(), Trials.GetFailure()))
            {
                task.Finish();

                PlayerPrefs.SetInt("Success Count", 0);
                PlayerPrefs.SetInt("Failure Count", 0);
                EditorSceneManager.LoadScene(Scenes.Next());
                return;
            }

            Trials.AddSuccess();

            PlayerPrefs.SetInt("Success Count", Trials.GetSuccess());
            PlayerPrefs.SetInt("Failure Count", Trials.GetFailure());
            EditorSceneManager.LoadScene(EditorSceneManager.GetActiveScene().name);
            return;
        }

        if (task.Failure())
        {
            if (Automator.Enabled())
            {
                Debug.LogError("You have enabled autorun but task has failed: check your automation sequence for task '" + PlayerPrefs.GetString("Task Name") + "'");
            }

            task.Reset();

            Trials.AddFailure();

            PlayerPrefs.SetInt("Success Count", Trials.GetSuccess());
            PlayerPrefs.SetInt("Failure Count", Trials.GetFailure());
            EditorSceneManager.LoadScene(EditorSceneManager.GetActiveScene().name);
            return;
        }

        elapsed += 1;

        PlayerPrefs.SetInt("Elapsed Time", elapsed);
    }
Ejemplo n.º 3
0
    void Start()
    {
        task = GetComponent <Task>();

        if (Automator.Enabled())
        {
            Automator.Setup(task.AutomationSequence());
        }

        Reward.Set(0.0F);

        if (!PlayerPrefs.HasKey("Task Name"))
        {
            PlayerPrefs.SetString("Task Name", task.Name());
            Trials.Reset();
        }

        if (PlayerPrefs.GetString("Task Name") != task.Name())
        {
            PlayerPrefs.SetString("Task Name", task.Name());
            Trials.Reset();
        }

        PlayerPrefs.SetInt("Elapsed Time", elapsed);

        int successCount = Trials.GetSuccess();
        int failureCount = Trials.GetFailure();

        task.Initialize(successCount, failureCount);

        if (Automator.Enabled())
        {
            Automator.Setup(task.AutomationSequence());
        }

        taskText.text    = PlayerPrefs.GetString("Task Name");
        successText.text = "Success: " + successCount;
        failureText.text = "Failure: " + failureCount;
        rewardText.text  = "Reward: 0";
    }