public bool DrawMarker(Map.Marker marker, float angle = 0f, float scale = 1f) { Vector2 vector = new Vector2((float)Screen.width / 2f, (float)Screen.height / 2f) + Position * Zoom; Vector2 vector2 = new Vector2((float)Screen.height * 1.777778f, Screen.height) * Zoom; Vector2 vector3 = WorldToMap(marker.WorldPosition); vector3.x *= vector2.x; vector3.y *= vector2.y; float num = GetMarkerSize() * scale; Rect textureCoords = GetTextureCoords(marker.Class.Texture); Vector2 pivotPoint = new Vector2(vector.x + vector3.x, vector.y + vector3.y); Rect position = new Rect(pivotPoint.x - num / 2f, pivotPoint.y - num / 2f, num, num); GUI.color = marker.Class.Color; if (angle != 0f) { Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(angle, pivotPoint); GUI.DrawTextureWithTexCoords(position, Markers, textureCoords); GUI.matrix = matrix; } else { GUI.DrawTextureWithTexCoords(position, Markers, textureCoords); } GUI.color = Color.white; return(position.Contains(Event.current.mousePosition)); }
private void OnGUI() { try { GUI.skin = Interface.Skin; GUI.color = Color.white; if (!Opened) { return; } GUI.DrawTexture(new Rect(0f, 0f, Camera.main.pixelWidth, Camera.main.pixelHeight), background); if (currentMap.Textures != null && currentMap.Textures.Length != 0) { Vector2 a = new Vector2((float)Screen.height * 1.777778f, Screen.height) * Zoom; if (a.x < a.y) { a.y = a.x; } else { a.x = a.y; } Vector2 vector = a / 8f; Vector2 vector2 = new Vector2((float)Screen.width / 2f, (float)Screen.height / 2f) + Position * Zoom - a / 2f; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { int num = i + (8 - j - 1) * 8; GUI.DrawTexture(new Rect(vector2.x + vector.x * (float)i, vector2.y + vector.y * (float)j, vector.x, vector.y), currentMap.Textures[num]); } } GUI.DrawTexture(new Rect(0f, 0f, 500f, 500f), currentMap.Texture); List <Map.Marker> list = new List <Map.Marker>(); for (int k = 0; k < currentMap.Markers.Count; k++) { if (currentMap.Markers[k].Class.Selected && DrawMarker(currentMap.Markers[k])) { list.Add(currentMap.Markers[k]); } } playerMarker = new Map.Marker { Class = new MarkerSetting { ID = "Player", Color = Color.magenta, Label = "플레이어", Texture = 31, Category = "플레이어" }, Description = "플레이어", WorldPosition = Vector3.zero }; playerMarker.WorldPosition.x = 0f - LocalPlayer.Transform.position.z; playerMarker.WorldPosition.y = LocalPlayer.Transform.position.y; playerMarker.WorldPosition.z = LocalPlayer.Transform.position.x; if (DrawMarker(playerMarker, 90f + LocalPlayer.Transform.rotation.eulerAngles.y, 2f)) { list.Add(playerMarker); } if (BoltNetwork.isRunning && Scene.SceneTracker != null && Scene.SceneTracker.allPlayerEntities != null) { PlayerManager.Players.Clear(); PlayerManager.Players.AddRange(from o in Scene.SceneTracker.allPlayerEntities where o.isAttached && o.StateIs <IPlayerState>() && LocalPlayer.Entity != o && o.gameObject.activeSelf && o.gameObject.activeInHierarchy && o.GetComponent <BoltPlayerSetup>() != null orderby o.GetState <IPlayerState>().name select new Player(o)); } if (BoltNetwork.isRunning) { foreach (Player player in PlayerManager.Players) { playerMPMarker = new Map.Marker { Class = new MarkerSetting { ID = "Player", Color = Color.red, Label = player.Name, Texture = 32, Category = "플레이어" }, Description = player.Name, WorldPosition = Vector3.zero }; playerMPMarker.WorldPosition.x = 0f - player.Position.z; playerMPMarker.WorldPosition.y = player.Position.y; playerMPMarker.WorldPosition.z = player.Position.x; if (DrawMarker(playerMPMarker, 0f, 2f)) { list.Add(playerMPMarker); } } } if (livemarkers) { List <GameObject> list2; if (LocalPlayer.IsInCaves) { list2 = new List <GameObject>(Scene.MutantControler.activeCaveCannibals); foreach (GameObject activeInstantSpawnedCannibal in Scene.MutantControler.activeInstantSpawnedCannibals) { if (!list2.Contains(activeInstantSpawnedCannibal)) { list2.Add(activeInstantSpawnedCannibal); } } list2.RemoveAll((GameObject o) => o == null); list2.RemoveAll((GameObject o) => (bool)o != o.activeSelf); } else { list2 = new List <GameObject>(Scene.MutantControler.activeWorldCannibals); foreach (GameObject activeInstantSpawnedCannibal2 in Scene.MutantControler.activeInstantSpawnedCannibals) { if (!list2.Contains(activeInstantSpawnedCannibal2)) { list2.Add(activeInstantSpawnedCannibal2); } } list2.RemoveAll((GameObject o) => o == null); list2.RemoveAll((GameObject o) => (bool)o != o.activeSelf); } if (list2.Count > 0) { foreach (GameObject item in list2) { if (item != null) { mutantMarker = new Map.Marker { Class = new MarkerSetting { ID = "Live Cannibal", Color = Color.red, Label = "식인종", Texture = 36, Category = "원주민" }, Description = "식인종", WorldPosition = Vector3.zero }; mutantMarker.WorldPosition.x = 0f - item.transform.position.z; mutantMarker.WorldPosition.y = item.transform.position.y; mutantMarker.WorldPosition.z = item.transform.position.x; float y = item.GetComponentInChildren <Animator>().rootRotation.eulerAngles.y; if (DrawMarker(mutantMarker, 90f + y, 2f)) { list.Add(mutantMarker); } } } } } if (list.Count > 0) { Vector2 vector3 = new Vector2(Event.current.mousePosition.x - 125f, Event.current.mousePosition.y + 5f); float height = (float)list.Count * 30f + 5f; GUI.Box(new Rect(vector3.x, vector3.y, 120f, height), ""); float num2 = 0f; for (int l = 0; l < list.Count; l++) { Rect position = new Rect(vector3.x, vector3.y + num2, 120f, 30f); GUI.color = new Color(list[l].Class.Color.r, list[l].Class.Color.g, list[l].Class.Color.b, 0.2f); GUI.DrawTexture(position, foreground); GUI.color = list[l].Class.Color; GUI.DrawTextureWithTexCoords(new Rect(vector3.x + 5f, vector3.y + num2 + 5f, 20f, 20f), Markers, GetTextureCoords(list[l].Class.Texture)); GUI.color = Color.white; GUI.Label(new Rect(vector3.x + 30f, vector3.y + num2 + 5f, 90f, 30f), list[l].Class.Label); num2 += 30f; } } float num3 = 0f; int num4 = 0; foreach (MarkerCategory value in Categories.Values) { num3 += 20f; if (!value.Selected) { continue; } num4 = 0; foreach (MarkerSetting marker in value.Markers) { _ = marker; if (num4 == 0) { num3 += 20f; } num4++; if (num4 >= 2) { num4 = 0; } } } float num5 = 70f; GUI.Box(new Rect(10f, (float)Screen.height - (num3 + 30f) - num5, 200f, num3 + 35f), "필터", GUI.skin.window); //Filter-Bar int num6 = 0; int num7 = 0; foreach (MarkerCategory value2 in Categories.Values) { num7 = 0; string category = value2.Markers[0].Category; value2.Selected = GUI.Toggle(new Rect(10f, (float)Screen.height - num3 - num5 + (float)num6, 200f, 20f), value2.Selected, category, GUI.skin.button); //All-Bar num6 += 20; if (!value2.Selected) { continue; } foreach (MarkerSetting marker2 in value2.Markers) { Rect position2 = new Rect(10 + num7, (float)Screen.height - num3 - num5 + (float)num6, 100f, 20f); //inside BG-bar (front, height, width, 20f) GUI.color = new Color(value2.Color.r, value2.Color.g, value2.Color.b, marker2.Selected ? 0.2f : 0f); GUI.DrawTexture(position2, foreground); GUI.color = value2.Color; position2 = new Rect(10 + num7, (float)Screen.height - num3 - num5 + (float)num6, 20f, 20f); //width-height inside text-icon GUI.DrawTextureWithTexCoords(position2, Markers, GetTextureCoords(marker2.Texture)); GUI.color = Color.white; position2 = new Rect(35 + num7, (float)Screen.height - num3 - num5 + (float)num6, 90f, 20f);//TEXT-width marker2.Selected = GUI.Toggle(position2, marker2.Selected, marker2.Label, GUI.skin.label); num7 += 100; if (num7 >= 200) { num7 = 0; num6 += 20; } } if (num7 == 100) { num6 += 20; } } GUI.Label(new Rect(40f, (float)Screen.height - 60f, 200f, 20f), "실시간 식인종", GUI.skin.label); livemarkers = GUI.Toggle(new Rect(10f, (float)Screen.height - 60f, 20f, 30f), livemarkers, ""); if (GUI.Button(new Rect(10f, (float)Screen.height - 30f, 200f, 20f), "저장")) { SaveMarkers(Categories, "Mods/Map.settings"); } if (Event.current.type == EventType.MouseDown) { Drag = true; LastMousePos = Event.current.mousePosition; } else if (Event.current.type == EventType.MouseDrag) { Vector2 a2 = Event.current.mousePosition - LastMousePos; float num8 = Mathf.Min(Screen.width, Screen.height); Position += a2 / Zoom; Position.x = Mathf.Clamp(Position.x, num8 / -2f, num8 / 2f); Position.y = Mathf.Clamp(Position.y, num8 / -2f, num8 / 2f); LastMousePos = Event.current.mousePosition; } else if (Event.current.type == EventType.MouseUp) { Drag = false; } if (Event.current.type == EventType.ScrollWheel) { Zoom = Mathf.Clamp(Zoom + Event.current.delta.y / -20f, 1f, 3f); } GUIContent content = new GUIContent("https://theforestmap.com/ 지도데이터를 만들어주신분께 감사를 드립니다."); GUIContent content2 = new GUIContent("https://cafe.naver.com/steamforest 네이버 더 포레스트 카페 방문하기"); Vector2 vector4 = GUI.skin.label.CalcSize(content); GUI.color = Color.black; GUI.Label(new Rect((float)Screen.width - 5f - vector4.x, (float)Screen.height - 25f, vector4.x + 10f, vector4.y + 10f), content); GUI.Label(new Rect((float)Screen.width - 5f - vector4.x, (float)Screen.height - 45f, vector4.x + 10f, vector4.y + 10f), content2); GUI.color = Color.white; GUI.Label(new Rect((float)Screen.width - 6f - vector4.x, (float)Screen.height - 26f, vector4.x + 10f, vector4.y + 10f), content); GUI.Label(new Rect((float)Screen.width - 6f - vector4.x, (float)Screen.height - 46f, vector4.x + 10f, vector4.y + 10f), content2); } if (currentMap.Loading) { if (currentMap.Textures == null || currentMap.Textures.Length == 0) { string text = "불러오는중..."; Vector2 vector5 = GUI.skin.label.CalcSize(new GUIContent(text)); GUI.Label(new Rect((float)Screen.width / 2f - vector5.x / 2f, (float)Screen.height / 2f - vector5.y - 5f, vector5.x + 10f, vector5.y + 10f), text, WhiteLabel); GUI.DrawTexture(new Rect((float)Screen.width / 4f, (float)Screen.height / 2f + 1f, (float)Screen.width / 2f * currentMap.Progress, 2f), foreground); string text2 = currentMap.CurrentTask + ": " + Mathf.FloorToInt(currentMap.Progress * 100f) + "% (" + Mathf.FloorToInt((float)currentMap.BytesLoaded) + "kb / " + Mathf.FloorToInt((float)currentMap.BytesTotal / 1024f) + "kb)"; vector5 = GUI.skin.label.CalcSize(new GUIContent(text2)); GUI.Label(new Rect((float)Screen.width / 2f - vector5.x / 2f, (float)Screen.height / 2f + 2f, vector5.x + 10f, vector5.y + 10f), text2, WhiteLabel); GUI.DrawTexture(new Rect((float)Screen.width / 4f, (float)Screen.height / 2f, (float)Screen.width / 2f, 1f), foreground); } else { string text3 = "불러오는중..."; Vector2 vector6 = GUI.skin.label.CalcSize(new GUIContent(text3)); GUI.Label(new Rect((float)Screen.width - 110f - vector6.x / 2f, (float)Screen.height - 40f - vector6.y - 5f, vector6.x + 10f, vector6.y + 10f), text3, WhiteLabel); GUI.DrawTexture(new Rect((float)Screen.width - 210f, (float)Screen.height - 40f + 1f, 200f * currentMap.Progress, 2f), foreground); string text4 = currentMap.CurrentTask + ": " + Mathf.FloorToInt(currentMap.Progress * 100f) + " % (" + Mathf.FloorToInt((float)currentMap.BytesLoaded) + "kb / " + Mathf.FloorToInt((float)currentMap.BytesTotal / 1024f) + "kb)"; vector6 = GUI.skin.label.CalcSize(new GUIContent(text4)); GUI.Label(new Rect((float)Screen.width - 110f - vector6.x / 2f, (float)Screen.height - 40f + 2f, vector6.x + 10f, vector6.y + 10f), text4, WhiteLabel); GUI.DrawTexture(new Rect((float)Screen.width - 210f, (float)Screen.height - 40f, 200f, 1f), foreground); } } } catch (Exception ex) { Log.Write(ex.ToString()); } }