Example #1
0
    /// <summary>
    /// Generate task
    /// </summary>
    /// <param name="slot">The slot the instrument argument is supposed to go in</param>
    /// <param name="instrument">The instrument for this task</param>
    public InstrumentPositionTask(InstrumentPositionTaskSlot slot, Instrument.INSTRUMENT_TAG instrument)
    {
        // Hacky: all tasks of this type have the same instruction, which is currently hardcoded
        // (this feature was requested later in the project and the 'Task' class wasn't very suitable for this particular type)
        instructions.Add("New task: position the instruments for a <b><u>Spay dog</u></b>");

        m_slot       = slot;
        m_instrument = instrument;
    }
Example #2
0
    public void PlaceInstrument(Instrument.INSTRUMENT_TAG instrument, GameObject parent)
    {
        // Get the instrument with each tag in the instrument gameobject list.
        // Also ensure there's no repeated instruments in the template list.
        List <Instrument> taggedGameObjects = InstrumentGameObjects.FindAll(a => a.instrumentTag == instrument);

        Assert.AreEqual(taggedGameObjects.Count, 1, "Duplicate INSTRUMENT_TAG in the InstrumentGameObjects");
        Instrument instrumentToPlace = taggedGameObjects[0];
        var        obj = Instantiate <GameObject>(instrumentToPlace.gameObject);

        MoveInstrument(obj, parent);
    }
Example #3
0
    /// <summary>
    /// Check if the instrument was placed in the right slot
    /// </summary>
    /// <param name="list">List of generic arguments. Index 0 must be the instrument selected tag, index 1 must be the slot it was placed in</param>
    /// <returns>Whether the task was completed successfully</returns>
    public override STATUS Evaluate(params object[] list)
    {
        Instrument.INSTRUMENT_TAG  instrumentSelected = (Instrument.INSTRUMENT_TAG)list[0];
        InstrumentPositionTaskSlot slotPlacedTo       = (InstrumentPositionTaskSlot)list[1];
        Session session = (Session)list[2];

        if (slotPlacedTo != m_slot)
        {
            session.sessionResults.Log_FailedToPositionInstrument(slotPlacedTo.CorrectInstrument, instrumentSelected);
            return(STATUS.COMPLETED_FAIL);
        }
        else
        {
            session.sessionResults.Log_CorrectlyPositionedInstrument(instrumentSelected);
            return(STATUS.COMPLETED_SUCCESS);
        }
    }
Example #4
0
    // Start is called before the first frame update
    // GameManager is set to be compiled after Player.cs, so when setting the game mode, the player reference is valid (see Project Setting -> Script execution order)
    void Start()
    {
        // Initialize other managers here
        GUIManager.Instance.Init();
        Player.Instance.Init();
        GUIManager.Instance.ConfigureCursor(true, CursorLockMode.None);
        Player.Instance.FreezePlayer(true);

        string order = PlayerPrefs.GetString("InstrumentOrder");

        if (!order.Equals(""))
        {
            InstrumentLocManager.Instance.PlaceInstrumentsInOrder(order);
        }
        else
        {
            // Read insturment order
            List <Instrument.INSTRUMENT_TAG> allTags = new List <Instrument.INSTRUMENT_TAG>();

            foreach (Instrument.INSTRUMENT_TAG tag in Enum.GetValues(typeof(Instrument.INSTRUMENT_TAG)))
            {
                if (tag != Instrument.INSTRUMENT_TAG.NONE)
                {
                    allTags.Add(tag);
                }
            }

            //Shuffle
            System.Random rand = new System.Random();
            int           n    = allTags.Count;
            while (n > 1)
            {
                n--;
                int k = rand.Next(n);
                Instrument.INSTRUMENT_TAG value = allTags[k];
                allTags[k] = allTags[n];
                allTags[n] = value;
            }

            InstrumentLocManager.Instance.PlaceInstrumentsInOrder(allTags);
        }

        assessmentMode = PlayerPrefs.GetInt("AssessmentMode", 0) == 1;
        GUIManager.Instance.GetMainCanvas().SetSceneSelectionGUIOn(false);
        GUIManager.Instance.GetMainCanvas().SetShowTutorialsPanelOn(true);
    }
    /*public override STATUS Evaluate(Instrument.INSTRUMENT_TAG instrumentTag, Session session)
     * {
     *  if (m_instrumentToSelect == instrumentTag)
     *  {
     *      taskStatus = STATUS.COMPLETED_SUCCESS;
     *      session.sessionResults.Log_CorrectlySelectedInstrumentByPurpose(m_instrumentToSelect);
     *  }
     *  else
     *  {
     *      session.sessionResults.Log_FailedToSelectByPurpose(m_instrumentToSelect, instrumentTag);
     *
     *      taskStatus = STATUS.COMPLETED_FAIL;
     *  }
     *
     *  return taskStatus;
     * }*/

    /// <summary>
    /// Evaluate task
    /// </summary>
    /// <param name="list">Index 0 must be the instrument tag, index 1 must be the session</param>
    /// <returns>The completion status of the task</returns>
    public override STATUS Evaluate(params object[] list)
    {
        Instrument.INSTRUMENT_TAG instrumentTag = (Instrument.INSTRUMENT_TAG)list[0];
        Session session = (Session)list[1];

        if (m_instrumentToSelect == instrumentTag)
        {
            taskStatus = STATUS.COMPLETED_SUCCESS;
            session.sessionResults.Log_CorrectlySelectedInstrumentByPurpose(m_instrumentToSelect);
        }
        else
        {
            session.sessionResults.Log_FailedToSelectByPurpose(m_instrumentToSelect, instrumentTag);

            taskStatus = STATUS.COMPLETED_FAIL;
        }

        return(taskStatus);
    }
