Esempio n. 1
0
 //When a collision has taken place and the object contains the desired tag,
 //player score is incrimented and the object is marked as expired
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == objectString && recievedBag == false)
     {
         if ((FindActiveChild(collision.gameObject).tag == desiredModel) && (FindActiveChild(collision.gameObject).GetComponentInChildren <Renderer>().material.color == desiredCol) && (FindActiveChild(collision.gameObject).GetComponentInChildren <Renderer>().material.GetTexture("_MainTex") == desiredTex))
         {
             if (collision.gameObject.GetComponent <ObjectInteractCursorScript>().hasExpired != true)
             {
                 gameController.IncrimentPlayerScore(10);
                 gameController.GetComponent <AudioManager>().PlaySound("General_Positive_Beep_01");
                 collision.gameObject.GetComponent <ObjectInteractCursorScript>().hasExpired = true;
                 //Set mood to Happy
                 moodScript.SetState(1);
             }
         }
         else
         {
             gameController.IncrimentPlayerScore(-5);
             gameController.GetComponent <AudioManager>().PlaySound("General_Negative_Beep_01");
             collision.gameObject.GetComponent <ObjectInteractCursorScript>().hasExpired = true;
             //Set mood to Angry
             moodScript.SetState(2);
         }
         recievedBag = true;
     }
     else if (collision.gameObject.tag == "ResetBarrier")
     {
         Reinitialise();
     }
 }
Esempio n. 2
0
    // Get a random line of dialogue and add it to the event log, substituting in certain words into the dialogue (like names) where necessary.
    protected void Speak()
    {
        string myMsg = myName + ": " + dialogue[Random.Range(0, dialogue.Count)];

        myMsg = myMsg.Replace("%name%", myName);
        myMsg = myMsg.Replace("%commonName%", commonName);
        myMsg = myMsg.Replace("%targetName%", target.myName);
        myMsg = myMsg.Replace("%targetCommonName%", target.commonName);
        myMsg = myMsg.Replace("%season%", gc.curSeason.ToString().ToLower());
        myMsg = myMsg.Replace("%seasonCap%", gc.curSeason.ToString());
        myMsg = myMsg.Replace("%weather%", DateWeatherSeasonLib.ClimateFuncs.WeatherToString(gc.curWeather).ToLower());
        myMsg = myMsg.Replace("%weatherCap%", DateWeatherSeasonLib.ClimateFuncs.WeatherToString(gc.curWeather));

        gc.GetComponent <GameControllerScript>().LogMessage(myMsg, "Cyan");
    }
    //Upon entering the collision space of a collider marked trigger via inspector
    //Used for gate collisions
    void OnTriggerEnter(Collider col)
    {
        //Game stage variable to track wether first or second set of turnstiles are in play
        int gameStage = GameObject.FindGameObjectWithTag("PassengerManager").GetComponent <PlayerMovementImmigration>().gameStage;
        //Gets the numerical value of the second last character in the string of a game objects name
        //Intended for use with the Turnstiles as their naming scheme ends with a number in (n) format thus the second last character is acquired
        int colliderNum = (int)char.GetNumericValue(col.gameObject.transform.parent.name.ToCharArray()[col.gameObject.transform.parent.name.ToCharArray().Length - 2]);

        //Only evaluates the collided object should it belong to the current game stage
        //game stage 1 numbers 0->3, game stage 2 numbers 4->7
        if ((gameStage == 0 && (colliderNum < 4)) || (gameStage == 1 && (colliderNum > 3)))
        {
            //If the colour of the gate matches with the colour of the passenger, reward points,set mood state to happy and play a positive sound effect
            //If the colour of the gate does not match, decrement points,set mood state to angry and play a negative sound effect
            if (col.tag == "Red")
            {
                if (gameObject.tag == "Red")
                {
                    gameController.IncrimentPlayerScore(10);
                    gameController.GetComponent <AudioManager>().PlaySound("General_Positive_Beep_01");
                    moodScript.SetState(1);
                }
                if (gameObject.tag == "Blue")
                {
                    gameController.IncrimentPlayerScore(-5);
                    gameController.GetComponent <AudioManager>().PlaySound("General_Negative_Beep_01");
                    moodScript.SetState(2);
                }
            }
            else if (col.tag == "Blue")
            {
                if (gameObject.tag == "Red")
                {
                    //score.playerScore -= 5;
                    gameController.IncrimentPlayerScore(-5);
                    gameController.GetComponent <AudioManager>().PlaySound("General_Negative_Beep_01");
                    moodScript.SetState(2);
                }
                if (gameObject.tag == "Blue")
                {
                    //score.playerScore += 10;
                    gameController.IncrimentPlayerScore(10);
                    gameController.GetComponent <AudioManager>().PlaySound("General_Positive_Beep_01");
                    moodScript.SetState(1);
                }
            }
        }
    }