void Start() { if (gameStarted) { return; } if (gameMode != GameMode.Editor) { difficulty = gameStartSettings.difficulty; SetDefaultValues(); //byte chunksize = gss.chunkSize; byte chunksize; chunksize = gameStartSettings.chunkSize; if (testMode && savenameToLoad != string.Empty) { gameStartSettings = new GameStartSettings(ChunkGenerationMode.GameLoading); savename = savenameToLoad; } if (gameStartSettings.generationMode != ChunkGenerationMode.GameLoading) { if (gameStartSettings.generationMode != ChunkGenerationMode.DontGenerate) { if (gameStartSettings.generationMode != ChunkGenerationMode.TerrainLoading) { Constructor.ConstructChunk(chunksize, gameStartSettings.generationMode); // Constructor.ConstructBlock(chunksize); if (gameStartSettings.generationMode == ChunkGenerationMode.Peak) { environmentMaster.PrepareIslandBasis(ChunkGenerationMode.Peak); } } else { LoadTerrain(SaveSystemUI.GetTerrainsPath() + '/' + savename + '.' + SaveSystemUI.TERRAIN_FNAME_EXTENSION); } } FollowingCamera.main.ResetTouchRightBorder(); FollowingCamera.main.CameraRotationBlock(false); warProximity = 0.01f; layerCutHeight = Chunk.chunkSize; prevCutHeight = layerCutHeight; switch (startGameWith) { case GameStart.Zeppelin: Instantiate(Resources.Load <GameObject>("Prefs/Zeppelin")); if (needTutorial) { GameLogUI.EnableDecisionWindow(null, Localization.GetTutorialHint(LocalizedTutorialHint.Landing)); } else { GameLogUI.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.SetLandingPoint)); } break; case GameStart.Headquarters: var sblocks = mainChunk.surfaces; Plane sb = sblocks[Random.Range(0, sblocks.Length)]; int xpos = sb.pos.x; int zpos = sb.pos.z; Structure s; if (testMode) { s = HeadQuarters.GetHQ(6); weNeedNoResources = true; } else { weNeedNoResources = false; s = HeadQuarters.GetHQ(1); } Plane b = mainChunk.GetHighestSurfacePlane(xpos, zpos); s.SetBasement(b, PixelPosByte.zero); sb = mainChunk.GetHighestSurfacePlane(xpos - 1, zpos + 1); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos, zpos + 1); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos + 1, zpos + 1); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos - 1, zpos); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos + 1, zpos); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos - 1, zpos - 1); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(xpos, zpos - 1); if (sb == null) { sb = mainChunk.GetHighestSurfacePlane(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); SetStartResources(); break; } FollowingCamera.main.WeNeedUpdate(); } else { LoadGame(SaveSystemUI.GetSavesPath() + '/' + savename + ".sav"); } } else { gameObject.AddComponent <PoolMaster>().Load(); mainChunk = new GameObject("chunk").AddComponent <Chunk>(); int size = Chunk.chunkSize; int[,,] blocksArray = new int[size, size, size]; size /= 2; blocksArray[size, size, size] = ResourceType.STONE_ID; mainChunk.CreateNewChunk(blocksArray); } { // set look point FollowingCamera.camBasisTransform.position = sceneCenter; } gameStarted = true; }
void PrepareSession() { if (sessionPrepared) { return; } bool activateEventTracker = false; switch (gameMode) { case GameMode.Survival: { uicontroller.ChangeUIMode(UIMode.Standart, true); difficulty = startSettings.DefineDifficulty(); SetDefaultValues(); var cgs = startSettings.GetChunkGenerationSettings(); var chunkAction = cgs.preparingActionMode; if (chunkAction != ChunkPreparingAction.NoAction) { if (chunkAction == ChunkPreparingAction.Load) { LoadTerrain(SaveSystemUI.GetTerrainsPath() + '/' + cgs.GetTerrainName() + '.' + SaveSystemUI.TERRAIN_FNAME_EXTENSION); } else { mainChunk = Constructor.ConstructChunk(cgs); var slist = mainChunk.GetSurfaces(); if (slist != null) { geologyModule.SpreadMinerals(slist); } mainChunk.InitializeNature().FirstLifeformGeneration(Chunk.chunkSize * Chunk.chunkSize * 500f); } } // var fcm = FollowingCamera.main; fcm.CameraToStartPosition(); fcm.ResetTouchRightBorder(); fcm.CameraRotationBlock(false); warProximity = 0.01f; layerCutHeight = Chunk.chunkSize; prevCutHeight = layerCutHeight; // switch (startSettings.DefineFoundingType()) { case StartFoundingType.Zeppelin: { Zeppelin.CreateNew(); AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.SetLandingPoint)); break; } case StartFoundingType.Headquarters: { Plane sb = mainChunk.GetRandomSurface(); int xpos = sb.pos.x; int zpos = sb.pos.z; Structure s; if (testMode) { s = HeadQuarters.GetHQ(6); weNeedNoResources = true; } else { weNeedNoResources = false; s = HeadQuarters.GetHQ(1); } Plane b = mainChunk.GetHighestSurfacePlane(xpos, zpos); s.SetBasement(b, PixelPosByte.zero); sb = mainChunk.GetNearestUnoccupiedSurface(b.pos); StorageHouse firstStorage = Structure.GetStructureByID(Structure.STORAGE_0_ID) as StorageHouse; firstStorage.SetBasement(sb, PixelPosByte.zero); SetStartResources(); break; } } fcm.WeNeedUpdate(); activateEventTracker = true; break; } case GameMode.Editor: { uicontroller.ChangeUIMode(UIMode.Editor, true); mainChunk = new GameObject("chunk").AddComponent <Chunk>(); int size = Chunk.chunkSize; int[,,] blocksArray = new int[size, size, size]; size /= 2; blocksArray[size, size, size] = ResourceType.STONE_ID; mainChunk.Rebuild(blocksArray); FollowingCamera.main.CameraToStartPosition(); break; } case GameMode.Scenario: { uicontroller.ChangeUIMode(UIMode.Standart, true); switch (startSettings.GetScenarioType()) { case ScenarioType.Embedded: { switch ((EmbeddedScenarioType)startSettings.GetSecondSubIndex()) { case EmbeddedScenarioType.Tutorial: { gameRules = GameRules.GetTutorialRules(); LoadTerrainFromAssets(TutorialScenarioNS.TutorialScenario.tutorialTerrainName); TutorialScenarioNS.TutorialUI.Initialize(); break; } } break; } } activateEventTracker = true; FollowingCamera.main.CameraToStartPosition(); break; } } if (activateEventTracker) { eventTracker = new EventChecker(); } startSettings = null; sessionPrepared = true; if (testMode) { AnnouncementCanvasController.MakeAnnouncement("game master loaded"); } autosaveTimer = AUTOSAVE_TIME; }
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); } }