Beispiel #1
0
    /// <summary>
    /// Will be passed as a delegate to collision cells so that collisions will properly
    /// add time to the user
    /// </summary>
    /// <param name="c">Collision parameter required by delegate definition</param>
    /// <returns>True always</returns>
    public bool AddTime(Collision2D c)
    {
        timeToComplete += COLLISION_TIME;
        collisions     += 1;

        //visual indication of obstacle hit
        c.gameObject.GetComponent <MazePlayerControllerScript>().ObstacleHit();

        //Do angle calculations to figure out what side of the player the collision occurred on
        Vector2 pointCont   = c.GetContact(0).point;
        Vector2 pointPlayer = c.gameObject.transform.position;
        float   contAngle   = WrapAngle(Vector2.Angle(new Vector2(0, 10), pointCont - pointPlayer));
        //Debug.Log("Contact Angle: " + contAngle);
        float angle = WrapAngle(c.gameObject.transform.rotation.eulerAngles.z);
        //Debug.Log("Player Angle: " + angle);
        float compositeAngle = WrapAngle(angle - contAngle);

        //Debug.Log("Composite Angle: " + compositeAngle);
        //need to check for stage like usual to record control changes correctly
        if (compositeAngle <= -45 && compositeAngle >= -135)
        {
            MazeSmartFeedbackProcessor.Collision(MazeSmartFeedbackProcessor.LEFT, currentStage % 2);
        }
        else if (compositeAngle < 45 && compositeAngle > -45)
        {
            MazeSmartFeedbackProcessor.Collision(MazeSmartFeedbackProcessor.CENTER, currentStage % 2);
        }
        else if (compositeAngle <= 135 && compositeAngle >= 45)
        {
            MazeSmartFeedbackProcessor.Collision(MazeSmartFeedbackProcessor.RIGHT, currentStage % 2);
        }

        return(true);
    }
Beispiel #2
0
    /// <summary>
    /// This function will be passed as a delegate to trigger cells so that when the player reaches the end
    /// of the map a proper scene change (or end of game) will occur
    /// </summary>
    /// <param name="c">Collision param required by delegate definition</param>
    /// <returns>True if successful, false if trigger has already been received</returns>
    public bool NextStage(Collider2D c)
    {
        //we check if the overlay is already active to prevent overincrementation of stage in the event that the player
        //triggers more than one trigger cell
        if (stageChangeOverlay.gameObject.activeSelf || gameOverScript.gameObject.activeSelf)
        {
            return(false);
        }

        Debug.Log("Next stage function triggered");
        //increment the trigger then determine whether to progress to a new stage or to end the game session

        audioSrc.PlayOneShot(stageEndClip);
        RecordStageData();
        currentStage += 1;
        if (currentStage < NUM_STAGES)
        {
            //set the text boxes to display accurate information
            string text1 = "- Stage " + (currentStage + 1) + " -";
            //bool showIcon = false;
            //we only notify of a control change half way through when it occurs
            //if (currentStage == NUM_STAGES / 2)
            //{
            //playerContScript.SwitchControls();
            //showIcon = true;
            //}

            //set values in overlay canvas and trigger the fade in change
            stageChangeOverlay.SetUIText(text1, false);
            stageChangeOverlay.TriggerStageChange();
        }
        else
        {
            //set timescale to zero so that time is not added once the game is over
            Time.timeScale = 0;
            gameOverScript.SetStars(GetNumStars());

            string[]           genDisplayCols = { "collisions", "time" };
            string[]           graphTitles    = { "Total Collisions Per Session", "Completion Time Per Session" };
            IGameSessionData[] dataArray      = dataList.ToArray();

            StringData[] tables =
            {
                new StringData(dataArray, genDisplayCols[0], format: "0"),
                new StringData(dataArray, genDisplayCols[1], unit: "s")
            };

            dataDisplay.AddTableView(tables);
            dataDisplay.AddTextView(MazeSmartFeedbackProcessor.LevelFinish());
            dataDisplay.AddGraph(_GlobalVariables.dataRep.GetSessionData(TABLE_NAME, DATA_POINTS),
                                 genDisplayCols, titles: graphTitles, difficulty: _GlobalVariables.difficulty);
            //game over overlay script will set timescale back to one once it is terminated
            gameOverScript.gameObject.SetActive(true);
            dataDisplay.InitializeDisplays();
        }

        return(true);
    }
Beispiel #3
0
 /// <summary>
 /// We use this method to signal to the communicator thread that the program may have just ended
 /// </summary>
 void OnDestroy()
 {
     _GlobalVariables.mainThreadActive = false;
     MazeSmartFeedbackProcessor.ResetVars();
 }