예제 #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 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);
        }