private void Init() { // Init Services services.Init(); services.SetLanguageCode(gameData.languageCode); services.LoadLocalisationService(); // Load Play Controller GameObject playControllerObject = Instantiate(gameObjectFactory.prefabPlayController); playControllerObject.SetActive(true); PlayController playController = playControllerObject.GetComponent <PlayController>(); playController.Load(); PlayController.main.ResetGameData(); // Load Result Controller GameObject resultControllerObject = Instantiate(gameObjectFactory.prefabResultController); resultControllerObject.SetActive(true); ResultController resultController = resultControllerObject.GetComponent <ResultController>(); resultController.Load(); // inject factory to states gameLoad.gameObjectFactory = gameObjectFactory; playEnter.gameObjectFactory = gameObjectFactory; // load gameLoad.OnLoadComplete += OnLoadComplete; gameLoad.Enter(); }
public void Load() { main = this; GameObjectFactory gameObjectFactory = GameObjectFactory.main; terrainHandlerObject = Instantiate(gameObjectFactory.prefabTerrain); TerrainHandler terrainHandler = terrainHandlerObject.GetComponent <TerrainHandler>(); terrainHandler.Load(); houseSmallClickerObject = gameObjectFactory.houseSmallClickerObject; houseMediumClickerObject = gameObjectFactory.houseMediumClickerObject; houseLargeClickerObject = gameObjectFactory.houseLargeClickerObject; foresterClickerObject = gameObjectFactory.foresterClickerObject; quarryClickerObject = gameObjectFactory.quarryClickerObject; cemeteryClickerObject = gameObjectFactory.cemeteryClickerObject; farmClickerObject = gameObjectFactory.farmClickerObject; clinicClickerObject = gameObjectFactory.clinicClickerObject; tavernClickerObject = gameObjectFactory.tavernClickerObject; villageDayPanelObject = gameObjectFactory.villageDayPanelObject; mainMenuPanelObject = gameObjectFactory.mainMenuPanelObject; resourceCostPanelObject = gameObjectFactory.resourceCostPanelObject; unitActionPanelObject = gameObjectFactory.unitActionPanelObject; resourceController = gameObject.GetComponent <ResourceController>(); resourceController.Load(ref gameData); gridController = gameObject.GetComponent <GridController>(); gridController.Load(ref gameData); dayNightController = gameObject.GetComponent <DayNightController>(); dayNightController.Load(ref gameData); }
private void Update() { PlayController pc = PlayController.main; if (pc != null) { if (mouseOver) { if (target != null) { foodCostText.text = pc.GetResourceController().GetVillagerFoodCost().ToString(); target.DOFade(1f, 0.25f) .OnStart(() => { target.gameObject.SetActive(true); }); } } } }
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(); }