/*------------------------------------------------- * Helpers * --------------------------------------------------*/ private void UpdateTerra(Terra terra) { if (terra.type != "" || terra.type != null) { this.terraUI.SetTerra(terra); } }
public Terra GenerateTerra() { Terra terra = ScriptableObject.CreateInstance <Terra>(); //Sprite terra.planetPrefab = PlanetPrefab[10]; //Nom terra.Nom = "Earth"; //Poblacio terra.Poblacio = PoblacioInicial; //Materials terra.materials[0] = MaterialsInicials; terra.materials[1] = 0; terra.materials[2] = 0; //Consum terra.consum[0] = 1 * PoblacioInicial; terra.consum[1] = 0; terra.consum[2] = 0; //Tipus terra.tipusPlaneta = Terra.tipus.modern; terra.indexTipus = 2; //Regim terra.Regim = (Terra.regim)Random.Range(0, 2); //Creo la llista d'atacants terra.atacants = new List <Faction>(); return(terra); }
protected override void OnRenderFrame(FrameEventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Matrix4 modelview = Matrix4.LookAt(Visao, Target, new Vector3(0, 1, 0)); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview); // Sol DesenhaPlaneta(1); GL.PushMatrix(); GL.MultMatrix(Terra.ObterDados()); // terra DesenhaPlaneta(2); GL.PushMatrix(); GL.MultMatrix(Lua.ObterDados()); DesenhaPlaneta(2); GL.PopMatrix(); GL.PopMatrix(); SwapBuffers(); }
public GameObject InitializePlanet(Planet planet) { PlanetTextureGenerator texGen = null; GameObject planetGO = null; var planetData = (PlanetData)planet.GetSerializationData(); switch (planetData.Type) { case PlanetType.Terra: planetGO = Instantiate(_terraPrefab, Vector2.zero, Quaternion.identity); texGen = new Terra(PlanetTextureGenerator.DefaultResolution, planetData); break; case PlanetType.Gas: planetGO = Instantiate(_gasPrefab, Vector2.zero, Quaternion.identity); texGen = new Gas(PlanetTextureGenerator.DefaultResolution, planetData); break; case PlanetType.Desert: planetGO = Instantiate(_desertPrefab, Vector2.zero, Quaternion.identity); texGen = new Desert(PlanetTextureGenerator.DefaultResolution, planetData); break; default: throw new ArgumentOutOfRangeException(); } planetGO.name = planetData.Name; var planetTexture = new Texture2D(texGen.XSize, texGen.YSize); planetTexture.Resize(texGen.XSize, texGen.YSize, TextureFormat.RGB565, true); planetTexture.SetPixels(texGen.TextureColors); planetTexture.Apply(); var meshes = planetGO.GetComponentsInChildren <MeshRenderer>(); //0 - планета, 1 - облака, 2 - кольца, осторожнее с иерархией в префабе meshes[0].material.mainTexture = planetTexture; if (planetData.RingsMass > 0) { var rings = new PlanetRings(PlanetTextureGenerator.DefaultResolution / 2, planetData); var ringsTexture = new Texture2D(rings.XSize, rings.YSize); ringsTexture.SetPixels(rings.TextureColors); ringsTexture.Apply(); meshes[2].material.mainTexture = ringsTexture; } else { meshes[2].gameObject.SetActive(false); } planetGO.GetComponentInChildren <PlanetRotator>().RotationSpeed = planetData.RotationSpeed; planetGO.AddComponent <PlanetWatcher>().Planet = planet; return(planetGO); }
private void UpdateTerraUI(Terra terra) { if (this.gameUI.GetTerraUI().currentTerraType != terra.type) { RaiseUpdateTerraUIEvent(terra); } }
public Foreman(Weltschmerz weltschmerz, Terra terra, Registry registry, ITerraMesher mesher, int viewDistance, float fov, int preparationThreads, ITerraSemaphore preparation, ITerraSemaphore generation) { this.preparationThreads = preparationThreads; this.preparation = preparation; this.generation = generation; this.weltschmerz = weltschmerz; this.terra = terra; this.octree = terra.GetOctree(); queue = new ConcurrentQueue <Tuple <int, int, int> > (); maxViewDistance = viewDistance; this.fov = fov; this.mesher = mesher; chunkSpeed = new List <long> (); stopwatch = new Stopwatch(); this.leafOctants = new ConcurrentDictionary <Tuple <int, int, int>, OctreeNode> (); List <Position> localCenters = new List <Position> (); for (int l = -maxViewDistance; l < maxViewDistance; l += 8) { for (int y = -Utils.GetPosFromFOV(fov, l); y < Utils.GetPosFromFOV(fov, l); y += 8) { for (int x = -Utils.GetPosFromFOV(fov, l); x < Utils.GetPosFromFOV(fov, l); x += 8) { localCenters.Add(new Position(x, y, -l)); } } } this.localCenters = localCenters.ToArray(); localCenters.Clear(); maxSize = this.localCenters.Length; }
private void RaiseShowTerraUIEvent(Terra terra) { UIEventData uiEventData = new UIEventData(); uiEventData.terra = terra; this.showTerraUI.Raise(uiEventData); }
public void Rotacionar() { while (true) { Terra.AtribuirRotacaoY(Velocidades.Terra.Move(Velocidade)); Thread.Sleep(1); } }
private void RaiseUpdateTerraUIEvent(Terra terra) { UIEventData uiEventData = new UIEventData(); uiEventData.terra = terra; this.updateTerraUI.Raise(uiEventData); }
public void OnPlanetInteraction(Planet planet, bool isDestroyed) { terra = gameManager.terra; RefreshFactions(); // Mirem si s'ha destruit if (isDestroyed) { foreach (Planet p in planetPool) { if (p.faction == planet.faction) { p.perillositat += 5; } } //Sumem els valors materials for (int i = 0; i < planet.materials.Length; i++) { terra.materials[i] += planet.materials[i]; } //Agressivitat de la faccio augmenta for (int i = 0; i < gameManager.factions.Count; i++) { if (planet.faction.especie == gameManager.factions[i].especie) { //Calculem la agresivitat que generem en una faccio al matar un dels seus planetes // agresivitat = (poblacio / (poblacioMax/5) ) gameManager.factions[i].agresivitat += (int)(planet.Poblacio / (planetGenerator.maxPopulation / 100) + 1) * (planet.indexTipus + 1); break; } } } else { foreach (Planet p in planetPool) { if (p.faction == planet.faction) { p.perillositat += -5; } } for (int i = 0; i < gameManager.factions.Count; i++) { if (planet.faction.especie == gameManager.factions[i].especie) { //Calculem la agresivitat que generem en una faccio al matar un dels seus planetes gameManager.factions[i].agresivitat -= (int)(planet.Poblacio / (planetGenerator.maxPopulation / 10)) * planet.indexTipus; break; } } } gameManager.terra = terra; }
private void RefreshInfoPaneXY(MouseEventArgs e) { //get current mouse position in map grid values var TempPositionXY = new PosXY(); TempPositionXY = Terra.GetPositionXY(e.X, e.Y); if (CurrentPositionXY != TempPositionXY) { if ((TempPositionXY.PosX != GlobalParameters.OutOfRange) && (TempPositionXY.PosY != GlobalParameters.OutOfRange)) { CurrentPositionXY = TempPositionXY; textBox1.Text = Convert.ToString(Convert.ToInt32(CurrentPositionXY.PosX)); labely.Text = Convert.ToString(Convert.ToInt32(CurrentPositionXY.PosY)); //friend foe label lblFriendFoe.Text = Terra.GetLabelsFriendFoe(Terra.FriendFoe[CurrentPositionXY.PosX, CurrentPositionXY.PosY]); if (Terra.FriendFoe[CurrentPositionXY.PosX, CurrentPositionXY.PosY] == (int)FriendFoeKind.friend) { lblFriendFoe.ForeColor = Color.Green; } else { lblFriendFoe.ForeColor = Color.Red; } //population label var i = Terra.Population[CurrentPositionXY.PosX, CurrentPositionXY.PosY]; var str = i.ToString("# ### ### ###"); lbl_population.Text = str; //army label if (Terra.IsArmy[CurrentPositionXY.PosX, CurrentPositionXY.PosY]) //if there is XY army on the map { var army_type = Convert.ToString(Terra.ArmyUnits[CurrentPositionXY].ArmyType); string fun = GlobalParameters.ArmyTypeLabels[Convert.ToInt32(army_type) - 1]; lbl_army_type.Text = fun; } else { //army label lbl_army_type.Text = ""; } } else { //temporary debugging 45 textBox1.Text = Convert.ToString(999); //friend foe label lblFriendFoe.Text = ""; //population label lbl_population.Text = ""; } } }
public static Terra[,] DataToTerra(string[,] data) { Terra[,] returnterra = new Terra[data.GetLength(0), data.GetLength(1)]; for (int i = 0; i < data.GetLength(0); i++) { for (int j = 0; j < data.GetLength(1); j++) { returnterra[i, j] = (Terra)Enum.Parse(typeof(Terra), data[i, j]); } } return(returnterra); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { registry = new Registry(); PrimitiveResources.Register(registry); weltschmerz = new Weltschmerz(); Config config = weltschmerz.GetConfig(); config.elevation.max_elevation = MAX_ELEVATION; config.elevation.min_elevation = MIN_ELEVATION; config.map.latitude = LATITUDE; config.map.longitude = LONGITUDE; if (LONGITUDE < 2) { LONGITUDE = 2; } if (LATITUDE < 2) { LATITUDE = 2; } if (MAX_ELEVATION < 2) { MAX_ELEVATION = 2; } Position boundries = new Position(); boundries.x = LONGITUDE; boundries.y = MAX_ELEVATION; boundries.z = LATITUDE; terra = new Terra(boundries, this); GodotSemaphore semaphore1 = new GodotSemaphore(); GodotSemaphore semaphore2 = new GodotSemaphore(); foreman = new Foreman(weltschmerz, registry, terra, LOAD_RADIUS); GameClient client = (GameClient)FindNode("GameClient"); GodotMesher mesher = (GodotMesher)FindNode("GameMesher"); mesher.SetRegistry(registry); client.AddServer(this, mesher); }
public Terra Copy() { Terra terra = ScriptableObject.CreateInstance <Terra>(); terra.Nom = Nom; terra.Poblacio = Poblacio; terra.materials = new long[3]; terra.materials[0] = materials[0]; terra.materials[1] = materials[1]; terra.materials[2] = materials[2]; terra.consum = consum; terra.indexTipus = indexTipus; terra.tipusPlaneta = tipusPlaneta; terra.atacants = atacants; terra.danyAtac = danyAtac; return(terra); }
private void btn_start2_Click(object sender, EventArgs e) { //the game entry point GameIsOn = true; //local settings for global variables Terra.glb_settings = glb_settings; //drawer = new DrawElements(CreateGraphics()); Drawer.glb_settings = glb_settings; //var x = CreateGraphics(); Drawer.DrawGrid(); Drawer.DrawBorderInitial(); //load the terrain from files Terra.Load_Map(); //generate the random population terra.GeneratePopulation(); //friend-foe initialisation Terra.FriendFoeInitialisation(); //isarmy initilisation Terra.IsArmyInitialisation(); //draw the whole map Drawer.DrawMap(Terra.MapTerrain); //temporary one unit generated Terra.GenerateArmy(); //draw army Drawer.DrawArmy(Terra); //next tour panel refresh RefreshInfoPanel(); //start button disable btn_start2.Visible = false; }
void Start() { planetUI.SetActive(true); homeUI.SetActive(false); planetGenerator = GetComponent <PlanetGenerator>(); factions = planetGenerator.GenerateFactions(); terra = planetGenerator.GenerateTerra(); //Guardem la terra del principi terraAnterior = terra.Copy(); poolControler = GetComponent <PoolControler>(); poolControler.CreatePool(InitialPoolNumber); laser1.SetActive(false); laser2.SetActive(false); StartCoroutine(StartRound()); }
public IEnumerator StartRound() { if (GameOver) { if (!GameOverUI.activeSelf) { StartCoroutine(showGameOverScreen()); yield return(null); } else { SceneManager.LoadScene("mainMenu"); } } else { round++; cameraShake.ShowBlackScreen(); yield return(new WaitForSeconds(cameraShake.BlackscreenAnimationDuration)); planetUI.SetActive(true); homeUI.SetActive(false); roundCounter = 0; savedPlanets = new List <Planet>(); terraAnterior = terra.Copy(); viewInfo.SetDificulty(round); //poolControler.RefreshFactions(); roundPlanets = poolControler.GetRoundPool(round / 3 + 3); numPlanets = roundPlanets.Count; viewInfo.SetData(roundPlanets[roundCounter]); roundActive = true; viewInfo.RoundActive = true; cameraShake.HideBlackScreen(); yield return(new WaitForSeconds(cameraShake.BlackscreenAnimationDuration)); } }
public void HandleMouseHover() { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); int numColliders = Physics2D.OverlapPointNonAlloc(mousePosition, this.mouseOverlapColliders); if (numColliders == 0) { HideTerraUI(); return; } foreach (Collider2D collider in mouseOverlapColliders) { GameObject colliderGameObject = collider.gameObject; if (colliderGameObject.tag == "Tile") { Terra colliderTerra = colliderGameObject.GetComponent <Tile>().GetTerra(); // TerraformOverlay terraformOverlay = colliderGameObject.GetComponent<Tile>().terraformOverlay; ShowTerraUI(colliderTerra); break; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.ClearColor(Color.Black); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); // Sol GL.GenTextures(1, out textura); GL.BindTexture(TextureTarget.Texture2D, textura); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); BitmapData dataSun = bitmapSun.LockBits(new System.Drawing.Rectangle(0, 0, bitmapSun.Width, bitmapSun.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, dataSun.Width, dataSun.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, dataSun.Scan0); bitmapSun.UnlockBits(dataSun); // Terra GL.GenTextures(2, out textura); GL.BindTexture(TextureTarget.Texture2D, textura); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); BitmapData dataEarth = bitmapEarth.LockBits(new System.Drawing.Rectangle(0, 0, bitmapEarth.Width, bitmapEarth.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, dataEarth.Width, dataEarth.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, dataEarth.Scan0); bitmapEarth.UnlockBits(dataEarth); // campo de visão da câmera sintética Visao = new Vector3(50, 50, 50); Target = new Vector3(0, 0, 0); Longe = 100.0f; Perto = 1.0f; // Matriz sol Transformacao4D matrizSolNova = new Transformacao4D(); matrizSolNova.AtribuirTranslacao(40, 0, 0); Sol = matrizSolNova.MultiplicarMatriz(Sol); // terra passa a ser "filho" do sol Terra = Sol.MultiplicarMatriz(Terra); //cria terra Transformacao4D matrizTerraNova = new Transformacao4D(); matrizTerraNova.AtribuirEscala(1.5, 1.5, 1.5); matrizTerraNova.AtribuirTranslacao(20, 0, 0); Terra = matrizTerraNova.MultiplicarMatriz(Terra); // Matriz atribui filho lua a terra Lua = Terra.MultiplicarMatriz(Lua); //cria lua Transformacao4D matrizLuaNova = new Transformacao4D(); matrizLuaNova.AtribuirEscala(0.3, 0.3, 0.3); Lua = matrizLuaNova.MultiplicarMatriz(Lua); }
private void ShowTerraUI(Terra terra) { RaiseShowTerraUIEvent(terra); }
// 画像一覧をボタン選択出来る形にして出力 private void DrawImageParts() { float x = 0.0f; float y = 00.0f; float w = 50.0f; float h = 50.0f; float maxW = 300.0f; if (subWindow != null) { EditorGUILayout.BeginVertical(); if (subWindow.selected == 0) { for (int i = 0; i < System.Enum.GetValues(typeof(Terra)).Length; i++) { if (x > maxW) { x = 0.0f; y += h; EditorGUILayout.EndHorizontal(); } if (x == 0.0f) { EditorGUILayout.BeginHorizontal(); } GUILayout.FlexibleSpace(); if (terratex[i] != null) { Texture2D tex = Texture2D.Instantiate(terratex[i]); TextureScale.Bilinear(tex, (int)w - 10, (int)h - 10); if (GUILayout.Button(tex, GUILayout.MaxWidth(w), GUILayout.MaxHeight(h), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { selectedTerra = (Terra)i; } } else { if (GUILayout.Button("", GUILayout.MaxWidth(w), GUILayout.MaxHeight(h), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { selectedTerra = (Terra)i; } } GUILayout.FlexibleSpace(); x += w; } } else if (subWindow.selected == 1) { for (int i = 0; i < System.Enum.GetValues(typeof(MovingObject)).Length; i++) { if (x > maxW) { x = 0.0f; y += h; EditorGUILayout.EndHorizontal(); } if (x == 0.0f) { EditorGUILayout.BeginHorizontal(); } GUILayout.FlexibleSpace(); if (objtex[i] != null) { Texture2D tex = Texture2D.Instantiate(objtex[i]); TextureScale.Bilinear(tex, (int)w - 10, (int)h - 10); if (GUILayout.Button(tex, GUILayout.MaxWidth(w), GUILayout.MaxHeight(h), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { selectedObj = (MovingObject)i; } } else { if (GUILayout.Button("", GUILayout.MaxWidth(w), GUILayout.MaxHeight(h), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { selectedObj = (MovingObject)i; } } GUILayout.FlexibleSpace(); x += w; } } EditorGUILayout.EndVertical(); } }
public void ActualitzaTerra() { terra = gameManager.terra; terra.indexTipus = Mathf.Clamp(gameManager.round / 5 + 2, 2, 4); terra.tipusPlaneta = (Terra.tipus)terra.indexTipus; long materialsRestants = 0; long materialsConsumits = 0; int probabilitat; int attack; terra.atacants = new List <Faction>(); terra.danyAtac = new List <long>(); // Restem els conusums als recursos que tenim for (int i = 0; i < terra.consum.Length; i++) { terra.materials[i] -= terra.consum[i]; if (terra.materials[i] <= 0) { long init = terra.Poblacio; terra.Poblacio -= terra.materials[i] * (long)0.1; terra.Poblacio -= 75000; long final = terra.Poblacio; Debug.Log("Poblacio restada x manca de recursos(" + i + "): " + (init - final)); terra.materials[i] = 0; } materialsRestants += terra.materials[i] * (i + 1); materialsConsumits += terra.consum[i] * (i + 1); } // Si hi ha materials suficients per fer creixer el planeta if (materialsRestants > 2 * materialsConsumits) { // Augmentem la poblacio long valorAugment = materialsRestants / (2 * materialsConsumits); terra.Poblacio += (long)(terra.Poblacio * valorAugment * 0.01); } else { /* * long valorAugment = materialsRestants / (2 * materialsConsumits); * terra.Poblacio -= (long)(terra.Poblacio * valorAugment * 0.01); * if (terra.Poblacio < 0) terra.Poblacio = 0; */ } // Depenent de la ronda, recalculem diferents consums switch (terra.indexTipus) { case 1: terra.consum[0] = terra.Poblacio * 5; terra.consum[1] = terra.Poblacio * 2; terra.consum[2] = terra.Poblacio * 1; break; case 2: terra.consum[0] = terra.Poblacio * 5; terra.consum[1] = terra.Poblacio * 2; terra.consum[2] = terra.Poblacio * 1; break; case 3: terra.consum[0] = terra.Poblacio * 10; terra.consum[1] = terra.Poblacio * 4; terra.consum[2] = terra.Poblacio * 2; break; case 4: terra.consum[0] = terra.Poblacio * 15; terra.consum[1] = terra.Poblacio * 8; terra.consum[2] = terra.Poblacio * 4; break; } //Primer mirerm les faccions for (int i = 0; i < gameManager.factions.Count; i++) { if (gameManager.factions[i].densitat == 0) { continue; //Si no tenen ningu no ataquen } if (terra.atacants.Count == 4) { break; } probabilitat = Random.Range(0, 100); //Calculem l'atack //Mirem si son enemics if (gameManager.factions[i].agresivitat > 30) //Si no es agresiu no atacara { // Calculem el rang del atac // Atac = agresivitat [-100/100] * perillositat [0/100] / 100; Queda sempre un valor entre 0 i 100 attack = gameManager.factions[i].agresivitat + gameManager.factions[i].mitjaPerillositat / 2; //Revisar valors if (probabilitat < attack) //Si supera el atac { //Calculem el dany que rebrem: densitat [0/100] * poblacio / 100; Resulta un valor entre 0 i el maxim de la teva poblacio long dany = -((gameManager.factions[i].densitat + 10) * terra.Poblacio / 100 + 100000); //ens apuntem qui ens ha atacat terra.danyAtac.Add(dany); terra.atacants.Add(gameManager.factions[i]); } } } // Restem el atac for (int i = 0; i < terra.danyAtac.Count; i++) { terra.Poblacio += terra.danyAtac[i]; if (terra.Poblacio < 0) { terra.Poblacio = 0; } } gameManager.terra = terra; }
public void SetDataTerra(Terra terra, Terra terraAnterior) { long variacio; Destroy(planetaHome); planetaHome = Instantiate(terra.planetPrefab, TerraPlaceholder.transform); ShowInfo(nomTerra, terra.Nom); ShowInfo(poblacioTerra, string.Format("{0:n0}", terra.Poblacio)); variacio = terra.Poblacio - terraAnterior.Poblacio; ColorOnValue(poblacioTerraVariacio, fletxaVariacioPoblacio, variacio); if (terra.Poblacio <= 0) { ShowInfo(poblacioTerra, "0"); } else { ShowInfo(poblacioTerra, string.Format("{0:n0}", terra.Poblacio)); } ShowInfo(poblacioTerraVariacio, TransformLong(variacio)); if (terra.materials[0] <= 0) { ShowInfo(recursosXTerra, "0"); } else { ShowInfo(recursosXTerra, TransformLong(terra.materials[0])); } variacio = terra.materials[0] - terraAnterior.materials[0]; ColorOnValue(recursosCanviXTerra, signeRecursosCanviXTerra, variacio); ShowInfo(recursosCanviXTerra, TransformLong(variacio)); ShowInfo(consumXTerra, string.Format("{0} / DAY", TransformLong(terra.consum[0]))); variacio = terra.materials[1] - terraAnterior.materials[1]; if (terra.materials[1] <= 0) { ShowInfo(recursosYTerra, "0"); } else { ShowInfo(recursosYTerra, TransformLong(terra.materials[1])); } ColorOnValue(recursosCanviYTerra, signeRecursosCanviYTerra, variacio); ShowInfo(recursosCanviYTerra, TransformLong(variacio)); ShowInfo(consumYTerra, string.Format("{0} / DAY", TransformLong(terra.consum[1]))); variacio = terra.materials[2] - terraAnterior.materials[2]; if (terra.materials[2] <= 0) { ShowInfo(recursosZTerra, "0"); } else { ShowInfo(recursosZTerra, TransformLong(terra.materials[2])); } ColorOnValue(recursosCanviZTerra, signeRecursosCanviZTerra, variacio); ShowInfo(recursosCanviZTerra, TransformLong(variacio)); ShowInfo(consumZTerra, string.Format("{0} / DAY", TransformLong(terra.consum[2]))); //ShowInfo(FaccioTerra, terra.faction.especie.ToString()); //imatgeFaccioTerra = gameManager.factions[terra.idFaction].imatge; //Desactivar tots el contenidors d'atacs Targeta1.SetActive(false); Targeta2.SetActive(false); Targeta3.SetActive(false); Targeta4.SetActive(false); if (terra.atacants.Count == 0) { infoNoAtacs.SetActive(true); } else { infoNoAtacs.SetActive(false); } for (int i = 0; i < terra.atacants.Count; i++) { if (i == 0) { Targeta1.SetActive(true); imatgeFaccio1.sprite = terra.atacants[i].imatge; ShowInfo(Faccio1, terra.atacants[i].especie.ToString()); ShowInfo(dany1, TransformLong(terra.danyAtac[i])); } if (i == 1) { Targeta2.SetActive(true); imatgeFaccio2.sprite = terra.atacants[i].imatge; ShowInfo(Faccio2, terra.atacants[i].especie.ToString()); ShowInfo(dany2, TransformLong(terra.danyAtac[i])); } if (i == 2) { Targeta3.SetActive(true); imatgeFaccio3.sprite = terra.atacants[i].imatge; ShowInfo(Faccio3, terra.atacants[i].especie.ToString()); ShowInfo(dany3, TransformLong(terra.danyAtac[i])); } if (i == 3) { Targeta4.SetActive(true); imatgeFaccio4.sprite = terra.atacants[i].imatge; ShowInfo(Faccio4, terra.atacants[i].especie.ToString()); ShowInfo(dany4, TransformLong(terra.danyAtac[i])); } } if (terra.Poblacio <= 0) { gameManager.GameOver = true; } }
public Picker(Terra terra, GodotMesher mesher) { this.terra = terra; this.mesher = mesher; chunksToProccess = new List <Chunk>(); }
public void Prepare(Camera camera, LoadMarker marker) { registry = new Registry(); PrimitiveResources.Register(registry); weltschmerz = new Weltschmerz(); Config config = weltschmerz.GetConfig(); config.elevation.max_elevation = MAX_ELEVATION; config.elevation.min_elevation = MIN_ELEVATION; config.map.latitude = LATITUDE; config.map.longitude = LONGITUDE; mesher = (GodotMesher)FindNode("GameMesher"); mesher.SetRegistry(registry); if (LONGITUDE < 2) { LONGITUDE = 2; } if (LATITUDE < 2) { LATITUDE = 2; } if (MAX_ELEVATION < 2) { MAX_ELEVATION = 2; } GD.Print("Using " + GENERATION_THREADS + " threads"); Position boundries = new Position(); boundries.x = LONGITUDE; boundries.y = MAX_ELEVATION; boundries.z = LATITUDE; terra = new Terra(boundries, this); picker = new Picker(terra, mesher); GodotSemaphore semaphore1 = new GodotSemaphore(); GodotSemaphore semaphore2 = new GodotSemaphore(); foreman = new Foreman(weltschmerz, terra, registry, mesher, VIEW_DISTANCE, camera.Fov, GENERATION_THREADS, semaphore1, semaphore2); for (int t = 0; t < GENERATION_THREADS; t++) { Thread thread = new Thread(); thread.Start(this, nameof(Generation)); } for (int t = 0; t < PROCESS_THREADS; t++) { Thread thread = new Thread(); thread.Start(this, nameof(Loading)); } foreman.SetMaterials(registry); marker.Attach(foreman); foreman.AddLoadMarker(marker); }