Exemple #1
0
    void OnTriggerEnter(Collider collision)
    {
        string tag = collision.gameObject.tag;

        if (tag.Equals("car") && !collision.gameObject.GetComponent <collisionAvoidance>().isStopped)
        {
            onCollision = this.transform;
            this.GetComponent <NavMeshAgent>().Stop();
            isStopped = true;
        }

        if (tag.Equals("Player"))
        {
            onCollision = this.transform;
            this.GetComponent <NavMeshAgent>().Stop();
            isStopped = true;

            if ((Time.time - lastCollisionWithPlayer) > 5.0f)
            {
                if (!GameOverOverlay.GameIsOver)
                {
                    CashEarnedHandler.notifyCashLost(50);
                }

                lastCollisionWithPlayer = Time.time;
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (hasPassanger == true && Vector3.Distance(transform.position, NavigationHandler.targetPosition) < 0.1f)
        {
            GameNotification.Reset();
            GameNotification.Message = dropOffText;
            displayingNotification   = true;
            GameNotification.ShowNotification();
        }
        else if (!PickUp.displayingNotification)
        {
            displayingNotification = false;
            GameNotification.HideNotification(dropOffText);
        }
        else if (hasPassanger == true && Vector3.Distance(transform.position, NavigationHandler.targetPosition) > 0.1f)
        {
            displayingNotification = false;
            GameNotification.HideNotification(dropOffText);
        }

        if (DropOff.hasPassanger && Time.time - lastMoneyRemoval > 20.0f)
        {
            moneyToGive     -= 1.0f;
            lastMoneyRemoval = Time.time;
        }

        if (Vector3.Distance(transform.position, NavigationHandler.targetPosition) < 0.1f && hasPassanger == true && (Time.time - PickUp.lastButtonPress) > InputConstants.MENU_ACTION_DELAY && (Input.GetKey(KeyCode.E) || theController.isButtonPressed(theController.STATE_OPTION1)))
        {
            hasPassanger = false;
            GameNotification.HideNotification(dropOffText);

            GameObject newHuman = Instantiate(human);
            newHuman.transform.position = PassengerSystem.NextPassengerDestination;
            newHuman.transform.rotation = Quaternion.Euler(0, 0, 0);

            PickUp.lastButtonPress = Time.time;

            PassengerSystem.PassengerIndex++;
            NavigationHandler.targetPosition = PassengerSystem.NextPassengerPosition;


            CashEarnedHandler.notifyCashEarned((int)moneyToGive);
        }
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        instance           = this;
        notifyCanvasEarned = gameObject;
        notifyCanvasEarned.GetComponent <CanvasRenderer>().SetAlpha(0.0f);

        notifyCanvasLost = GameObject.Find("ui_notify_cash_out");
        notifyCanvasLost.GetComponent <CanvasRenderer>().SetAlpha(0.0f);

        cashEarned         = GameObject.Find("ui_notify_cashearned").GetComponent <Text>();
        cashEarned.enabled = false;

        cashValueEarned         = GameObject.Find("ui_notify_value").GetComponent <Text>();
        cashValueEarned.enabled = false;

        cashLost         = GameObject.Find("ui_notify_cashlost").GetComponent <Text>();
        cashLost.enabled = false;

        cashValueLost         = GameObject.Find("ui_notify_value_lost").GetComponent <Text>();
        cashValueLost.enabled = false;
    }