Exemple #1
0
 public void RefreshEmails()
 {
     mEmailGroup.UpdateRenderables(SaveData.Get().emails);
     if (mSelectedEmail != null)
     {
         emailMainView.gameObject.SetActive(true);
         Email.RenderToEmailMainView(mSelectedEmail, emailMainView.gameObject);
     }
     else
     {
         emailMainView.gameObject.SetActive(false);
     }
 }
Exemple #2
0
 public void RefreshDocs()
 {
     mDocumentGroup.UpdateRenderables(SaveData.Get().documents);
     if (mSelectedDocument != null)
     {
         docMainView.gameObject.SetActive(true);
         Document.RenderToDocMainView(mSelectedDocument, docMainView.gameObject);
     }
     else
     {
         docMainView.gameObject.SetActive(false);
     }
 }
Exemple #3
0
    public void Update()
    {
        invList.Clear();
        for (int i = 0; i < (int)ItemType.NUM_TYPES; i++)
        {
            invList.Add(new InventoryEntry((ItemType)i, SaveData.Get().inventory[i]));
        }
        mSaleRowGroup.UpdateRenderables(invList);
        int totalPrice = GetTotalInventoryValue();

        totalPriceText.text     = "$" + totalPrice.ToString();
        sellButton.interactable = (totalPrice > 0);
        // current balance
        currentBalanceText.text = "Balance: $" + SaveData.Get().GetCash();
    }
Exemple #4
0
    public void PerformSearch(string text)
    {
        Debug.Log("Searched for: " + text);
        List <SearchResult> results = new List <SearchResult>();

        if (text != "")
        {
            results.Add(new SearchResult(text + " title", text + " Content content content content content"));
            results.Add(new SearchResult(text + " whoaaa", text + " Content content content content content content content"));
            results.Add(new SearchResult(text + " again?", text + " Content content content"));
        }
        else
        {
            results.Add(new SearchResult("", "No results."));
        }
        mSearchResultGroup.UpdateRenderables(results);
    }
