Esempio n. 1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        TrackNode trackNode = collider.GetComponent <TrackNode>();

        if (trackNode)
        {
            int trackNodeIndex = trackNode.GetIndex();
            // If Player moved to the next waypoint of passed lap-start position
            // TODO: here is small bug - if player will go back on start and then pass start - condition will be met. Seems like not-real scenario.
            if (lastPassedWaypoint < trackNodeIndex || (lastPassedWaypoint > trackNodeIndex && trackNodeIndex == 1))
            {
                // if start passed
                if (lastPassedWaypoint > trackNodeIndex && trackNodeIndex == 1)
                {
                    if (_dashNumberAvailable < INITIAL_NUMBER_OF_DASHES)
                    {
                        _dashNumberAvailable = INITIAL_NUMBER_OF_DASHES;
                    }
                }

                waypointSum       += WAYPOINT_VALUE;
                lastPassedWaypoint = trackNodeIndex;
            }
        }
    }