public static void Draw() { //options menu box BoxStruct Box1 = new BoxStruct(); Box1.left = (Screen.width/2)-((Screen.width/6)/2); Box1.top = (Screen.height/2)-((Screen.height/2)/2); Box1.width = (Screen.width/6); Box1.height = (Screen.height/2); Box1.text = GetLanguageValueXml.GetValue("optionsmenu", "title"); GUI.Box(new Rect(Box1.left, Box1.top, Box1.width, Box1.height), Box1.text); //options menu language selector //QuitButton.left has to be calculated after QuitButton.width! ButtonStruct LanguageButton = new ButtonStruct(); LanguageButton.top = Box1.top + ((Box1.height/4)); LanguageButton.width = (Box1.width - (Box1.width/8)); LanguageButton.left = Box1.left + ((Box1.width - LanguageButton.width)/2); LanguageButton.height = 20; LanguageButton.text = GetLanguageValueXml.GetValue("optionsmenu", "language"); GUIContent[] listContent = new GUIContent[3]; listContent[0] = new GUIContent(""); listContent[1] = new GUIContent(GetLanguageValueXml.GetValue("optionsmenu", "english")); listContent[2] = new GUIContent(GetLanguageValueXml.GetValue("optionsmenu", "german")); GUIStyle listStyle = new GUIStyle(); //listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 10; listStyle.normal.textColor = Color.white; Texture2D tex = new Texture2D(1, 1); listStyle.hover.background = tex; listStyle.onHover.background = tex; //listStyle.hover.textColor = Color.grey; //listStyle.onHover.textColor = Color.grey; listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4; Popup.List(new Rect(LanguageButton.left, LanguageButton.top, LanguageButton.width, LanguageButton.height), ref showList, ref selectedItem, new GUIContent(LanguageButton.text), listContent, listStyle); //options menu cancel button //CancelButton.left has to be calculated after CancelButton.width! ButtonStruct CancelButton = new ButtonStruct(); CancelButton.top = LanguageButton.top + (LanguageButton.height * (listContent.Length + 1)) + (LanguageButton.height/2); CancelButton.width = (Box1.width - (Box1.width/8)); CancelButton.left = Box1.left + ((Box1.width - CancelButton.width)/2); CancelButton.height = 20; CancelButton.text = GetLanguageValueXml.GetValue("escmenu", "cancel"); if (GUI.Button (new Rect(CancelButton.left, CancelButton.top, CancelButton.width, CancelButton.height), CancelButton.text)) { Deactivate(); } }
public static void Draw() { //escape menu box BoxStruct Box1 = new BoxStruct(); Box1.left = (Screen.width/2)-((Screen.width/6)/2); Box1.top = (Screen.height/2)-((Screen.height/2)/2); Box1.width = (Screen.width/6); Box1.height = (Screen.height/2); Box1.text = GetLanguageValueXml.GetValue("escmenu", "title"); GUI.Box(new Rect(Box1.left, Box1.top, Box1.width, Box1.height), Box1.text); //escape menu options button //QuitButton.left has to be calculated after QuitButton.width! ButtonStruct OptionsButton = new ButtonStruct(); OptionsButton.top = Box1.top + ((Box1.height/4)); OptionsButton.width = (Box1.width - (Box1.width/8)); OptionsButton.left = Box1.left + ((Box1.width - OptionsButton.width)/2); OptionsButton.height = 20; OptionsButton.text = GetLanguageValueXml.GetValue("escmenu", "options"); if (GUI.Button (new Rect(OptionsButton.left, OptionsButton.top, OptionsButton.width, OptionsButton.height), OptionsButton.text)) { EscMenuActive = false; OptionsMenu.Call(); } //escape menu quit button //OptionsButton.left has to be calculated after CancelButton.width! ButtonStruct QuitButton = new ButtonStruct(); QuitButton.top = OptionsButton.top + OptionsButton.height + (OptionsButton.height/2); QuitButton.width = (Box1.width - (Box1.width/8)); QuitButton.left = Box1.left + ((Box1.width - OptionsButton.width)/2); QuitButton.height = 20; QuitButton.text = GetLanguageValueXml.GetValue("escmenu", "quit"); if (GUI.Button (new Rect(QuitButton.left, QuitButton.top, QuitButton.width, QuitButton.height), QuitButton.text)) { Application.Quit(); } //escape menu cancel button //CancelButton.left has to be calculated after CancelButton.width! ButtonStruct CancelButton = new ButtonStruct(); CancelButton.top = QuitButton.top + QuitButton.height + (QuitButton.height/2); CancelButton.width = (Box1.width - (Box1.width/8)); CancelButton.left = Box1.left + ((Box1.width - CancelButton.width)/2); CancelButton.height = 20; CancelButton.text = GetLanguageValueXml.GetValue("escmenu", "cancel"); if (GUI.Button (new Rect(CancelButton.left, CancelButton.top, CancelButton.width, CancelButton.height), CancelButton.text)) { Deactivate(); } }
/// <summary> /// Checks collision between box A and the supplied coordinates. If they collide, return true. /// </summary> protected bool CheckCollision(VertexStruct PlayerPosition, BoxStruct Box) { if ( (PlayerPosition.PositionX >= Box.MinX && PlayerPosition.PositionX <= Box.MaxX) && (PlayerPosition.PositionY >= Box.MinY && PlayerPosition.PositionY <= Box.MaxY) && (PlayerPosition.PositionZ >= Box.MinZ && PlayerPosition.PositionZ <= Box.MaxZ) ) { return(true); } else { return(false); } }
public BoxStruct(BoxStruct <T> other) : this(other.top, other.bottom, other.left, other.right) { }
/// <summary> /// Constructs collision handlers used for collision detection. /// </summary> /// <param name="BoxPath">Path to the .OBJ file defining multiple boxes.</param> private CollisionHandler ConstructBox(string BoxPath) { // Define Handler CollisionHandler Collision_Handler = new CollisionHandler(); // Allocate Memory Collision_Handler.collisionBoxes = new List <BoxStruct>(); // Read The Box Collision Files. List <VertexStruct> Vertices = new List <VertexStruct>(); // List of vertices for spline. string[] OBJ_File = File.ReadAllLines(BoxPath); // Read all of the lines. string[] Vertex_XYZ; // Used when splitting current lines of OBJ Files. BoxStruct CollisionBox = new BoxStruct(); // Iterate over all lines. for (int x = 0; x < OBJ_File.Length; x++) { try { // Convert 3DS Notation if (OBJ_File[x].StartsWith("v ")) { OBJ_File[x] = OBJ_File[x].Replace("v ", "v "); } if (OBJ_File[x].Contains("object")) { // Get largest and smallest vertex in each axis from a list of structs containing XYZ. CollisionBox.MinX = Vertices.Min(z => z.PositionX); CollisionBox.MinY = Vertices.Min(z => z.PositionY); CollisionBox.MinZ = Vertices.Min(z => z.PositionZ); CollisionBox.MaxX = Vertices.Max(z => z.PositionX); CollisionBox.MaxY = Vertices.Max(z => z.PositionY); CollisionBox.MaxZ = Vertices.Max(z => z.PositionZ); // Add current Collision Box. Collision_Handler.collisionBoxes.Add(CollisionBox); // Reset the box struct and vertex struct. Vertices = new List <VertexStruct>(); CollisionBox = new BoxStruct(); } else if (OBJ_File[x].StartsWith("v ")) { // Remove spaces, place strings to array. Vertex_XYZ = OBJ_File[x].Split(' '); // Define a new Vertex. VertexStruct TempVertex; // Get coordinates. TempVertex.PositionX = Convert.ToSingle(Vertex_XYZ[1]); TempVertex.PositionY = Convert.ToSingle(Vertex_XYZ[2]); TempVertex.PositionZ = Convert.ToSingle(Vertex_XYZ[3]); // Add vertex to list of vertices. Vertices.Add(TempVertex); } } catch { } } // Spaghetti Code Warning - Add Last/First (if only) Box try { CollisionBox.MinX = Vertices.Min(z => z.PositionX); CollisionBox.MinY = Vertices.Min(z => z.PositionY); CollisionBox.MinZ = Vertices.Min(z => z.PositionZ); CollisionBox.MaxX = Vertices.Max(z => z.PositionX); CollisionBox.MaxY = Vertices.Max(z => z.PositionY); CollisionBox.MaxZ = Vertices.Max(z => z.PositionZ); Collision_Handler.collisionBoxes.Add(CollisionBox); } catch { } return(Collision_Handler); }