Exemple #1
0
    // Ends the current mission
    public void EndMission(bool completed)
    {
        StopCoroutine("IncreaseTimeTaken");
        passengerTimer.GetComponent <Text> ().text = "";

        if (completed)
        {
            // Passenger delivered successfully
            passengerLeave.volume = PlayerPrefs.GetFloat("sfx", 1);
            passengerLeave.Play();

            if (passengerTime - timeTaken > 0)
            {
                // If the time left is positive
                noticesManager.ShowMainScreenNotice("Passenger Delivered", "+ " + moneyManager.moneySymbol + ((passengerTime - timeTaken) * fareMultiplier), new Color(93 / 255, 255 / 255, 0 / 255), successSound);
            }
            else
            {
                // If the time left is negative
                noticesManager.ShowMainScreenNotice("Passenger Refunded", "- " + moneyManager.moneySymbol + (((passengerTime - timeTaken) * fareMultiplier) * -1), new Color(255 / 255, 69 / 255, 69 / 255), failSound);
            }
            moneyManager.ChangeMoney((passengerTime - timeTaken) * fareMultiplier);
            timeTaken = 0;
        }
        else
        {
            // Passenger not delivered successfully
            noticesManager.ShowMainScreenNotice("Passenger Killed", "- " + moneyManager.moneySymbol + killPenaltyAmount, new Color(255 / 255, 69 / 255, 69 / 255), failSound);
            moneyManager.ChangeMoney(-killPenaltyAmount);
        }

        Destroy(GameObject.Find("Destination").gameObject);
        GameObject.Find("Player").transform.Find("Passenger").gameObject.SetActive(false);
        GameObject.Find("Player").GetComponent <CarDrive> ().ForceHandbrake = false;
        pedestrianManager.KillPed();
        StartCoroutine("FindNewPassenger");
    }
Exemple #2
0
    void OnCollisionEnter(Collision other)
    {
        // On collision with the player
        if (other.gameObject.tag == "Player")
        {
            if (jobManager.CurrentPassenger == gameObject && carDrive.Handbrake && player.GetComponent <Rigidbody>().velocity.magnitude < 1f)
            {
                // If the NPC is the player's customer and the player is stopped
                if (transform.parent != player.transform)
                {
                    // Enter the car
                    EnterCar();
                }
            }
            else if (player.GetComponent <Rigidbody>().velocity.magnitude > 1f)
            {
                // Collateral game mode
                if (gameObject.tag != "Untagged" && gameModeManager.gameMode == "collateral")
                {
                    noticesManager.ShowMainScreenNotice("Pedestrian Killed", "- " + moneyManager.moneySymbol + "25", new Color(255 / 255, 69 / 255, 69 / 255), GameObject.Find("SFX").transform.Find("Failure").GetComponent <AudioSource> ());
                    moneyManager.ChangeMoney(-25);
                }

                // Kill the NPC
                gameObject.tag = "Untagged";
                GetComponent <GuyMovement> ().walking = false;
                GetComponent <GuyMovement> ().Dead    = true;
                rb.constraints = RigidbodyConstraints.None;
                rb.AddForce(Vector3.up * 20f * GameObject.Find("Player").GetComponent <Rigidbody> ().velocity.magnitude);

                // If the NPC was the passenger, end the mission
                if (jobManager.CurrentPassenger == gameObject)
                {
                    jobManager.EndMission(false);
                }

                // Tutorial
                if (!tutorialManager.TutorialIsShown(2))
                {
                    tutorialManager.ShowTutorial(2);
                }

                StartCoroutine(RespawnNew());
            }
        }
    }
Exemple #3
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.name == "Player")
        {
            // Collateral game mode
            if (!dead && gameModeManager.gameMode == "collateral")
            {
                noticesManager.ShowMainScreenNotice("Car Crash", "- " + moneyManager.moneySymbol + "25", new Color(255 / 255, 69 / 255, 69 / 255), GameObject.Find("SFX").transform.Find("Failure").GetComponent <AudioSource> ());
                moneyManager.ChangeMoney(-25);
            }

            // Kill car
            dead = true;
            Rigidbody rb = GetComponent <Rigidbody> ();
            rb.constraints = RigidbodyConstraints.None;
            rb.AddForce(Vector3.up * 20f * GameObject.Find("Player").GetComponent <Rigidbody> ().velocity.magnitude);
            gameObject.name = "Car [Dead]";             // prevents other cars stopping for the debris
            StartCoroutine("DestroyAfterTime");
        }
    }