Example #6
0
    /// <summary>
    /// Callback invoked when an insturment is placed on a slot
    /// </summary>
    /// <param name="instrumentTag">The instrument placed</param>
    /// <param name="slot">The slot</param>
    /// <returns></returns>
    public bool OnInstrumentPlaced(Instrument.INSTRUMENT_TAG instrumentTag, InstrumentPositionTaskSlot slot)
    {
        if (m_currentSession != null)
        {
            // If current task is to position the instruments, select the chosen instrument.
            InstrumentPositionTask instrumentPositionTask = null;

            //Find the task related to slot
            foreach (InstrumentPositionTask t in m_currentSession.tasks)
            {
                if (t.m_instrument == instrumentTag)
                {
                    instrumentPositionTask = t;
                }
            }

            // Cjeck if the instrument was in the right slot
            Task.STATUS status  = instrumentPositionTask.Evaluate(instrumentTag, slot, m_currentSession);
            bool        success = false;

            // If training mode, give feedback
            if (status == Task.STATUS.COMPLETED_SUCCESS && !GameManager.Instance.IsAssessmentMode())
            {
                GUIManager.Instance.GetMainCanvas().DogPopUp(2, "Correct placement");
                success = true;
            }
            else if (status == Task.STATUS.COMPLETED_FAIL)
            {
                if (!GameManager.Instance.IsAssessmentMode())
                {
                    GUIManager.Instance.GetMainCanvas().DogPopUp(2, "Wrong placement");
                }

                m_currentSession.sessionResults.errors++;
            }

            return(success);
        }
        return(false);
    }
