コード例 #1
0
    private void CalculateElevationAndMoisture()
    {
        float elevationFrequency = 2.66f;
        float moistureFrequency  = 2.94f;
        float tempFrequency      = 2.4f;

        float elevationRand   = UnityEngine.Random.Range(500f, 2000f);
        float moistureRand    = UnityEngine.Random.Range(500f, 2000f);
        float temperatureRand = UnityEngine.Random.Range(500f, 2000f);

        string[] splittedNameEq = EquatorGenerator.Instance.listEquator[0].name.Split(new char[] { ',' });
        int      equatorY       = int.Parse(splittedNameEq [1]);

        for (int i = 0; i < GridMap.Instance.listHexes.Count; i++)
        {
            string[] splittedName = GridMap.Instance.listHexes[i].name.Split(new char[] { ',' });
            int[]    xy           = { int.Parse(splittedName[0]), int.Parse(splittedName[1]) };

            float nx = ((float)xy[0] / GridMap.Instance.width);
            float ny = ((float)xy[1] / GridMap.Instance.height);

            float     elevationNoise = Mathf.PerlinNoise((nx + elevationRand) * elevationFrequency, (ny + elevationRand) * elevationFrequency);
            ELEVATION elevationType  = GetElevationType(elevationNoise);

            GridMap.Instance.listHexes[i].GetComponent <HexTile>().elevationNoise = elevationNoise;
            GridMap.Instance.listHexes[i].GetComponent <HexTile>().elevationType  = elevationType;
            GridMap.Instance.listHexes[i].GetComponent <HexTile>().moistureNoise  = Mathf.PerlinNoise((nx + moistureRand) * moistureFrequency, (ny + moistureRand) * moistureFrequency);

            int   distanceToEquator = Mathf.Abs(xy [1] - equatorY);
            float tempGradient      = 1.2f / GridMap.Instance.height;
            GridMap.Instance.listHexes [i].GetComponent <HexTile>().temperature = distanceToEquator * tempGradient;
            GridMap.Instance.listHexes[i].GetComponent <HexTile>().temperature += (Mathf.PerlinNoise((nx + temperatureRand) * tempFrequency, (ny + temperatureRand) * tempFrequency)) * 0.6f;
        }
    }
コード例 #2
0
    internal void GenerateBareBiome()
    {
        for (int i = 0; i < GridMap.Instance.listHexes.Count; i++)
        {
            ELEVATION elevationType = GridMap.Instance.listHexes[i].GetComponent <HexTile>().elevationType;
            float     moisture      = GridMap.Instance.listHexes[i].GetComponent <HexTile>().moistureNoise;

            if (elevationType == ELEVATION.WATER)
            {
                if (moisture <= 0.2f)
                {
                    GridMap.Instance.listHexes[i].GetComponent <HexTile>().biomeType    = BIOMES.BARE;
                    GridMap.Instance.listHexes[i].GetComponent <SpriteRenderer>().color = new Color(186f / 255f, 154f / 255f, 154f / 255f);
                }
            }
        }
    }
コード例 #3
0
ファイル: Form1.cs プロジェクト: moamenibrahim/Orion-GUI
        void CheckSerial(object sender, SerialDataEventArgs e, int flag)
        {
            switch (flag)
            {
            case 1:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "p")
                {
                    PressureBox.AppendText("\n" + d + "-->");
                }
                PressureBox.AppendText(str);
                PressureBox.ScrollToCaret();

                lon = longitude.Text;
                if (lon.StartsWith("o"))
                {
                    lon = lon.Substring(1);
                }
                ///////////////////////////////////////////////////////////////////////
                double lat_temp;
                double lat_deg;
                double lat_m;
                double lat_final;
                double lon_temp;
                double lon_deg;
                double lon_m;
                double lon_final;
                if (str == "p")
                {
                    webBrowser1.Refresh();
                }

                if (lat == string.Empty || lon == string.Empty)
                {
                    lat = "a3112.631494";

                    if (lat.StartsWith("a"))
                    {
                        lat = lat.Substring(1);
                    }
                    lon = "o2954.511475";
                    if (lon.StartsWith("o"))
                    {
                        lon = lon.Substring(1);
                    }
                }

                lat_temp = Convert.ToDouble(lat);
                lat_deg  = lat_temp / 100;
                lat_m    = lat_temp % 100;    ////miniuts double
                lat_deg  = Math.Floor(lat_deg);
                //int lat_d = Convert.ToInt16(lat_deg);////degrees integer
                // lat_deg = Convert.ToDouble(lat_d);///Degrees double
                lat_m     = lat_m / 60;
                lat_final = lat_m + lat_deg;
                lat       = Convert.ToString(lat_final);
                /////////////////////////////////////////////////


                lon_temp = Convert.ToDouble(lon);
                lon_deg  = lon_temp / 100;
                lon_m    = lon_temp % 100;    ////miniuts double
                // int lon_d = Convert.ToInt16(lon_deg);////degrees integer
                // lon_deg = Convert.ToDouble(lon_d);///Degrees double
                lon_deg   = Math.Floor(lon_deg);
                lon_m     = lon_m / 60;
                lon_final = lon_m + lon_deg;
                lon       = Convert.ToString(lon_final);


                StringBuilder queryAddress = new StringBuilder();
                queryAddress.Append("http://www.bing.com/maps/?v=2&cp=");

                if (lat != string.Empty)
                {
                    queryAddress.Append(lat + "~");
                }

                if (lon != string.Empty)
                {
                    queryAddress.Append(lon + "&lvl=18&style=a&dir=180&sp=point." + lat + "_" + lon + "_Cansat%203");
                }
                if (str == "p")
                {
                    webBrowser1.Navigate(queryAddress.ToString());
                }

                //////////////////////////////////////////////////////////////////////
                break;
            }

            case 2:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "t")
                {
                    TempBox.AppendText("\n");
                    TempBox.AppendText(d + "-->");
                }
                TempBox.AppendText(str);
                TempBox.ScrollToCaret();


                break;
            }

            case 3:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "e")
                {
                    ELEVATION.AppendText("\n");
                    ELEVATION.AppendText(d + "-->");
                }
                ELEVATION.AppendText(str);
                ELEVATION.ScrollToCaret();
                break;
            }

            case 4:
            {
                latitude.Clear();
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "h")
                {
                    HumidityBox.AppendText("\n");
                    HumidityBox.AppendText(d + "-->");
                }
                HumidityBox.AppendText(str);
                HumidityBox.ScrollToCaret();
                break;
            }

            case 5:
            {
                longitude.Clear();
                string str = Encoding.ASCII.GetString(e.Data);
                latitude.AppendText(str);
                latitude.ScrollToCaret();

                break;
            }

            case 6:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                longitude.AppendText(str);
                longitude.ScrollToCaret();

                lat = latitude.Text;
                if (lat.StartsWith("a"))
                {
                    lat = lat.Substring(1);
                }

                break;
            }

            case 7:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "B")
                {
                    Bitch.AppendText("\n");
                    Bitch.AppendText(d + "-->");
                }
                Bitch.AppendText(str);
                Bitch.ScrollToCaret();
                break;
            }

            case 8:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "Y")
                {
                    YAW.AppendText("\n");
                    YAW.AppendText(d + "-->");
                }
                YAW.AppendText(str);
                YAW.ScrollToCaret();
                break;
            }

            case 9:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "R")
                {
                    Roll.AppendText("\n");
                    Roll.AppendText(d + "-->");
                }
                Roll.AppendText(str);
                Roll.ScrollToCaret();
                break;
            }
            }
        }