Exemplo n.º 1
0
    // Start is called before the first frame update
    public void FinishFlight()
    {
        if (IsPlaneAbleToFinish())
        {
            float moneyEarned = planeController.distance / 100f * planeController.pricePerMeter * planeController.publicPassengers * planeController.pricePerPassenger;
            int   expEarned   = (int)Mathf.Floor(planeController.distance / 1000 * planeController.publicPassengers);
            if (finishLevelUI)
            {
                finishLevelUI.SetActive(true);
            }

            if (distanceTravelledText)
            {
                distanceTravelledText.text = "Distance travelled: " + Mathf.Round(planeController.distance).ToString() + " m";
            }

            if (passengersDeliveredText)
            {
                passengersDeliveredText.text = "Passengers delivered: " + planeController.publicPassengers.ToString();
            }

            if (moneyText)
            {
                moneyText.text = (Mathf.Round(moneyEarned * 100f) / 100f).ToString() + " $";
            }

            if (expText)
            {
                expText.text = expEarned.ToString() + " EXP";
            }

            planeController.RemoveAllPassengers();
            planeController.playerStats.AddMoney(moneyEarned);
            planeController.playerStats.AddExp(expEarned);
        }
    }