Пример #1
0
    //Trade Panel
    //Sell Button Function
    public void Sell_TradeButtonFunction(Slot slot)
    {
        double cashToAdd = slot.count * slot.valueCost;

        //count = 0
        slot.MinusCount(slot.count);

        //Update UI
        slot.countText.text = ShortScaleString.parseInt(slot.count);

        slot.tradeSlot.info_1           = slot.count + " x " + slot.valueCost;
        slot.tradeSlot.info_1_Text.text = slot.tradeSlot.info_1.ToString();

        slot.tradeSlot.info_2           = cashToAdd.ToString("F2");
        slot.tradeSlot.info_2_Text.text = slot.tradeSlot.info_2.ToString();

        Economy.AddCash(cashToAdd);

        //invoke callbacks
        checkColorsInRecipeTextDelegate(slots);
        checkButtonStatusDelegate(Economy.cash);
        checkTradeUIDelegate(slots);
        checkManagerUIDelegate(slots, Economy.cash);
        checkUpgreadeUIDelegate(slots, Economy.cash);
        checkSellAllButtonUIDelegate(slots);
    }
Пример #2
0
    //Sell all function: invoke in BottomPanel
    public void SellAll()
    {
        double cashToAdd = 0;

        for (int i = 0; i < slots.Length; i++)
        {
            cashToAdd += slots[i].count * slots[i].valueCost;

            //count = 0
            slots[i].MinusCount(slots[i].count);

            //Update UI
            slots[i].countText.text = ShortScaleString.parseInt(slots[i].count);
        }

        Economy.AddCash(cashToAdd);

        //invoke callbacks
        checkColorsInRecipeTextDelegate(slots);
        checkButtonStatusDelegate(Economy.cash);
        checkTradeUIDelegate(slots);
        checkManagerUIDelegate(slots, Economy.cash);
        checkUpgreadeUIDelegate(slots, Economy.cash);
        checkSellAllButtonUIDelegate(slots);
    }
Пример #3
0
    public void SetRecipeText(Slot[] slots)
    {
        if (recipeElements.Count > 0)
        {
            recipeText.text = String.Empty;
            string greenColor = "green";
            string redColor   = "red";

            for (int i = 0; i < recipeElements.Count; i++)
            {
                //colors
                if (slots[recipeElements[i].indexElementFromSlotsList].count >= recipeElements[i].count * slotLevel)
                {
                    recipeText.text += "<b><color=" + greenColor + ">" + (ShortScaleString.parseDoubleForRecipeText(slots[recipeElements[i].indexElementFromSlotsList].count)) + "/" + ShortScaleString.parseDoubleForRecipeText(recipeElements[i].count * slotLevel) + "</color></b>" + " ";
                }
                else
                {
                    recipeText.text += "<b><color=" + redColor + ">" + (ShortScaleString.parseDoubleForRecipeText(slots[recipeElements[i].indexElementFromSlotsList].count)) + "/" + ShortScaleString.parseDoubleForRecipeText(recipeElements[i].count * slotLevel) + "</color></b>" + " ";
                }

                //recipeText.text += recipeElements[i].name;
                string iconName = recipeElements[i].name.ToLower() + "Icon";
                recipeText.text += "<sprite=\"" + iconName + "\" index=0>";

                if (i != (recipeElements.Count - 1))
                {
                    recipeText.text += " + ";
                }
            }
        }
    }
Пример #4
0
    //Set Value to earn if now is equal null and set value Text to update
    private void SetSlotVlue(Slot slot)
    {
        if (slot.value == null)
        {
            slot.value = slot.slotGO.transform.Find("Value").GetComponent <Text>();
        }

        slot.value.text = "$ " + ShortScaleString.parseDouble(slot.valueCost);
    }
Пример #5
0
    public void UpdateUIs(Slot[] slots, double cash)
    {
        string green = "green";
        string red   = "red";
        int    counterForManagerTopUI = 0;

        for (int i = 0; i < slots.Length; i++)
        {
            slots[i].managerSlot.name          = slots[i].name + " Manager";
            slots[i].managerSlot.nameText.text = slots[i].managerSlot.name.ToString();

            if (cash >= slots[i].managerSlot.cost && slots[i].managerSlot.isActive == false)
            {
                //active
                info_managerCost = "<color=" + green + ">" + "$" + ShortScaleString.parseDouble(slots[i].managerSlot.cost) + "</color>";
            }
            else
            {
                //no active
                info_managerCost = "<color=" + red + ">" + "$" + ShortScaleString.parseDouble(slots[i].managerSlot.cost) + "</color>";
            }

            slots[i].managerSlot.info_managerCost_text.text = info_managerCost;

            if (cash >= slots[i].managerSlot.cost && slots[i].managerSlot.isActive == false)
            {
                slots[i].managerSlot.buyButton.interactable = true;
                counterForManagerTopUI += 1;
            }
            else
            {
                slots[i].managerSlot.buyButton.interactable = false;
            }
        }

        if (counterForManagerTopUI > 0)
        {
            GameObject managerTopUI     = GameObject.FindObjectOfType <UI>().managerTopUI;
            Text       managerTopUIText = managerTopUI.transform.Find("TopText").GetComponent <Text>();

            managerTopUI.SetActive(true);

            if (counterForManagerTopUI < 10)
            {
                managerTopUIText.text = counterForManagerTopUI.ToString();
            }
            else
            {
                managerTopUIText.text = "+9";
            }
        }
        else
        {
            GameObject.FindObjectOfType <UI>().managerTopUI.SetActive(false);
        }
    }
