Beispiel #1
0
    public string Craft(int quantity)  // craft quantity of medicine according to selected recipe (field)
    {
        characteristics *= quantity;
        Player player = GameController.instance.player;

        if (player.resources.currentHealingPlants >= characteristics.healingPlantsNeeded && // does player has enough resources?
            player.resources.currentChemistry >= characteristics.chemistryNeeded &&
            player.resources.currentPlastic >= characteristics.plasticNeeded)
        {
            player.resources.SpendResources(characteristics.healingPlantsNeeded, characteristics.chemistryNeeded, characteristics.plasticNeeded);
            characteristics /= quantity;
            player.inventory.Set(recipeSelected, quantity); // set selected recipe to a new quantity
            Debug.Log(recipeSelected.description.Name + " " + quantity);
            Recipe r = recipeSelected;

            PopulateRecipeList(view.recipesListView, view.recipeInList); // refresh view
            recipeSelected = r;
            player.finances.AddToProducedItems(quantity);
            EventManager.TriggerEvent("OnCraftMedicine", quantity);

            PlayGameScript.IncrementAchievement(GPGSIds.achievement_chemical_engineering, quantity);
            player.GainExperience(100 * (recipeSelected.PTalents.Count + recipeSelected.STalents.Count));
            view.PlayOnCraftParticles();
            return("TRUE");
        }
        else
        {
            characteristics /= quantity;
            return("FALSE");
        }
    }
Beispiel #2
0
    public void Sell(Recipe recipe, Invoice invoice)
    {
        if (!GameController.instance.player.inventory.CheckIfWarehouseContains(recipe.description.Name) || invoice.quantity + area.soldItems > area.maxQuotum)
        {
            return;
        }

        bool soldSuccesfully = GameController.instance.player.inventory.Remove(recipe.description.Name, invoice.quantity);

        if (soldSuccesfully)
        {
            if (!tutorial.isTutorialCompleted)
            {
                tutorial.ContinueTutorial();
            }
            view.returnBtn.gameObject.SetActive(true);
            var messageBox = GameController.instance.buttons.messageBox;
            messageBox.Show(
                "x" + invoice.quantity.ToString() + " "
                + RecipeSelector.recipeHolderSelected.recipe.description.Name + " sold",
                RecipeSelector.recipeHolderSelected.recipe.description.sprite
                );
            GameController.instance.player.GainExperience(invoice.quantity * 10 * (area.experienceMultiplier + (recipe.Talents.Count) / 4));
            GameController.instance.player.resources.ChangeBalance(invoice.Summary, true);
            int healAmount = recipe.characteristics.healingRate * invoice.quantity;
            area.health    += healAmount; area.health = Mathf.Clamp(area.health, 0, area.maxHealth);
            area.soldItems += invoice.quantity;
            // refresh dead/alive rate
            int    alive  = 0;
            int    dead   = 0;
            Reaper reaper = new Reaper();
            dead               = reaper.GetDeadAliveRate(recipe, invoice.quantity, out alive);
            area.dead         += dead;
            area.cured        += alive;
            area.health       -= dead * 10;
            recipe.soldAmount += invoice.quantity;
            recipe.deadAmount += dead;
            recipe.RecalculatePrice();
            view.onSell.Play();
            // achieve quest's objective if it exists
            EventManager.TriggerEvent("OnSell", invoice.quantity);
            EventManager.TriggerEvent("OnKill", dead);
            EventManager.TriggerEvent("OnCure", alive);
            EventManager.TriggerEvent("OnHeal", healAmount);
            // increment achievement
            PlayGameScript.IncrementAchievement(GPGSIds.achievement_life_saver, alive);
            PlayGameScript.IncrementAchievement(GPGSIds.achievement_grim_reaper, dead);
            GameController.instance.audio.MakeSound(onSellSound);
        }
        view.SetViewToArea(area);
        view.RemoveCheckmarks();

        ListPopulator.PopulateRecipeList(view.recipeView, view.recipePrefab, GameController.instance.player.inventory.recipes.Where(x => x.GetDeathRating() <= area.deathRatingAllowed &&
                                                                                                                                    GameController.instance.player.inventory.GetQuantity(x.description.Name) > 0).ToList());
    }
