예제 #1
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);
    }
예제 #2
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();
                            }
                        });
                    }
                }
            }
        }
    }