Пример #1
0
    void PopulateRevenue()
    {
        float total = 0;

        foreach (var rev in gameRevenues)
        {
            total += rev;
        }
        for (int i = 0; i < financeReportRows.Length; i++)
        {
            if (i == 0)
            {
                financeReportRows[i].label.text = "Total Revenues";
                financeReportRows[i].value.text = string.Format("${0:N0}", total);
            }
            else if (MarketManager.IsGameAvailable((GameType)(i - 1)) && GameManager.IsDepartmentExists(Departments.Finance))
            {
                financeReportRows[i].label.text = string.Format("- {0}", MarketManager.GetGameNames((GameType)(i - 1)));
                financeReportRows[i].value.text = string.Format("({1}) ${0:N0}", gameRevenues[i - 1], gameSaleCount[i - 1]);
            }
            else
            {
                financeReportRows[i].label.text = "";
                financeReportRows[i].value.text = "";
            }
        }

        if (!GameManager.IsDepartmentExists(Departments.Finance))
        {
            financeDeptMissingObject.SetActive(true);
        }

        expenseByDept.SetActive(false);
    }
Пример #2
0
 private void UpdateAllPricesUI()
 {
     for (int i = 0; i < pricesRows.Length; i++)
     {
         if (MarketManager.IsGameAvailable(i))
         {
             UpdatePricesUI(i);
         }
     }
 }
Пример #3
0
 private void UpdateAllRestockUI()
 {
     for (int i = 0; i < restockRows.Length; i++)
     {
         if (MarketManager.IsGameAvailable(i))
         {
             UpdateRestockUI(i);
         }
     }
 }
Пример #4
0
 void PopulatePrices(bool init = false)
 {
     for (int i = 0; i < pricesRows.Length; i++)
     {
         if (MarketManager.IsGameAvailable(i))
         {
             pricesRows[i].gameName.transform.parent.gameObject.SetActive(true);
             pricesRows[i].gameName.text = string.Format("{0}", MarketManager.GetGameNames((GameType)i));
             UpdatePricesUI(i);
         }
         else
         {
             pricesRows[i].gameName.transform.parent.gameObject.SetActive(false);
         }
     }
 }
Пример #5
0
 void PopulateInitialRestock()
 {
     for (int i = 0; i < restockRows.Length; i++)
     {
         if (MarketManager.IsGameAvailable(i))
         {
             restockRows[i].gameName.transform.parent.gameObject.SetActive(true);
             restockRows[i].gameName.text        = string.Format("{0}", MarketManager.GetGameNames((GameType)i));
             restockRows[i].stockText.text       = string.Format("{0:N0}", Logistics.GetStock(i));
             restockRows[i].priceText.text       = "$0";
             restockRows[i].stockSlider.value    = 0;
             restockRows[i].stockSlider.maxValue = Logistics.GetCapacity() - Logistics.GetStock(i);
         }
         else
         {
             restockRows[i].gameName.transform.parent.gameObject.SetActive(false);
         }
     }
 }
Пример #6
0
    void UpdateRestockUI(int id)
    {
        float totalPrice = 0;
        int   totalStock = 0;

        if (addedStocks[id] != 0)
        {
            restockRows[id].stockText.text = string.Format("{0:N0} ({1:+#;-#;0})", Logistics.GetStock((GameType)id), addedStocks[id]);
        }
        else
        {
            restockRows[id].stockText.text = string.Format("{0:N0}", Logistics.GetStock((GameType)id));
        }
        restockRows[id].priceText.text = string.Format("${0:N0}", MarketManager.GetBuyPrice(id) * addedStocks[id]);
        for (int i = 0; i < addedStocks.Length; i++)
        {
            if (MarketManager.IsGameAvailable(i))
            {
                totalPrice += MarketManager.GetBuyPrice(i) * addedStocks[i];
                totalStock += addedStocks[i];
            }
        }
        instance.moneyText.text = GameManager.Cash > 0 ? string.Format("${0:N0}", GameManager.Cash - totalPrice) : string.Format("<color=red>-${0:N0}</color>", Mathf.Abs(GameManager.Cash - totalPrice));;

        if (Logistics.GetTotalStocks() + totalStock > Logistics.GetCapacity())
        {
            restockTitle.text = string.Format("Restock <color=red>({0}/{1})</color>", Logistics.GetTotalStocks() + totalStock, Logistics.GetCapacity());
        }
        else
        {
            restockTitle.text = string.Format("Restock ({0}/{1})", Logistics.GetTotalStocks() + totalStock, Logistics.GetCapacity());
        }

        if (Logistics.GetTotalStocks() + totalStock > Logistics.GetCapacity() || GameManager.Cash - totalPrice < 0)
        {
            instance.commitButton.interactable = false;
        }
        else
        {
            instance.commitButton.interactable = true;
        }
    }