Example #7
0
    /// <summary>
    /// Only for SelectByName or SelectByPurpose Task
    /// </summary>
    /// <param name="instrumentTag"></param>
    private void OnInstrumentSelected(Instrument.INSTRUMENT_TAG instrumentTag)
    {
        if (m_currentSession != null)
        {
            // Puas icon is up
            GUIManager.Instance.GetMainCanvas().SetPauseIconOn(true);

            // If current task is to position the instruments, select the chosen instrument.
            InstrumentPositionTask instrumentPositionTask = m_currentSession.GetCurrentTask() as InstrumentPositionTask;

            // If current task is to select by name or purpose, evaluate the task outcome.
            if (m_currentSession.GetCurrentTask() is InstrumentSelectByNameTask ||
                m_currentSession.GetCurrentTask() is InstrumentSelectByPurpose)
            {
                Task.STATUS status = m_currentSession.GetCurrentTask().Evaluate(instrumentTag, m_currentSession);

                // Check if tasks wa ok (eg. the user selected the correct instrument)
                if (status == Task.STATUS.COMPLETED_SUCCESS)
                {
                    // Make sure the player can't move
                    Player.Instance.FreezePlayer(true);

                    // If it's training mode, give feedback
                    if (!GameManager.Instance.IsAssessmentMode())
                    {
                        GUIManager.Instance.GetMainCanvas().DogInstructionSequence(new string[] { "Nicely done!" }, () => {
                            Player.Instance.ResetItemAndPlayerToFree();
                            Player.Instance.FreezePlayer(false);
                            Player.Instance.SetPickingEnabled(false); // Will be set to true when the task start
                            GUIManager.Instance.GetMainCanvas().SetPauseIconOn(false);

                            // Next task. If there is no next task, go to complete session
                            if (!m_currentSession.NextTask())
                            {
                                CompleteCurrentSession();
                            }
                        });
                    }
                    else
                    {
                        // If it's assessment mode, no feedback.
                        GUIManager.Instance.GetMainCanvas().DogInstructionSequence(new string[] { "The item was selected." }, () => {
                            Player.Instance.ResetItemAndPlayerToFree();
                            Player.Instance.FreezePlayer(false);
                            Player.Instance.SetPickingEnabled(false); // Will be set to true when the task start
                            GUIManager.Instance.GetMainCanvas().SetPauseIconOn(false);

                            // Next task
                            if (!m_currentSession.NextTask())
                            {
                                CompleteCurrentSession();
                            }
                        });
                    }
                }
                else // If the task was not successfull
                {
                    Player.Instance.FreezePlayer(true);
                    // If training, give feedback
                    if (!GameManager.Instance.IsAssessmentMode())
                    {
                        GUIManager.Instance.GetMainCanvas().DogInstructionSequence(new string[] { "Oh no, wrong item!" }, () => {
                            Player.Instance.ResetItemAndPlayerToFree();
                            Player.Instance.FreezePlayer(false);
                            GUIManager.Instance.GetMainCanvas().SetPauseIconOn(false);

                            Player.Instance.SetPickingEnabled(false); // Will be set to true when the task start
                            m_currentSession.sessionResults.errors++;
                            if (!m_currentSession.NextTask())
                            {
                                CompleteCurrentSession();
                            }
                        });
                    }
                    else // If assessment mode, no feedback
                    {
                        GUIManager.Instance.GetMainCanvas().DogInstructionSequence(new string[] { "The item was selected." }, () => {
                            Player.Instance.ResetItemAndPlayerToFree();
                            Player.Instance.FreezePlayer(false);
                            Player.Instance.SetPickingEnabled(false); // Will be set to true when the task start
                            m_currentSession.sessionResults.errors++;
                            if (!m_currentSession.NextTask())
                            {
                                CompleteCurrentSession();
                            }
                        });
                    }
                }
            }
        }
    }
    public InstrumentSelectByPurpose(Instrument.INSTRUMENT_TAG instrumentTag)
    {
        m_instrumentToSelect = instrumentTag;

        instructions.Add("New task: pick up the best instrument for <b><u>" + Instrument.GetPurposeDescription(m_instrumentToSelect) + "</u></b>");
    }
Example #9
0
 public void Log_CorrectlySelectedInstrumentByName(Instrument.INSTRUMENT_TAG instrumentTag)
 {
     logs.Add(DateTime.Now.ToShortTimeString() + " - Correctly selected by name " + Instrument.GetName(instrumentTag));
 }
Example #10
0
 public void Log_CorrectlyPositionedInstrument(Instrument.INSTRUMENT_TAG instrumentTag)
 {
     logs.Add(DateTime.Now.ToShortTimeString() + " - Correctly placed " + Instrument.GetName(instrumentTag));
 }
Example #11
0
 public void Log_FailedToSelectByPurpose(Instrument.INSTRUMENT_TAG toSelectinstrumentTag, Instrument.INSTRUMENT_TAG selectedInstrumentTag)
 {
     logs.Add(DateTime.Now.ToShortTimeString() + " - Failed to select by purpose " + Instrument.GetName(toSelectinstrumentTag) + ". Selected: " + Instrument.GetName(selectedInstrumentTag));
 }
Example #12
0
 public void Log_FailedToPositionInstrument(Instrument.INSTRUMENT_TAG correctInstrumentTag, Instrument.INSTRUMENT_TAG actualInstrumentTag)
 {
     logs.Add(DateTime.Now.ToShortTimeString() + " - Failed to place instrument, put " + Instrument.GetName(actualInstrumentTag) + " where the " + Instrument.GetName(correctInstrumentTag) + " should have gone.");
 }
    public InstrumentSelectByNameTask(Instrument.INSTRUMENT_TAG instrumentTag)
    {
        m_instrumentToSelect = instrumentTag;

        instructions.Add("New task: pick up a <b><u>" + Instrument.GetName(m_instrumentToSelect) + "</u></b>");
    }