Ejemplo n.º 1
0
    public void StartBuilding(string buttonContent)
    {
        Debug.Log("button click: " + buttonContent);
        if (buttonContent == "add-stall")
        {
            if (PlayerEconomy.Money >= Prices.GetStallConstructionPrice(unlockedStalls))
            {
                PlayerEconomy.PayMoney(Prices.GetStallConstructionPrice(unlockedStalls));


                //enable GO, construction
                stalls [unlockedStalls].gameObject.SetActive(true);
                stalls [unlockedStalls].underConstruction.SetActive(true);
                for (int i = 0; i < stalls [unlockedStalls].finished.Length; ++i)
                {
                    stalls [unlockedStalls].finished [i].SetActive(false);
                }

                //store in duration dict. index is nr of unlocked stalls
                constructionDaysRemainingPerStallIndex.Add(unlockedStalls, Durations.GetStallConstructionDuration(unlockedStalls));
                UI.instance.constructionUI.underConstructionDaysRemaining.text = constructionDaysRemainingPerStallIndex[unlockedStalls].ToString() + " " + GetDayPluralSingular(constructionDaysRemainingPerStallIndex[unlockedStalls]) + " remaining";

                unlockedStalls++;

                UI.instance.constructionUI.hideOnConstruction.SetActive(false);
                UI.instance.constructionUI.showOnConstruction.SetActive(true);
            }
            else
            {
                Debug.Log("not enough money for stall construction!");
            }
        }
    }
Ejemplo n.º 2
0
    private void LoadGame()
    {
        //read file into a Save
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Open(Application.persistentDataPath + saveFilePath, FileMode.Open);
        Save            save = (Save)bf.Deserialize(file);

        file.Close();

        day = save.day;
        HayCart[] carts = FindObjectsOfType <HayCart> ();
        for (int i = 0; i < carts.Length; ++i)
        {
            if (carts [i].fillType == equippableItemID.HAY)
            {
                carts [i].InitOrRestockCart(save.hayCartFill);
            }
            else if (carts [i].fillType == equippableItemID.STRAW)
            {
                carts [i].InitOrRestockCart(save.strawCartFill);
            }
        }

        FindObjectOfType <ConstructionBook> ().SetUnlockedStallsFromSave(save.unlockedStallUnits, save.buildingsUnderConstruction, save.paddockPartitions);

        PlayerEconomy.LoadMoneyFromSave(save.money);
        StartNewDay();
    }
Ejemplo n.º 3
0
    public override void PlayerInteracts(Player player)
    {
        base.PlayerInteracts(player);

        if (currentlyRelevantActionIDs.Count > selectedInteractionIndex)
        {
            switch (currentlyRelevantActionIDs [selectedInteractionIndex])
            {
            case actionID.TALK_TO:
                UI.instance.ShowDialogue(Dialogues.RetrieveDialogue(TimeLogic.day, characterId, DialogueID.GREETING) [0], portrait, characterId, Dialogues.RetrieveReward(TimeLogic.day, characterId, DialogueID.GREETING));


                if (characterId == Character.GRANDMA)
                {
                    Quests.instance.FulfilledQuestCondition(QuestTask.TALK_TO_GRANDMA);
                }

                break;

            case actionID.SELL:
                Equippable item = player.currentlyEquippedItem;
                PlayerEconomy.ReceiveMoney(Prices.GetPriceByID(player.currentlyEquippedItem.id));
                player.UnequipEquippedItem(false, true);
                Destroy(item.gameObject);
                break;
            }
        }
    }
Ejemplo n.º 4
0
    public void ContinueInDialogue()
    {
        //eventually, this needs to handle multi-line dialogues
        //tie dialogues in sequences somehow?

        //actually get reward upon continuing
        switch (currentReward.rewardType)
        {
        case RewardType.MONEY:
            PlayerEconomy.ReceiveMoney(currentReward.rewardAmount);
            break;

        default:
            break;
        }

        //if (this line is last in sequence){
        inventoryUI.transform.position = regularInvPos.position;
        dialogueBox.SetActive(false);
        if (lastRelevantPlayer != null)
        {
            lastRelevantPlayer.allowPlayerInput = true;
        }
        dialogueIsVisible        = false;
        currentReward.rewardType = RewardType.NONE;
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Awake()
    {
        playerEconomy = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerEconomy>();
        text          = GetComponent <Text>();

        cakes = playerEconomy.currentCakes;
    }
Ejemplo n.º 6
0
    // Start is called before the first frame update
    void Awake()
    {
        playerEconomy = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerEconomy>();
        text          = GetComponent <Text>();

        storage = playerEconomy.storedCakes;
    }
Ejemplo n.º 7
0
    void callForPurchase()
    {
        OnObjectPurchase?.Invoke(currentBuyObject);
        OnObjectSatisfaction?.Invoke(currentBuyObject.SatisfactionGain);

        PlayerEconomy.createPurchase(currentBuyObject.BuyName, -currentBuyObject.BuyValue);
        currentBuyObject = null;
    }
    public virtual void PrepareFood()
    {
        if (PlayerDataHolder.Current.PlayerMoney.getValue <float>() >= cost)
        {
            PlayerDataHolder.Current.Foodamount.ChangeStat(increaseAmount);

            PlayerEconomy.createPurchase("Ruokakauppareissut", -cost, true);
        }
        else
        {
            MainCanvas.mainCanvas.createEconomyWarning();
        }
    }
Ejemplo n.º 9
0
    float CalculatedPerusOmaVastuu() //Omavastuu ei vaikuta, jos tulot ovat liian pieniä...
                                     //Oletus on siinä että pelaaja asuu yksin.
    {
        float value = 0;
        float calculatedTotalIncome = 0;

        calculatedTotalIncome += PlayerEconomy.getAllIncomeSourceGrossTotals(1);
        if (calculatedTotalIncome > maximumGrossIncomeWhereOmaVastuuDoesNotDecreaseSupportAmount)
        {
            value = 0.42f * (calculatedTotalIncome - (603 + 100)); //Pelkistetty laskukaava, mutta simulaatiossa oletetaan se, että opiskelijalla ei ole lapsia, tai muita ruokakuntalaisia. (asuu yksin)
            return(value);
        }
        else
        {
            return(value);
        }
    }
Ejemplo n.º 10
0
 void Awake()
 {
     player        = GameObject.FindGameObjectWithTag("Player");
     playerEconomy = player.GetComponent <PlayerEconomy>();
 }
Ejemplo n.º 11
0
 protected void IncreaseIncome()
 {
     playerEconomy = GameObject.Find("PlayerBase").GetComponent <PlayerEconomy>();
     playerEconomy.generationRate += rateIncrease;
 }
 void UpdateUI()
 {
     incomeEconomyText.text  = (PlayerEconomy.totalSpeculatedNetIncomeInAMonth() + " euroa/kk");
     expenseEconomyText.text = (PlayerDataHolder.Current.getTotalCosts()) + " euroa/kk";
 }
Ejemplo n.º 13
0
 private void RefillHayCart()
 {
     PlayerEconomy.PayMoney(refillPrice);
     cartToRestock.InitOrRestockCart(cartToRestock.currentUnits + refillUnits);
 }
Ejemplo n.º 14
0
 public void Save(PlayerEconomy economy)
 {
     PlayerPrefs.SetInt("coins", economy.Coins);
 }