Пример #7
0
    public void OnCommit()
    {
        restocksOrig = new int[5];
        float totalCash = 0;

        for (int i = 0; i < restockRows.Length; i++)
        {
            if (MarketManager.IsGameAvailable(i) && addedStocks[i] > 0)
            {
                totalCash       += addedStocks[i] * MarketManager.GetBuyPrice(i);
                restocksOrig[i] += addedStocks[i];
                Logistics.RestockGame((GameType)i, addedStocks[i]);
            }
        }

        GameManager.AdjustCash(totalCash);
        addedStocks = new int[5];

        PopulateInitialRestock();
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        if (exiting)
        {
            return;
        }
        if (!depts.ContainsKey(Departments.Logistics) || !depts.ContainsKey(Departments.Cashier) || !depts.ContainsKey(Departments.Showcase))
        {
            Debug.LogError("Cannot load game: Department requirements not met\nRequired Logistics, Cashier and Showcase");
            enabled = false;
        }

        if (canSpawnCustomer && !isSpawning)
        {
            t += Time.deltaTime;
        }
        if (t >= NetCustomerSpawnTime && canSpawnCustomer)
        {
            t          = 0;
            isSpawning = true;
            StartCoroutine(SpawnTime());
        }
        if (!mainMenuMode)
        {
            timeText.text = string.Format("{0:N0}:{1:00}", DaytimeManager.TimeHour, DaytimeManager.TimeMinute);

            stockTab.totalStocks.text        = string.Format("{0:N0}/{1:N0}", Logistics.GetTotalStocks(), Logistics.GetCapacity());
            stockTab.totalStocksBar.maxValue = Logistics.GetCapacity();
            stockTab.totalStocksBar.value    = Logistics.GetTotalStocks();
            stockTab.totalStocksFill.color   = Color.HSVToRGB((1 - (float)Logistics.GetTotalStocks() / Logistics.GetCapacity()) / 3.6f, 1, 1);
            for (int i = 0; i < 5; i++)
            {
                if (MarketManager.IsGameAvailable((GameType)i))
                {
                    stockTab.gameTitles[i].text = MarketManager.GetGameNames((GameType)i);
                    stockTab.gameStocks[i].text = Logistics.GetStock(i).ToString("n0");
                    if (i > 0)
                    {
                        stockTab.separators[i - 1].SetActive(true);
                    }
                }
                else
                {
                    stockTab.gameTitles[i].text = "";
                    stockTab.gameStocks[i].text = "";
                    if (i > 0)
                    {
                        stockTab.separators[i - 1].SetActive(false);
                    }
                }
            }

            //Input (touch)
            if (Time.timeScale != 0 && !EndDayManager.IsPanelOpen)
            {
                var touch = Input.touches;
                if (touch.Length == 1 && touch[0].deltaPosition.magnitude > 0.2f)
                {
                    Vector3 delta = new Vector3(touch[0].deltaPosition.x, 0, touch[0].deltaPosition.y);
                    cameraPivot.Translate(delta * -Time.deltaTime * 0.4f * panSensitivity);
                }
                else if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        ISelectable sel = hit.collider.GetComponent <ISelectable>();

                        if (sel != null && !(sel is Showcase))
                        {
                            if (selected == null)
                            {
                                selectStatusAnim.Play("Open");
                            }
                            DeselectAll();

                            selected = sel;
                            selected.Select();
                        }
                        else
                        {
                            if (selected != null)
                            {
                                selectStatusAnim.Play("Close");
                            }
                            DeselectAll();
                        }
                    }
                }
            }
            if (selected != null)
            {
                if (selected is Customer)
                {
                    var selectedCustomer = selected as Customer;
                    customerSelect.SetActive(true);
                    departmentSelect.SetActive(false);
                    customerSelectContents.NameText.text            = selectedCustomer.custName;
                    customerSelectContents.Text1Text.text           = selectedCustomer.CurrentActionName + " " + (selectedCustomer.CurrentActionName == "Shopping" ? MarketManager.GetGameNames(selectedCustomer.GameDemand) : "");
                    customerSelectContents.Bar1Slider.maxValue      = 100;
                    customerSelectContents.Bar1Slider.value         = selectedCustomer.Happiness;
                    customerSelectContents.Progress1Slider.maxValue = selectedCustomer.MaxProgressTime;
                    customerSelectContents.Progress1Slider.value    = selectedCustomer.CurrentProgressTime;
                    customerSelectContents.stat1.text = selectedCustomer.Visits.ToString("n0");
                    customerSelectContents.stat2.text = string.Format("${0:n0}", selectedCustomer.TotalSpendings);
                }
                else if (selected is DepartmentBase)
                {
                    var selectedDept = selected as DepartmentBase;
                    departmentSelect.SetActive(true);
                    customerSelect.SetActive(false);
                    departmentSelectContents.departmentName.text = selectedDept.departmentName;
                    departmentSelectContents.trustBar.maxValue   = 100;
                    departmentSelectContents.trustBar.value      = selectedDept.CurrentTrust;
                    if (selected is Cashier || selected is CustomerService)
                    {
                        departmentSelectContents.workSpeedLbl.text = "Work Speed";
                    }
                    else
                    {
                        departmentSelectContents.workSpeedValue.text = "Effectiveness";
                    }
                    departmentSelectContents.workSpeedValue.text = string.Format("{0:N0}%", selectedDept.WorkSpeed * 100);
                }
            }
        }
    }