Example #1
0
    public void SimulateWaitForPassengers(float time)
    {
        int minPercent = 0;
        int maxPercent = 0;

        minPercent = communityTimeInfo.MinPercentIn;
        maxPercent = communityTimeInfo.MaxPercentIn;

        PlayerSaveData.PassengerData passengersData = PlayerSaveData.reference.passengerData;
        if (passengersData.IsFull())
        {
            return;
        }
        float waitingTime = time;

        while (true)
        {
            if (waitingTime >= passengerTickTime)
            {
                waitingTime -= passengerTickTime;

                float passengersComing = ((float)passengersData.GetMaxPassengers() * Random.Range(minPercent, maxPercent)) / 100;
                passengersCame += passengersComing;

                passengersCameShown += (int)passengersCame;

                Color color = passengersLabel.color;
                color.a = 255;
                passengersLabel.color = color;
                passengersLabel.text  = "passengers +" + passengersCameShown;

                while (passengersCame >= 1)
                {
                    passengersData.AddPassenger();
                    passengersCame -= 1;
                    if (passengersData.IsFull())
                    {
                        break;
                    }
                }
                if (passengersData.IsFull())
                {
                    break;
                }
            }
            else
            {
                return;
            }
        }
    }
Example #2
0
    IEnumerator WaitForPassengers()
    {
        int minPercent = 0;
        int maxPercent = 0;

        if (GlobalUI.reference.IsState(GlobalUI.States.Town))
        {
            minPercent = TownController.reference.passengerInfo.MinPercentIn;
            maxPercent = TownController.reference.passengerInfo.MaxPercentIn;
        }
        else if (GlobalUI.reference.IsState(GlobalUI.States.Waystation))
        {
            minPercent = WaystationController.reference.passengerInfo.MinPercentIn;
            maxPercent = WaystationController.reference.passengerInfo.MaxPercentIn;
        }

        PlayerSaveData.PassengerData passengersData = PlayerSaveData.reference.passengerData;
        if (passengersData.IsFull())
        {
            ToggleWaitForPassengers();
            return(true);
        }
        float waitinGameSeconds = 0;

        while (true)
        {
            Debug.Log("waiting");
            waitinGameSeconds -= Time.unscaledDeltaTime * waitingTimeSpeedMultiplier;
            while (waitinGameSeconds < 0)
            {
                waitinGameSeconds += 1;
                AddTime(-1);
                waitingTime += 1;
            }
            if (waitingTime >= passengerTickTime)
            {
                waitingTime -= passengerTickTime;

                float passengersComing = ((float)passengersData.GetMaxPassengers() * Random.Range(minPercent, maxPercent)) / 100;
                passengersCame += passengersComing;

                passengersCameShown += (int)passengersCame;

                Color color = passengersLabel.color;
                color.a = 255;
                passengersLabel.color = color;
                passengersLabel.text  = "passengers +" + passengersCameShown;

                while (passengersCame >= 1)
                {
                    passengersData.AddPassenger();
                    passengersCame -= 1;
                    if (passengersData.IsFull())
                    {
                        ToggleWaitForPassengers();
                        break;
                    }
                }
                if (passengersData.IsFull())
                {
                    ToggleWaitForPassengers();
                    break;
                }
            }
            yield return(null);
        }
    }