public static string GetLabel(this PeacockExtraType extraType) { string name = extraType.GetProperName(); string price = Utilities.FormatMoney(extraType.GetPrice()); return(name + " " + price); }
public static string GetProperName(this PeacockExtraType extraType) { switch (extraType) { case PeacockExtraType.ET_MEDICINE: return("Medicine"); case PeacockExtraType.ET_PILLOW: return("Blanket"); case PeacockExtraType.ET_HORMONES: return("Growth Hormones"); // TODO: probably change this to something more fantasy-sounding } return("Unknown"); }
public static string GetName(this PeacockExtraType extraType) { switch (extraType) { case PeacockExtraType.ET_MEDICINE: return("medicine"); case PeacockExtraType.ET_PILLOW: return("a blanket"); case PeacockExtraType.ET_HORMONES: return("growth hormones"); // TODO: probably change this to something more fantasy-sounding } return("????"); }
public static int GetPrice(this PeacockExtraType extraType) { switch (extraType) { case PeacockExtraType.ET_MEDICINE: return(400); case PeacockExtraType.ET_PILLOW: return(100); case PeacockExtraType.ET_HORMONES: return(300); } return(0); }
public void PeacockScreenExtra(int extraType) { Debug.Log("extra peacock " + extraType); Transform extras = PeacockView.transform.Find("ExtraPlan"); Transform button = extras.GetChild(extraType); Image img = button.GetComponent <Image>(); bool prevSelected = img.color.a == 1f; PeacockExtraType extra = (PeacockExtraType)extraType; int price = extra.GetPrice(); if (!prevSelected && GameData.singleton.money - GameData.singleton.peacockQuarterlyTotalCost < price) { Debug.Log("not enough money"); return; } img.color = new Color(1f, 1f, 1f, prevSelected ? 0.1f : 1f); Peacock.SetQuarterlyExtra(extraType, !prevSelected); PeacockView.transform.Find("CostTitle/Cost").GetComponent <Text>().text = Utilities.FormatMoney(GameData.singleton.peacockQuarterlyTotalCost); }
/** * Call this at the end of the quarter to setup the peacock view */ public void PreparePeacockSummary() { for (int i = 0; i < PeacockView.transform.childCount; ++i) { GameObject go = PeacockView.transform.GetChild(i).gameObject; if (go.GetComponent <CanvasGroup>() != null) { if (GameData.singleton.quarter < 2) { go.GetComponent <CanvasGroup>().alpha = 0; FancyUIAnimations.PushFadeIn(go); } } } // I assume there's a more proper way to do this, but I'm too lazy to figure it out PeacockView.transform.Find("Date").GetComponent <Text>().text = string.Format("{0}, Year {1}", GameData.singleton.season.GetName(), GameData.singleton.year); PeacockView.transform.Find("FoodReport").GetComponent <Text>().text = GameData.singleton.peacockReportFoodDesc; PeacockView.transform.Find("ActivityReport").GetComponent <Text>().text = GameData.singleton.peacockReportActivityDesc; PeacockView.transform.Find("ExtraReport").GetComponent <Text>().text = GameData.singleton.peacockReportExtraDesc; PeacockView.transform.Find("StatusReport").GetComponent <Text>().text = GameData.singleton.peacockReportGeneralDesc; PeacockView.transform.Find("NextQuarterTitle").GetComponent <Text>().text = string.Format("Plan for the {0}: ", GameData.singleton.season.GetNextSeasonName()); Transform foodPlan = PeacockView.transform.Find("FoodPlan"); for (int i = (int)FoodType.FT_MAX - 1; i >= 0; --i) { FoodType food = ((FoodType)i); Transform button = foodPlan.GetChild(i); button.GetChild(0).GetComponent <Text>().text = food.GetLabel(); bool isActiveFood = (int)GameData.singleton.peacockQuarterlyFoodType == i; if (isActiveFood) { // if we can no longer afford the food we previously bought, force a downgrade int price = food.GetPrice(); if (price > GameData.singleton.money) { isActiveFood = false; GameData.singleton.peacockQuarterlyFoodType = (FoodType)(i - 1); // assumption: the first available food type is free GameData.singleton.peacockQuarterlyFoodCost = GameData.singleton.peacockQuarterlyFoodType.GetPrice(); } } button.GetComponent <Image>().color = new Color(1f, 1f, 1f, isActiveFood ? 1f : PEACOCK_SCREEN_UNSELECTED_ALPHA); } Transform activityPlan = PeacockView.transform.Find("ActivityPlan"); for (int i = 0; i < (int)PeacockActivityType.PA_MAX; ++i) { PeacockActivityType activity = ((PeacockActivityType)i); Transform button = activityPlan.GetChild(i); button.GetChild(0).GetComponent <Text>().text = activity.GetLabel(); if ((int)GameData.singleton.peacockQuarterlyActivity == i) { button.GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f); } } Transform extraPlan = PeacockView.transform.Find("ExtraPlan"); for (int i = 0; i < (int)PeacockExtraType.ET_MAX; ++i) { PeacockExtraType extra = ((PeacockExtraType)i); Transform button = extraPlan.GetChild(i); button.GetChild(0).GetComponent <Text>().text = extra.GetLabel(); button.GetComponent <Image>().color = new Color(1f, 1f, 1f, Peacock.HasQuarterlyExtra(i) ? 1f : PEACOCK_SCREEN_UNSELECTED_ALPHA); } PeacockView.transform.Find("CostTitle/Cost").GetComponent <Text>().text = Utilities.FormatMoney(GameData.singleton.peacockQuarterlyTotalCost); }