示例#1
0
        public static BoardDiffState Compare(BoardNode[,] boardA, BoardNode[,] boardB)
        {
            int  width        = boardA.GetLength(0);
            int  height       = boardA.GetLength(1);
            bool heightChange = false;
            bool biomeChange  = false;
            bool nodeChange   = false;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (boardA[x, y] == boardB[x, y])
                    {
                        continue;
                    }

                    nodeChange = true;

                    if (heightChange == false)
                    {
                        if (boardA[x, y].altitude != boardB[x, y].altitude)
                        {
                            heightChange = true;
                        }
                    }

                    if (biomeChange == false)
                    {
                        Biome biomeA = BiomeGenerator.GetBiome(boardA[x, y]);
                        Biome biomeB = BiomeGenerator.GetBiome(boardB[x, y]);

                        if (biomeA != biomeB)
                        {
                            biomeChange = true;
                        }
                    }

                    if (nodeChange && heightChange && biomeChange)
                    {
                        return(new BoardDiffState(nodeChange, heightChange, biomeChange));
                    }
                }
            }

            return(new BoardDiffState(nodeChange, heightChange, biomeChange));
        }
示例#2
0
    public void ApplyActionAtCursor(Action action, int brushMagnitude)
    {
        if (board == null || cursorPosition == null)
        {
            return;
        }

        BoardNode node = board[cursorPosition.row, cursorPosition.col];

        if (action == Action.Wet)
        {
            node.moisture = Mathf.Clamp(node.moisture + brushMagnitude, 0, 100);
        }
        else if (action == Action.Dry)
        {
            node.moisture = Mathf.Clamp(node.moisture - brushMagnitude, 0, 100);
        }
        else if (action == Action.Raise)
        {
            node.altitude = Mathf.Clamp(node.altitude + brushMagnitude, 0, 100);
        }
        else if (action == Action.Lower)
        {
            node.altitude = Mathf.Clamp(node.altitude - brushMagnitude, 0, 100);
        }
        else if (action == Action.Hot)
        {
            node.temperature = Mathf.Clamp(node.temperature + brushMagnitude, 0, 100);
        }
        else if (action == Action.Cold)
        {
            node.temperature = Mathf.Clamp(node.temperature - brushMagnitude, 0, 100);
        }
        else if (action == Action.Inspect)
        {
            Biome biome = BiomeGenerator.GetBiome(node);
            SetInspectText(node, biome, cursorPosition.row, cursorPosition.col);
        }

        board[cursorPosition.row, cursorPosition.col] = node;

        if (display != null)
        {
            display.DrawBoard(board);
        }
    }
示例#3
0
    void DrawBiomeClouds(BoardNode[,] board, float[,] heightMap)
    {
        int width  = board.GetLength(0);
        int height = board.GetLength(1);

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                BoardNode node  = board[x, y];
                Biome     biome = BiomeGenerator.GetBiome(node);

                if (biome.moisture == MoistureBiome.Dry || biome.moisture == MoistureBiome.Moist)
                {
                    continue;
                }

                Vector3 scale;

                if (biome.moisture == MoistureBiome.Wet)
                {
                    scale = new Vector3(.75f, .25f, .75f);
                }
                else
                {
                    scale = new Vector3(1f, .5f, 1f);
                }
                float   nodeHeight = heightMap[x, y];
                Vector3 position   = new Vector3(x - width / 2 + .5f, nodeHeight / 2 + 5, y - width / 2 + .5f);

                GameObject   obj          = GameObject.CreatePrimitive(PrimitiveType.Cube);
                MeshRenderer meshRenderer = obj.GetComponent <MeshRenderer> ();
                meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                meshRenderer.receiveShadows    = false;
                obj.transform.localScale       = scale;
                obj.transform.localPosition    = position;
                obj.transform.parent           = transform;
                obj.GetComponent <MeshRenderer> ().sharedMaterial = cloudMaterial;
                doodads.Add(obj);
            }
        }
    }