public void Init(Terrain _terrain) { //populate the settlementData with the height and angle of the terrain TerrainData terData = _terrain.terrainData; //height is y, width is x width = terData.heightmapWidth; height = terData.heightmapHeight; terrainCoordData = new List <List <CoordData> > (); for (int y = 0; y < height; y++) { List <CoordData> tempList = new List <CoordData>(); for (int x = 0; x < width; x++) { CoordData tempCoordData = new CoordData(); tempCoordData.pos = new Vector2Int(x, y); tempCoordData.height = terData.GetHeight(x, y); tempCoordData.steepness = terData.GetSteepness((float)x / (width - 1), (float)y / (height - 1)); tempList.Add(tempCoordData); } terrainCoordData.Add(tempList); } Debug.Log("Finished Creating Settlement Data"); }
private static CoordData convertPolarToCoordData(double angle, double distance) { double angleRadians = angle * Math.PI / 180; // convert Degrees to Radians int x = Convert.ToInt32(distance * Math.Cos(angleRadians)); int y = -1 * Convert.ToInt32(distance * Math.Sin(angleRadians)); CoordData point = new CoordData(x, y, angle, distance); return(point); }
// Token: 0x06001B84 RID: 7044 RVA: 0x0030CD10 File Offset: 0x0030AF10 public void SetupSoliderIcon() { Vector2 a = new Vector2(-248f, -164f); for (int i = 0; i < 16; i++) { CoordData recordByIndex = DataManager.Instance.CoordTable.GetRecordByIndex((int)(UIFormationSelect.NowArmyCoordIndex * 16) + i); Vector2 b = new Vector2((float)recordByIndex.AtkX * 0.1f, (float)recordByIndex.AtkY * 0.1f); this.SoliderIcon[i].anchoredPosition = a + b; } }
/// <summary> /// Generates a Bitmap of points based on a list of (x,y) [cartesian] points. /// </summary> /// <param name="width">Width of the bitmap</param> /// <param name="height">Height of the bitmap</param> /// <param name="plotList">List of (theta, magnitude) points</param> /// <returns></returns> private Bitmap generateDataImage(int width, int height, List <CoordData> plotList) { Bitmap bmp = new Bitmap(width, height); Graphics g = Graphics.FromImage(bmp); foreach (CoordData point in plotList) { int newX = Convert.ToInt32((point.x / 12.0f) + (width / 2.0f)); int newY = Convert.ToInt32((point.y / 12.0f) + (height / 2.0f)); if (newX > 3000 || newY > 3000 || newX < 0 || newY < 0) { //Do nothing, outside bounds } else { if (checkDistances(point.angle, point.distance, Convert.ToInt32(textStartAngle.Value), Convert.ToInt32(textEndAngle.Value), Convert.ToInt32(textDistance.Value))) { g.DrawEllipse(new Pen(Color.Red, 4), newX, newY, 4, 4); } else { //bmp.SetPixel(newX, newY, Color.Black); g.DrawEllipse(new Pen(Color.Blue, 4), newX, newY, 4, 4); } } } int originX = Convert.ToInt32(width / 2.0f); int originY = Convert.ToInt32(height / 2.0f); CoordData startAnglePoint = convertPolarToCoordData(Convert.ToDouble(textStartAngle.Value), Convert.ToDouble(textDistance.Value)); startAnglePoint.x = Convert.ToInt32((startAnglePoint.x / 12.0f) + (width / 2.0f)); startAnglePoint.y = Convert.ToInt32((startAnglePoint.y / 12.0f) + (height / 2.0f)); CoordData endAnglePoint = convertPolarToCoordData(Convert.ToDouble(textEndAngle.Value), Convert.ToDouble(textDistance.Value)); endAnglePoint.x = Convert.ToInt32((endAnglePoint.x / 12.0f) + (width / 2.0f)); endAnglePoint.y = Convert.ToInt32((endAnglePoint.y / 12.0f) + (height / 2.0f)); g.DrawLine(new Pen(Color.Green, 2), originX, originY, startAnglePoint.x, startAnglePoint.y); g.DrawLine(new Pen(Color.Green, 2), originX, originY, endAnglePoint.x, endAnglePoint.y); //TODO: Add drawings to g here. Something like this would add a single point to the bitmap: // g.DrawEllipse(new Pen(Color.Black, 2), x, y, 2, 2); // You could probably use a for loop or foreach loop to add more than one point in the list. I prefer the foreach loop for this. return(bmp); }
//set a coordinate to be a road coord public void SetRoadCoord(int _x, int _y, float _fullWidth, float _maxWidth) { CoordData currentData = GetDataAt(_x, _y); RoadCoord newData = new RoadCoord(); newData.pos = currentData.pos; newData.height = currentData.height; newData.steepness = currentData.steepness; newData.fullWidth = _fullWidth; newData.maxWidth = _maxWidth; SetDataAt(_x, _y, newData); //Debug.Log ("Setting Road Coord at (" + _x + "," + _y + ")"); }
private async void buttonGetWeather_Click(object sender, EventArgs e) { if (textBoxCity.Text == "") { MessageBox.Show("Ошибка! Введите город"); return; } string dataCoordFromYa = await ApiWorker.GetCoord(this); JObject jsonDataCoord = JObject.Parse(dataCoordFromYa); CoordData coord = JsonConvert.DeserializeObject <CoordData>(jsonDataCoord["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]["Point"].ToString()); string[] coordArray = coord.Pos.Split(new char[] { ' ' }); labelLon.Text = coordArray[0]; labelLat.Text = coordArray[1]; string dataWeatherFromYa = await ApiWorker.GetWeather(this); JObject jsonDataWeather = JObject.Parse(dataWeatherFromYa); WeatherData weatherData = JsonConvert.DeserializeObject <WeatherData>(jsonDataWeather["fact"].ToString()); WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; webClient.DownloadFile($"https://yastatic.net/weather/i/icons/blueye/color/svg/{weatherData.Icon}.svg", "icon.svg"); labelTemp.Text = weatherData.Temp; labelFeelsLike.Text = weatherData.FeelsLike; SvgDocument svg = SvgDocument.Open("icon.svg"); pictureIcon.Image = svg.Draw(); labelCondition.Text = ApiHelper.WeatherConditions[weatherData.Condition]; labelWindSpeed.Text = weatherData.WindSpeed; labelWindDir.Text = ApiHelper.WeatherWindDir[weatherData.WindDir]; labelPressureMM.Text = weatherData.PressureMM; }
private static List <CoordData> convertPolarToCoordData(List <int> polarList) { List <CoordData> cartesianList = new List <CoordData>(); for (int i = 0; i < polarList.Count; i++) { double angle = i; // in Degrees double distance = polarList[i]; // in mm CoordData point = convertPolarToCoordData(angle, distance); cartesianList.Add(point); //TODO: Do conversion here: convert (angle, distance) to (x,y) and add to cartesianList // e.g. int x = ... ; int y = ... ; // CoordData newData = new CoordData(x, y); // cartesianList.Add(newData); } return(cartesianList); }
//set a coordinate to be a building coord public void SetBuildingCoord(int _x, int _y, int _buildingID, float _buildingHeight, bool _centre, float _yRotation) { CoordData currentData = GetDataAt(_x, _y); BuildingCoord newData = new BuildingCoord(); newData.pos = currentData.pos; newData.height = currentData.height; newData.steepness = currentData.steepness; newData.buildingID = _buildingID; newData.buildingHeight = _buildingHeight; newData.centre = _centre; newData.yRotation = _yRotation; SetDataAt(_x, _y, newData); //Debug.Log ("Setting Building Coord at (" + _x + "," + _y + ")"); }
public Pair(CoordMetrics x, CoordData y) { Item1 = x; Item2 = y; }
public void SetDataAt(int _x, int _y, CoordData _data) { terrainCoordData [_y] [_x] = _data; }