Пример #1
0
    private void Update()
    {
        #region Inputs
        if (Input.GetMouseButtonDown(0))
        {
            swipe = true;
            swipeFirstPosition = Input.mousePosition.x;
            StartCoroutine(Swiping());
        }
        if (Input.GetMouseButton(0) && swipe)
        {
            swipeFinished = false;
        }
        if (Input.GetMouseButtonUp(0))
        {
            swipe         = false;
            swipeFinished = true;
            carDirection  = CarDirection.None;
            StopCoroutine(Swiping());
            isDriftingStopped = true;
        }
        #endregion

        #region Rotations
        if (carDirection == CarDirection.Left)
        {
            movement.TurnLeft();
            driftLine.StartEmitting();
            carDriftDust.OpenDust();
        }
        else if (carDirection == CarDirection.Right)
        {
            movement.TurnRight();
            driftLine.StartEmitting();
            carDriftDust.OpenDust();
        }
        else
        {
            if (isDriftingStopped) // I check drifting status to call these operations once
            {
                driftLine.StopEmitting();
                StartCoroutine(carDriftDust.DriftDust());
                isDriftingStopped = false;
            }
        }
        #endregion

        carPowerUpControl.CheckForPowerUp(ballColliderCommon, carColliderCommon, ballPosition, ball);
    }
Пример #2
0
    private void Update()
    {
        #region AI
        if (aIState == AIStates.None)
        {
            FindClosestCar();
        }

        if (aIState == AIStates.ClosestCarFound)
        {
            movement.TurnToObject(closestCar.transform);
            CheckDriftingDistance(closestCar.transform);
        }

        if (aIState == AIStates.GetReadyToDrift)
        {
            IdentifyDriftTimeAndRotation();
        }

        if (aIState == AIStates.Drift)
        {
            if (carDirection == CarDirection.Left)
            {
                movement.TurnLeft();
                driftLine.StartEmitting();
                carDriftDust.OpenDust();
            }
            else if (carDirection == CarDirection.Right)
            {
                movement.TurnRight();
                driftLine.StartEmitting();
                carDriftDust.OpenDust();
            }
        }

        if (isDriftingStopped)
        {
            driftLine.StopEmitting();
            StartCoroutine(carDriftDust.DriftDust());
            isDriftingStopped = false;
        }
        #endregion

        carPowerUpControl.CheckForPowerUp(ballColliderCommon, carColliderCommon, ballPosition, ball);
    }