Esempio n. 1
0
    void Update()
    {
        switch (state)
        {
        case HoursState.WAITING:
            //if the race has started
            if (RaceManager.RM.CurrentState == RaceManager.RaceState.RACING)
            {
                state = HoursState.RACING;
            }
            break;

        case HoursState.RACING:
            //if the horse is not at the end point
            if (GoToEndPoint())
            {
                //Sets the state to finished
                state = HoursState.FINISHED;
            }
            //if it is still racing
            else
            {
                //counts down
                curentdelt -= Time.deltaTime;
                //if it is at 0
                if (curentdelt <= 0)
                {
                    //New speed
                    float min = speed - veriant;
                    if (min < minSeed)
                    {
                        min = minSeed;
                    }
                    float max = speed + veriant;
                    if (max > minSeed)
                    {
                        max = maxSpeed;
                    }
                    speed = Random.Range(min, max);
                    //Resets time
                    curentdelt = baseDelta;
                }
            }
            break;

        case HoursState.IDLE:
            break;

        case HoursState.FINISHED:
            //Gets the finished position
            FinishPlace = RaceManager.RM.GetNextFinishPoition();
            //Sets the state
            state = HoursState.IDLE;
            break;
        }
    }
Esempio n. 2
0
 //Sets the current state
 public void SetWatingState()
 {
     state = HoursState.WAITING;
 }