Пример #1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        StopWheel.SetActive(false);
        _manager.promptIsPossible = true;
        Time.timeScale            = 1f;
        NullifyTimingSlider();
        if (_manager.promptIsPossible && pressedInTime == false) //ErrorCount timing
        {
            car = collision.GetComponent <CarAI>();
            switch (signId)
            {
            case 0:
                //Stop sign Function
                if (collision.CompareTag("Car") | collision.CompareTag("Player"))
                {
                    StartCoroutine(Stop());
                }
                break;

            case 1:
                //TurnLeft sign Function
                if (CanNPCsUseLeft && currentWaypointLeft != null)
                {
                    if (collision.CompareTag("Car") | collision.CompareTag("Player"))
                    {
                        navigator = collision.GetComponent <WaypointNavigator>();
                        navigator.currentWaypoint = currentWaypointLeft;
                        car.SetDestination(currentWaypointLeft.GetPosition());
                    }
                }
                else if (collision.CompareTag("Player") && currentWaypointLeft != null)
                {
                    navigator = collision.GetComponent <WaypointNavigator>();
                    navigator.currentWaypoint = currentWaypointLeft;
                    car.SetDestination(currentWaypointLeft.GetPosition());
                }
                break;

            case 2:
                if (CanNPCsUseForward && currentWaypointForward != null)
                {
                    if (collision.CompareTag("Car") | collision.CompareTag("Player"))
                    {
                        navigator = collision.GetComponent <WaypointNavigator>();
                        navigator.currentWaypoint = currentWaypointForward;
                        car.SetDestination(currentWaypointForward.GetPosition());
                    }
                }
                else if (collision.CompareTag("Player") && currentWaypointForward != null)
                {
                    navigator = collision.GetComponent <WaypointNavigator>();
                    navigator.currentWaypoint = currentWaypointForward;
                    car.SetDestination(currentWaypointForward.GetPosition());
                }
                break;

            case 3:
                //TurnRight sign Function
                if (CanNPCsUseRight && currentWaypointRight != null)
                {
                    if (collision.CompareTag("Car") | collision.CompareTag("Player"))
                    {
                        navigator = collision.GetComponent <WaypointNavigator>();
                        navigator.currentWaypoint = currentWaypointRight;
                        car.SetDestination(currentWaypointRight.GetPosition());
                    }
                }
                else if (collision.CompareTag("Player") && currentWaypointRight != null)
                {
                    navigator = collision.GetComponent <WaypointNavigator>();
                    navigator.currentWaypoint = currentWaypointRight;
                    car.SetDestination(currentWaypointRight.GetPosition());
                }
                break;

            case 4:
                car.TargetSpeed = 5f;
                break;

            case 5:
                car.TargetSpeed = 8.3333333f;
                break;
            }
        }
    }
Пример #2
0
 private void Start()
 {
     car.SetDestination(currentWaypoint.GetPosition());
 }