Beispiel #1
0
 /*********************
 * Protected methods *
 *********************/
 //make a version of this method that will add to joy and anger depending on if hitting enemy, collect coin, getting hit, etc
 protected override void FacialExpressions()
 {
     if (biofeedback)
     {
         if (!usingPowerup)
         {
             if (userEmotions.joyLevel > 0.0022f)
             {
                 if (userEmotions.smiling > 10 || userEmotions.innerBrowRaise > 0.01f || userEmotions.noseWrinkle > 0.4f)
                 {
                     counterOne += 0.1f;
                 }
             }
             if (counterOne >= 5)
             {
                 counterOne = 0;
                 GameMaster.AddToJoy(10);
             }
             if (userEmotions.angerLevel > 0.01f)
             {
                 if (userEmotions.browRaise > 10 || userEmotions.browFurrow > 0.01f || userEmotions.upperLipRaise > 0.4f)
                 {
                     counterTwo += 0.1f;
                 }
             }
             if (counterTwo >= 5)
             {
                 counterTwo = 0;
                 GameMaster.AddToAnger(10);
             }
         }
     }
 }
Beispiel #2
0
    /*******************************
    * Collision Detection Methods *
    *******************************/

    void OnTriggerEnter2D(Collider2D coll)                                              //When touches another 2D collider trigger
    {
        if (coll.gameObject.tag == "HealthPackSmall")
        {
            Heal(25);
            Destroy(coll.gameObject);
        }

        if (coll.gameObject.tag == "HealthPackLarge")
        {
            Heal(25);
            Destroy(coll.gameObject);
        }

        if (coll.gameObject.tag == "Checkpoint")
        {
            GameMaster.SetSpawningRoom(currentRoom);
        }

        if (!biofeedback)
        {
            if (coll.gameObject.tag == "gem")
            {
                GameMaster.AddToJoy(20);
            }

            if (coll.gameObject.tag == "diamond")
            {
                GameMaster.AddToJoy(50);
            }

            if (coll.gameObject.tag == "collectible" || coll.gameObject.tag == "collectible_ground")
            {
                GameMaster.AddToJoy(10);
            }
        }

        if (coll.gameObject.tag == "EnemySm" && !GameMaster.PlayerIsInvulnerable())
        {
            if (!biofeedback)
            {
                GameMaster.AddToAnger(5);
            }
            Damageplayer(5, coll.gameObject);
        }

        if (coll.gameObject.tag == "Enemy" && !GameMaster.PlayerIsInvulnerable())
        {
            if (!biofeedback)
            {
                GameMaster.AddToAnger(10);
            }
            Damageplayer(10, coll.gameObject);
        }

        /* This check is the "Room transition" check. Rooms in this game are based off of objects with BoxCollider2D triggers
         +	This makes it so that when entering a new "room" (entering another trigger), the following happens:
         +		- The player is diabled from moving or pressing any buttons to prevent unwanted effects
         +		- The player's current room is updated
         +		- The camera transitions to the new room
         +		- The player finishes transitioning and can now freely move about
         */
        if (coll.gameObject.tag == "Room" && newRoom != coll.gameObject && !GameMaster.PlayerTransitionState())
        {
            //If we're triggering a	new	room, the room isn't the one we're in or transitioning to, and we aren't current transitioning
            //Hold the player's	velocity before	the	transition starts
            GameMaster.PlayerTransitionStateCheck(true);
            tempVelocity = velocity;

            //Disable the player from moving
            DisablePlayer();

            //Get the new room
            newRoom = coll.gameObject;

            //Get the bottom left of the room, using the center of the room as the origin
            newRoomBL = new     Vector2(Mathf.Round((coll.transform.position.x - (coll.bounds.size.x / 2)) * 2) / 2,
                                        Mathf.Round((coll.transform.position.y - (coll.bounds.size.y / 2)) * 2) / 2);

            //Get the top right of the room, using the center of the room as the origin
            newRoomTR = new     Vector2(Mathf.Round((coll.transform.position.x + (coll.bounds.size.x / 2)) * 2) / 2,
                                        Mathf.Round((coll.transform.position.y + (coll.bounds.size.y / 2)) * 2) / 2);

            //Create a local copy of the player's position at the start	of the transition
            Vector3 playerPos = rb2d.transform.position;

            //Find whether the transition will be horizontal or	vertical
            if (newRoomBL.x >= currentRoomTR.x)                         //If the new room's	bottom left	is further right than our current top right
            {
                currentTransitionDir = Vector2.right;                   //Then we must be transitioning	right
            }
            else if (newRoomTR.x <= currentRoomBL.x)                    //Otherwise	if the new room's top right	is further left	than our current bottom	left
            {
                currentTransitionDir = Vector2.left;                    //Transitioning	Left
            }
            else if (newRoomBL.y >= currentRoomTR.y)                    //If the new room's	bottom left	is further up (higher y	value) than	the	current	room's top right
            {
                currentTransitionDir = Vector2.up;                      //Transitioning	Up
            }
            else if (newRoomTR.y <= currentRoomBL.y)                    //If the new room's	top	right is lower than	the	current	rooms bottom left
            {
                currentTransitionDir = Vector2.down;                    //Transitioning	Down
            }
            else
            {
                currentTransitionDir = Vector2.zero;                            //Placeholder for if something goes	wrong
            }

            targetPos = ClampCamera(newRoom, cam.transform.position);                 //Clamp the camera's position	to the bounds of the new room
        }

        if (coll.gameObject.tag == "EnemyProjectile" && !GameMaster.PlayerIsInvulnerable())
        {
            if (!biofeedback)
            {
                GameMaster.AddToAnger(10);
            }
            Damageplayer(10, coll.gameObject);
        }
        if (coll.gameObject.tag == "Hazards" && !GameMaster.PlayerIsInvulnerable())
        {
            Damageplayer(1000, coll.gameObject);
        }
    }