Пример #6
0
    //Set count text if is not set up
    private void SetCountText(Slot slot)
    {
        if (slot.countText == null)
        {
            slot.countText = slot.slotGO.transform.Find("Count").GetComponent <Text>();
        }

        //Update UI
        slot.countText.text = ShortScaleString.parseInt(slot.count);
    }
Пример #7
0
    //Upgreade Slot
    public void UpgreadeSlot_ButtonFunction(Slot slot)
    {
        if (Economy.cash >= slot.upgreadeCost)
        {
            Economy.MinusCash(slot.upgreadeCost);

            //slotLevel
            slot.slotLevel++;
            PlayerPrefs.SetInt("SlotLevel_" + slot.index, slot.slotLevel);


            if (slot.slotLevel % 10 == 0)
            {
                //U = B + 0.325 * B
                //W = U * 0.18 + 0.00003 * B * slotLevel + slotLevel
                slot.upgreadeCost += 0.45f * slot.buyCost + 0.01f * slot.buyCost * (slot.slotLevel + 1) + slot.slotLevel;
            }
            else
            {
                //U = B + 0.325 * B
                //W = U * 0.18 + 0.00003 * B * slotLevel
                slot.upgreadeCost += 0.45f * slot.buyCost + 0.01f * slot.buyCost * (slot.slotLevel + 1);
            }
            PlayerPrefs.SetString("SlotUpgreadeCost_" + slot.index, slot.upgreadeCost.ToString());

            //Update UI
            slot.SetButtonText(slot.upgreadeButton, ShortScaleString.parseDouble(slot.upgreadeCost) + "$");

            //Update UI Recipe
            slot.SetRecipeText(slots);

            //Update UI
            slot.slotLevelText.text = slot.slotLevel.ToString();

            //callbacks
            checkMissionDataDelegate(slot, MissionType.LevelCounter, 1);
            foreach (Mission mission in FindObjectOfType <GameManager>().missions)
            {
                if (mission.thisIsActiveMission == true)
                {
                    FindObjectOfType <UI>().UpdateUIMissionPanel(mission);
                    break;
                }
            }
            checkButtonStatusDelegate(Economy.cash);
            checkManagerUIDelegate(slots, Economy.cash);
            checkUpgreadeUIDelegate(slots, Economy.cash);
        }
        else
        {
            Debug.Log("Nie masz wystarczająco duzo pieniędzy");
        }
    }
Пример #8
0
    //Async work slider function
    private IEnumerator SliderWork(Slot slot, float timerAsync)
    {
        slot.SliderIsActive = true;
        int currentSlotLevel = slot.slotLevel;

        slot.icon.GetComponent <Button>().interactable = false;

        float timer = timerAsync;

        slot.slider.maxValue = timerAsync;

        while (slot.slider.value < slot.slider.maxValue)
        {
            slot.slider.value  += 1 * Time.deltaTime;
            timer              -= 1 * Time.deltaTime;
            slot.timerText.text = timer.ToString("F1") + "s";
            yield return(null);
        }

        slot.slider.value = 0;

        //Set timer
        slot.timerText.text = timerAsync.ToString("F1") + "s";

        //GetCash(slot);
        slot.AddCount(1 * currentSlotLevel);

        slot.countText.text = ShortScaleString.parseInt(slot.count);

        slot.SliderIsActive = false;
        slot.icon.GetComponent <Button>().interactable = true;

        //invoke callbacks
        checkMissionDataDelegate(slot, MissionType.EntityCounter, (1 * currentSlotLevel));
        foreach (Mission mission in FindObjectOfType <GameManager>().missions)
        {
            if (mission.thisIsActiveMission == true)
            {
                FindObjectOfType <UI>().UpdateUIMissionPanel(mission);
                break;
            }
        }
        checkColorsInRecipeTextDelegate(slots);
        checkButtonStatusDelegate(Economy.cash);
        checkTradeUIDelegate(slots);
        checkSellAllButtonUIDelegate(slots);

        //if manager is active in this slot
        if (slot.managerSlot.isActive == true)
        {
            StartEntityProduction_ButtonFunction(slot);
        }
    }
