public override void Refresh()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("Selected point: x = {0}, y = {1}", ControlPanel.selectedPoint.x.ToString("F3"), ControlPanel.selectedPoint.y.ToString("F3"));


            var terrain       = sim.getTerrainLayers(ControlPanel.selectedPoint);
            var terrainHeight = terrain.x + terrain.y + terrain.z + terrain.w;

            sb.Append("\nTerrain height: ").Append(terrainHeight);
            sb.Append("\n\t").Append((Layers)0).Append(" height: ").Append(terrain.x);
            sb.Append("\n\t").Append((Layers)1).Append(" height: ").Append(terrain.y);
            sb.Append("\n\t").Append((Layers)2).Append(" height: ").Append(terrain.z);
            sb.Append("\n\t").Append((Layers)3).Append(" height: ").Append(terrain.w);

            var lavaHeight = sim.getLavaLevel(ControlPanel.selectedPoint);

            sb.Append("\n\t").Append((Layers)4).Append(" height: ").Append(lavaHeight);

            var waterHeight = sim.getWaterLevel(ControlPanel.selectedPoint);

            sb.Append("\n\t").Append((Layers)5).Append(" height: ").Append(waterHeight);

            sb.Append("\nTotal height: ").Append(lavaHeight + waterHeight + terrainHeight);

            sb.Append("\nSand in water: ").Append(sim.getSedimentInWater(ControlPanel.selectedPoint).x);

            var waterVelocity = sim.getWaterVelocity(ControlPanel.selectedPoint);

            sb.Append("\nWater velocity: ").Append(waterVelocity);
            sb.Append("\nWater speed: ").Append(waterVelocity.magnitude);
            sb.Append("\nWater flow: ").Append(sim.getWaterFlow(ControlPanel.selectedPoint));

            sb.Append("\nTerrain deposition(+)/dissolution(-): ").Append(sim.getDeposition(ControlPanel.selectedPoint));

            sb.Append("\nLava flow: ").Append(sim.getLavaFlow(ControlPanel.selectedPoint));
            var lavaTemperature = sim.getLavaTemperature(ControlPanel.selectedPoint);

            sb.Append("\nLava temperature, K: ").Append(lavaTemperature);

            //Should be same as in shader!!
            var fluidity = sim.getLavaFluidity() * Mathf.Pow(lavaTemperature, 3);

            fluidity = Mathf.Clamp01(fluidity);
            sb.Append("\nLava fluidity: ").Append(fluidity);
            text.text = sb.ToString();
        }
Beispiel #2
0
        // Update is called once per frame
        void Update()
        {
            Refresh();
            if (selectedAction != Action.Nothing && Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                // currently. works as for flat plane

                if (RaycastToPlain() < 0)
                {
                    mapPointer.SetActive(false);
                }
                else
                {
                    mapPointer.SetActive(true);
                    mapPointer.transform.position = lastClick;

                    // lift pointer at terrain height
                    var height = sim.getTerrainLevel(selectedPoint);
                    height += sim.getLavaLevel(selectedPoint);
                    //height *= (float)ErosionSim.TOTAL_GRID_SIZE / (float)ErosionSim.TEX_SIZE;
                    height *= ErosionSim.terrainAmountScale;
                    height += 12f;
                    mapPointer.transform.position = new Vector3(mapPointer.transform.position.x, mapPointer.transform.position.y + height, mapPointer.transform.position.z);
                    if (Input.GetMouseButton(0))
                    {
                        if (selectedAction == Action.Add)
                        {
                            if (selectedMaterial == MaterialsForEditing.water)
                            {
                                sim.AddWater(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.watersource)
                            {
                                sim.MoveWaterSource(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.volcanotest)
                            {
                                sim.MoveLavaSource(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.waterdrain)
                            {
                                sim.MoveWaterDrainage(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.ocean)
                            {
                                sim.AddOcean(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.sediment)
                            {
                                sim.AddSediment(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.lavatest)
                            {
                                sim.AddLava(selectedPoint);
                            }
                            else //rest of materials
                            {
                                sim.AddToTerrainLayer(selectedMaterial, selectedPoint);
                            }
                        }
                        if (selectedAction == Action.Remove)
                        {
                            if (selectedMaterial == MaterialsForEditing.water)
                            {
                                sim.RemoveWater(selectedPoint);
                            }
                            if (selectedMaterial == MaterialsForEditing.lavatest)
                            {
                                sim.RemoveLava(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.watersource)
                            {
                                sim.RemoveWaterSource();
                            }
                            else if (selectedMaterial == MaterialsForEditing.volcanotest)
                            {
                                sim.RemoveLavaSource();
                            }
                            else if (selectedMaterial == MaterialsForEditing.waterdrain)
                            {
                                sim.RemoveWaterDrainage();
                            }
                            else if (selectedMaterial == MaterialsForEditing.ocean)
                            {
                                sim.RemoveOcean(selectedPoint);
                            }
                            else if (selectedMaterial == MaterialsForEditing.sediment)
                            {
                                sim.RemoveSediment(selectedPoint);
                            }
                            else //rest of materials
                            {
                                sim.RemoveFromTerrainLayer(selectedMaterial, selectedPoint);
                            }
                        }
                        else if (selectedAction == Action.Info)
                        {
                            infoWindow.Show();
                        }
                    }
                }
            }
        }