private void GenerateDebugMethod(TypeBlock typeBlock, UnityComponentDetails details) { typeBlock.Method("protected override void WriteDebugInfo()", mb => { mb.Line($"UnityEngine.Debug.Log(\"{details.Name} generated from '{details.SchemaFilePath}' with Component ID '{details.ComponentId}'\");"); }); }
protected Block(Vector2f _pos, Vector2f _size, string _filename, BlockName _name, TypeBlock _blocktype = TypeBlock.solid) : base(_pos, _size, _filename, Type.block, _name.ToString()) { blockType = _blocktype; Pos = new Vector2f(BlockWidth * ((int)PosX / BlockWidth) + BlockWidth / 2, BlockHeight * ((int)PosY / BlockHeight) + BlockHeight / 2); Sprite.Scale = new Vector2f((float)BlockWidth / (float)Sprite.TextureRect.Width, (float)BlockHeight / (float)Sprite.TextureRect.Height); }
public BiomeData(float Height, TypeBlock typeBlock, BlockVariant blockVariant, TreeType treeType) { _typeBlock = typeBlock; _blockVariant = blockVariant; _treeType = treeType; _Height = Height; }
public Coin(Texture2D tex, Vector2 pos, TypeBlock _type) : base(tex, pos, Blok.TypeBlock.Coin) { _tex = tex; _pos = pos; origin = new Vector2(50 / 2, 74 / 2); coinAnim = new SpriteAnimation(WorldAnimationFrames.CoinFrameList); }
public Blok(Texture2D tex, Vector2 pos, TypeBlock typeblock) { _tex = tex; _pos = pos; _typeBlock = typeblock; _origin = new Vector2(_tex.Width / 2, _tex.Height / 2); }
private void GenerateUpdateMethod(TypeBlock typeBlock, UnityTypeDetails details) { typeBlock.Method($"public override void Update({details.FullyQualifiedName} data)", mb => { mb.TextList(details.FieldDetails.Select(fd => fieldTypeHandler.ToUiFieldUpdate(fd, "data"))); }); }
public Water(Texture2D tex, Vector2 pos, TypeBlock _type) : base(tex, pos, Blok.TypeBlock.Water) { _tex = tex; _pos = pos; _origin = new Vector2(128 / 2, 128 / 2); waterAnim = new SpriteAnimation(WorldAnimationFrames.WaterFrameList); waterAnim.AantalBewegingenPerSeconde = 10; }
public ElementInfo(ZoneController element, TypeBlock type, int number) { t = element.GetComponent <Transform>(); zc = element.GetComponent <ZoneController>(); obj = element.gameObject; this.type = type; this.number = number; }
public Block(int _x, int _y, int _z, float _density, TypeBlock _Type) { x = _x; y = _y; z = _z; Type = _Type; density = _density; /*if (y <= 0) * { * * } * else * { * float thisHeight = VoxelStruct.GetTerrainHeight(x, z); * * // Set the value of this point in the terrainMap. * density = (float)y - thisHeight; * * if (density <= 0.6f && density >= 0.5f) * { * isSurface = true; * * System.Random rand = new System.Random(World.Instance.seed + x * y * z); * * if (rand.Next(0,10) <= 3) * { * HaveTree = true; * } * * SetBlock(BlockType.Grass); * } * else if (density < 0.5f) * { * FastNoise noise = new FastNoise(0); * * noise.SetFrequency(0.2f); * noise.SetInterp(FastNoise.Interp.Quintic); * * density = noise.GetPerlin(x, y, z); * * if (density <= 0.5f) * { * SetBlock(BlockType.DirtRoad); * } * else * { * SetBlock(BlockType.Air); * } * } * else * { * SetBlock(BlockType.Air); * } * }*/ }
private void GenerateUpdateMethod(TypeBlock typeBlock, UnityComponentDetails details) { typeBlock.Method("public override void Update(EntityManager manager, Entity entity)", mb => { mb.Line($"AuthoritativeToggle.value = manager.HasComponent<{details.Name}.HasAuthority>(entity);"); mb.Line($"var component = manager.GetComponentData<{details.Name}.Component>(entity);"); mb.TextList(details.FieldDetails.Select(fd => typeGenerator.ToUiFieldUpdate(fd, "component"))); }); }
public Block(int _x, int _z, Vector3 chunkPosition, float _density) { index = 0; x = _x; z = _z; System.Random rand = new System.Random(0 + x * z); hight = _density; Type = TypeBlock.Grass; }
private void GenerateConstructor(TypeBlock typeBlock, UnityTypeDetails details) { typeBlock.Method($"public {details.Name}Renderer(string label) : base(label)", mb => { foreach (var field in details.FieldDetails) { mb.TextList(fieldTypeHandler.ToFieldInitialisation(field, "Container")); } }); }
public Chest(Texture2D tex, Player player, Vector2 pos, TypeBlock _type) : base(tex, pos, Blok.TypeBlock.Chest) { this.player = player; _tex = tex; _pos = pos; _origin = new Vector2(128 / 2, 128 / 2); chestAnim = new SpriteAnimation(WorldAnimationFrames.ChestFrameList); chestAnim.AantalBewegingenPerSeconde = 5; chestAnim.IsPlaying = false; }
public override void SetDefaultFocus() { if (TypeBlock.IsSet()) { this.NameBlock.SetCursorToTheBeginning(); } else { this.TypeBlock.RemoveFocus(MoveFocusDirection.SelectPrev); } }
private void GenerateConstructor(TypeBlock typeBlock, UnityComponentDetails details) { typeBlock.Method($"public {details.Name}Renderer() : base()", mb => { mb.Line($"ComponentFoldout.text = \"{details.Name}\";"); mb.Line($"AuthoritativeToggle.SetEnabled(false);"); foreach (var field in details.FieldDetails) { mb.TextList(typeGenerator.ToFieldInitialisation(field, "ComponentFoldout")); } mb.Line($"InjectComponentIcon(\"{GetComponentIcon(details)}\");"); }); }
public void PlaceBlock(TypeBlock blockType) { SetBlock(blockType); World.Instance.GetChunk(CurrentChunk).UpdateMeshChunk(); }
public Block(int _x, int _z, Vector3 chunkPosition, float _Height, Chunk chunk) { index = 0; x = _x; z = _z; float xDistance = (float)Math.Pow(Math.Abs(x), 2); float yDistance = (float)Math.Pow(Math.Abs(z), 2); float distance = (float)Math.Sqrt(xDistance + yDistance) / 500f; height = _Height - distance; Chunk = chunkPosition; #region BiomeGen HeatType HeatType; MoistureType MoistureType; float XX = x; float ZZ = z; MidleWorld.biomeNoise.GradientPerturbFractal(ref XX, ref ZZ); heatValue = Math.Abs(MidleWorld.biomeNoise.GetCellular(XX, ZZ)); MoistureValue = Math.Abs(MidleWorld.biomeNoise.GetCellular(XX, ZZ)); if (heatValue <= GlobalData.ColdestValue) { HeatType = HeatType.Coldest; } else if (heatValue <= GlobalData.ColderValue) { HeatType = HeatType.Colder; } else if (heatValue <= GlobalData.ColdValue) { HeatType = HeatType.Cold; } else if (heatValue <= GlobalData.WarmValue) { HeatType = HeatType.Warm; } else if (heatValue <= GlobalData.WarmerValue) { HeatType = HeatType.Warmer; } else { HeatType = HeatType.Warmest; } /// if (MoistureValue <= GlobalData.DryerValue) { MoistureType = MoistureType.Dryer; } else if (MoistureValue <= GlobalData.DryValue) { MoistureType = MoistureType.Dry; } else if (MoistureValue <= GlobalData.WetValue) { MoistureType = MoistureType.Wet; } else if (MoistureValue <= GlobalData.WetterValue) { MoistureType = MoistureType.Wetter; } else if (MoistureValue <= GlobalData.WettestValue) { MoistureType = MoistureType.Wettest; } else { MoistureType = MoistureType.Wettest; } TileBiome = GlobalData.BiomeTable[(int)MoistureType, (int)HeatType]; //TileBiome = BiomeType.Woodland; #endregion treeType = TreeType.none; Type = TypeBlock.Air; if (height <= 0 && height >= -2f) { TileBiome = BiomeType.Bench; Type = TypeBlock.Sand; } else if (height < -2f) { TileBiome = BiomeType.Ocean; Type = TypeBlock.Sand; } else { BiomeData biomeData; switch (TileBiome) { case BiomeType.Grassland: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; break; case BiomeType.Desert: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; biomeData._typeBlock = TypeBlock.Sand; break; case BiomeType.TropicalRainforest: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; break; case BiomeType.Savanna: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; break; case BiomeType.Ice: biomeData = SnowForest.GetBiome(x, z, chunk); break; case BiomeType.Tundra: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; biomeData._typeBlock = TypeBlock.Grass; break; case BiomeType.Woodland: biomeData = OakForest.GetBiome(x, z, chunk); break; case BiomeType.Bench: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; break; default: biomeData = OakForest.GetBiome(x, z, chunk); biomeData._treeType = TreeType.none; break; } Type = biomeData._typeBlock; treeType = biomeData._treeType; height = Math.Abs(biomeData._Height + _Height / 10f); } }
public static VoxelDataItem GetDensity(int x, int y, int z) { FastNoise globalNoise = new FastNoise(); globalNoise.SetFrequency(0.001f); int n = Biomeslayers.Length; float l = globalNoise.GetPerlin(x, z); float YY = 0; TypeBlock blocktype = TypeBlock.Air; for (int i = 0; i < Biomeslayers.Length; i++) { if ((i - 1f) / n <= l && l <= (i + 1f) / n) { switch (Biomeslayers[i]) { case BiomeType.ForestNormal: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinForestNormal(x, z) * 20; blocktype = Teste(Get_PerlinForestNormal(x, z) * 20); break; case BiomeType.Desert: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinDesert(x, z); blocktype = Teste(Get_PerlinDesert(x, z)); break; case BiomeType.Jungle: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinJungle(x, z); blocktype = Teste(Get_PerlinJungle(x, z)); break; case BiomeType.Plain: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinPlaine(x, z); blocktype = Teste(Get_PerlinPlaine(x, z)); break; case BiomeType.Snow: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinForestSnow(x, z); blocktype = Snow(Get_PerlinForestSnow(x, z)); break; case BiomeType.Bench: YY += (-Mathf.Abs(n * l - i) + 1) * l; blocktype = Teste(l); break; case BiomeType.Montahas: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinMontanhas(x, z); blocktype = Teste(Get_PerlinMontanhas(x, z)); break; case BiomeType.ForestNormal_Dense: YY += (-Mathf.Abs(n * l - i) + 1) * Get_PerlinForestNormal_Dense(x, z); blocktype = Teste(Get_PerlinForestNormal_Dense(x, z)); break; } } } if ((y - YY) < -1) { blocktype = TypeBlock.Air; } return(new VoxelDataItem(y - YY, blocktype)); }
public BiomeType biomeType; //biome type and the same up public BiomeOnly(Vector3 _position, TypeBlock _tileType, BiomeType _biomeType) { position = _position; tileType = _tileType; biomeType = _biomeType; }
public EnemySpike(Texture2D tex, Vector2 pos, Player player, TypeBlock _type) : base(tex, pos, Blok.TypeBlock.Enemy) { this.player = player; _tex = tex; _pos = pos; }
public void SetBlock(TypeBlock blockType) { Type = blockType; }
public VoxelDataItem(float _density, TypeBlock _typeBlock) { density = _density; typeBlock = _typeBlock; }
void MarchCube(Vector3Int position, List <VertVoxel> vertices, List <int> triangles, Chunk chunk, Block block) { TypeBlock type = block.Type; // Sample terrain values at each corner of the cube. float[] cube = new float[8]; for (int i = 0; i < 8; i++) { Vector3Int point = position + VoxelStruct.CornerTable[i]; cube[i] = chunk.Blocks[point.x, point.y, point.z].density; } // Get the configuration index of this cube. int configIndex = GetCubeConfiguration(cube); // If the configuration of this cube is 0 or 255 (completely inside the terrain or completely outside of it) we don't need to do anything. if (configIndex == 0 || configIndex == 255) { return; } // Loop through the triangles. There are never more than 5 triangles to a cube and only three vertices to a triangle. int edgeIndex = 0; for (int i = 0; i < 5; i++) { for (int p = 0; p < 3; p++) { // Get the current indice. We increment triangleIndex through each loop. int indice = VoxelStruct.TriangleTable[configIndex, edgeIndex]; // If the current edgeIndex is -1, there are no more indices and we can exit the function. if (indice == -1) { return; } // Get the vertices for the start and end of this edge. Vector3 vert1 = position + VoxelStruct.CornerTable[VoxelStruct.EdgeIndexes[indice, 0]]; Vector3 vert2 = position + VoxelStruct.CornerTable[VoxelStruct.EdgeIndexes[indice, 1]]; Vector3 vertPosition; // Get the terrain values at either end of our current edge from the cube array created above. float vert1Sample = cube[VoxelStruct.EdgeIndexes[indice, 0]]; float vert2Sample = cube[VoxelStruct.EdgeIndexes[indice, 1]]; // Calculate the difference between the terrain values. float difference = vert2Sample - vert1Sample; // If the difference is 0, then the terrain passes through the middle. if (difference == 0) { difference = terrainSurface; } else { difference = (terrainSurface - vert1Sample) / difference; } // Calculate the point along the edge that passes through. vertPosition = vert1 + ((vert2 - vert1) * difference); Color vertColor = Color.white; switch (type) { case TypeBlock.Grass: vertColor = Color.white; break; case TypeBlock.Rock: vertColor = Color.red; break; case TypeBlock.Snow: vertColor = Color.green; break; default: vertColor = Color.white; break; } // Add to our vertices and triangles list and incremement the edgeIndex. triangles.Add(VertForIndice(vertPosition, vertices, vertColor)); edgeIndex++; } } }
public Door(Texture2D tex, Rectangle dest, Vector2 pos, TypeBlock typeblock) : base(tex, pos, typeblock) { _origin = new Vector2(dest.X / 2, dest.Y / 2); this.dest = dest; }
public void Type(TypeBlock typeBlock) { ParentBlock.Add(typeBlock); }
public Saw(Texture2D tex, Vector2 pos, TypeBlock _type) : base(tex, pos, Blok.TypeBlock.Enemy) { }