예제 #1
0
    void Update()
    {
        //If we're boosting, move at boostSpeed and enable boost particles. If not, move at normal speed and
        //disable boost particles.
        speed = boosting ? boostSpeed : normalSpeed;
        boostEmitter.SetActive(boosting);

        //If there are wires to follow in the level and if we're not past the last wire,
        int numOfWires = WireManager.GetCount();

        if (numOfWires > 0 && currentIndex < numOfWires)
        {
            //If the current isn't transitioning between wires,
            if (!currentTransitioning)
            {
                //Move the current to towards its destination, the end of the wire it's on.
                Wire currentWire = WireManager.GetWire(currentIndex);
                transform.position = Vector3.MoveTowards
                                     (
                    transform.position,
                    currentWire.end.position,
                    speed * Time.deltaTime
                                     );
                //Face in the same direction as the wire we're on.
                transform.forward = currentWire.transform.forward;

                //If the current is at the end of the current wire...
                if (transform.position.Equals(currentWire.end.position))
                {
                    //Go to the next wire and do all relevant logic.
                    GoToNextWire();
                }
            }
            //If the current IS transitioning between wires,
            else
            {
                //Move through the gap at a speed dictated by transitionSpeed.
                DoCurrentTransition();
            }
        }
        //If there are wires in the level and we got this far, the wire's reached the end. Initiate
        //the win sequence.
        else if (numOfWires > 0)
        {
            EventDispatcher.Dispatch(new EventDefiner.LevelEnd(true));
            CurrentBurst();
        }
    }