Esempio n. 1
0
    public void buildHouse()     //Change name to hut or something more generic
    {
        //This is called when user wants to build house
        // Must have 50 coins
        // call method spawnObjects which creates prefab
        //Within spawnObjects it will be active all the time so set it to false;
        // Only allow 1 object to be placed.

        //Set amount of house
        //One house allows 3 people?


        bool valid = false;

        Debug.Log("House selected");


        //Would you like to upgrade these houses to an estate for 1300 Coins

        //Benefits - Community spirt and happiness increase
        //  Debug.Log("Would you like to upgrade these houses to an estate for 1300 Coins");

        //User input but we want it to be a button yes or no buttons
        //  if(userInput == "Yes")
        //  {
        //Yes
        //   CharacterCreator.currentPlayerCoin = CharacterCreator.currentPlayerCoin - 1300;

        //Upgrade House build
        //   upgradeBuild.UpgradeHouseBuild();
        // }

        //   else if(userInput == "No")
        // {
        //No
        //     Debug.Log("Purchase cancelled");
        //  }



        //Purchase + funds Check
        if (CharacterCreator.currentPlayerCoin >= 10)
        {
            CharacterCreator.currentPlayerCoin = CharacterCreator.currentPlayerCoin - purchaseBuildingObjects[0].EffectOnStatCoin;
            ch.setPlayerCoin();

            valid = true;

            Debug.Log("House purchase");
        }
        else
        {
            Debug.Log("Not enough funds - 10 coins are needed");

            valid = false;
        }


        //Timer of how often water gens


        if (valid == true) // IF the player has enough funds  -  stats and update stats - Instantiate prefab
        {
            Debug.Log("creating House");



            //Storage - Player Storage/SAVE

            // Population check ?? add people into it?

            statsManager.PopulationCheck();

            //Update AreaType Label - GUI
            setAreaType();

            CharacterCreator.currentPopulation = CharacterCreator.currentPopulation + 1;
            Debug.Log(CharacterCreator.currentPopulation);

            //Update Population Label - GUI
            setAreaPopulation();

            //XP
            CharacterCreator.currentXP = CharacterCreator.currentXP + 100;
            statsManager.PlayerLevelCheck();

            //Increase Area Level
            statsManager.increaseAreaLevel();

            validInstantiate = true; // Allows SpawnObject Script to call method which spawns prefab


            //Create House / Prefab on screen
            spawnObjects.SetItem(hut);
            spawnObjects.name = "Hut";


            houseCounter++;
        }

        else // prevents prefab instantiate
        {
            Debug.Log("Unable to spawn due player not having funds");
        }
    }