1111 lines
36 KiB
C#
1111 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class global_settings_tc : MonoBehaviour
|
|
{
|
|
public int tc_script_id;
|
|
|
|
public bool tc_installed;
|
|
|
|
public Texture2D check_image;
|
|
|
|
public string[] examples;
|
|
|
|
public bool layer_count;
|
|
|
|
public bool placed_count;
|
|
|
|
public bool display_project;
|
|
|
|
public bool tabs;
|
|
|
|
public bool color_scheme;
|
|
|
|
public color_settings_class color_layout;
|
|
|
|
public bool color_layout_converted;
|
|
|
|
public bool box_scheme;
|
|
|
|
public bool display_color_curves;
|
|
|
|
public bool display_mix_curves;
|
|
|
|
public bool filter_select_text;
|
|
|
|
public string install_path;
|
|
|
|
public string install_path_full;
|
|
|
|
public bool object_fast;
|
|
|
|
public bool preview_texture;
|
|
|
|
public int preview_texture_buffer;
|
|
|
|
public bool preview_colors;
|
|
|
|
public int preview_texture_resolution;
|
|
|
|
public int preview_texture_resolution1;
|
|
|
|
public int preview_quick_resolution_min;
|
|
|
|
public float preview_splat_brightness;
|
|
|
|
public bool preview_texture_dock;
|
|
|
|
public int preview_target_frame;
|
|
|
|
public List<Color> splat_colors;
|
|
|
|
public int splat_custom_texture_resolution;
|
|
|
|
public int splat_custom_texture_resolution1;
|
|
|
|
public List<Color> tree_colors;
|
|
|
|
public List<Color> grass_colors;
|
|
|
|
public List<Color> object_colors;
|
|
|
|
public bool toggle_text_no;
|
|
|
|
public bool toggle_text_short;
|
|
|
|
public bool toggle_text_long;
|
|
|
|
public bool tooltip_text_no;
|
|
|
|
public bool tooltip_text_short;
|
|
|
|
public bool tooltip_text_long;
|
|
|
|
public int tooltip_mode;
|
|
|
|
public bool video_help;
|
|
|
|
public bool run_in_background;
|
|
|
|
public bool display_bar_auto_generate;
|
|
|
|
public bool unload_textures;
|
|
|
|
public bool clean_memory;
|
|
|
|
public bool auto_speed;
|
|
|
|
public int target_frame;
|
|
|
|
public bool auto_save;
|
|
|
|
public int auto_save_tc_instances;
|
|
|
|
public int auto_save_scene_instances;
|
|
|
|
public bool auto_save_tc;
|
|
|
|
public List<string> auto_save_tc_list;
|
|
|
|
public bool auto_save_scene;
|
|
|
|
public List<string> auto_save_scene_list;
|
|
|
|
public float auto_save_timer;
|
|
|
|
public float auto_save_time_start;
|
|
|
|
public bool auto_save_on_play;
|
|
|
|
public string auto_save_path;
|
|
|
|
public int terrain_tiles_max;
|
|
|
|
public List<auto_search_class> auto_search_list;
|
|
|
|
public map_class map;
|
|
|
|
public Texture2D tex1;
|
|
|
|
public Texture2D tex2;
|
|
|
|
public Texture2D tex3;
|
|
|
|
public Texture2D tex4;
|
|
|
|
public select_window_class select_window;
|
|
|
|
public List<int> preview_window;
|
|
|
|
public float PI;
|
|
|
|
public Texture2D map0;
|
|
|
|
public Texture2D map1;
|
|
|
|
public Texture2D map2;
|
|
|
|
public Texture2D map3;
|
|
|
|
public Texture2D map4;
|
|
|
|
public Texture2D map5;
|
|
|
|
public bool map_combine;
|
|
|
|
public bool map_load;
|
|
|
|
public bool map_load2;
|
|
|
|
public bool map_load3;
|
|
|
|
public bool map_load4;
|
|
|
|
public int map_zoom1;
|
|
|
|
public int map_zoom2;
|
|
|
|
public int map_zoom3;
|
|
|
|
public int map_zoom4;
|
|
|
|
public latlong_class map_latlong;
|
|
|
|
public latlong_class map_latlong_center;
|
|
|
|
public int map_zoom;
|
|
|
|
public int map_zoom_old;
|
|
|
|
public global_settings_class settings;
|
|
|
|
public double minLatitude;
|
|
|
|
public double maxLatitude;
|
|
|
|
public double minLongitude;
|
|
|
|
public double maxLongitude;
|
|
|
|
public global_settings_tc()
|
|
{
|
|
examples = new string[5] { "Procedural Mountains", "Procedural Canyons", "Procedural Plateaus", "Procedural Islands", "Island Example" };
|
|
layer_count = true;
|
|
placed_count = true;
|
|
display_project = true;
|
|
tabs = true;
|
|
color_scheme = true;
|
|
color_layout = new color_settings_class();
|
|
display_mix_curves = true;
|
|
filter_select_text = true;
|
|
object_fast = true;
|
|
preview_texture = true;
|
|
preview_texture_buffer = 100;
|
|
preview_colors = true;
|
|
preview_texture_resolution = 128;
|
|
preview_texture_resolution1 = 128;
|
|
preview_quick_resolution_min = 16;
|
|
preview_splat_brightness = 1f;
|
|
preview_texture_dock = true;
|
|
preview_target_frame = 30;
|
|
splat_colors = new List<Color>();
|
|
splat_custom_texture_resolution = 128;
|
|
splat_custom_texture_resolution1 = 128;
|
|
tree_colors = new List<Color>();
|
|
grass_colors = new List<Color>();
|
|
object_colors = new List<Color>();
|
|
toggle_text_short = true;
|
|
tooltip_text_long = true;
|
|
tooltip_mode = 2;
|
|
video_help = true;
|
|
run_in_background = true;
|
|
display_bar_auto_generate = true;
|
|
auto_speed = true;
|
|
target_frame = 40;
|
|
auto_save = true;
|
|
auto_save_tc_instances = 2;
|
|
auto_save_scene_instances = 2;
|
|
auto_save_tc = true;
|
|
auto_save_tc_list = new List<string>();
|
|
auto_save_scene = true;
|
|
auto_save_scene_list = new List<string>();
|
|
auto_save_timer = 10f;
|
|
auto_save_on_play = true;
|
|
terrain_tiles_max = 15;
|
|
auto_search_list = new List<auto_search_class>();
|
|
map = new map_class();
|
|
select_window = new select_window_class();
|
|
preview_window = new List<int>();
|
|
PI = (float)Math.PI;
|
|
map_latlong = new latlong_class();
|
|
map_latlong_center = new latlong_class();
|
|
map_zoom = 17;
|
|
settings = new global_settings_class();
|
|
minLatitude = -85.05113220214844;
|
|
maxLatitude = 85.05113220214844;
|
|
minLongitude = -180.0;
|
|
maxLongitude = 180.0;
|
|
}
|
|
|
|
public virtual Vector2 drawText(string text, Vector2 pos, bool background, Color color, Color backgroundColor, float rotation, float fontSize, bool bold, int mode)
|
|
{
|
|
Matrix4x4 identity = Matrix4x4.identity;
|
|
Matrix4x4 identity2 = Matrix4x4.identity;
|
|
int fontSize2 = GUI.skin.label.fontSize;
|
|
FontStyle fontStyle = GUI.skin.label.fontStyle;
|
|
Color color2 = GUI.color;
|
|
GUI.skin.label.fontSize = (int)fontSize;
|
|
if (bold)
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Bold;
|
|
}
|
|
else
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Normal;
|
|
}
|
|
Vector2 result = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(text));
|
|
identity2.SetTRS(new Vector3(pos.x, pos.y, 0f), Quaternion.Euler(0f, 0f, rotation), Vector3.one);
|
|
switch (mode)
|
|
{
|
|
case 1:
|
|
GUI.matrix = identity2;
|
|
break;
|
|
case 2:
|
|
identity.SetTRS(new Vector3((0f - result.x) / 2f, 0f - result.y, 0f), Quaternion.identity, Vector3.one);
|
|
GUI.matrix = identity2 * identity;
|
|
break;
|
|
case 3:
|
|
identity.SetTRS(new Vector3(0f, 0f - result.y, 0f), Quaternion.identity, Vector3.one);
|
|
GUI.matrix = identity2 * identity;
|
|
break;
|
|
case 4:
|
|
identity.SetTRS(new Vector3((0f - result.x) / 2f, (0f - result.y) / 2f, 0f), Quaternion.identity, Vector3.one);
|
|
GUI.matrix = identity2 * identity;
|
|
break;
|
|
case 5:
|
|
identity.SetTRS(new Vector3(0f - result.x, 0f, 0f), Quaternion.identity, Vector3.one);
|
|
GUI.matrix = identity2 * identity;
|
|
break;
|
|
case 6:
|
|
identity.SetTRS(new Vector3(0f - result.x, 0f - result.y, 0f), Quaternion.identity, Vector3.one);
|
|
GUI.matrix = identity2 * identity;
|
|
break;
|
|
}
|
|
if (background)
|
|
{
|
|
GUI.color = backgroundColor;
|
|
}
|
|
GUI.color = color;
|
|
GUI.Label(new Rect(0f, 0f, result.x, result.y), text);
|
|
GUI.skin.label.fontSize = fontSize2;
|
|
GUI.skin.label.fontStyle = fontStyle;
|
|
GUI.color = color2;
|
|
GUI.matrix = Matrix4x4.identity;
|
|
return result;
|
|
}
|
|
|
|
public virtual bool drawText(Rect rect, edit_class edit, bool background, Color color, Color backgroundColor, float fontSize, bool bold, int mode)
|
|
{
|
|
Vector2 vector = default(Vector2);
|
|
int num = default(int);
|
|
FontStyle fontStyle = default(FontStyle);
|
|
Color color2 = GUI.color;
|
|
Vector2 vector2 = default(Vector2);
|
|
if (background)
|
|
{
|
|
GUI.color = backgroundColor;
|
|
}
|
|
GUI.color = color;
|
|
if (!edit.edit)
|
|
{
|
|
num = GUI.skin.label.fontSize;
|
|
fontStyle = GUI.skin.label.fontStyle;
|
|
GUI.skin.label.fontSize = (int)fontSize;
|
|
if (bold)
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Bold;
|
|
}
|
|
else
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Normal;
|
|
}
|
|
vector2 = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(edit.default_text));
|
|
vector = calc_rect_allign(rect, vector2, mode);
|
|
GUI.Label(new Rect(vector.x, vector.y, vector2.x, vector2.y), edit.default_text);
|
|
GUI.skin.label.fontSize = num;
|
|
GUI.skin.label.fontStyle = fontStyle;
|
|
}
|
|
else
|
|
{
|
|
num = GUI.skin.textField.fontSize;
|
|
fontStyle = GUI.skin.textField.fontStyle;
|
|
GUI.skin.textField.fontSize = (int)fontSize;
|
|
if (bold)
|
|
{
|
|
GUI.skin.textField.fontStyle = FontStyle.Bold;
|
|
}
|
|
else
|
|
{
|
|
GUI.skin.textField.fontStyle = FontStyle.Normal;
|
|
}
|
|
vector2 = GUI.skin.GetStyle("TextField").CalcSize(new GUIContent(edit.text));
|
|
if (!(vector2.x >= rect.width))
|
|
{
|
|
vector2.x = rect.width;
|
|
}
|
|
vector2.x += 10f;
|
|
vector = calc_rect_allign(rect, vector2, mode);
|
|
edit.text = GUI.TextField(new Rect(vector.x, vector.y, vector2.x, vector2.y), edit.text);
|
|
GUI.skin.textField.fontSize = num;
|
|
GUI.skin.textField.fontStyle = fontStyle;
|
|
}
|
|
if (Event.current.button == 0 && Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown && new Rect(vector.x, vector.y, vector2.x, vector2.y).Contains(Event.current.mousePosition))
|
|
{
|
|
edit.edit = !edit.edit;
|
|
}
|
|
int result;
|
|
if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Escape)
|
|
{
|
|
edit.edit = false;
|
|
GUI.color = color2;
|
|
result = 1;
|
|
}
|
|
else
|
|
{
|
|
GUI.color = color2;
|
|
result = 0;
|
|
}
|
|
return (byte)result != 0;
|
|
}
|
|
|
|
public virtual void drawText(Rect rect, string text, bool background, Color color, Color backgroundColor, float fontSize, bool bold, int mode)
|
|
{
|
|
Vector2 vector = default(Vector2);
|
|
int fontSize2 = GUI.skin.label.fontSize;
|
|
FontStyle fontStyle = GUI.skin.label.fontStyle;
|
|
Color color2 = GUI.color;
|
|
Vector2 vector2 = default(Vector2);
|
|
if (background)
|
|
{
|
|
GUI.color = backgroundColor;
|
|
}
|
|
GUI.color = color;
|
|
GUI.skin.label.fontSize = (int)fontSize;
|
|
if (bold)
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Bold;
|
|
}
|
|
else
|
|
{
|
|
GUI.skin.label.fontStyle = FontStyle.Normal;
|
|
}
|
|
vector2 = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(text));
|
|
vector = calc_rect_allign(rect, vector2, mode);
|
|
GUI.Label(new Rect(vector.x, vector.y, vector2.x, vector2.y), text);
|
|
GUI.skin.label.fontSize = fontSize2;
|
|
GUI.skin.label.fontStyle = fontStyle;
|
|
GUI.color = color2;
|
|
}
|
|
|
|
public virtual Vector2 calc_rect_allign(Rect rect, Vector2 size, int mode)
|
|
{
|
|
Vector2 result = default(Vector2);
|
|
switch (mode)
|
|
{
|
|
case 1:
|
|
result.x = rect.x;
|
|
result.y = rect.y;
|
|
break;
|
|
case 2:
|
|
result.x = rect.x + rect.width / 2f - size.x / 2f;
|
|
result.y = rect.yMax;
|
|
break;
|
|
case 3:
|
|
result.x = rect.x;
|
|
result.y = rect.yMax;
|
|
break;
|
|
case 4:
|
|
result.x = rect.x + rect.width / 2f - size.x / 2f;
|
|
result.y = rect.y + rect.height / 2f - size.y / 2f;
|
|
break;
|
|
case 5:
|
|
result.x = rect.xMax - size.x;
|
|
result.y = rect.y;
|
|
break;
|
|
case 6:
|
|
result.x = rect.x + rect.width / 2f - size.x / 2f;
|
|
result.y = rect.y - size.y;
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public virtual bool drawGUIBox(Rect rect, edit_class edit, float fontSize, bool label2, float labelHeight, Color backgroundColor, Color highlightColor, Color highlightColor2, Color textColor, bool border, int width, Rect screen, bool select, Color select_color, bool active)
|
|
{
|
|
if (!select)
|
|
{
|
|
highlightColor += new Color(-0.3f, -0.3f, -0.3f);
|
|
highlightColor2 += new Color(-0.3f, -0.3f, -0.3f);
|
|
}
|
|
GUI.color = highlightColor;
|
|
bool result = drawText(rect, edit, false, textColor, new Color(0.1f, 0.1f, 0.1f, 1f), fontSize, true, 6);
|
|
if (label2)
|
|
{
|
|
GUI.color = highlightColor2;
|
|
GUI.color = Color.white;
|
|
if (!active)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x + 1f, rect.y + labelHeight + 1f), new Vector2(rect.xMax - 1f, rect.yMax - labelHeight - 1f), new Color(1f, 0f, 0f, 0.7f), 3f, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x + 1f, rect.yMax - labelHeight - 1f), new Vector2(rect.xMax - 1f, rect.y + labelHeight + 1f), new Color(1f, 0f, 0f, 0.7f), 3f, false, screen);
|
|
}
|
|
}
|
|
else if (!active)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x + 1f, rect.y + labelHeight + 1f), new Vector2(rect.xMax - 1f, rect.yMax - 1f), new Color(1f, 0f, 0f, 0.7f), 3f, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x + 1f, rect.yMax - 1f), new Vector2(rect.xMax - 1f, rect.y + labelHeight + 1f), new Color(1f, 0f, 0f, 0.7f), 3f, false, screen);
|
|
}
|
|
if (border)
|
|
{
|
|
DrawRect(rect, highlightColor, width, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, rect.y + labelHeight), new Vector2(rect.xMax, rect.y + labelHeight), highlightColor, width, false, screen);
|
|
if (label2)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, rect.yMax - labelHeight), new Vector2(rect.xMax, rect.yMax - labelHeight), highlightColor, width, false, screen);
|
|
}
|
|
}
|
|
GUI.color = Color.white;
|
|
return result;
|
|
}
|
|
|
|
public virtual void drawJoinNode(Rect rect, int length, string text, float fontSize, bool label2, float labelHeight, Color backgroundColor, Color highlightColor, Color highlightColor2, Color textColor, bool border, int width, Rect screen, bool select, Color select_color, bool active)
|
|
{
|
|
if (!select)
|
|
{
|
|
highlightColor += new Color(-0.3f, -0.3f, -0.3f);
|
|
highlightColor2 += new Color(-0.3f, -0.3f, -0.3f);
|
|
}
|
|
GUI.color = highlightColor;
|
|
int num = 0;
|
|
for (num = 0; num < length; num++)
|
|
{
|
|
}
|
|
for (num = 0; num < length; num++)
|
|
{
|
|
if (num < length - 1)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, rect.y + (float)(num + 1) * select_window.node_zoom), new Vector2(rect.xMax, rect.y + (float)(num + 1) * select_window.node_zoom), highlightColor, width, false, screen);
|
|
}
|
|
}
|
|
drawText(rect, text, false, textColor, new Color(0.1f, 0.1f, 0.1f, 1f), fontSize, true, 6);
|
|
if (border)
|
|
{
|
|
DrawRect(new Rect(rect.x, rect.y, rect.width, (float)length * select_window.node_zoom), highlightColor, width, screen);
|
|
}
|
|
GUI.color = Color.white;
|
|
}
|
|
|
|
public virtual int get_label_width(string text, bool bold)
|
|
{
|
|
Vector2 vector = default(Vector2);
|
|
if (bold)
|
|
{
|
|
FontStyle fontStyle = GUI.skin.label.fontStyle;
|
|
GUI.skin.label.fontStyle = FontStyle.Bold;
|
|
vector = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(text));
|
|
GUI.skin.label.fontStyle = fontStyle;
|
|
}
|
|
else
|
|
{
|
|
vector = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(text));
|
|
}
|
|
return (int)vector.x;
|
|
}
|
|
|
|
public virtual void DrawRect(Rect rect, Color color, float width, Rect screen)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.xMin, rect.yMin), new Vector2(rect.xMax, rect.yMin), color, width, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.xMin, rect.yMin), new Vector2(rect.xMin, rect.yMax), color, width, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.xMin, rect.yMax), new Vector2(rect.xMax, rect.yMax), color, width, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.xMax, rect.yMin), new Vector2(rect.xMax, rect.yMax), color, width, false, screen);
|
|
}
|
|
|
|
public virtual void draw_arrow(Vector2 point1, int length, int length_arrow, float rotation, Color color, int width, Rect screen)
|
|
{
|
|
length_arrow = (int)(Mathf.Sqrt(2f) * (float)length_arrow);
|
|
Vector2 vector = calc_rotation_pixel(point1.x, point1.y - (float)length, point1.x, point1.y, rotation);
|
|
Vector2 pointB = calc_rotation_pixel(vector.x - (float)length_arrow, vector.y - (float)length_arrow, vector.x, vector.y, -180f + rotation);
|
|
Vector2 pointB2 = calc_rotation_pixel(vector.x + (float)length_arrow, vector.y - (float)length_arrow, vector.x, vector.y, 180f + rotation);
|
|
Drawing_tc1.DrawLine(point1, vector, color, width, false, screen);
|
|
Drawing_tc1.DrawLine(vector, pointB, color, width, false, screen);
|
|
Drawing_tc1.DrawLine(vector, pointB2, color, width, false, screen);
|
|
}
|
|
|
|
public virtual bool draw_latlong_raster(latlong_class latlong1, latlong_class latlong2, Vector2 offset, double zoom, double current_zoom, int resolution, Rect screen, Color color, int width)
|
|
{
|
|
bool result = true;
|
|
Vector2 vector = latlong_to_pixel(latlong1, map_latlong_center, current_zoom, new Vector2(screen.width, screen.height));
|
|
Vector2 vector2 = latlong_to_pixel(latlong2, map_latlong_center, current_zoom, new Vector2(screen.width, screen.height));
|
|
Vector2 vector3 = vector2 - vector;
|
|
vector += new Vector2(0f - offset.x, offset.y);
|
|
vector2 += new Vector2(0f - offset.x, offset.y);
|
|
double num = Mathf.Pow(2f, (float)(zoom - current_zoom));
|
|
float num2 = (float)((double)resolution / num);
|
|
if (Mathf.Abs(Mathf.Round(vector3.x / num2) - vector3.x / num2) > 0.01f || !(Mathf.Abs(Mathf.Round(vector3.y / num2) - vector3.y / num2) <= 0.01f))
|
|
{
|
|
result = false;
|
|
color = Color.red;
|
|
}
|
|
for (float num3 = vector.x; num3 < vector.x + vector3.x; num3 += num2)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(num3, vector.y), new Vector2(num3, vector2.y), color, width, false, screen);
|
|
}
|
|
for (float num4 = vector.y; num4 < vector.y + vector3.y; num4 += num2)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(vector.x, num4), new Vector2(vector2.x, num4), color, width, false, screen);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public virtual void draw_grid(Rect rect, int tile_x, int tile_y, Color color, int width, Rect screen)
|
|
{
|
|
Vector2 vector = new Vector2
|
|
{
|
|
x = rect.width / (float)tile_x,
|
|
y = rect.height / (float)tile_y
|
|
};
|
|
for (float num = rect.x; num <= rect.xMax + vector.x / 2f; num += vector.x)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(num, rect.y), new Vector2(num, rect.yMax), color, width, false, screen);
|
|
}
|
|
for (float num2 = rect.y; num2 <= rect.yMax + vector.y / 2f; num2 += vector.y)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, num2), new Vector2(rect.xMax, num2), color, width, false, screen);
|
|
}
|
|
}
|
|
|
|
public virtual void draw_scale_grid(Rect rect, Vector2 offset, float zoom, float scale, Color color, int width, bool draw_center, Rect screen)
|
|
{
|
|
float num = default(float);
|
|
num = zoom;
|
|
Vector2 vector = new Vector2(screen.width, screen.height) / 2f + offset;
|
|
Vector2 vector2 = default(Vector2);
|
|
Vector2 vector3 = default(Vector2);
|
|
float num2 = vector.x - rect.x;
|
|
float num3 = vector.y - rect.y;
|
|
int num4 = (int)(num2 / num);
|
|
num4 = (int)(num2 - (float)num4 * num);
|
|
num4 = (int)((float)num4 + rect.x);
|
|
int num5 = calc_rest_value((vector.x - (float)num4) / num, 10f);
|
|
num5 = ((num5 >= 0) ? (9 - num5) : (-9 - num5));
|
|
int num6 = (int)(0f - (vector.x - (float)num4) / num + (float)(9 - num5));
|
|
int num7 = (int)(num3 / num);
|
|
num7 = (int)(num3 - (float)num7 * num);
|
|
num7 = (int)((float)num7 + rect.y);
|
|
for (float num8 = num4; num8 <= rect.xMax; num8 += num)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(num8, rect.y), new Vector2(num8, rect.yMax), color, width, false, screen);
|
|
if (num5 > 9)
|
|
{
|
|
num5 = 0;
|
|
}
|
|
num5++;
|
|
}
|
|
num5 = 0;
|
|
num6 = 0;
|
|
for (float num9 = num7; num9 <= rect.yMax; num9 += num)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, num9), new Vector2(rect.xMax, num9), color, width, false, screen);
|
|
}
|
|
if (draw_center)
|
|
{
|
|
Drawing_tc1.DrawLine(new Vector2(vector.x, rect.y), new Vector2(vector.x, rect.yMax), color, width + 2, false, screen);
|
|
Drawing_tc1.DrawLine(new Vector2(rect.x, vector.y), new Vector2(rect.xMax, vector.y), color, width + 2, false, screen);
|
|
}
|
|
}
|
|
|
|
public virtual Vector2 calc_rotation_pixel(float x, float y, float xx, float yy, float rotation)
|
|
{
|
|
Vector2 result = new Vector2(x - xx, y - yy);
|
|
float magnitude = result.magnitude;
|
|
if (magnitude != 0f)
|
|
{
|
|
result.x /= magnitude;
|
|
result.y /= magnitude;
|
|
}
|
|
float num = Mathf.Acos(result.x);
|
|
if (!(result.y >= 0f))
|
|
{
|
|
num = PI * 2f - num;
|
|
}
|
|
num -= rotation * ((float)Math.PI / 180f);
|
|
result.x = Mathf.Cos(num) * magnitude + xx;
|
|
result.y = Mathf.Sin(num) * magnitude + yy;
|
|
return result;
|
|
}
|
|
|
|
public virtual double clip(double n, double minValue, double maxValue)
|
|
{
|
|
return calcMin(calcMax(n, minValue), maxValue);
|
|
}
|
|
|
|
public virtual latlong_class clip_latlong(latlong_class latlong)
|
|
{
|
|
if (!(latlong.latitude <= maxLatitude))
|
|
{
|
|
latlong.latitude -= maxLatitude * 2.0;
|
|
}
|
|
else if (!(latlong.latitude >= minLatitude))
|
|
{
|
|
latlong.latitude += maxLatitude * 2.0;
|
|
}
|
|
if (!(latlong.longitude <= 180.0))
|
|
{
|
|
latlong.longitude -= 360.0;
|
|
}
|
|
else if (!(latlong.longitude >= -180.0))
|
|
{
|
|
latlong.longitude += 360.0;
|
|
}
|
|
return latlong;
|
|
}
|
|
|
|
public virtual map_pixel_class clip_pixel(map_pixel_class map_pixel, double zoom)
|
|
{
|
|
double num = 256f * Mathf.Pow(2f, (float)zoom);
|
|
if (!(map_pixel.x <= num - 1.0))
|
|
{
|
|
map_pixel.x -= num - 1.0;
|
|
}
|
|
else if (!(map_pixel.x >= 0.0))
|
|
{
|
|
map_pixel.x = num - 1.0 - map_pixel.x;
|
|
}
|
|
if (!(map_pixel.y <= num - 1.0))
|
|
{
|
|
map_pixel.y -= num - 1.0;
|
|
}
|
|
else if (!(map_pixel.y >= 0.0))
|
|
{
|
|
map_pixel.y = num - 1.0 - map_pixel.y;
|
|
}
|
|
return map_pixel;
|
|
}
|
|
|
|
public virtual double calcMin(double a, double b)
|
|
{
|
|
return (a >= b) ? b : a;
|
|
}
|
|
|
|
public virtual double calcMax(double a, double b)
|
|
{
|
|
return (a <= b) ? b : a;
|
|
}
|
|
|
|
public virtual int mapSize(int zoom)
|
|
{
|
|
return (int)(Mathf.Pow(2f, zoom) * 256f);
|
|
}
|
|
|
|
public virtual Vector2 latlong_to_pixel(latlong_class latlong, latlong_class latlong_center, double zoom, Vector2 screen_resolution)
|
|
{
|
|
latlong = clip_latlong(latlong);
|
|
latlong_center = clip_latlong(latlong_center);
|
|
double num = 3.1415927410125732;
|
|
double num2 = (latlong.longitude + 180.0) / 360.0;
|
|
double num3 = Mathf.Sin((float)(latlong.latitude * num / 180.0));
|
|
double num4 = 0.5 - (double)Mathf.Log((float)((1.0 + num3) / (1.0 - num3))) / (4.0 * num);
|
|
Vector2 vector = new Vector2((float)num2, (float)num4);
|
|
num2 = (latlong_center.longitude + 180.0) / 360.0;
|
|
num3 = Mathf.Sin((float)(latlong_center.latitude * num / 180.0));
|
|
num4 = 0.5 - (double)Mathf.Log((float)((1.0 + num3) / (1.0 - num3))) / (4.0 * num);
|
|
Vector2 vector2 = new Vector2((float)num2, (float)num4);
|
|
Vector2 vector3 = vector - vector2;
|
|
vector3 *= 256f * Mathf.Pow(2f, (float)zoom);
|
|
return vector3 + screen_resolution / 2f;
|
|
}
|
|
|
|
public virtual map_pixel_class latlong_to_pixel2(latlong_class latlong, double zoom)
|
|
{
|
|
latlong = clip_latlong(latlong);
|
|
double num = 3.1415927410125732;
|
|
double num2 = (latlong.longitude + 180.0) / 360.0;
|
|
double num3 = Mathf.Sin((float)(latlong.latitude * num / 180.0));
|
|
double num4 = 0.5 - (double)Mathf.Log((float)((1.0 + num3) / (1.0 - num3))) / (4.0 * num);
|
|
num2 *= (double)(256f * Mathf.Pow(2f, (float)zoom));
|
|
num4 *= (double)(256f * Mathf.Pow(2f, (float)zoom));
|
|
map_pixel_class map_pixel_class2 = new map_pixel_class();
|
|
map_pixel_class2.x = num2;
|
|
map_pixel_class2.y = num4;
|
|
return map_pixel_class2;
|
|
}
|
|
|
|
public virtual latlong_class pixel_to_latlong2(map_pixel_class map_pixel, double zoom)
|
|
{
|
|
map_pixel = clip_pixel(map_pixel, zoom);
|
|
double num = 3.1415927410125732;
|
|
double num2 = 256f * Mathf.Pow(2f, (float)zoom);
|
|
double num3 = map_pixel.x / num2 - 0.5;
|
|
double num4 = 0.5 - map_pixel.y / num2;
|
|
latlong_class latlong_class2 = new latlong_class();
|
|
latlong_class2.latitude = 90.0 - (double)(360f * Mathf.Atan(Mathf.Exp((float)((0.0 - num4) * 2.0 * num)))) / num;
|
|
latlong_class2.longitude = 360.0 * num3;
|
|
return latlong_class2;
|
|
}
|
|
|
|
public virtual latlong_class pixel_to_latlong(Vector2 offset, latlong_class latlong_center, double zoom)
|
|
{
|
|
double num = 3.1415927410125732;
|
|
double num2 = 256f * Mathf.Pow(2f, (float)zoom);
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong_center, zoom);
|
|
map_pixel_class map_pixel_class3 = new map_pixel_class();
|
|
map_pixel_class3.x = map_pixel_class2.x + (double)offset.x;
|
|
map_pixel_class3.y = map_pixel_class2.y + (double)offset.y;
|
|
double num3 = map_pixel_class3.x / num2 - 0.5;
|
|
double num4 = 0.5 - map_pixel_class3.y / num2;
|
|
latlong_class latlong_class2 = new latlong_class();
|
|
latlong_class2.latitude = 90.0 - (double)(360f * Mathf.Atan(Mathf.Exp((float)((0.0 - num4) * 2.0 * num)))) / num;
|
|
latlong_class2.longitude = 360.0 * num3;
|
|
return clip_latlong(latlong_class2);
|
|
}
|
|
|
|
public virtual map_pixel_class calc_latlong_area_size(latlong_class latlong1, latlong_class latlong2, latlong_class latlong_center)
|
|
{
|
|
double num = 3.1415927410125732;
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong1, 19.0);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(latlong2, 19.0);
|
|
double num2 = 156543.05f * Mathf.Cos((float)(latlong_center.latitude * (num / 180.0))) / Mathf.Pow(2f, 19f);
|
|
map_pixel_class map_pixel_class4 = new map_pixel_class();
|
|
map_pixel_class4.x = (map_pixel_class3.x - map_pixel_class2.x) * num2;
|
|
map_pixel_class4.y = (map_pixel_class3.y - map_pixel_class2.y) * num2;
|
|
return map_pixel_class4;
|
|
}
|
|
|
|
public virtual double calc_latlong_area_resolution(latlong_class latlong, double zoom)
|
|
{
|
|
double num = 3.1415927410125732;
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong, zoom);
|
|
return 156543.05f * Mathf.Cos((float)(latlong.latitude * (num / 180.0))) / Mathf.Pow(2f, (float)zoom);
|
|
}
|
|
|
|
public virtual latlong_area_class calc_latlong_area_rounded(latlong_class latlong1, latlong_class latlong2, double zoom, int resolution, bool square, int mode)
|
|
{
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong1, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(latlong2, zoom);
|
|
map_pixel_class map_pixel_class4 = new map_pixel_class();
|
|
map_pixel_class4.x = Mathf.Round((float)((map_pixel_class3.x - map_pixel_class2.x) / (double)resolution)) * (float)resolution;
|
|
if (square)
|
|
{
|
|
map_pixel_class4.y = map_pixel_class4.x;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class4.y = Mathf.Round((float)((map_pixel_class3.y - map_pixel_class2.y) / (double)resolution)) * (float)resolution;
|
|
}
|
|
switch (mode)
|
|
{
|
|
case 1:
|
|
if (!(map_pixel_class2.x <= map_pixel_class3.x - (double)resolution))
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - map_pixel_class4.x;
|
|
}
|
|
break;
|
|
case 2:
|
|
if (!(map_pixel_class3.x >= map_pixel_class2.x + (double)resolution))
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + map_pixel_class4.x;
|
|
}
|
|
break;
|
|
case 3:
|
|
if (!(map_pixel_class2.y <= map_pixel_class3.y - (double)resolution))
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - map_pixel_class4.y;
|
|
}
|
|
break;
|
|
case 4:
|
|
if (!(map_pixel_class3.y >= map_pixel_class2.y + (double)resolution))
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + map_pixel_class4.y;
|
|
}
|
|
break;
|
|
case 5:
|
|
if (!(map_pixel_class2.x <= map_pixel_class3.x - (double)resolution))
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - map_pixel_class4.x;
|
|
}
|
|
if (!(map_pixel_class2.y <= map_pixel_class3.y - (double)resolution))
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - map_pixel_class4.y;
|
|
}
|
|
break;
|
|
case 6:
|
|
if (!(map_pixel_class3.x >= map_pixel_class2.x + (double)resolution))
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + map_pixel_class4.x;
|
|
}
|
|
if (!(map_pixel_class2.y <= map_pixel_class3.y - (double)resolution))
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.y = map_pixel_class3.y - map_pixel_class4.y;
|
|
}
|
|
break;
|
|
case 7:
|
|
if (!(map_pixel_class2.x <= map_pixel_class3.x - (double)resolution))
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class2.x = map_pixel_class3.x - map_pixel_class4.x;
|
|
}
|
|
if (!(map_pixel_class3.y >= map_pixel_class2.y + (double)resolution))
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + map_pixel_class4.y;
|
|
}
|
|
break;
|
|
case 8:
|
|
if (!(map_pixel_class3.x - (double)resolution >= map_pixel_class2.x))
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.x = map_pixel_class2.x + map_pixel_class4.x;
|
|
}
|
|
if (!(map_pixel_class3.y - (double)resolution >= map_pixel_class2.y))
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + (double)resolution;
|
|
}
|
|
else
|
|
{
|
|
map_pixel_class3.y = map_pixel_class2.y + map_pixel_class4.y;
|
|
}
|
|
break;
|
|
}
|
|
latlong_area_class latlong_area_class2 = new latlong_area_class();
|
|
latlong_area_class2.latlong1 = pixel_to_latlong2(map_pixel_class2, zoom);
|
|
latlong_area_class2.latlong2 = pixel_to_latlong2(map_pixel_class3, zoom);
|
|
return latlong_area_class2;
|
|
}
|
|
|
|
public virtual tile_class calc_latlong_area_tiles(latlong_class latlong1, latlong_class latlong2, double zoom, int resolution)
|
|
{
|
|
tile_class tile_class2 = new tile_class();
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong1, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(latlong2, zoom);
|
|
map_pixel_class map_pixel_class4 = new map_pixel_class();
|
|
tile_class2.x = (int)Mathf.Round((float)((map_pixel_class3.x - map_pixel_class2.x) / (double)resolution));
|
|
tile_class2.y = (int)Mathf.Round((float)((map_pixel_class3.y - map_pixel_class2.y) / (double)resolution));
|
|
return tile_class2;
|
|
}
|
|
|
|
public virtual latlong_class calc_latlong_center(latlong_class latlong1, latlong_class latlong2, double zoom, Vector2 screen_resolution)
|
|
{
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong1, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(latlong2, zoom);
|
|
map_pixel_class map_pixel_class4 = new map_pixel_class();
|
|
map_pixel_class4.x = (map_pixel_class2.x + map_pixel_class3.x) / 2.0;
|
|
map_pixel_class4.y = (map_pixel_class2.y + map_pixel_class3.y) / 2.0;
|
|
return pixel_to_latlong2(map_pixel_class4, zoom);
|
|
}
|
|
|
|
public virtual void calc_latlong_area_from_center(map_area_class area, latlong_class center, double zoom, Vector2 resolution)
|
|
{
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(area.center, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(center, zoom);
|
|
map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.upper_left, zoom);
|
|
map_pixel_class map_pixel_class5 = latlong_to_pixel2(area.lower_right, zoom);
|
|
map_pixel_class map_pixel_class6 = new map_pixel_class();
|
|
map_pixel_class6.x = map_pixel_class3.x - map_pixel_class2.x;
|
|
map_pixel_class6.y = map_pixel_class3.y - map_pixel_class2.y;
|
|
map_pixel_class4.x += map_pixel_class6.x;
|
|
map_pixel_class4.y += map_pixel_class6.y;
|
|
map_pixel_class5.x = map_pixel_class4.x + (double)resolution.x;
|
|
map_pixel_class5.y = map_pixel_class4.y + (double)resolution.y;
|
|
area.upper_left = pixel_to_latlong2(map_pixel_class4, zoom);
|
|
area.lower_right = pixel_to_latlong2(map_pixel_class5, zoom);
|
|
area.center = center;
|
|
}
|
|
|
|
public virtual void calc_latlong1_area_from_center(map_area_class area, latlong_class center, double zoom)
|
|
{
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(area.upper_left, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(center, zoom);
|
|
map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.center, zoom);
|
|
map_pixel_class map_pixel_class5 = latlong_to_pixel2(area.lower_right, zoom);
|
|
map_pixel_class map_pixel_class6 = new map_pixel_class();
|
|
map_pixel_class6.x = map_pixel_class3.x - map_pixel_class2.x;
|
|
map_pixel_class6.y = map_pixel_class3.y - map_pixel_class2.y;
|
|
map_pixel_class4.x += map_pixel_class6.x;
|
|
map_pixel_class4.y += map_pixel_class6.y;
|
|
map_pixel_class5.x += map_pixel_class6.x;
|
|
map_pixel_class5.y += map_pixel_class6.y;
|
|
area.upper_left = center;
|
|
area.center = pixel_to_latlong2(map_pixel_class4, zoom);
|
|
area.lower_right = pixel_to_latlong2(map_pixel_class5, zoom);
|
|
}
|
|
|
|
public virtual void calc_latlong2_area_from_center(map_area_class area, latlong_class center, double zoom)
|
|
{
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(area.lower_right, zoom);
|
|
map_pixel_class map_pixel_class3 = latlong_to_pixel2(center, zoom);
|
|
map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.center, zoom);
|
|
map_pixel_class map_pixel_class5 = latlong_to_pixel2(area.upper_left, zoom);
|
|
map_pixel_class map_pixel_class6 = new map_pixel_class();
|
|
map_pixel_class6.x = map_pixel_class3.x - map_pixel_class2.x;
|
|
map_pixel_class6.y = map_pixel_class3.y - map_pixel_class2.y;
|
|
map_pixel_class4.x += map_pixel_class6.x;
|
|
map_pixel_class4.y += map_pixel_class6.y;
|
|
map_pixel_class5.x += map_pixel_class6.x;
|
|
map_pixel_class5.y += map_pixel_class6.y;
|
|
area.lower_right = center;
|
|
area.center = pixel_to_latlong2(map_pixel_class4, zoom);
|
|
area.upper_left = pixel_to_latlong2(map_pixel_class5, zoom);
|
|
}
|
|
|
|
public virtual Vector2 calc_pixel_zoom(Vector2 pixel, double zoom, double current_zoom, Vector2 screen_resolution)
|
|
{
|
|
double num = Mathf.Pow(2f, (float)(zoom - current_zoom));
|
|
Vector2 vector = pixel - screen_resolution;
|
|
vector *= (float)num;
|
|
return vector + screen_resolution;
|
|
}
|
|
|
|
public virtual latlong_area_class calc_latlong_area_by_tile(latlong_class latlong, tile_class tile, double zoom, int resolution, Vector2 bresolution, Vector2 offset)
|
|
{
|
|
float num = Mathf.Pow(2f, (float)(19.0 - zoom));
|
|
zoom = 19.0;
|
|
resolution = (int)((float)resolution * num);
|
|
bresolution *= num;
|
|
latlong_area_class latlong_area_class2 = new latlong_area_class();
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong, zoom);
|
|
Vector2 vector = new Vector2(0f, 0f);
|
|
map_pixel_class2.x += (float)(tile.x * resolution) + offset.x;
|
|
map_pixel_class2.y += (float)(tile.y * resolution) + offset.y;
|
|
if (tile.x > 0)
|
|
{
|
|
map_pixel_class2.x += num;
|
|
vector.x = num;
|
|
}
|
|
if (tile.y > 0)
|
|
{
|
|
map_pixel_class2.y += num;
|
|
vector.y = num;
|
|
}
|
|
latlong_class latlong2 = pixel_to_latlong2(map_pixel_class2, zoom);
|
|
latlong_area_class2.latlong1 = latlong2;
|
|
map_pixel_class2.x += bresolution.x - vector.x;
|
|
map_pixel_class2.y += bresolution.y - vector.y;
|
|
latlong2 = pixel_to_latlong2(map_pixel_class2, zoom);
|
|
latlong_area_class2.latlong2 = latlong2;
|
|
return latlong_area_class2;
|
|
}
|
|
|
|
public virtual latlong_area_class calc_latlong_area_by_tile2(latlong_class latlong, tile_class tile, double zoom, int resolution, Vector2 bresolution)
|
|
{
|
|
latlong_area_class latlong_area_class2 = new latlong_area_class();
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong, zoom);
|
|
Vector2 vector = new Vector2(0f, 0f);
|
|
map_pixel_class2.x += tile.x * resolution;
|
|
map_pixel_class2.y += tile.y * resolution;
|
|
latlong_class latlong2 = pixel_to_latlong2(map_pixel_class2, zoom);
|
|
latlong_area_class2.latlong1 = latlong2;
|
|
map_pixel_class2.x += bresolution.x;
|
|
map_pixel_class2.y += bresolution.y;
|
|
latlong2 = pixel_to_latlong2(map_pixel_class2, zoom);
|
|
latlong_area_class2.latlong2 = latlong2;
|
|
return latlong_area_class2;
|
|
}
|
|
|
|
public virtual latlong_class calc_latlong_center_by_tile(latlong_class latlong, tile_class tile, tile_class subtile, tile_class subtiles, double zoom, int resolution, Vector2 offset)
|
|
{
|
|
float num = Mathf.Pow(2f, (float)(19.0 - zoom));
|
|
zoom = 19.0;
|
|
resolution = (int)((float)resolution * num);
|
|
latlong_class latlong_class2 = new latlong_class();
|
|
map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong, zoom);
|
|
map_pixel_class2.x += tile.x * subtiles.x * resolution + subtile.x * resolution;
|
|
map_pixel_class2.y += tile.y * subtiles.y * resolution + subtile.y * resolution;
|
|
map_pixel_class2.x += (float)(resolution / 2) + offset.x;
|
|
map_pixel_class2.y += (float)(resolution / 2) + offset.y;
|
|
return pixel_to_latlong2(map_pixel_class2, zoom);
|
|
}
|
|
|
|
public virtual int calc_rest_value(float value1, float divide)
|
|
{
|
|
int num = (int)(value1 / divide);
|
|
return (int)(value1 - (float)num * divide);
|
|
}
|
|
|
|
public virtual map_pixel_class calc_latlong_to_mercator(latlong_class latlong)
|
|
{
|
|
map_pixel_class map_pixel_class2 = new map_pixel_class();
|
|
map_pixel_class2.x = latlong.latitude * 20037508.0 / 180.0;
|
|
map_pixel_class2.y = Mathf.Log(Mathf.Tan((float)((90.0 + latlong.longitude) * 3.1415927410125732 / 360.0))) / ((float)Math.PI / 180f);
|
|
map_pixel_class2.y = map_pixel_class2.y * 20037508.0 / 180.0;
|
|
return map_pixel_class2;
|
|
}
|
|
|
|
public virtual latlong_class calc_mercator_to_latlong(map_pixel_class pixel)
|
|
{
|
|
latlong_class latlong_class2 = new latlong_class();
|
|
latlong_class2.longitude = pixel.x / 20037508.0 * 180.0;
|
|
latlong_class2.latitude = pixel.y / 20037508.0 * 180.0;
|
|
latlong_class2.latitude = 180f / (float)Math.PI * (2f * Mathf.Atan(Mathf.Exp((float)(latlong_class2.latitude * 3.1415927410125732 / 180.0))) - (float)Math.PI / 2f);
|
|
return latlong_class2;
|
|
}
|
|
|
|
public virtual bool rect_contains(Rect rect1, Rect rect2)
|
|
{
|
|
return (rect1.Contains(new Vector2(rect2.x, rect2.y)) || rect1.Contains(new Vector2(rect2.x, rect2.yMax)) || rect1.Contains(new Vector2(rect2.xMax, rect2.y)) || rect1.Contains(new Vector2(rect2.xMax, rect2.yMax))) ? true : false;
|
|
}
|
|
|
|
public virtual tile_class calc_terrain_tile(int terrain_index, tile_class tiles)
|
|
{
|
|
tile_class tile_class2 = new tile_class();
|
|
tile_class2.y = terrain_index / tiles.x;
|
|
tile_class2.x = terrain_index - tile_class2.y * tiles.x;
|
|
return tile_class2;
|
|
}
|
|
|
|
public virtual void Main()
|
|
{
|
|
}
|
|
}
|