Пример #9
0
    public void UpgreadeUIs(Slot[] slots, double cash)
    {
        int counterForUpgreadeTopUI = 0;

        for (int i = 0; i < slots.Length; i++)
        {
            slots[i].upgreadeSlot.name          = slots[i].name + " Upgreade";
            slots[i].upgreadeSlot.nameText.text = slots[i].upgreadeSlot.name.ToString();

            info_upgreadeCost = "-$" + ShortScaleString.parseDouble(slots[i].upgreadeSlot.cost);

            slots[i].upgreadeSlot.info_upgreadeCost_text.text = info_upgreadeCost;

            if (cash >= slots[i].upgreadeSlot.cost && slots[i].upgreadeSlot.isActive == false)
            {
                slots[i].upgreadeSlot.buyButton.interactable = true;
                counterForUpgreadeTopUI += 1;
            }
            else
            {
                slots[i].upgreadeSlot.buyButton.interactable = false;
            }
        }

        if (counterForUpgreadeTopUI > 0)
        {
            GameObject upgreadeTopUI     = GameObject.FindObjectOfType <UI>().updateTopUI;
            Text       upgreadeTopUIText = upgreadeTopUI.transform.Find("TopText").GetComponent <Text>();

            upgreadeTopUI.SetActive(true);

            if (counterForUpgreadeTopUI < 10)
            {
                upgreadeTopUIText.text = counterForUpgreadeTopUI.ToString();
            }
            else
            {
                upgreadeTopUIText.text = "+9";
            }
        }
        else
        {
            GameObject.FindObjectOfType <UI>().updateTopUI.SetActive(false);
        }
    }
Пример #10
0
    //Upgreade Panel
    //Buy Button Function
    public void BuyUpgreade_ButtonFunction(Slot slot)
    {
        if (Economy.cash >= slot.upgreadeSlot.cost)
        {
            Economy.MinusCash(slot.upgreadeSlot.cost);
            slot.upgreadeSlot.isActive = true;
            PlayerPrefs.SetInt("SlotUpgreadeIsActive_" + slot.index, 1);

            //multiply value money to get for every sold entity
            slot.valueCost = slot.valueCost * (double)2;

            //Update UI
            slot.value.text = "$ " + ShortScaleString.parseDouble(slot.valueCost);
        }

        //invoke callbacks
        checkButtonStatusDelegate(Economy.cash);
        checkTradeUIDelegate(slots);
        checkManagerUIDelegate(slots, Economy.cash);
        checkUpgreadeUIDelegate(slots, Economy.cash);
    }
Пример #11
0
    public void SellAllButtonUpdateUI(Slot[] slots)
    {
        double tmpSellAllButton_value = 0;

        foreach (Slot slot in slots)
        {
            tmpSellAllButton_value += slot.count * slot.valueCost;
        }
        sellAllButton_value = tmpSellAllButton_value;

        //Sell all UI
        if (sellAllButton_value <= 0)
        {
            sellAllButton_TopText.gameObject.SetActive(false);
        }
        else
        {
            sellAllButton_TopText.gameObject.SetActive(true);
            sellAllButton_TopText.text = "+$" + ShortScaleString.parseDouble(sellAllButton_value);
        }
    }
Пример #12
0
 private void Update()
 {
     cashText.text    = "$" + ShortScaleString.parseDouble(Economy.cash);
     diamondText.text = "D: " + gameManager.economy.diamond.ToString();
     levelText.text   = gameManager.economy.level.ToString();
 }
 void Update()
 {
     inputValue        = double.Parse(inputTarget.text);
     outputTarget.text = ShortScaleString.parseDouble(inputValue);
 }