Beispiel #3
0
    /*
     * Updates the GazePoint so all methods in this class can access its position.
     */
    protected override void GetGaze()
    {
        FallingOutOfBounds();

        if (Input.GetKeyDown(KeyCode.U))
        {
            GameMaster.AddToJoy(100);
            GameMaster.AddToAnger(100);
        }

        if (biofeedback)
        {
            gazePoint = TobiiAPI.GetGazePoint();
        }

        if (Input.GetAxis(ControllerInputManager.Grab()) > 0)
        {
            pointerAni.SetBool("holdL", true);
            gazeUIAni.SetBool("holdL", true);
            Vector3 centerPt;
            float   radius;
            float   distance;

            //if using biofeedback, will set pointer to gaze positions
            if (biofeedback)
            {
                gaze = Camera.main.ScreenToWorldPoint(gazePoint.Screen);

                centerPt = GetComponentInChildren <SphereCollider>().transform.position;
                radius   = GetComponentInChildren <SphereCollider>().radius;

                distance = Vector3.Distance(Camera.main.ScreenToWorldPoint(gazePoint.Screen), centerPt);

                if (distance > radius)
                {
                    Vector3 newPos = transform.position - centerPt;
                    newPos *= radius / distance;
                    pointer.transform.position = centerPt + newPos;
                }
                else
                {
                    pointer.transform.position = gaze;
                }
            }
            else
            {
                //else will move via analog stick movement
                pointer.transform.position += new Vector3(15 * Input.GetAxis("PS4_RightAnalogHorizontal"),
                                                          -15 * Input.GetAxis("PS4_RightAnalogVertical"), 0);

                centerPt = GetComponentInChildren <CircleCollider2D>().transform.position;
                radius   = GetComponentInChildren <CircleCollider2D>().radius;
                distance = Vector3.Distance(pointer.transform.position, centerPt);

                if (distance > radius)
                {
                    Vector3 newPos = pointer.transform.position - centerPt;
                    newPos *= radius / distance;

                    pointer.transform.position = centerPt + newPos;
                }
            }
        }
        else
        {
            if (pointer != null)
            {
                pointerAni.SetBool("holdL", false);
            }
            gazeUIAni.SetBool("holdL", false);
        }
    }