public void ShowPackageInfoScreen(int packageIdx)
    {
        packageIdx--;
        if (packageIdx >= 0 && packageIdx < packages.Count)
        {
            chosenPackage = packages[packageIdx];
        }
        else
        {
            return;
        }

        Text[] textFields = packageInfoScreen.GetComponentsInChildren <Text>();
        textFields[0].text = chosenPackage.title;
        textFields[1].text = chosenPackage.description;
        moneyResVal.text   = chosenPackage.resources[typeof(MoneyResource)] + " EUR";
        timeResVal.text    = chosenPackage.days + (chosenPackage.days > 1 ? " Tage" : " Tag");
        co2ResVal.text     = chosenPackage.resources[typeof(CO2Resource)] + "g";
        cultureResVal.text = chosenPackage.culturePoints.ToString();

        Button [] buttons = packageInfoScreen.GetComponentsInChildren <Button>();

        if (PlayerResourceCalculator.EnoughForPackage(chosenPackage))
        {
            buttons[1].interactable = true;
        }
        else
        {
            buttons[1].interactable = false;
        }

        inCity.ToPackageInfoScreen();
    }
Exemple #2
0
 private void UsePackageResources(SightseeingPackage package)
 {
     foreach (KeyValuePair <Type, float> entry in package.resources)
     {
         if (Resources.ContainsKey(entry.Key))
         {
             Resources[entry.Key].Use(entry.Value);
         }
     }
     OnResourceUpdate();
 }
Exemple #3
0
    public void AddCityStayWithPkg(City city, SightseeingPackage package)
    {
        CityStay newStay = new CityStay(city, package.days);

        Trip.AddStay(newStay);

        if (Trip.arrivedInTime)
        {
            CulturePoints += package.culturePoints;
        }

        UsePackageResources(package);
    }
Exemple #4
0
    public static bool EnoughForPackage(SightseeingPackage package)
    {
        float cityCosts;
        float days = package.days;
        City  city = GraphGenerator.GetCity(package.cityName);

        if (days > 1)
        {
            cityCosts = days * city.CostsPerNight[GetPlayer().Avatar.AvatarType];
        }
        else
        {
            cityCosts = city.CostsPerDay[GetPlayer().Avatar.AvatarType];
        }

        float totalCosts = cityCosts + package.resources[typeof(MoneyResource)];

        return(EnoughMoneyAndTime(totalCosts, days));
    }
    public void SetupPackages()
    {
        packages.Clear();

        // add as many packages as there are parents
        for (int day = 1; day <= packageObjects.Count; day++)
        {
            SightseeingPackage pack = SightseeingManager.GetPackage(day, inCity.curCity.Name);
            packages.Add(pack);

            // fill out title and description for current package
            Text[] textFields = packageObjects[day - 1].GetComponentsInChildren <Text>();
            textFields[0].text  = pack.title;
            textFields[1].text  = pack.days + (pack.days > 1 ? " Tage\n" : " Tag\n");
            textFields[1].text += pack.resources[typeof(CO2Resource)] + "g CO2\n";
            textFields[1].text += pack.resources[typeof(MoneyResource)] + ",- EUR\n";
            textFields[1].text += pack.culturePoints + " Wissenspunkte";
        }

        SetupPackagesButton();
    }
Exemple #6
0
    public void AddCityStayInCurrent(SightseeingPackage package)
    {
        City city = GameManager.Instance.Player.Trip.CurrentCity;

        if (PlayerResourceCalculator.EnoughForCityStay(city, package.days))
        {
            GameManager.Instance.Player.AddCityStayWithPkg(city, package);

            if (MobileOnlyActivator.IsMobile)
            {
                ClosePackageInfoScreen();
            }

            else
            {
                DisplayCityChoiceScreen();
                UpdateCity();
            }
        }
        else
        {
            GameManager.Instance.SetErrorMessage(ErrorMessageType.ResourcesError, "not enough resources");
        }
    }