Пример #14
0
    private void CreateSlotsConfiguration()
    {
        if (gameLogic.slots.Length > 0)
        {
            for (int i = 0; i < gameLogic.slots.Length; i++)
            {
                //current slot
                Slot tmpSlot = gameLogic.slots[i];

                //Generate main slots in main scrollPanel
                GenerateSlotGO(slotPrefab, viewportMainScrollPanel);
                //Generate slots is trade scroll Panel
                GenerateSlotGO(tradeSlotPrefab, viewportTradeScrollPanel);
                //Generate slots is manager scroll Panel
                GenerateSlotGO(managerSlotPrefab, viewportManagerScrollPanel);
                //Generate slots is upgreade scroll Panel
                GenerateSlotGO(upgreadeSlotPrefab, viewportUpgreadeScrollPanel);

                SetSlotMoneyValue(tmpSlot, i);
                SetSlotIndex(tmpSlot, i);
                SetSlotName(tmpSlot, "Slot_" + i);
                SetSlotGO(tmpSlot, i, viewportMainScrollPanel);
                SetSlotButtonBuy(tmpSlot);
                SetSlotIcon(tmpSlot);
                SetSlotIconImage(tmpSlot);
                SetSlotSlider(tmpSlot);
                SetSlotUpgreadeButton(tmpSlot);
                SetSlotVlue(tmpSlot);
                SetSlotIsActiveValue(tmpSlot, i);
                SetSlotLevel(tmpSlot);
                SetSlotTimer(tmpSlot, i);
                SetSlotTimerText(tmpSlot);
                SetSlotLevelText(tmpSlot);
                SetSlotCount(tmpSlot, i);
                SetCountText(tmpSlot);

                SetRecipe(tmpSlot);
                SetRecipeText(tmpSlot);

                SetTradeSlot(tmpSlot);
                SetManagerSlot(tmpSlot);
                SetUpgreadeSlot(tmpSlot);

                //Configure BuyButton
                tmpSlot.SetButtonText(tmpSlot.buttonBuy, tmpSlot.name + "\n" + ShortScaleString.parseDouble(tmpSlot.buyCost));
                tmpSlot.buttonBuy.onClick.AddListener(delegate { gameLogic.UnlockSlot_ButtonFunction(tmpSlot); });

                //Configure IconButton
                tmpSlot.icon.GetComponent <Button>().onClick.AddListener(delegate { gameLogic.StartEntityProduction_ButtonFunction(tmpSlot); });

                //Configure UpgreadeButton
                tmpSlot.SetButtonText(tmpSlot.upgreadeButton, ShortScaleString.parseDouble(tmpSlot.upgreadeCost) + "$");
                tmpSlot.upgreadeButton.onClick.AddListener(delegate { gameLogic.UpgreadeSlot_ButtonFunction(tmpSlot); });

                //Configure sell button in trade slot
                tmpSlot.tradeSlot.sellButton.onClick.AddListener(delegate { gameLogic.Sell_TradeButtonFunction(tmpSlot); });

                //Configure buy button in manager slot
                tmpSlot.managerSlot.buyButton.onClick.AddListener(delegate { gameLogic.BuyManager_ButtonFunction(tmpSlot); });

                //Configure buy button in upgreade slot
                tmpSlot.upgreadeSlot.buyButton.onClick.AddListener(delegate { gameLogic.BuyUpgreade_ButtonFunction(tmpSlot); });

                //callbacks button status
                gameLogic.checkButtonStatusDelegate += tmpSlot.CheckStatusUpgreadeButton;
                gameLogic.checkButtonStatusDelegate += tmpSlot.CheckStatusBuyButton;

                //callbacks colors in recipe text
                gameLogic.checkColorsInRecipeTextDelegate += tmpSlot.SetRecipeText;

                //callbacks UI in trade
                gameLogic.checkTradeUIDelegate += tmpSlot.tradeSlot.UpdateUIs;

                //callbacks UI in managers
                gameLogic.checkManagerUIDelegate += tmpSlot.managerSlot.UpdateUIs;

                //callbacks UI in upgreade
                gameLogic.checkUpgreadeUIDelegate += tmpSlot.upgreadeSlot.UpgreadeUIs;
            }
        }

        //callback UI is SellAllButton
        gameLogic.checkSellAllButtonUIDelegate += FindObjectOfType <UI>().SellAllButtonUpdateUI;


        //Missions
        //Configure mission button in top panel
        ui.MissionButton.onClick.AddListener(delegate { ui.Mission_ButtonFunction(); });
        ui.backButton.onClick.AddListener(delegate { ui.Mission_ButtonFunction(); });

        gameManager.GenerateMissionsForConfigurator(gameLogic.slots);

        foreach (Mission mission in gameManager.missions)
        {
            //callback Mission Update UI
            gameLogic.checkMissionDataDelegate += mission.UpdateData;
        }

        for (int i = 0; i < gameManager.missions.Count; i++)
        {
            if (gameManager.missions[i].isPassed == false)
            {
                gameManager.missions[i].SetMissionActive();

                ui.UpdateUIMissionPanel(gameManager.missions[i]);
                break;
            }
        }

        //invoke callbacks after configuration (becouse when loaded data you have to update status button etc.)
        gameLogic.checkButtonStatusDelegate(Economy.cash);
        gameLogic.checkColorsInRecipeTextDelegate(gameLogic.slots);
        gameLogic.checkTradeUIDelegate(gameLogic.slots);
        gameLogic.checkManagerUIDelegate(gameLogic.slots, Economy.cash);
        gameLogic.checkUpgreadeUIDelegate(gameLogic.slots, Economy.cash);
        gameLogic.checkSellAllButtonUIDelegate(gameLogic.slots);
    }