コード例 #1
0
        private void GrowFoods(int pFoodCount)
        {
            GridController gridController = PlayController.main.GetGridController();

            int maxFoodCount = gridController.GetFoodObjectMaxCount();
            int randomExtra  = Utils.RandomRange(0, 2);

            for (int i = pFoodCount - randomExtra; i < maxFoodCount; ++i)
            {
                Vector3 foodPosition = gridController.PickRandomGridPosition();
                gridController.SliceGridPosition(foodPosition);

                GameObject goFood = gameObjectFactory.FetchFoodObject();
                goFood.transform.localPosition = foodPosition;
                FoodHandler foodHandler = goFood.GetComponent <FoodHandler>();
                foodHandler.PlayGrow(1.0f, Utils.RandomRange(0f, 0.5f));

                gridController.AddFoodObjectCount(1);
            }
        }
コード例 #2
0
        public void Load()
        {
            Transform pParent = transform;

            // Prefabs
            for (int i = 0; i < 100; ++i)
            {
                // tree
                GameObject  goTree      = Instantiate(prefabTree);
                TreeHandler treeHandler = goTree.GetComponent <TreeHandler>();
                treeHandler.Load(pParent);
                treeObjectPool.Enqueue(goTree);

                // stone
                GameObject   goStone      = Instantiate(prefabStone);
                StoneHandler stoneHandler = goStone.GetComponent <StoneHandler>();
                stoneHandler.Load(pParent);
                stoneObjectPool.Enqueue(goStone);

                // food
                GameObject  goFood      = Instantiate(prefabFood);
                FoodHandler foodHandler = goFood.GetComponent <FoodHandler>();
                foodHandler.Load(pParent);
                foodObjectPool.Enqueue(goFood);
            }

            // Preloads
            PlayController pc = PlayController.main;



            BuildingsHandler buildingsHandler = buildingsHandlerObject.GetComponent <BuildingsHandler>();

            buildingsHandler.Load();

            // houses
            BuildingClicker houseClicker = houseSmallClickerObject.GetComponent <BuildingClicker>();

            houseClicker.Load(pc.gameData.houseSmallResourceCost);

            houseClicker = houseMediumClickerObject.GetComponent <BuildingClicker>();
            houseClicker.Load(pc.gameData.houseMediumResourceCost);

            houseClicker = houseLargeClickerObject.GetComponent <BuildingClicker>();
            houseClicker.Load(pc.gameData.houseLargeResourceCost);

            // resources
            BuildingClicker satisfactionClicker = farmClickerObject.GetComponent <BuildingClicker>();

            satisfactionClicker.Load(pc.gameData.farmResourceCost);

            BuildingClicker resourceClicker = foresterClickerObject.GetComponent <BuildingClicker>();

            resourceClicker.Load(pc.gameData.foresterResourceCost);

            resourceClicker = quarryClickerObject.GetComponent <BuildingClicker>();
            resourceClicker.Load(pc.gameData.quarryResourceCost);

            // satisfaction
            resourceClicker = cemeteryClickerObject.GetComponent <BuildingClicker>();
            resourceClicker.Load(pc.gameData.cemeteryResourceCost);

            satisfactionClicker = clinicClickerObject.GetComponent <BuildingClicker>();
            satisfactionClicker.Load(pc.gameData.clinicResourceCost);

            satisfactionClicker = tavernClickerObject.GetComponent <BuildingClicker>();
            satisfactionClicker.Load(pc.gameData.tavernResourceCost);

            OnLoadComplete?.Invoke();
        }
コード例 #3
0
        public void Enter()
        {
            PlayController.main.OnDayStartedEvent -= OnDayStarted;
            PlayController.main.OnDayStartedEvent += OnDayStarted;
            PlayController.main.EnableClickers();

            PlayBuildingsEnter();

            PlayGridEnter();

            GridController gridController = PlayController.main.GetGridController();

            // Tree
            int treeCount = gridController.GetTreeObjectMaxCount();

            for (int i = 0; i < treeCount; ++i)
            {
                Vector3 treePosition = gridController.PickRandomGridPosition();
                gridController.SliceGridPosition(treePosition);

                GameObject goTree = gameObjectFactory.FetchTreeObject();
                goTree.transform.localPosition = treePosition;
                TreeHandler treeHandler = goTree.GetComponent <TreeHandler>();
                treeHandler.PlayGrow(1.0f, Utils.RandomRange(1.0f, 1.5f));

                gridController.AddTreeObjectCount(1);
            }

            // Stone
            int stoneCount = gridController.GetStoneObjectMaxCount();

            for (int i = 0; i < stoneCount; ++i)
            {
                Vector3 stonePosition = gridController.PickRandomGridPosition();
                gridController.SliceGridPosition(stonePosition);

                GameObject goStone = gameObjectFactory.FetchStoneObject();
                goStone.transform.localPosition = stonePosition;
                StoneHandler stoneHandler = goStone.GetComponent <StoneHandler>();
                stoneHandler.PlayGrow(1.0f, Utils.RandomRange(1.0f, 1.5f));

                gridController.AddStoneObjectCount(1);
            }

            // Food
            int foodCount = gridController.GetFoodObjectMaxCount();

            for (int i = 0; i < foodCount; ++i)
            {
                Vector3 foodPosition = gridController.PickRandomGridPosition();
                gridController.SliceGridPosition(foodPosition);

                GameObject goFood = gameObjectFactory.FetchFoodObject();
                goFood.transform.localPosition = foodPosition;
                FoodHandler foodHandler = goFood.GetComponent <FoodHandler>();
                foodHandler.PlayGrow(1.0f, Utils.RandomRange(1.0f, 1.5f));

                gridController.AddFoodObjectCount(1);
            }

            PlayController.main.ShowMainMenu();
            PlayController.main.WaitForMainMenuPlayClick(MainMenuPlayClicked);
        }