Exemple #5
0
 public void UpdateForSale()
 {
     mShopItemsGroup.UpdateRenderables(shopItemList);
 }
    // Change text and other fields in UI content
    private void UpdateUiContent()
    {
        GameStage stage = GameData.singleton.currentStage;

        /**
         * Inventory
         */
        {
            // Inventory (cash)
            InventoryView.transform.Find("InvGroups/InventoryCash/IconAndCount/Count")
            .GetComponent <Text>().text = string.Format("{0}", GameData.singleton.money);
            // Inventory (feathers)
            List <FeatherAndCount> resourceCounts = new List <FeatherAndCount>();
            for (int i = 0; i < (int)FeatherType.FT_MAX; i++)
            {
                resourceCounts.Add(new FeatherAndCount((FeatherType)i, GameData.singleton.feathersOwned[i]));
            }
            mInventoryResourceRenderGroup.UpdateRenderables(resourceCounts);
            // Inventory (feathers)
            List <PotionAndCount> productCounts = new List <PotionAndCount>();
            for (int i = 0; i < (int)PotionType.PT_MAX; i++)
            {
                productCounts.Add(new PotionAndCount((PotionType)i, GameData.singleton.potionsOwned[i]));
            }
            mInventoryProductRenderGroup.UpdateRenderables(productCounts);
        }

        /**
         * Summary
         */
        if (SummaryView.activeInHierarchy)
        {
            // Per-item reports
            mItemQuarterlySummaryRenderGroup.UpdateRenderables(BusinessState.GetPerItemReports());
        }

        /**
         * Peacock view
         */
        if (PeacockView.activeInHierarchy)
        {
            mPeacockFeatherRenderGroup.UpdateRenderables(GameData.singleton.peacockReportFeatherCounts);
        }

        /**
         * Simulation / Event
         */
        if (SimulationView.activeInHierarchy)
        {
            // Color and show/hide potions in the shop
            for (int i = 0; i < (int)PotionType.PT_MAX; i++)
            {
                var PotionGroup = GetPotionGroup((PotionType)i);
                for (int j = 0; j < PotionGroup.childCount; j++)
                {
                    PotionGroup.GetChild(j).gameObject.SetActive(j < GameData.singleton.potionsOwned[i]);
                    PotionGroup.GetChild(j).GetComponent <Image>().color = ((PotionType)i).GetColor();
                    // TODO: if a potion stopped being visible it was just sold. Show the +money animation there
                }
            }
            SimulationDefaultContent.transform.Find("Shop/Season").GetComponent <Image>().sprite = null; // clear the sprite in case of weird sprite change bug
            SimulationDefaultContent.transform.Find("Shop/Season").GetComponent <Image>().sprite = SpriteManager.GetSprite(GameData.singleton.season.GetImage());

            // Date
            SimulationView.transform.Find("Overlay/TopLeft/Date/Month/Text").GetComponent <Text>().text = GameData.singleton.month;
            SimulationView.transform.Find("Overlay/TopLeft/Date/Day/Text").GetComponent <Text>().text   = GameData.singleton.dayOfMonth.ToString();
        }

        /**
         * Overlay views
         */
        int totalPotionRevenue = 0;

        foreach (BusinessState.PerItemReport report in BusinessState.GetPerItemReports())
        {
            totalPotionRevenue += (report.numSold * report.salePrice);
        }
        if (OverlayViewFeathers.activeInHierarchy)
        {
            //OverlayViewPotions.transform.Find("Content/Content").GetComponent<Text>().text = "";
            mOverlayFeatherCollectionFeatherRenderGroup.UpdateRenderables(
                GameData.singleton.peacockReportFeatherCounts.FindAll(fc => fc.count > 0));
        }
        else if (OverlayViewPotions.activeInHierarchy)
        {
            mOverlayPotionSalesRenderGroup.UpdateRenderables(BusinessState.GetPerItemReports());
            OverlayViewPotions.transform.Find("PotionSaleTotal/Row/H/Total").GetComponent <Text>().text
                = string.Format("${0}", totalPotionRevenue);
        }
        else if (OverlayViewFinancial.activeInHierarchy)
        {
            int startOfQuarterBalance = GameData.singleton.initialBalance;
            int eventIncome           = GameData.singleton.eventIncome;
            int peacockExpenses       = GameData.singleton.peacockQuarterlyTotalCost;
            int eventExpense          = GameData.singleton.eventExpenses;
            int profit     = (totalPotionRevenue + eventIncome) - (peacockExpenses + eventExpense);
            int rent       = GameData.singleton.livingExpenses;
            int newBalance = (int)GameData.singleton.money - rent;
            // totalRevenue = sum of perItemReport sales
            // include some event revenue and expenses
            // revenue rent etc
            List <string[]> financialReportRows = new List <string[]>();
            financialReportRows.Add(new string[] { "Beginning Balance", "", string.Format("{0}", startOfQuarterBalance) });
            financialReportRows.Add(new string[] { "Potion Sales", string.Format("+{0}", totalPotionRevenue), "" });
            financialReportRows.Add(new string[] { "Peacock Care", string.Format("-{0}", peacockExpenses), "" });
            // Only show event-related if non-zero
            financialReportRows.Add(new string[] { "Events", string.Format("{0:+#;-#;+0}", eventIncome - eventExpense), "" });
            // <LINE> at index 4
            financialReportRows.Add(new string[] { "Profit", "", string.Format("{0:+#;-#;+0}", profit) });
            // TODO: make expenses that happen right now stand out
            financialReportRows.Add(new string[] { "Pay Rent", "", string.Format("<b>-{0}</b>", rent) });
            // <LINE> at index 7
            financialReportRows.Add(new string[] { "New Balance", "", string.Format("{0}", newBalance) });
            mOverlayFinancialRenderGroup.UpdateRenderables(financialReportRows, new int[] { 4, 7 });
        }

        /**
         * Event
         */
        if (EventState.currentEvent != null)
        {
            // Set the image in one of two possible spots
            string focusImage   = EventState.currentEventImage;
            bool   isFace       = focusImage.Contains("face");
            bool   isOtherImage = (focusImage != "" && !isFace);
            Sprite focusSprite  = SpriteManager.GetSprite(EventState.currentEventImage);
            SimulationEventContent.transform.Find("Face").GetComponent <Image>().sprite = null; // clear sprite to reset size information
            SimulationEventContent.transform.Find("Face").GetComponent <Image>().sprite = focusSprite;
            SimulationEventContent.transform.Find("Face").GetComponent <Image>().color  = EventState.currentEventImageColor;
            SimulationEventContent.transform.Find("Face").gameObject.SetActive(isFace && focusSprite != null);
            SimulationEventContent.transform.Find("NonFace/Image").GetComponent <Image>().sprite = null; // clear the sprite in case of weird sprite change bug
            SimulationEventContent.transform.Find("NonFace/Image").GetComponent <Image>().sprite = focusSprite;
            SimulationEventContent.transform.Find("NonFace/Image").GetComponent <Image>().color  = EventState.currentEventImageColor;
            SimulationEventContent.transform.Find("NonFace").gameObject.SetActive(isOtherImage && focusSprite != null);
            // Set the text and options
            // Set option text on the event buttons
            GameObject b1 = SimulationEventContent.transform.Find("DecisionPanel/Options/ButtonLeft").gameObject;
            GameObject b2 = SimulationEventContent.transform.Find("DecisionPanel/Options/ButtonRight").gameObject;
            GameObject b3 = SimulationEventContent.transform.Find("DecisionPanel/Options/ButtonWide").gameObject;
            b1.GetComponent <Image>().alphaHitTestMinimumThreshold = 0.2f;
            b2.GetComponent <Image>().alphaHitTestMinimumThreshold = 0.2f;
            b3.GetComponent <Image>().alphaHitTestMinimumThreshold = 0.2f;
            if (EventState.currentEventOptions != null)
            {
                SimulationEventContent.transform.Find("DecisionPanel/TextTop").GetComponent <Text>().text  = EventState.currentEventText;
                SimulationEventContent.transform.Find("DecisionPanel/TextFull").GetComponent <Text>().text = "";
                b1.SetActive(EventState.currentEventOptions.Length > 1);
                b2.SetActive(EventState.currentEventOptions.Length > 1);
                b3.SetActive(EventState.currentEventOptions.Length == 1);
                if (EventState.currentEventOptions.Length == 1)
                {
                    b3.GetComponentInChildren <Text>().text = EventState.currentEventOptions[0];
                }
                else
                {
                    b1.GetComponentInChildren <Text>().text = EventState.currentEventOptions[0];
                    b2.GetComponentInChildren <Text>().text = EventState.currentEventOptions[1];
                }
            }
            else
            {
                SimulationEventContent.transform.Find("DecisionPanel/TextTop").GetComponent <Text>().text  = "";
                SimulationEventContent.transform.Find("DecisionPanel/TextFull").GetComponent <Text>().text = EventState.currentEventText;
                b1.SetActive(false);
                b2.SetActive(false);
                b3.SetActive(false);
            }
        }

        if (EpilogueView.activeInHierarchy)
        {
            UpdateEpilogueText();
        }
    }