Example #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");
        }
    }
Example #2
0
    IEnumerator InitCoroutine()
    {
        yield return(new WaitForEndOfFrame());

        Instance = this;

        if (!PlayerPrefs.HasKey(SAVE_NAME))
        {
            PlayerPrefs.SetString(SAVE_NAME, string.Empty);
        }

        if (!PlayerPrefs.HasKey("IsFirstTime"))
        {
            PlayerPrefs.SetInt("IsFirstTime", 1);
        }

        LoadLocal();

        if (Application.platform == RuntimePlatform.Android)
        {
            Debug.Log("Do something special here!");
        }

                #if UNITY_ANDROID
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();
                #endif



        SignIn();
    }
Example #3
0
    public IEnumerator UnlockTalent(int id)
    {
        timeToWait    = GameController.instance.talentTree.talents[id].timeToResearch / (ResearchSpeed / 100);
        researchable  = GameController.instance.talentTree.talents[id];
        isResearching = true;
        while (timeToWait > 0)
        {
            timeToWait--;
            yield return(new WaitForSeconds(1));
        }
        GameController.instance.talentTree.talents[id].isUnlocked = true;
        GameController.instance.talentTree.talents[id].isSelected = false;
        isResearching = false;
        view.holders[id].ChangeHolderPicture(true);
        view.holders[id].onResearch.Play();
        view.onResearch.Play();
        GameController.instance.audio.MakeSound(view.onResearchSound);
        EventManager.TriggerEvent("OnResearch", 1);
        player.GainExperience(50 * id);
        if (!tutorial.isTutorialCompleted)
        {
            GameController.instance.buttons.ShowCancel();
            tutorial.ContinueTutorial();
        }
        List <int> allIDs = new List <int>();

        foreach (Talent t in GameController.instance.talentTree.talents)
        {
            allIDs.Add(t.id);
        }
        if (id == allIDs.Max())
        {
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_mad_scientist);
        }
    }
Example #4
0
    public void LevelUp()
    {
        Researcher researcher = GameController.instance.researcher;

        level           += 1;
        experienceNeeded = CalculateExperienceNeeded();
        EventManager.TriggerEvent(OnLevelEvent);
        GainExperience(1);
        panel.SetPanel();
        levelPanel.SetPanel();
        // unlock new inventory slots
        if (level == 4)
        {
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_student);
        }
        else if (level == 10)
        {
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_scientific_worker);
        }
        else if (level == 16)
        {
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_scholar);
        }
        if (level % 8 == 0)
        {
            var messabox = GameController.instance.buttons.messageBox;
            messabox.Show("Inventory capacity is increased");
            inventory.capacity += 2;
        }
    }
 public override void OnSell()
 {
     foreach (Manufactory sObject in GameController.instance.roomOverseer.GetAllSceneObjects().Where(x => x.GetComponent <Manufactory>() != null))
     {
         sObject.resourcePerTime *= productionMultiplier;
     }
     PlayGameScript.UnlockAchievement(GPGSIds.achievement_man_of_honor);
 }
Example #6
0
    public override void OnSell()
    {
        List <Talent>   empty           = new List <Talent>();
        Characteristics characteristics = new Characteristics(0, 0, 0, 0, healingAmount);
        Recipe          medkit          = new Recipe("Medkit", empty, characteristics, true, Resources.Load <Sprite>("Icons/Recipe/medkit"));

        GameController.instance.player.inventory.Set(medkit, 1, true);
        PlayGameScript.UnlockAchievement(GPGSIds.achievement_man_of_honor);
    }
Example #7
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());
    }
 void Start()
 {
     //thisButton = gameObject.GetComponent<Button> ();
     maxLevel       = PlayerPrefs.GetInt("MaxLevel", 1);
     playGameScript = FindObjectOfType(typeof(PlayGameScript)) as PlayGameScript;
     levelOpener    = FindObjectOfType(typeof(LevelOpener)) as LevelOpener;
     levelofButton  = int.Parse(gameObject.GetComponentInChildren <Text> ().text);
     if (maxLevel < levelofButton)
     {
         gameObject.GetComponent <Button> ().interactable  = false;
         gameObject.GetComponent <Image> ().color          = Color.black;
         gameObject.GetComponentInChildren <Text> ().color = Color.black;
     }
 }
Example #9
0
    public void GenerateReport()
    {
        revenue.Add(0);
        staticExpences.Add(0);
        activeExpences.Add(0);
        itemsProduced.Add(0);
        dates.Add(GameController.instance.time.date);
        investments.Add(GameController.instance.player.resources.money);
        int productivityEfficiency = Mathf.RoundToInt(GetProductivity() * 100);

        PlayGameScript.AddToLeaderboard(GPGSIds.leaderboard_productivity_factor, productivityEfficiency);
        PlayGameScript.AddToLeaderboard(GPGSIds.leaderboard_healed_humans, GetHealedAmount());

        if (productivityEfficiency >= 75)
        {
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_finally_some_good_management);
        }
    }
Example #10
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);
    }
Example #11
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);
     }
 }
Example #12
0
    public void CompleteTutorial()
    {
        isTutorialCompleted = true;

        if (dialogue.dialogueName == "General")
        {
            Debug.Log("UNLOCK ACHIEV");
            PlayGameScript.UnlockAchievement(GPGSIds.achievement_youve_lasted_so_far_heh);
        }
        if (tPanel.gameObject.activeInHierarchy)
        {
            tPanel.Hide();
        }
        if (objectsToClose.Count > 0)
        {
            foreach (GameObject g in objectsToClose)
            {
                g.SetActive(false);
            }
        }
    }
Example #13
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");
        }
    }
Example #14
0
 public override void OnSell()
 {
     GameController.instance.player.hasAutoClicker = true;
     PlayGameScript.UnlockAchievement(GPGSIds.achievement_man_of_honor);
 }
Example #15
0
 public void ShowLeaderboard()
 {
     PlayGameScript.ShowLeaderboardUI();
 }
Example #16
0
 public void ShowAchievements()
 {
     PlayGameScript.ShowAchievementsUI();
 }
 public void RestartGame()
 {
     PlayGameScript.AddScoreToLeaderboard(GPGSIds.leaderboard_leaderboard, Counter);
 }
Example #18
0
 public override void OnSell()
 {
     reward.RewardPlayer();
     PlayGameScript.UnlockAchievement(GPGSIds.achievement_man_of_honor);
 }
 void Start()
 {
     playGameScript = FindObjectOfType(typeof(PlayGameScript)) as PlayGameScript;
 }
Example #20
0
 public override void OnSell()
 {
     GameController.instance.player.resources.AddSecondChance(1);
     PlayGameScript.UnlockAchievement(GPGSIds.achievement_man_of_honor);
 }