Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Random random    = new Random();
            int    mapLenght = 10;
            int    mapHeight = 10;

            TerrainEnum[,] map = new TerrainEnum[mapLenght, mapHeight];

            Console.OutputEncoding = UTF8Encoding.UTF8;

            for (int i = 0; i < map.GetLength(0); i++)
            {
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    if (i == 0 || j == 0 || i == mapLenght - 1 || j == mapHeight - 1)
                    {
                        map[i, j] = TerrainEnum.wall;
                        Console.ForegroundColor = map[i, j].GetColor();
                        Console.Write($"{map[i, j].GetChar()}");
                    }
                    else
                    {
                        map[i, j] = (TerrainEnum)random.Next(1, 4);
                        Console.ForegroundColor = map[i, j].GetColor();
                        Console.Write($"{map[i, j].GetChar()}");
                    }
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
    public static void PlantSeedAtPoint(RaycastHit hit)
    {
        TerrainEnum       terrain = TerrainManager.GetTerrainAt(new Vector2(hit.textureCoord2.y, hit.textureCoord2.x));
        ColorTerrainPlant ctp     = ColorManager.GetValuesForTerrain(terrain);
        Plant             plant   = Instantiate(ctp.PlantPrefab, hit.point, Quaternion.identity);

        plant.SetBaseColor(ctp.RainColor);
        RegisterPlant(plant);
    }
Ejemplo n.º 3
0
        public static ConsoleColor GetColor(this TerrainEnum terrain)
        {
            switch (terrain)
            {
            case TerrainEnum.GRASS: return(ConsoleColor.Green);

            case TerrainEnum.SAND: return(ConsoleColor.Yellow);

            case TerrainEnum.WATER: return(ConsoleColor.Blue);

            default: return(ConsoleColor.DarkGray);
            }
        }
Ejemplo n.º 4
0
        public static char GetChar(this TerrainEnum terrain)
        {
            switch (terrain)
            {
            case TerrainEnum.GRASS: return('\u201c');

            case TerrainEnum.SAND: return('\u25cb');

            case TerrainEnum.WATER: return('\u2248');

            default: return('\u25cf');
            }
        }
        public static ConsoleColor GetColor(this TerrainEnum terrain)
        {
            switch (terrain)
            {
            case TerrainEnum.grass: return(ConsoleColor.Green);

            case TerrainEnum.sand: return(ConsoleColor.Yellow);

            case TerrainEnum.water: return(ConsoleColor.Blue);

            default: return(ConsoleColor.DarkGray);
            }
        }
        public static char GetChar(this TerrainEnum terrain)
        {
            switch (terrain)
            {
            case TerrainEnum.grass: return('\u201c');

            case TerrainEnum.sand: return('\u25cb');

            case TerrainEnum.water: return('\u2248');

            default: return('\u25cf');
            }
        }
Ejemplo n.º 7
0
        public Field(Tile parentTile, Rectangle rect, TerrainEnum terrain, bool openLeft = true, bool openRight = true, bool openTop = true, bool openBottom = true)
        {
            ParentTile = parentTile;
            Rect = rect;
            OriginRect = rect;
            Terrain = terrain;
            OpenBottom = openBottom;
            OpenLeft = openLeft;
            OpenRight = openRight;
            OpenTop = openTop;

            ObjectsOnField = new Collection<object>();
        }
Ejemplo n.º 8
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         brushColor = primaryBrushColor;
         brushType  = primaryBrushType;
     }
     if (Input.GetMouseButtonDown(1))
     {
         brushColor = secondaryBrushColor;
         brushType  = secondaryBrushType;
     }
 }
Ejemplo n.º 9
0
 public void AddBrushStroke(TerrainEnum terrain, float weight)
 {
     weights.Keys.ToList().ForEach((key) => {
         weights[key] = weights[key] * (1f - weight);
     });
     if (weights.ContainsKey(terrain))
     {
         weights[terrain] += weight;
     }
     else
     {
         weights [terrain] = weight;
     }
     CalcHeight();
 }
Ejemplo n.º 10
0
    public static void PaintTerrain(float[,] area, int xOffset, int yOffset, TerrainEnum terrain)
    {
        int xMax = Mathf.Min(area.GetUpperBound(0) + xOffset, Width);
        int yMax = Mathf.Min(area.GetUpperBound(1) + yOffset, Height);
        int xMin = Mathf.Max(0, xOffset);
        int yMin = Mathf.Max(0, yOffset);

        for (int x = xMin; x < xMax; x++)
        {
            for (int y = yMin; y < yMax; y++)
            {
                t.weightMap[x, y].AddBrushStroke(terrain, area[x - xOffset, y - yOffset]);
                t.heightMap[x, y] = t.weightMap[x, y].Height;
            }
        }
        UpdateTerrainHeight();
    }
Ejemplo n.º 11
0
    void ModifyHeightInternal(Vector2 point, float weight, int brushThickness, TerrainEnum terrainEnum)
    {
        int xStart = (int)(point.x * width);
        int yStart = (int)(point.y * height);
        int xEnd   = Mathf.Min(width, brushThickness + xStart);
        int yEnd   = Mathf.Min(height, brushThickness + yStart);
        int avg    = (xEnd - xStart + yEnd - yStart) / 2;

        for (int x = xStart; x < xEnd; x++)
        {
            for (int y = yStart; y < yEnd; y++)
            {
                weightMap [x, y].AddBrushStroke(terrainEnum, Time.deltaTime * 3);
                heightMap [x, y] = weightMap [x, y].Height;
            }
        }
    }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            TerrainEnum[,] map = new TerrainEnum[3, 3] {
                { TerrainEnum.GRASS, TerrainEnum.GRASS, TerrainEnum.WALL },
                { TerrainEnum.WATER, TerrainEnum.WATER, TerrainEnum.WALL },
                { TerrainEnum.SAND, TerrainEnum.WATER, TerrainEnum.WALL }
            };

            Console.OutputEncoding = UTF8Encoding.UTF8;

            for (int i = 0; i < map.GetLength(1); i++)
            {
                for (int j = 0; j < map.GetLength(0); j++)
                {
                    Console.ForegroundColor = map[i, j].GetColour();
                    Console.Write(map[i, j].GetSymbol() + " ");
                }
                Console.WriteLine("");
            }
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 13
0
 public static void ModifyHeight(Vector2 point, float weight, int brushThickness, TerrainEnum terrainEnum)
 {
     t.ModifyHeightInternal(point, weight, brushThickness, terrainEnum);
 }
Ejemplo n.º 14
0
 public static ColorTerrainPlant GetValuesForTerrain(TerrainEnum terrain)
 {
     return(t.TerrainDict.GetValueOrDefault(terrain));
 }
Ejemplo n.º 15
0
 public Tile(TerrainEnum Terrain)
 {
     this.Terrain = Terrain;
 }
Ejemplo n.º 16
0
 public static float GetHeightAt(TerrainEnum terrainEnum, int x, int y)
 {
     return(t.terrains [terrainEnum] [x, y]);
 }