Beispiel #3
0
    public Constructible Build(int id, Constructible[] objectsArray, Cell cell, bool playEffects = true)
    {
        Constructible selectedObject = objectsArray[id];

        if (selectedObject.gameObject.tag == "Room")
        {
            EventManager.TriggerEvent("OnBuildRoom", 1);
            if (onRoomBuild != null)
            {
                if (playEffects)
                {
                    ParticleSystem particle = Instantiate(onRoomBuild, cell.transform.position, Quaternion.identity);
                    particle.gameObject.SetActive(true);
                    particle.Play();
                }
                PlayGameScript.UnlockAchievement(GPGSIds.achievement_builder);
            }
        }
        else
        {
            EventManager.TriggerEvent("OnBuildObject", 1);
            PlayGameScript.IncrementAchievement(GPGSIds.achievement_a_new_beginning, 1);
            if (onObjectBuild != null)
            {
                if (playEffects)
                {
                    ParticleSystem particle = Instantiate(onObjectBuild, cell.transform.position, Quaternion.identity);
                    particle.gameObject.SetActive(true);
                    particle.Play();
                }
            }
        }
        if (playEffects)
        {
            GameController.instance.player.GainExperience(100 * GameController.instance.roomOverseer.rooms.Count);
            GameController.instance.player.finances.AddToActiveExpences(selectedObject.description.buyPrice);
            GameController.instance.audio.MakeSound(onBuildSounds[Random.Range(0, onBuildSounds.Length)]);
        }
        Constructible toReturn = Instantiate(selectedObject, new Vector3(cell.transform.position.x, cell.transform.position.y, cell.transform.position.z - 0.5f), cell.transform.rotation);

        StartCoroutine(Camera.main.gameObject.GetComponent <CameraController>().FocusCamera(toReturn.transform.position));

        return(toReturn);
    }
Beispiel #4
0
 public void ChangeBalance(int amount, bool activeIncome = false)
 {
     money += amount;
     rPanel.SetPanel(this);
     if (amount != 0)
     {
         GameController.instance.buttons.paymentPanel.SetPanel(amount);
     }
     if (amount > 0 && activeIncome)
     {
         GameController.instance.player.finances.AddToRevenue(amount);
     }
     if (amount > 0)
     {
         EventManager.TriggerEvent("OnCollectMoney", amount);
         //add to achievement in google play
         PlayGameScript.IncrementAchievement(GPGSIds.achievement_greed_before_need, amount);
     }
 }
Beispiel #5
0
    public string Craft(string Name, int quantity, Sprite avatar) // craft new recipe
    {
        Player player = GameController.instance.player;

        characteristics *= quantity;
        int researchPoints = CalculateResearchPoints(selectedTalents);

        if (player.resources.currentHealingPlants >= characteristics.healingPlantsNeeded && // does player has enough resources?
            player.resources.currentChemistry >= characteristics.chemistryNeeded &&
            player.resources.currentPlastic >= characteristics.plasticNeeded &&
            player.resources.ResearchPoints >= researchPoints)
        {
            characteristics /= quantity;
            Recipe recipe          = new Recipe(Name, selectedTalents, characteristics, isLiquid, avatar); // create recipe
            int    storageCapacity = player.inventory.GetNumberOfElements();
            player.inventory.Set(recipe, quantity);                                                        // set recipe to it's quantity via dictionary
            if (storageCapacity == player.inventory.GetNumberOfElements())                                 // check for max capacity in inventory
            {
                return("FULL");
            }
            characteristics *= quantity;
            player.resources.SpendResources(characteristics.healingPlantsNeeded, characteristics.chemistryNeeded, characteristics.plasticNeeded, researchPoints);
            characteristics /= quantity;
            PopulateRecipeList(view.recipesListView, view.recipeInList);                                                           // refresh view
            view.capacity.text = player.inventory.GetNumberOfElements().ToString() + " / " + player.inventory.capacity.ToString(); // refresh capacity text
            recipeSelected     = recipe;
            EventManager.TriggerEvent("OnCraftMedicine", quantity);

            EventManager.TriggerEvent("OnCraftRecipe", 1);
            player.GainExperience(100 * (recipeSelected.PTalents.Count + recipeSelected.STalents.Count));
            player.finances.AddToProducedItems(quantity);
            PlayGameScript.IncrementAchievement(GPGSIds.achievement_chemical_engineering, quantity);
            return("TRUE");
        }
        else
        {
            characteristics /= quantity;
            return("FALSE");
        }
    }