public override void SetBasement(Plane b, PixelPosByte pos) { base.SetBasement(b, pos); gm = GameMaster.geologyModule; storage = GameMaster.realMaster.colonyController.storage; var em = GameMaster.realMaster.environmentMaster; richness = em.envRichness; em.environmentChangingEvent += EnvironmentUpdate; }
private void Awake() { //testzone //gameStartSettings.generationMode = ChunkGenerationMode.GameLoading; //savename = "test"; // if (realMaster != null & realMaster != this) { Destroy(this); return; } gameMode = _gameMode; realMaster = this; sceneClearing = false; if (PoolMaster.current == null) { PoolMaster pm = gameObject.AddComponent <PoolMaster>(); pm.Load(); } if (gameMode == GameMode.Play) { if (globalMap == null) { globalMap = gameObject.AddComponent <GlobalMap>(); } globalMap.Prepare(); eventTracker = new EventChecker(); } if (environmentMaster == null) { environmentMaster = new GameObject("Environment master").AddComponent <EnvironmentMaster>(); } environmentMaster.Prepare(); if (audiomaster == null) { audiomaster = gameObject.AddComponent <Audiomaster>(); audiomaster.Prepare(); } if (geologyModule == null) { geologyModule = gameObject.AddComponent <GeologyModule>(); } }
// private void Awake() { gameRules = GameRules.defaultRules; if (testMode && test_gameStartSettings != null) { _applyingGameStartSettings = test_gameStartSettings; test_gameStartSettings = null; } if (_applyingGameStartSettings == null && startSettings == null) { _applyingGameStartSettings = GameStartSettings.GetDefaultStartSettings(); } if (startSettings == null) { startSettings = _applyingGameStartSettings; _applyingGameStartSettings = null; } gameMode = startSettings.DefineGameMode(); if (gameMode == GameMode.MainMenu) { Destroy(gameObject); return; } if (realMaster != null & realMaster != this) { Destroy(realMaster); realMaster = this; return; } realMaster = this; sceneClearing = false; // uicontroller = UIController.GetCurrent(); // if (PoolMaster.current == null) { PoolMaster pm = gameObject.AddComponent(typeof(PoolMaster)) as PoolMaster; pm.Load(); } if (gameMode == GameMode.Survival) { globalMap = InitializeGlobalMap(); } if (environmentMaster == null) { environmentMaster = new GameObject("Environment master").AddComponent <EnvironmentMaster>(); } environmentMaster.Prepare(); if (audiomaster == null) { audiomaster = gameObject.AddComponent <Audiomaster>(); audiomaster.Prepare(); } if (geologyModule == null) { geologyModule = gameObject.AddComponent <GeologyModule>(); } Screen.sleepTimeout = SleepTimeout.NeverSleep; }
void Start() { if (!firstSet) { return; } gameSpeed = 1; editMode = _editMode; if (!editMode) { lifeGrowCoefficient = 1; //Localization.ChangeLanguage(Language.English); if (geologyModule == null) { geologyModule = gameObject.AddComponent <GeologyModule>(); } difficulty = gameStartSettings.difficulty; if (colonyController == null) { colonyController = gameObject.AddComponent <ColonyController>(); colonyController.CreateStorage(); } if (PoolMaster.current == null) { PoolMaster pm = gameObject.AddComponent <PoolMaster>(); pm.Load(); } //byte chunksize = gss.chunkSize; byte chunksize; chunksize = gameStartSettings.chunkSize; if (gameStartSettings.generationMode != ChunkGenerationMode.GameLoading) { if (gameStartSettings.generationMode != ChunkGenerationMode.DontGenerate) { if (gameStartSettings.generationMode != ChunkGenerationMode.TerrainLoading) { Chunk.SetChunkSize(chunksize); constructor.ConstructChunk(chunksize, gameStartSettings.generationMode); } else { LoadTerrain(Application.persistentDataPath + "/Terrains/" + savename + '.' + SaveSystemUI.TERRAIN_FNAME_EXTENSION); } } FollowingCamera.CenterCamera(Vector3.one * chunksize / 2f); switch (difficulty) { case Difficulty.Utopia: LUCK_COEFFICIENT = 1; demolitionLossesPercent = 0; lifepowerLossesPercent = 0; sellPriceCoefficient = 1; tradeVesselsTrafficCoefficient = 0.2f; upgradeDiscount = 0.5f; upgradeCostIncrease = 1.1f; environmentalConditions = 1; break; case Difficulty.Easy: LUCK_COEFFICIENT = 0.7f; demolitionLossesPercent = 0.2f; lifepowerLossesPercent = 0.1f; sellPriceCoefficient = 0.9f; tradeVesselsTrafficCoefficient = 0.4f; upgradeDiscount = 0.3f; upgradeCostIncrease = 1.3f; environmentalConditions = 1; break; case Difficulty.Normal: LUCK_COEFFICIENT = 0.5f; demolitionLossesPercent = 0.4f; lifepowerLossesPercent = 0.3f; sellPriceCoefficient = 0.75f; tradeVesselsTrafficCoefficient = 0.5f; upgradeDiscount = 0.25f; upgradeCostIncrease = 1.5f; environmentalConditions = 0.95f; break; case Difficulty.Hard: LUCK_COEFFICIENT = 0.1f; demolitionLossesPercent = 0.7f; lifepowerLossesPercent = 0.5f; sellPriceCoefficient = 0.5f; tradeVesselsTrafficCoefficient = 0.75f; upgradeDiscount = 0.2f; upgradeCostIncrease = 1.7f; environmentalConditions = 0.9f; break; case Difficulty.Torture: LUCK_COEFFICIENT = 0.01f; demolitionLossesPercent = 1; lifepowerLossesPercent = 0.85f; sellPriceCoefficient = 0.33f; tradeVesselsTrafficCoefficient = 1; upgradeDiscount = 0.1f; upgradeCostIncrease = 2f; environmentalConditions = 0.8f; break; } warProximity = 0.01f; layerCutHeight = Chunk.CHUNK_SIZE; prevCutHeight = layerCutHeight; switch (startGameWith) { case GameStart.Zeppelin: LandingUI lui = gameObject.AddComponent <LandingUI>(); lui.lineDrawer = systemDrawLR; Instantiate(Resources.Load <GameObject>("Prefs/Zeppelin")); break; case GameStart.Headquarters: List <SurfaceBlock> sblocks = mainChunk.surfaceBlocks; SurfaceBlock sb = sblocks[(int)(Random.value * (sblocks.Count - 1))]; int xpos = sb.pos.x; int zpos = sb.pos.z; if (colonyController == null) { colonyController = gameObject.AddComponent <ColonyController>(); } Structure s = Structure.GetStructureByID(Structure.LANDED_ZEPPELIN_ID); SurfaceBlock b = mainChunk.GetSurfaceBlock(xpos, zpos); s.SetBasement(b, PixelPosByte.zero); b.MakeIndestructible(true); b.myChunk.GetBlock(b.pos.x, b.pos.y - 1, b.pos.z).MakeIndestructible(true); colonyController.AddCitizens(START_WORKERS_COUNT); sb = mainChunk.GetSurfaceBlock(xpos - 1, zpos + 1); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos, zpos + 1); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos + 1, zpos + 1); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos - 1, zpos); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos + 1, zpos); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos - 1, zpos - 1); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos, zpos - 1); if (sb == null) { sb = mainChunk.GetSurfaceBlock(xpos + 1, zpos - 1); if (sb == null) { print("bad generation, do something!"); } } } } } } } } StorageHouse firstStorage = Structure.GetStructureByID(Structure.STORAGE_0_ID) as StorageHouse; firstStorage.SetBasement(sb, PixelPosByte.zero); //start resources colonyController.storage.AddResource(ResourceType.metal_K, 100); colonyController.storage.AddResource(ResourceType.metal_M, 50); colonyController.storage.AddResource(ResourceType.metal_E, 20); colonyController.storage.AddResource(ResourceType.Plastics, 100); colonyController.storage.AddResource(ResourceType.Food, 200); //UI ui = gameObject.AddComponent<UI>(); //ui.lineDrawer = systemDrawLR; break; } FollowingCamera.main.WeNeedUpdate(); } else { LoadGame(Application.persistentDataPath + "/Saves/" + savename + ".sav"); } } else { gameObject.AddComponent <PoolMaster>().Load(); Chunk.SetChunkSize(test_size); mainChunk = new GameObject("chunk").AddComponent <Chunk>(); mainChunk.InitializeBlocksArray(); mainChunk.ChunkLightmapFullRecalculation(); mainChunk.AddBlock(new ChunkPos(Chunk.CHUNK_SIZE / 2, Chunk.CHUNK_SIZE / 2, Chunk.CHUNK_SIZE / 2), BlockType.Cube, ResourceType.STONE_ID, true); FollowingCamera.CenterCamera(Vector3.one * Chunk.CHUNK_SIZE / 2f); } }