diff --git a/Farseer Physics Engine 3.5/Collision/Shapes/PolygonShape.cs b/Farseer Physics Engine 3.5/Collision/Shapes/PolygonShape.cs index 2480555a2..5d0a4b37d 100644 --- a/Farseer Physics Engine 3.5/Collision/Shapes/PolygonShape.cs +++ b/Farseer Physics Engine 3.5/Collision/Shapes/PolygonShape.cs @@ -196,6 +196,11 @@ namespace FarseerPhysics.Collision.Shapes I += (0.25f * k_inv3 * D) * (intx2 + inty2); } + if (area <= Settings.Epsilon) + { + int alsmfkldsmfdkasf = 1; + } + //The area is too small for the engine to handle. Debug.Assert(area > Settings.Epsilon); diff --git a/Subsurface/Characters/AI/PathFinder.cs b/Subsurface/Characters/AI/PathFinder.cs new file mode 100644 index 000000000..1ba662db4 --- /dev/null +++ b/Subsurface/Characters/AI/PathFinder.cs @@ -0,0 +1,240 @@ +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Linq; + +namespace Subsurface +{ + class PathNode + { + private WayPoint wayPoint; + + private int wayPointID; + + public int state; + + public PathNode Parent; + + private Vector2 position; + + public float F,G,H; + + public List connections; + public float[] distances; + + public WayPoint Waypoint + { + get { return wayPoint; } + } + + public Vector2 Position + { + get {return position;} + } + + public PathNode(WayPoint wayPoint) + { + this.wayPoint = wayPoint; + this.position = wayPoint.SimPosition; + wayPointID = wayPoint.ID; + + connections = new List(); + } + + public static List GenerateNodes(List wayPoints) + { + var nodes = new Dictionary(); + foreach (WayPoint wayPoint in wayPoints) + { + nodes.Add(wayPoint.ID, new PathNode(wayPoint)); + } + + foreach (KeyValuePair node in nodes) + { + foreach (MapEntity linked in node.Value.wayPoint.linkedTo) + { + PathNode connectedNode = null; + nodes.TryGetValue(linked.ID, out connectedNode); + if (connectedNode == null) continue; + + node.Value.connections.Add(connectedNode); + } + } + + var nodeList = nodes.Values.ToList(); + foreach (PathNode node in nodeList) + { + node.distances = new float[node.connections.Count]; + for (int i = 0; i< node.distances.Length; i++) + { + node.distances[i] = Vector2.Distance(node.position, node.connections[i].position); + } + } + return nodeList; + } + + } + + class PathFinder + { + List nodes; + + private bool insideSubmarine; + + public PathFinder(List wayPoints, bool insideSubmarine = false) + { + nodes = PathNode.GenerateNodes(wayPoints.FindAll(w => w.MoveWithLevel != insideSubmarine)); + + this.insideSubmarine = insideSubmarine; + } + + public SteeringPath FindPath(Vector2 start, Vector2 end) + { + float closestDist = 0.0f; + PathNode startNode = null; + foreach (PathNode node in nodes) + { + float dist = Vector2.Distance(start,node.Position); + if (dist finalPath = new List(); + + PathNode pathNode = end; + while (pathNode != start && pathNode != null) + { + finalPath.Add(pathNode.Waypoint); + + pathNode = pathNode.Parent; + } + + finalPath.Reverse(); + + foreach (WayPoint wayPoint in finalPath) + { + path.AddNode(wayPoint); + } + + return path; + } + } +} + + + diff --git a/Subsurface/Characters/AI/SteeringPath.cs b/Subsurface/Characters/AI/SteeringPath.cs index 9ad1215a5..d88ba2106 100644 --- a/Subsurface/Characters/AI/SteeringPath.cs +++ b/Subsurface/Characters/AI/SteeringPath.cs @@ -5,32 +5,30 @@ namespace Subsurface { class SteeringPath { - private Queue nodes; - - const float MinDistance = 0.1f; - - Vector2 currentNode; + private Queue nodes; + + WayPoint currentNode; public SteeringPath() { - nodes = new Queue(); + nodes = new Queue(); } - public void AddNode(Vector2 node) + public void AddNode(WayPoint node) { - if (node == Vector2.Zero) return; + if (node == null) return; nodes.Enqueue(node); } - public Vector2 CurrentNode + public WayPoint CurrentNode { get { return currentNode; } } - public Vector2 GetNode(Vector2 pos) + public WayPoint GetNode(Vector2 pos, float minDistance = 0.1f) { - if (nodes.Count == 0) return Vector2.Zero; - if (currentNode == Vector2.Zero || Vector2.Distance(pos, currentNode) < MinDistance) currentNode = nodes.Dequeue(); + if (nodes.Count == 0) return null; + if (currentNode == null || Vector2.Distance(pos, currentNode.SimPosition) < minDistance) currentNode = nodes.Dequeue(); return currentNode; } diff --git a/Subsurface/Characters/Character.cs b/Subsurface/Characters/Character.cs index 25b82a20b..2d54ed133 100644 --- a/Subsurface/Characters/Character.cs +++ b/Subsurface/Characters/Character.cs @@ -1,4 +1,5 @@ using FarseerPhysics; +using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics.Joints; using Lidgren.Network; using Microsoft.Xna.Framework; @@ -94,6 +95,11 @@ namespace Subsurface } } + public float Mass + { + get { return AnimController.Mass; } + } + public Inventory Inventory { get { return inventory; } @@ -397,6 +403,11 @@ namespace Subsurface } } + public int GetSkillLevel(string skillName) + { + return Info.Job.GetSkillLevel(skillName); + } + public void Control(float deltaTime, Camera cam, bool forcePick = false) { if (isDead) return; @@ -509,12 +520,23 @@ namespace Subsurface if (moveCam) { cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition); - cam.OffsetAmount = 250.0f; + cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f); } cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition); Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition); + Body body = Submarine.PickBody(AnimController.limbs[0].SimPosition, mouseSimPos); + Structure structure = null; + if (body != null) structure = body.UserData as Structure; + if (structure!=null) + { + if (!structure.CastShadow && moveCam) + { + cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 500.0f, 0.05f); + } + } + if (AnimController.onGround && !AnimController.InWater && AnimController.Anim != AnimController.Animation.UsingConstruction) @@ -780,14 +802,12 @@ namespace Subsurface if (torso == null) torso = AnimController.GetLimb(LimbType.Head); Vector2 centerOfMass = Vector2.Zero; - float totalMass = 0.0f; foreach (Limb limb in AnimController.limbs) { centerOfMass += limb.Mass * limb.SimPosition; - totalMass += limb.Mass; } - centerOfMass /= totalMass; + centerOfMass /= AnimController.Mass; health = 0.0f; diff --git a/Subsurface/Characters/CharacterInfo.cs b/Subsurface/Characters/CharacterInfo.cs index 4eb7d32c4..947a58083 100644 --- a/Subsurface/Characters/CharacterInfo.cs +++ b/Subsurface/Characters/CharacterInfo.cs @@ -15,7 +15,17 @@ namespace Subsurface public Job Job; - public Gender Gender; + private Gender gender; + public Gender Gender + { + get { return gender; } + set + { + if (gender == value) return; + gender = value; + LoadHeadSprite(); + } + } public int Salary; @@ -26,6 +36,16 @@ namespace Subsurface // return gender.ToString(); //} + private Sprite headSprite; + public Sprite HeadSprite + { + get + { + if (headSprite == null) LoadHeadSprite(); + return headSprite; + } + } + public CharacterInfo(string file, string name = "", Gender gender = Gender.None, JobPrefab jobPrefab = null) { this.File = file; @@ -42,11 +62,11 @@ namespace Subsurface if (gender == Gender.None) { float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f); - this.Gender = (Rand.Range(0.0f, 1.0f, false) < femaleRatio) ? Gender.Female : Gender.Male; + this.gender = (Rand.Range(0.0f, 1.0f, false) < femaleRatio) ? Gender.Female : Gender.Male; } else { - this.Gender = gender; + this.gender = gender; } } @@ -55,7 +75,7 @@ namespace Subsurface { headSpriteRange = ToolBox.GetAttributeVector2( doc.Root, - this.Gender == Gender.Female ? "femaleheadid" : "maleheadid", + this.gender == Gender.Female ? "femaleheadid" : "maleheadid", Vector2.Zero); } @@ -77,26 +97,82 @@ namespace Subsurface string firstNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "firstname", ""); if (firstNamePath != "") { - firstNamePath = firstNamePath.Replace("[GENDER]", (this.Gender == Gender.Female) ? "f" : ""); + firstNamePath = firstNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : ""); this.Name = ToolBox.GetRandomLine(firstNamePath); } string lastNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "lastname", ""); if (lastNamePath != "") { - lastNamePath = lastNamePath.Replace("[GENDER]", (this.Gender == Gender.Female) ? "f" : ""); + lastNamePath = lastNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : ""); if (this.Name != "") this.Name += " "; this.Name += ToolBox.GetRandomLine(lastNamePath); } } } + private void LoadHeadSprite() + { + XDocument doc = ToolBox.TryLoadXml(File); + if (doc == null) return; + + XElement ragdollElement = doc.Root.Element("ragdoll"); + foreach (XElement limbElement in ragdollElement.Elements()) + { + if (ToolBox.GetAttributeString(limbElement, "type", "").ToLower() != "head") continue; + + XElement spriteElement = limbElement.Element("sprite"); + + string spritePath = spriteElement.Attribute("texture").Value; + + spritePath = spritePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : ""); + spritePath = spritePath.Replace("[HEADID]", HeadSpriteId.ToString()); + + headSprite = new Sprite(spriteElement, "", spritePath); + break; + } + } + + public GUIFrame CreateInfoFrame(Rectangle rect) + { + GUIFrame frame = new GUIFrame(rect, Color.Transparent); + frame.Padding = new Vector4(10.0f,10.0f,10.0f,10.0f); + + return CreateInfoFrame(frame); + } + + public GUIFrame CreateInfoFrame(GUIFrame frame) + { + GUIImage image = new GUIImage(new Rectangle(0,0,30,30), HeadSprite, Alignment.TopLeft, frame); + + int x = 0, y = 0; + new GUITextBlock(new Rectangle(x+80, y, 200, 20), Name, GUI.style, frame); + y += 20; + new GUITextBlock(new Rectangle(x+80, y, 200, 20), Job.Name, GUI.style, frame); + y += 30; + + var skills = Job.Skills; + skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level)); + + new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", GUI.style, frame); + y += 20; + foreach (Skill skill in skills) + { + Color textColor = Color.White * (0.5f + skill.Level/200.0f); + new GUITextBlock(new Rectangle(x+20, y, 200, 20), skill.Name, Color.Transparent, textColor, Alignment.Left, GUI.style, frame); + new GUITextBlock(new Rectangle(x + 20, y, 200, 20), skill.Level.ToString(), Color.Transparent, textColor, Alignment.Right, GUI.style, frame); + y += 20; + } + + return frame; + } + public CharacterInfo(XElement element) { Name = ToolBox.GetAttributeString(element, "name", "unnamed"); string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLower(); - Gender = (genderStr == "male") ? Gender.Male : Gender.Female; + gender = (genderStr == "male") ? Gender.Male : Gender.Female; File = ToolBox.GetAttributeString(element, "file", ""); Salary = ToolBox.GetAttributeInt(element, "salary", 1000); @@ -119,7 +195,7 @@ namespace Subsurface charElement.Add( new XAttribute("name", Name), new XAttribute("file", File), - new XAttribute("gender", Gender == Gender.Male ? "male" : "female"), + new XAttribute("gender", gender == Gender.Male ? "male" : "female"), new XAttribute("salary", Salary), new XAttribute("headspriteid", HeadSpriteId), new XAttribute("startitemsgiven", StartItemsGiven)); diff --git a/Subsurface/Characters/FishAnimController.cs b/Subsurface/Characters/FishAnimController.cs index be14ee66e..3a2be93df 100644 --- a/Subsurface/Characters/FishAnimController.cs +++ b/Subsurface/Characters/FishAnimController.cs @@ -20,6 +20,8 @@ namespace Subsurface private float flipTimer; + private float? footRotation; + public FishAnimController(Character character, XElement element) : base(character, element) { @@ -31,6 +33,12 @@ namespace Subsurface walkSpeed = ToolBox.GetAttributeFloat(element, "walkspeed", 1.0f); swimSpeed = ToolBox.GetAttributeFloat(element, "swimspeed", 1.0f); + float footRot = ToolBox.GetAttributeFloat(element,"footrotation", float.NaN); + if (!float.IsNaN(footRot)) + { + footRotation = MathHelper.ToRadians(footRot); + } + rotateTowardsMovement = ToolBox.GetAttributeBool(element, "rotatetowardsmovement", true); } @@ -202,19 +210,20 @@ namespace Subsurface Limb torso = GetLimb(LimbType.Torso); Limb head = GetLimb(LimbType.Head); + if (torso!=null) { colliderLimb = torso; colliderHeight = TorsoPosition; - colliderLimb.body.SmoothRotate(TorsoAngle*Dir, 5.0f); + colliderLimb.body.SmoothRotate(TorsoAngle*Dir, 10.0f); } else { colliderLimb = head; colliderHeight = HeadPosition; - colliderLimb.body.SmoothRotate(HeadAngle*Dir, 10.0f); + colliderLimb.body.SmoothRotate(HeadAngle*Dir, 100.0f); } Vector2 colliderPos = colliderLimb.SimPosition; @@ -270,7 +279,9 @@ namespace Subsurface colliderLimb.Move(new Vector2(colliderPos.X + movement.X * 0.2f, floorY + colliderHeight), 5.0f); } - float walkCycleSpeed = head.LinearVelocity.X * 0.08f; + //colliderLimb.body.SetTransform(Vector2.Zero, colliderLimb.Rotation); + + float walkCycleSpeed = head.LinearVelocity.X * 0.05f; walkPos -= walkCycleSpeed; @@ -308,6 +319,9 @@ namespace Subsurface (-transformedStepSize.Y > 0.0f) ? -transformedStepSize.Y : 0.0f), 8.0f); } + + if (footRotation!=null) limb.body.SmoothRotate((float)footRotation*Dir, 50.0f); + break; case LimbType.LeftLeg: case LimbType.RightLeg: diff --git a/Subsurface/Characters/HumanoidAnimController.cs b/Subsurface/Characters/HumanoidAnimController.cs index 201a801c8..d11ea22d3 100644 --- a/Subsurface/Characters/HumanoidAnimController.cs +++ b/Subsurface/Characters/HumanoidAnimController.cs @@ -17,6 +17,8 @@ namespace Subsurface { Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition; + if (inWater) stairs = null; + Vector2 rayStart = colliderPos; // at the bottom of the player sprite Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition); if (stairs != null) rayEnd.Y -= 0.5f; @@ -31,10 +33,11 @@ namespace Subsurface switch (fixture.CollisionCategories) { case Physics.CollisionStairs: + if (inWater) return -1; Structure structure = fixture.Body.UserData as Structure; - if (stairs == null && !inWater && structure!=null) + if (stairs == null && structure!=null) { - if (LowestLimb.SimPosition.Y skills; + private Dictionary skills; public string Name { @@ -34,15 +56,26 @@ namespace Subsurface get { return prefab.ItemNames; } } + public List Skills + { + get { return skills.Values.ToList(); } + } + + //public List SkillLevels + //{ + // get { return skills.Values.ToList(); } + //} public Job(JobPrefab jobPrefab) { prefab = jobPrefab; - skills = new Dictionary(); + skills = new Dictionary(); foreach (KeyValuePair skill in prefab.Skills) { - skills.Add(skill.Key, Rand.Range(skill.Value.X, skill.Value.Y, false)); + skills.Add( + skill.Key, + new Skill( skill.Key, (int)Rand.Range(skill.Value.X, skill.Value.Y, false))); } } @@ -53,10 +86,12 @@ namespace Subsurface foreach (XElement subElement in element.Elements()) { - skills.Add(subElement.Name.ToString(), ToolBox.GetAttributeFloat(subElement, "level", 0.0f)); + skills.Add( + subElement.Name.ToString(), + new Skill(subElement.Name.ToString(), ToolBox.GetAttributeInt(subElement, "level", 0))); } } - + public static Job Random() { JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count-1, false)]; @@ -64,12 +99,12 @@ namespace Subsurface return new Job(prefab); } - public float GetSkill(string skillName) + public int GetSkillLevel(string skillName) { - float skillLevel = 0.0f; - skills.TryGetValue(skillName.ToLower(), out skillLevel); + Skill skill = null; + skills.TryGetValue(skillName, out skill); - return skillLevel; + return (skill==null) ? 0 : skill.Level; } public virtual XElement Save(XElement parentElement) @@ -78,9 +113,9 @@ namespace Subsurface jobElement.Add(new XAttribute("name", Name)); - foreach (KeyValuePair skill in skills) + foreach (KeyValuePair skill in skills) { - jobElement.Add(new XElement(skill.Key, new XAttribute("level", skill.Value))); + jobElement.Add(new XElement(skill.Key, new XAttribute("level", skill.Value.Level))); } parentElement.Add(jobElement); diff --git a/Subsurface/Characters/Jobs/JobPrefab.cs b/Subsurface/Characters/Jobs/JobPrefab.cs index e492989e8..81890e419 100644 --- a/Subsurface/Characters/Jobs/JobPrefab.cs +++ b/Subsurface/Characters/Jobs/JobPrefab.cs @@ -85,17 +85,18 @@ namespace Subsurface { foreach (XElement subElement in element.Elements()) { - string skillName = subElement.Name.ToString(); - if (Skills.ContainsKey(skillName)) continue; + string skillName = ToolBox.GetAttributeString(subElement, "name", ""); - var levelAttribute = subElement.Attribute("level").ToString(); - if (levelAttribute.Contains("'")) + if (string.IsNullOrEmpty(skillName) || Skills.ContainsKey(skillName)) continue; + + var levelString = ToolBox.GetAttributeString(subElement, "level", ""); + if (levelString.Contains(",")) { - Skills.Add(skillName, ToolBox.ParseToVector2(levelAttribute, false)); + Skills.Add(skillName, ToolBox.ParseToVector2(levelString, false)); } else { - float skillLevel = float.Parse(levelAttribute, CultureInfo.InvariantCulture); + float skillLevel = float.Parse(levelString, CultureInfo.InvariantCulture); Skills.Add(skillName, new Vector2(skillLevel, skillLevel)); } diff --git a/Subsurface/Characters/Ragdoll.cs b/Subsurface/Characters/Ragdoll.cs index dc9160fd4..dd00ad5c4 100644 --- a/Subsurface/Characters/Ragdoll.cs +++ b/Subsurface/Characters/Ragdoll.cs @@ -59,6 +59,12 @@ namespace Subsurface get { return lowestLimb; } } + public float Mass + { + get; + private set; + } + public Vector2 TargetMovement { get { return (correctionMovement == Vector2.Zero) ? targetMovement : correctionMovement; } @@ -173,6 +179,7 @@ namespace Subsurface limb.body.FarseerBody.OnCollision += OnLimbCollision; limbs[ID] = limb; + Mass += limb.Mass; if (!limbDictionary.ContainsKey(limb.type)) limbDictionary.Add(limb.type, limb); break; case "joint": @@ -257,7 +264,7 @@ namespace Subsurface } else if (structure.StairDirection!=Direction.None) { - if (inWater || (!(targetMovement.Y>Math.Abs(targetMovement.X/2.0f)) && lowestLimb.body.Position.Y < ConvertUnits.ToSimUnits(structure.Rect.Y - structure.Rect.Height) + 0.5f)) + if (inWater || !(targetMovement.Y>Math.Abs(targetMovement.X/2.0f)) && lowestLimb.body.Position.Y < ConvertUnits.ToSimUnits(structure.Rect.Y - structure.Rect.Height) + 0.5f) { stairs = null; return false; diff --git a/Subsurface/Content/Characters/Jobs.xml b/Subsurface/Content/Characters/Jobs.xml index 6e0a0fa3b..0c4a58b35 100644 --- a/Subsurface/Content/Characters/Jobs.xml +++ b/Subsurface/Content/Characters/Jobs.xml @@ -2,21 +2,41 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Subsurface/Content/Characters/Mantis/mantis.png b/Subsurface/Content/Characters/Mantis/mantis.png new file mode 100644 index 000000000..b0b287343 Binary files /dev/null and b/Subsurface/Content/Characters/Mantis/mantis.png differ diff --git a/Subsurface/Content/Characters/Mantis/mantis.xml b/Subsurface/Content/Characters/Mantis/mantis.xml new file mode 100644 index 000000000..bda79ebba --- /dev/null +++ b/Subsurface/Content/Characters/Mantis/mantis.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml index 036f95675..856d8462b 100644 --- a/Subsurface/Content/Items/Engine/engine.xml +++ b/Subsurface/Content/Items/Engine/engine.xml @@ -32,6 +32,8 @@ + + diff --git a/Subsurface/Content/Items/Engine/pingCircle.png b/Subsurface/Content/Items/Engine/pingCircle.png new file mode 100644 index 000000000..6449f1272 Binary files /dev/null and b/Subsurface/Content/Items/Engine/pingCircle.png differ diff --git a/Subsurface/Content/Items/Engine/radarOverlay.png b/Subsurface/Content/Items/Engine/radarOverlay.png new file mode 100644 index 000000000..5b50d0e4d Binary files /dev/null and b/Subsurface/Content/Items/Engine/radarOverlay.png differ diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml index d73e3941c..93bdd6a4c 100644 --- a/Subsurface/Content/Items/Weapons/weapons.xml +++ b/Subsurface/Content/Items/Weapons/weapons.xml @@ -31,6 +31,7 @@ + diff --git a/Subsurface/Content/Map/StructurePrefabs.xml b/Subsurface/Content/Map/StructurePrefabs.xml index 7465c0d23..a0515b9c3 100644 --- a/Subsurface/Content/Map/StructurePrefabs.xml +++ b/Subsurface/Content/Map/StructurePrefabs.xml @@ -18,7 +18,10 @@ width = "64" height ="32" resizehorizontal="true" body="true" health="500"/> + width = "128" height ="80" body="true" health="100"/> + + diff --git a/Subsurface/Content/Map/locationNames.txt b/Subsurface/Content/Map/locationNames.txt new file mode 100644 index 000000000..757584b11 --- /dev/null +++ b/Subsurface/Content/Map/locationNames.txt @@ -0,0 +1,91 @@ +Annwn +Argadnel +Balagtan +Dyfed +Falga +Moytura +Powys +Tara +Arran Chaos +Conamara Chaos +Murias Chaos +Narbeth Chaos +Rathmore Chaos +Thotep Chaos +Cilicia Flexus +Delphi Flexus +Gortyna Flexus +Phocis Flexus +Sidon Flexus +Adonis Linea +Agave Linea +Agenor Linea +Alphesiboea Linea +Androgeos Linea +Argiope Linea +Asterius Linea +Astypalaea Linea +Autonoe Linea +Belus Linea +Butterdon Linea +Cadmus Linea +Chthonius Linea +Corick Linea +Drizzlecomb Linea +Drumskinny Linea +Echion Linea +Euphemus Linea +Glaukos Linea +Harmonia Linea +Hyperenor Linea +Ino Linea +Katreus Linea +Kennet Linea +Libya Linea +Mehen Linea +Merrivale Linea +Minos Linea +Onga Linea +Pelagon Linea +Pelorus Linea +Phineus Linea +Phoenix Linea +Rhadamanthys Linea +Sarpedon Linea +Sharpitor Linea +Sparti Linea +Staldon Linea +Tectamus Linea +Telephassa Linea +Thasus Linea +Thynia Linea +Tormsdale Linea +Udaeus Linea +Yelland Linea +Boeotia Macula +Castalia Macula +Cyclades Macula +Sabbati Macula +Thera Macula +Thrace Macula +Apep +Milda +Ana +Anid +Noctae +Set +Berith +Hyldemoer +Arid Troma +New Iapetus +Alkonost +Skaani +Topol +Sontu +Nome +Attis +Bast +Ashvini II +Oshan +Vorta +Tnaboe \ No newline at end of file diff --git a/Subsurface/Content/Map/locationTypes.xml b/Subsurface/Content/Map/locationTypes.xml new file mode 100644 index 000000000..777e1cffe --- /dev/null +++ b/Subsurface/Content/Map/locationTypes.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/Map/testroom.png b/Subsurface/Content/Map/testroom.png index 2c69bfd73..945cbe7d9 100644 Binary files a/Subsurface/Content/Map/testroom.png and b/Subsurface/Content/Map/testroom.png differ diff --git a/Subsurface/Game1.cs b/Subsurface/Game1.cs index b4244a162..608233fff 100644 --- a/Subsurface/Game1.cs +++ b/Subsurface/Game1.cs @@ -74,7 +74,7 @@ namespace Subsurface { get { return NetworkMember as GameClient; } } - + public Game1() { Graphics = new GraphicsDeviceManager(this); @@ -121,6 +121,8 @@ namespace Subsurface GameMode.Init(); GUIComponent.Init(Window); DebugConsole.Init(Window); + + LocationType.Init("Content/Map/locationTypes.xml"); //Event.Init("Content/randomevents.xml"); } diff --git a/Subsurface/GameSession/GameSession.cs b/Subsurface/GameSession/GameSession.cs index 432bc70b1..c9fd04fc5 100644 --- a/Subsurface/GameSession/GameSession.cs +++ b/Subsurface/GameSession/GameSession.cs @@ -49,7 +49,7 @@ namespace Subsurface } - public GameSession(Submarine selectedMap, GameMode gameMode = null) + public GameSession(Submarine selectedSub, GameMode gameMode = null) { taskManager = new TaskManager(this); @@ -83,7 +83,7 @@ namespace Subsurface //startTime = DateTime.Now; //endTime = startTime + gameDuration; - this.submarine = selectedMap; + this.submarine = selectedSub; //if (!save) return; @@ -134,6 +134,14 @@ namespace Subsurface submarine.SetPosition(level.StartPosition - new Vector2(0.0f, 2000.0f)); } + foreach (Item item in Item.itemList) + { + foreach (ItemComponent ic in item.components) + { + ic.OnMapLoaded(); + } + } + taskManager.StartShift(level); } diff --git a/Subsurface/Items/Components/Holdable/RangedWeapon.cs b/Subsurface/Items/Components/Holdable/RangedWeapon.cs index 4e1f2afbc..8f804ead7 100644 --- a/Subsurface/Items/Components/Holdable/RangedWeapon.cs +++ b/Subsurface/Items/Components/Holdable/RangedWeapon.cs @@ -57,6 +57,8 @@ namespace Subsurface.Items.Components isActive = true; reload = 1.0f; + bool failed = UseFailed(character); + List limbBodies = new List(); foreach (Limb l in character.AnimController.limbs) { @@ -75,18 +77,44 @@ namespace Subsurface.Items.Components Projectile projectileComponent= projectile.GetComponent(); if (projectileComponent == null) continue; - projectileComponent.ignoredBodies = limbBodies; - projectile.body.ResetDynamics(); projectile.SetTransform(TransformedBarrelPos, (item.body.Dir == 1.0f) ? item.body.Rotation : item.body.Rotation - MathHelper.Pi); projectile.Use(deltaTime); + + + if (failed) + { + Vector2 modifiedVelocity = projectile.body.LinearVelocity; + modifiedVelocity.X *= Rand.Range(0.0f, 0.5f); + modifiedVelocity.Y *= Rand.Range(0.0f, 0.5f); + + projectile.body.LinearVelocity = modifiedVelocity; + projectile.body.ApplyTorque(projectile.body.Mass * Rand.Range(-10.0f, 10.0f)); + + //recoil + item.body.ApplyLinearImpulse( + new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -10.0f); + + if (Rand.Int(2) == 0) + { + item.Drop(character); + item.body.ApplyTorque(projectile.body.Mass * Rand.Range(-10.0f, 10.0f)); + } + } + else + { + projectileComponent.ignoredBodies = limbBodies; + + //recoil + item.body.ApplyLinearImpulse( + new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * -item.body.Mass); + } + item.RemoveContained(projectile); - //recoil - item.body.ApplyLinearImpulse( - new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass); + Rope rope = item.GetComponent(); if (rope != null) rope.Attach(projectile); diff --git a/Subsurface/Items/Components/ItemComponent.cs b/Subsurface/Items/Components/ItemComponent.cs index 9910c839d..1b644c05a 100644 --- a/Subsurface/Items/Components/ItemComponent.cs +++ b/Subsurface/Items/Components/ItemComponent.cs @@ -52,6 +52,8 @@ namespace Subsurface public List requiredItems; + public List requiredSkills; + private List sounds; private GUIFrame guiFrame; @@ -133,6 +135,8 @@ namespace Subsurface requiredItems = new List(); + requiredSkills = new List(); + sounds = new List(); statusEffects = new List(); @@ -165,6 +169,12 @@ namespace Subsurface RelatedItem ri = RelatedItem.Load(subElement); if (ri != null) requiredItems.Add(ri); break; + + case "requiredskill": + case "requiredskills": + string skillName = ToolBox.GetAttributeString(subElement, "name", ""); + requiredSkills.Add(new Skill(skillName, ToolBox.GetAttributeInt(subElement, "level", 0))); + break; case "statuseffect": statusEffects.Add(StatusEffect.Load(subElement)); break; @@ -340,6 +350,30 @@ namespace Subsurface } } + public bool HasRequiredSkills(Character character) + { + foreach (Skill skill in requiredSkills) + { + int characterLevel = character.GetSkillLevel(skill.Name); + if (characterLevel < skill.Level) return false; + } + + return true; + } + + protected bool UseFailed(Character character) + { + foreach (Skill skill in requiredSkills) + { + int characterLevel = character.GetSkillLevel(skill.Name); + if (characterLevel > skill.Level) continue; + + if (Rand.Int(characterLevel) - skill.Level < 0) return true; + } + + return false; + } + public bool HasRequiredContainedItems(bool addMessage) { if (!requiredItems.Any()) return true; @@ -367,7 +401,7 @@ namespace Subsurface foreach (RelatedItem ri in requiredItems) { - if (ri.Type == RelatedItem.RelationType.Equipped) + if (ri.Type.HasFlag(RelatedItem.RelationType.Equipped)) { for (int i = 0; i < character.SelectedItems.Length; i++ ) { @@ -381,7 +415,7 @@ namespace Subsurface //if (addMessage && !String.IsNullOrEmpty(ri.Msg)) GUI.AddMessage(ri.Msg, Color.Red); return false; } - else if (ri.Type == RelatedItem.RelationType.Picked) + else if (ri.Type.HasFlag(RelatedItem.RelationType.Picked)) { Item pickedItem = character.Inventory.items.FirstOrDefault(x => x!=null && x.Condition>0.0f && ri.MatchesItem(x)); if (pickedItem == null) diff --git a/Subsurface/Items/Components/Machines/Engine.cs b/Subsurface/Items/Components/Machines/Engine.cs index db7f52063..3e1d26073 100644 --- a/Subsurface/Items/Components/Machines/Engine.cs +++ b/Subsurface/Items/Components/Machines/Engine.cs @@ -30,7 +30,7 @@ namespace Subsurface.Items.Components } } - [Editable, HasDefaultValue(500.0f, true)] + [Editable, HasDefaultValue(2000.0f, true)] public float MaxForce { get { return maxForce; } diff --git a/Subsurface/Items/Components/Machines/Pump.cs b/Subsurface/Items/Components/Machines/Pump.cs index 409011e4d..7e67133c3 100644 --- a/Subsurface/Items/Components/Machines/Pump.cs +++ b/Subsurface/Items/Components/Machines/Pump.cs @@ -163,7 +163,7 @@ namespace Subsurface.Items.Components else if (connection.Name == "set_speed") { float tempSpeed; - if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out tempSpeed)) + if (float.TryParse(signal, NumberStyles.Any, CultureInfo.InvariantCulture, out tempSpeed)) { flowPercentage = MathHelper.Clamp(tempSpeed, -100.0f, 100.0f); } @@ -171,7 +171,7 @@ namespace Subsurface.Items.Components else if (connection.Name == "set_targetlevel") { float tempTarget; - if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out tempTarget)) + if (float.TryParse(signal, NumberStyles.Any, CultureInfo.InvariantCulture, out tempTarget)) { targetLevel = MathHelper.Clamp(tempTarget, 0.0f, 100.0f); } diff --git a/Subsurface/Items/Components/Machines/Radar.cs b/Subsurface/Items/Components/Machines/Radar.cs index d0471101c..b60e9d1ff 100644 --- a/Subsurface/Items/Components/Machines/Radar.cs +++ b/Subsurface/Items/Components/Machines/Radar.cs @@ -15,8 +15,12 @@ namespace Subsurface.Items.Components float angle; + float pingState; + //RenderTarget2D renderTarget; + Sprite pingCircle, screenOverlay; + [HasDefaultValue(0.0f, false)] public float Range { @@ -27,6 +31,19 @@ namespace Subsurface.Items.Components public Radar(Item item, XElement element) : base(item, element) { + foreach (XElement subElement in element.Elements()) + { + switch (subElement.Name.ToString().ToLower()) + { + case "pingcircle": + pingCircle = new Sprite(subElement); + break; + case "screenoverlay": + screenOverlay = new Sprite(subElement); + break; + } + } + //renderTarget = new RenderTarget2D(Game1.CurrGraphicsDevice, GuiFrame.Rect.Width, GuiFrame.Rect.Height); } @@ -34,6 +51,9 @@ namespace Subsurface.Items.Components { base.Update(deltaTime, cam); + pingState = (pingState + deltaTime * 0.5f) % 1.0f; + + angle = (angle + deltaTime) % MathHelper.TwoPi; } @@ -42,38 +62,67 @@ namespace Subsurface.Items.Components int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height; int x = GuiFrame.Rect.X; int y = GuiFrame.Rect.Y; - + GuiFrame.Draw(spriteBatch); if (GUI.DrawButton(spriteBatch, new Rectangle(x+20, y+20, 200, 30), "Activate Radar")) isActive = !isActive; - Vector2 lineEnd = GuiFrame.Center; - lineEnd += new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle))*Math.Min(width,height)/2.0f; - GUI.DrawLine(spriteBatch, GuiFrame.Center, lineEnd, Color.Green); + int radius = GuiFrame.Rect.Height / 2 - 10; + DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2)); + } - if (!isActive) return; + private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect) + { - float scale = 0.01f; + Vector2 center = new Vector2(rect.Center.X, rect.Center.Y); + //lineEnd += new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Math.Min(width, height) / 2.0f; + //GUI.DrawLine(spriteBatch, GuiFrame.Center, lineEnd, Color.Green); - List edges = Level.Loaded.GetCellEdges(-Level.Loaded.Position, 5); + if (!isActive || Level.Loaded == null) return; + + if (pingCircle!=null) + { + pingCircle.Draw(spriteBatch, center, Color.White * (1.0f-pingState), 0.0f, (rect.Width/pingCircle.size.X)*pingState); + } + + + float scale = 0.015f; + + List edges = Level.Loaded.GetCellEdges(-Level.Loaded.Position, 7); Vector2 offset = Vector2.Zero; for (int i = 0; i < edges.Count; i++) { GUI.DrawLine(spriteBatch, - GuiFrame.Center + (edges[i][0] - offset) * scale, - GuiFrame.Center + (edges[i][1] - offset) * scale, Color.Green); + center + (edges[i][0] - offset) * scale, + center + (edges[i][1] - offset) * scale, Color.White); } scale = ConvertUnits.ToDisplayUnits(scale); - for (int i = 0; i< Submarine.Loaded.HullVertices.Count; i++) + for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++) { - Vector2 start =Submarine.Loaded.HullVertices[i] * scale; + Vector2 start = Submarine.Loaded.HullVertices[i] * scale; start.Y = -start.Y; - Vector2 end = Submarine.Loaded.HullVertices[(i+1)%Submarine.Loaded.HullVertices.Count] * scale; + Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * scale; end.Y = -end.Y; - GUI.DrawLine(spriteBatch, GuiFrame.Center + start,GuiFrame.Center + end, Color.Green); + GUI.DrawLine(spriteBatch, center + start, center + end, Color.White); + } + + foreach (Character c in Character.CharacterList) + { + if (c.AnimController.CurrentHull != null) continue; + + if (c.SimPosition!=Vector2.Zero && c.SimPosition.Length() < 7*Level.GridCellWidth) + { + int width = (int)c.Mass/5; + GUI.DrawRectangle(spriteBatch, new Rectangle((int)c.Position.X - width / 2, (int)c.Position.Y - width / 2, width, width), Color.White); + } + } + + if (screenOverlay!=null) + { + screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X); } } diff --git a/Subsurface/Items/Components/Machines/Steering.cs b/Subsurface/Items/Components/Machines/Steering.cs index 8ce407bd1..991be701a 100644 --- a/Subsurface/Items/Components/Machines/Steering.cs +++ b/Subsurface/Items/Components/Machines/Steering.cs @@ -1,7 +1,9 @@ -using Microsoft.Xna.Framework; +using FarseerPhysics; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using System.Xml.Linq; @@ -13,18 +15,69 @@ namespace Subsurface.Items.Components Vector2 currVelocity; Vector2 targetVelocity; + bool autoPilot; + + SteeringPath steeringPath; + + private Vector2 TargetVelocity + { + get { return targetVelocity;} + set + { + targetVelocity.X = MathHelper.Clamp(value.X, -100.0f, 100.0f); + targetVelocity.Y = MathHelper.Clamp(value.Y, -100.0f, 100.0f); + } + } + public Steering(Item item, XElement element) : base(item, element) { isActive = true; } + public override void OnMapLoaded() + { + PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false); + steeringPath = pathFinder.FindPath( + ConvertUnits.ToSimUnits(Level.Loaded.StartPosition), + ConvertUnits.ToSimUnits(Level.Loaded.EndPosition)); + } + public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); - item.SendSignal(targetVelocity.X.ToString(), "velocity_x_out"); - item.SendSignal((-targetVelocity.Y).ToString(), "velocity_y_out"); + if (autoPilot || true) + { + steeringPath.GetNode(Vector2.Zero, 5.0f); + + if (steeringPath.CurrentNode!=null) + { + Vector2 targetSpeed = steeringPath.CurrentNode.Position; + + float dist = targetSpeed.Length(); + targetSpeed = Vector2.Normalize(targetSpeed); + + if (dist<2000.0f) + { + targetSpeed = targetSpeed * Math.Max(dist / 2000.0f, 0.5f); + + } + + + Vector2 currSpeed = (Submarine.Loaded.Speed == Vector2.Zero) ? Vector2.Zero : Vector2.Normalize(Submarine.Loaded.Speed); + + //targetSpeed.X = (targetSpeed.X - currSpeed.X); + //targetSpeed.Y = (targetSpeed.Y - currSpeed.Y); + + //TargetVelocity += targetSpeed; + + TargetVelocity += (targetSpeed-currSpeed); + } + } + + item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out"); + item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out"); } public override void DrawHUD(SpriteBatch spriteBatch, Character character) @@ -52,7 +105,7 @@ namespace Subsurface.Items.Components GUI.DrawRectangle(spriteBatch, new Rectangle((int)targetVelPos.X - 5, (int)targetVelPos.Y - 5, 10, 10), Color.White); - if (Vector2.Distance(PlayerInput.MousePosition, targetVelPos)<10.0f) + if (Vector2.Distance(PlayerInput.MousePosition, new Vector2(velRect.Center.X, velRect.Center.Y)) < 200.0f) { GUI.DrawRectangle(spriteBatch, new Rectangle((int)targetVelPos.X -10, (int)targetVelPos.Y - 10, 20, 20), Color.Red); @@ -82,8 +135,18 @@ namespace Subsurface.Items.Components public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message) { - targetVelocity.X = message.ReadFloat(); - targetVelocity.Y = message.ReadFloat(); + Vector2 newTargetVelocity = Vector2.Zero; + try + { + newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat()); + } + + catch + { + return; + } + + TargetVelocity = newTargetVelocity; } } } diff --git a/Subsurface/Items/Components/Projectile.cs b/Subsurface/Items/Components/Projectile.cs index 1f0b3e97e..d595e72af 100644 --- a/Subsurface/Items/Components/Projectile.cs +++ b/Subsurface/Items/Components/Projectile.cs @@ -84,8 +84,8 @@ namespace Subsurface.Items.Components Debug.WriteLine(item.body.Rotation); Launch(new Vector2( - (float)Math.Cos(item.body.Rotation), - (float)Math.Sin(item.body.Rotation))*launchImpulse*item.body.Mass); + (float)Math.Cos(item.body.Rotation), + (float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass); return true; } diff --git a/Subsurface/Items/Item.cs b/Subsurface/Items/Item.cs index fff0ea37b..d428d2044 100644 --- a/Subsurface/Items/Item.cs +++ b/Subsurface/Items/Item.cs @@ -727,10 +727,13 @@ namespace Subsurface public bool Pick(Character picker, bool forcePick=false) { - + + bool hasRequiredSkills = true; + bool picked = false, selected = false; foreach (ItemComponent ic in components) { + if (!ic.HasRequiredSkills(picker)) hasRequiredSkills = false; if ((ic.CanBePicked || ic.CanBeSelected) && (ic.HasRequiredEquippedItems(picker, picker == Character.Controlled) || forcePick) && ic.Pick(picker)) @@ -747,6 +750,11 @@ namespace Subsurface picker.SelectedConstruction = (picker.SelectedConstruction == this) ? null : this; } + if (!hasRequiredSkills) + { + GUI.AddMessage("Your skills may be insufficient to use the item!", Color.Red, 5.0f); + } + if (container!=null) container.RemoveContained(this); return true; diff --git a/Subsurface/Map/Level.cs b/Subsurface/Map/Levels/Level.cs similarity index 85% rename from Subsurface/Map/Level.cs rename to Subsurface/Map/Levels/Level.cs index 05991cdba..567bfb627 100644 --- a/Subsurface/Map/Level.cs +++ b/Subsurface/Map/Levels/Level.cs @@ -30,9 +30,11 @@ namespace Subsurface private int siteInterval; - const int GridCellWidth = 2000; + public const int GridCellWidth = 2000; private List[,] cellGrid; + private float shaftHeight; + //List bodies; private List cells; @@ -59,6 +61,11 @@ namespace Subsurface private set; } + public Vector2 EndPosition + { + get { return endPosition; } + } + public bool AtEndPosition { get; @@ -67,7 +74,7 @@ namespace Subsurface public Vector2 Position { - get { return ConvertUnits.ToDisplayUnits(cells[0].body.Position); } + get { return ConvertUnits.ToDisplayUnits(cells[1].body.Position); } } public string Seed @@ -97,7 +104,6 @@ namespace Subsurface public void Generate(float minWidth, bool mirror=false) { - mirror = true; Stopwatch sw = new Stopwatch(); sw.Start(); @@ -112,7 +118,7 @@ namespace Subsurface List sites = new List(); - Random rand = new Random(100); + Random rand = new Random(seed.GetHashCode()); float siteVariance = siteInterval * 0.8f; for (int x = siteInterval / 2; x < borders.Width; x += siteInterval) @@ -186,17 +192,23 @@ namespace Subsurface borders.X + (int)minWidth * 2, borders.Y + (int)minWidth * 2, borders.Right - (int)minWidth * 4, borders.Y + borders.Height - (int)minWidth * 4); - Vector2 startPath = new Vector2((int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); - Vector2 endPath = new Vector2(borders.Width - (int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); + List pathNodes = new List(); + + startPosition = new Vector2((int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); + endPosition = new Vector2(borders.Width - (int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); + + pathNodes.Add(new Vector2(startPosition.X, borders.Height)); + pathNodes.Add(startPosition); + pathNodes.Add(endPosition); + pathNodes.Add(new Vector2(endPosition.X, borders.Height)); if (mirror) { - startPath.X = borders.Width - startPath.X; - endPath.X = borders.Width - endPath.X; + pathNodes.Reverse(); } List pathCells = GeneratePath(rand, - startPath, endPath, cells, pathBorders, minWidth); + pathNodes, cells, pathBorders, minWidth, 0.3f, mirror, true); //place some enemy spawnpoints at random points in the path for (int i = 0; i <3 ; i++ ) @@ -228,22 +240,22 @@ namespace Subsurface pathCells.AddRange ( - GeneratePath(rand, start, end, cells, pathBorders, 0.0f, 0.8f) + GeneratePath(rand, new List { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror) ); } Debug.WriteLine("path: " + sw2.ElapsedMilliseconds + " ms"); sw2.Restart(); - for (int i = 0; i < 2; i++ ) - { - Vector2 tunnelStart = (i == 0) ? startPosition : endPosition; + //for (int i = 0; i < 2; i++ ) + //{ + // Vector2 tunnelStart = (i == 0) ? startPosition : endPosition; - pathCells.AddRange - ( - GeneratePath(rand, tunnelStart, new Vector2(tunnelStart.X, borders.Height), cells, pathBorders, minWidth, 0.1f) - ); - } + // pathCells.AddRange + // ( + // GeneratePath(rand, tunnelStart, new Vector2(tunnelStart.X, borders.Height), cells, pathBorders, minWidth, 0.1f, mirror) + // ); + //} cells = CleanCells(pathCells); @@ -276,14 +288,14 @@ namespace Subsurface int cellIndex = FindCellIndex(new Vector2(tunnelStart.X + minWidth * 0.5f * n, tunnelStart.Y), 3); foreach (GraphEdge ge in cells[cellIndex].edges) { - if (ge.point1.Y > cells[cellIndex].Center.Y) ge.point1.Y = borders.Height + 5000.0f; - if (ge.point2.Y > cells[cellIndex].Center.Y) ge.point2.Y = borders.Height + 5000.0f; + if (ge.point1.Y > cells[cellIndex].Center.Y) ge.point1.Y = borders.Height + shaftHeight; + if (ge.point2.Y > cells[cellIndex].Center.Y) ge.point2.Y = borders.Height + shaftHeight; } } } - startPosition.Y += 5000.0f; - endPosition.Y += 5000.0f; + startPosition.Y += shaftHeight; + endPosition.Y += shaftHeight; GeneratePolygons(cells, pathCells); @@ -309,10 +321,17 @@ namespace Subsurface basicEffect = new BasicEffect(Game1.CurrGraphicsDevice); basicEffect.VertexColorEnabled = true; + if (mirror) + { + Vector2 temp = startPosition; + startPosition = endPosition; + endPosition = temp; + } + Debug.WriteLine("Generated a map with " + sites.Count + " sites in " + sw.ElapsedMilliseconds + " ms"); } - private List GeneratePath(Random rand, Vector2 start, Vector2 end, List cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f) + private List GeneratePath(Random rand, List points, List cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f, bool mirror=false, bool placeWaypoints=false) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); @@ -323,11 +342,18 @@ namespace Subsurface List pathCells = new List(); - VoronoiCell currentCell = cells[FindCellIndex(start)]; + VoronoiCell[] targetCells = new VoronoiCell[points.Count]; + for (int i = 0; i 0) edgeIndex = allowedEdges.Count - edgeIndex; + edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]); + } } currentCell = currentCell.edges[edgeIndex].AdjacentCell(currentCell); - - pathCells.Add(currentCell); - } while (currentCell != endCell); + if (currentCell==targetCells[currentTargetIndex]) + { + currentTargetIndex += 1; + if (currentTargetIndex>=targetCells.Length) break; + } + + } while (currentCell != targetCells[targetCells.Length-1]); + + if (placeWaypoints) + { + WayPoint newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10)); + newWaypoint.MoveWithLevel = true; + + WayPoint prevWaypoint = newWaypoint; + + for (int i = 0; i < pathCells.Count; i++) + { + newWaypoint = new WayPoint(new Rectangle((int)pathCells[i].Center.X, (int)pathCells[i].Center.Y, 10, 10)); + newWaypoint.MoveWithLevel = true; + if (prevWaypoint != null) + { + prevWaypoint.linkedTo.Add(newWaypoint); + newWaypoint.linkedTo.Add(prevWaypoint); + } + prevWaypoint = newWaypoint; + } + + newWaypoint = new WayPoint(new Rectangle((int)pathCells[pathCells.Count - 1].Center.X, (int)(borders.Height + shaftHeight), 10, 10)); + newWaypoint.MoveWithLevel = true; + + if (prevWaypoint != null) + { + prevWaypoint.linkedTo.Add(newWaypoint); + newWaypoint.linkedTo.Add(prevWaypoint); + } + } Debug.WriteLine("genpath: " + sw2.ElapsedMilliseconds + " ms"); sw2.Restart(); @@ -537,8 +604,10 @@ namespace Subsurface for (int i = 0; i < triangles.Count; i++) { - Vertices bodyVertices = new Vertices(triangles[i]); + if (triangles[i][0].Y == triangles[i][1].Y && triangles[i][0].Y == triangles[i][2].Y) continue; + if (triangles[i][0].X == triangles[i][1].X && triangles[i][0].X == triangles[i][2].X) continue; + Vertices bodyVertices = new Vertices(triangles[i]); FixtureFactory.AttachPolygon(bodyVertices, 5.0f, edgeBody); } diff --git a/Subsurface/Map/Voronoi.cs b/Subsurface/Map/Levels/Voronoi.cs similarity index 100% rename from Subsurface/Map/Voronoi.cs rename to Subsurface/Map/Levels/Voronoi.cs diff --git a/Subsurface/Map/VoronoiElements.cs b/Subsurface/Map/Levels/VoronoiElements.cs similarity index 100% rename from Subsurface/Map/VoronoiElements.cs rename to Subsurface/Map/Levels/VoronoiElements.cs diff --git a/Subsurface/Map/Location.cs b/Subsurface/Map/Location.cs index 35705c869..dd6fa2cc2 100644 --- a/Subsurface/Map/Location.cs +++ b/Subsurface/Map/Location.cs @@ -6,12 +6,15 @@ using System.Text; namespace Subsurface { + class Location { string name; Vector2 mapPosition; + LocationType type; + public string Name { get { return name; } @@ -22,16 +25,23 @@ namespace Subsurface get { return mapPosition; } } - public Location(string name, Vector2 mapPosition) + public Location(Vector2 mapPosition) { - this.name = name; + this.name = RandomName(LocationType.Random()); this.mapPosition = mapPosition; } public static Location CreateRandom(Vector2 position) { - return new Location("Location " + Rand.Int(10000, false), position); + return new Location(position); + } + + private string RandomName(LocationType type) + { + string name = ToolBox.GetRandomLine("Content/Map/locationNames.txt"); + int nameFormatIndex = Rand.Int(type.NameFormats.Count); + return type.NameFormats[nameFormatIndex].Replace("[name]", name); } } } diff --git a/Subsurface/Map/LocationType.cs b/Subsurface/Map/LocationType.cs new file mode 100644 index 000000000..877cf1c29 --- /dev/null +++ b/Subsurface/Map/LocationType.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Xml.Linq; + +namespace Subsurface +{ + class LocationType + { + private static List list = new List(); + //sum of the commonness-values of each location type + private static int totalWeight; + + string name; + + private int commonness; + + List nameFormats; + + public string Name + { + get { return name; } + } + + public List NameFormats + { + get { return nameFormats; } + } + + private LocationType(XElement element) + { + name = element.Name.ToString(); + + commonness = ToolBox.GetAttributeInt(element, "commonness", 1); + totalWeight += commonness; + + nameFormats = new List(); + foreach (XAttribute nameFormat in element.Element("nameformats").Attributes()) + { + nameFormats.Add(nameFormat.Value.ToString()); + } + } + + public static LocationType Random() + { + Debug.Assert(list.Count > 0, "LocationType.list.Count == 0, you probably need to initialize LocationTypes"); + + int randInt = Rand.Int(totalWeight); + + foreach (LocationType type in list) + { + if (randInt < type.commonness) return type; + randInt -= type.commonness; + } + + return null; + } + + public static void Init(string file) + { + XDocument doc = ToolBox.TryLoadXml(file); + + if (doc==null) + { + return; + } + + foreach (XElement element in doc.Root.Elements()) + { + LocationType locationType = new LocationType(element); + list.Add(locationType); + } + } + } +} diff --git a/Subsurface/Map/Map.cs b/Subsurface/Map/Map.cs index 4ea6fa1c0..61c1314e5 100644 --- a/Subsurface/Map/Map.cs +++ b/Subsurface/Map/Map.cs @@ -98,9 +98,9 @@ namespace Subsurface newLocations[i] = Location.CreateRandom(position); locations.Add(newLocations[i]); - } - - connections.Add(new LocationConnection(newLocations[0], newLocations[1], Level.CreateRandom())); + } + int seed = (newLocations[0].GetHashCode() | newLocations[1].GetHashCode()); + connections.Add(new LocationConnection(newLocations[0], newLocations[1], Level.CreateRandom(seed.ToString()))); } @@ -157,9 +157,9 @@ namespace Subsurface float offsetAmount = 5.0f; - for (int n = 0; n DateTime.Now) return; - - //if (reconnectBox != null) - //{ - // ConnectToServer(serverIP); - // return; - //} - + if (Client.ConnectionStatus == NetConnectionStatus.Disconnected) { reconnectBox = new GUIMessageBox("CONNECTION LOST", "You have been disconnected from the server. Reconnecting...", new string[0]); @@ -472,7 +471,7 @@ namespace Subsurface.Networking public void SendRandomData() { NetOutgoingMessage msg = Client.CreateMessage(); - switch (Rand.Int(4)) + switch (Rand.Int(5)) { case 0: msg.Write((byte)PacketTypes.NetworkEvent); @@ -485,6 +484,12 @@ namespace Subsurface.Networking msg.Write(Rand.Int(MapEntity.mapEntityList.Count)); break; case 2: + msg.Write((byte)PacketTypes.NetworkEvent); + msg.Write((byte)NetworkEventType.UpdateComponent); + msg.Write((int)Item.itemList[Rand.Int(Item.itemList.Count)].ID); + msg.Write(Rand.Int(8)); + break; + case 3: msg.Write((byte)Enum.GetNames(typeof(PacketTypes)).Length); break; } diff --git a/Subsurface/Networking/GameServer.cs b/Subsurface/Networking/GameServer.cs index 08c6d9d84..79a244cc2 100644 --- a/Subsurface/Networking/GameServer.cs +++ b/Subsurface/Networking/GameServer.cs @@ -58,7 +58,17 @@ namespace Subsurface.Networking // If "inc" is null -> ReadMessage returned null -> Its null, so dont do this :) NetIncomingMessage inc = Server.ReadMessage(); - if (inc != null) ReadMessage(inc); + if (inc != null) + { + try + { + ReadMessage(inc); + } + catch + { + + } + } // if 30ms has passed if (updateTimer < DateTime.Now) diff --git a/Subsurface/Rand.cs b/Subsurface/Rand.cs index 018dd4473..eefd649bc 100644 --- a/Subsurface/Rand.cs +++ b/Subsurface/Rand.cs @@ -56,7 +56,7 @@ namespace Subsurface { Vector2 randomVector = new Vector2(Range(-1.0f, 1.0f, local), Range(-1.0f, 1.0f, local)); - if (randomVector == Vector2.Zero) return Vector2.One * length; + if (randomVector == Vector2.Zero) return new Vector2(0.0f, length); return Vector2.Normalize(randomVector) * length; } diff --git a/Subsurface/Screens/EditCharacterScreen.cs b/Subsurface/Screens/EditCharacterScreen.cs index a71ec647f..bea7865ef 100644 --- a/Subsurface/Screens/EditCharacterScreen.cs +++ b/Subsurface/Screens/EditCharacterScreen.cs @@ -200,7 +200,7 @@ namespace Subsurface if (Vector2.Distance(PlayerInput.MousePosition, limbBodyPos)<5.0f && PlayerInput.LeftButtonDown()) { - limb.sprite.Origin -= PlayerInput.MouseSpeed; + limb.sprite.Origin += PlayerInput.MouseSpeed; } } @@ -259,17 +259,30 @@ namespace Subsurface if (joint.BodyA == limb.body.FarseerBody) { - jointPos = limbBodyPos + ConvertUnits.ToDisplayUnits(joint.LocalAnchorA); + jointPos = ConvertUnits.ToDisplayUnits(joint.LocalAnchorA); } else if (joint.BodyB == limb.body.FarseerBody) { - jointPos = limbBodyPos + ConvertUnits.ToDisplayUnits(joint.LocalAnchorB); + jointPos = ConvertUnits.ToDisplayUnits(joint.LocalAnchorB); } else { continue; } + + jointPos.Y = -jointPos.Y; + jointPos += limbBodyPos; + if (joint.BodyA == limb.body.FarseerBody) + { + float a1 = joint.UpperLimit - MathHelper.PiOver2; + float a2 = joint.LowerLimit - MathHelper.PiOver2; + float a3 =( a1+a2)/2.0f; + GUI.DrawLine(spriteBatch, jointPos, jointPos + new Vector2((float)Math.Cos(a1), -(float)Math.Sin(a1)) * 30.0f, Color.Green); + GUI.DrawLine(spriteBatch, jointPos, jointPos + new Vector2((float)Math.Cos(a2), -(float)Math.Sin(a2)) * 30.0f, Color.DarkGreen); + + GUI.DrawLine(spriteBatch, jointPos, jointPos + new Vector2((float)Math.Cos(a3), -(float)Math.Sin(a3)) * 30.0f, Color.LightGray); + } GUI.DrawRectangle(spriteBatch, jointPos, new Vector2(5.0f, 5.0f), Color.Red, true); if (Vector2.Distance(PlayerInput.MousePosition, jointPos) < 6.0f) @@ -277,13 +290,15 @@ namespace Subsurface GUI.DrawRectangle(spriteBatch, jointPos - new Vector2(3.0f, 3.0f), new Vector2(11.0f, 11.0f), Color.Red, false); if (PlayerInput.LeftButtonDown()) { + Vector2 speed = ConvertUnits.ToSimUnits(PlayerInput.MouseSpeed); + speed.Y = -speed.Y; if (joint.BodyA == limb.body.FarseerBody) { - joint.LocalAnchorA += ConvertUnits.ToSimUnits(PlayerInput.MouseSpeed); + joint.LocalAnchorA += speed; } else { - joint.LocalAnchorB += ConvertUnits.ToSimUnits(PlayerInput.MouseSpeed); + joint.LocalAnchorB += speed; } } } diff --git a/Subsurface/Screens/LobbyScreen.cs b/Subsurface/Screens/LobbyScreen.cs index 4f4b40146..0bd660047 100644 --- a/Subsurface/Screens/LobbyScreen.cs +++ b/Subsurface/Screens/LobbyScreen.cs @@ -23,10 +23,7 @@ namespace Subsurface SinglePlayerMode gameMode; - Body previewPlatform; - Hull previewHull; - - Character previewCharacter; + GUIFrame previewFrame; Level selectedLevel; @@ -112,57 +109,57 @@ namespace Subsurface { base.Deselect(); - if (previewPlatform != null) - { - Game1.World.RemoveBody(previewPlatform); - previewPlatform = null; - } + //if (previewPlatform != null) + //{ + // Game1.World.RemoveBody(previewPlatform); + // previewPlatform = null; + //} - if (previewHull != null) - { - previewHull.Remove(); - previewHull = null; - } + //if (previewHull != null) + //{ + // previewHull.Remove(); + // previewHull = null; + //} - if (previewCharacter != null) - { - previewCharacter.Remove(); - previewCharacter = null; - } + //if (previewCharacter != null) + //{ + // previewCharacter.Remove(); + // previewCharacter = null; + //} } - private void CreatePreviewCharacter() - { - if (previewCharacter != null) previewCharacter.Remove(); + //private void CreatePreviewCharacter() + //{ + // if (previewCharacter != null) previewCharacter.Remove(); - Vector2 pos = new Vector2(1000.0f, 1000.0f); + // Vector2 pos = new Vector2(1000.0f, 1000.0f); - previewCharacter = new Character(characterList.SelectedData as CharacterInfo, pos); + // previewCharacter = new Character(characterList.SelectedData as CharacterInfo, pos); - previewCharacter.AnimController.IsStanding = true; + // previewCharacter.AnimController.IsStanding = true; - if (previewPlatform == null) - { - Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f); - platform.SetTransform(new Vector2(pos.X, pos.Y - 3.5f), 0.0f); - platform.IsStatic = true; - } + // if (previewPlatform == null) + // { + // Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f); + // platform.SetTransform(new Vector2(pos.X, pos.Y - 3.5f), 0.0f); + // platform.IsStatic = true; + // } - if (previewHull == null) - { - pos = ConvertUnits.ToDisplayUnits(pos); - previewHull = new Hull(new Rectangle((int)pos.X - 100, (int)pos.Y + 100, 200, 500)); - } + // if (previewHull == null) + // { + // pos = ConvertUnits.ToDisplayUnits(pos); + // previewHull = new Hull(new Rectangle((int)pos.X - 100, (int)pos.Y + 100, 200, 500)); + // } - Physics.Alpha = 1.0f; + // Physics.Alpha = 1.0f; - for (int i = 0; i < 500; i++) - { - previewCharacter.AnimController.Update((float)Physics.step); - previewCharacter.AnimController.UpdateAnim((float)Physics.step); - Game1.World.Step((float)Physics.step); - } - } + // for (int i = 0; i < 500; i++) + // { + // previewCharacter.AnimController.Update((float)Physics.step); + // previewCharacter.AnimController.UpdateAnim((float)Physics.step); + // Game1.World.Step((float)Physics.step); + // } + //} public void SelectLocation(Location location, LocationConnection connection) { @@ -258,22 +255,34 @@ namespace Subsurface if (characterList.SelectedData != null && selectedRightPanel == (int)PanelTab.Crew) { - if (previewCharacter != null) + if (previewFrame==null || previewFrame.UserData != characterList.UserData) { - Vector2 position = new Vector2(characterList.Rect.Right + 100, characterList.Rect.Y + 25.0f); + CharacterInfo previewCharacter = (characterList.SelectedData as CharacterInfo); - Vector2 pos = previewCharacter.Position; - pos.Y = -pos.Y; - Matrix transform = Matrix.CreateTranslation(new Vector3(-pos + position, 0.0f)); + GUIFrame frameRoot = new GUIFrame(new Rectangle(350, 30, 300, 500), + new Color(0.0f, 0.0f, 0.0f, 0.8f), + Alignment.Top, GUI.style, rightPanel[selectedRightPanel]); + frameRoot.Padding = new Vector4(20.0f,20.0f,20.0f,20.0f); - spriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, transform); - previewCharacter.Draw(spriteBatch); - spriteBatch.End(); - } - else - { - CreatePreviewCharacter(); + previewFrame = previewCharacter.CreateInfoFrame(frameRoot); + previewFrame.UserData = previewCharacter; } + //if (previewCharacter != null) + //{ + // Vector2 position = new Vector2(characterList.Rect.Right + 100, characterList.Rect.Y + 25.0f); + + // Vector2 pos = previewCharacter.Position; + // pos.Y = -pos.Y; + // Matrix transform = Matrix.CreateTranslation(new Vector3(-pos + position, 0.0f)); + + // spriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, transform); + // previewCharacter.Draw(spriteBatch); + // spriteBatch.End(); + //} + //else + //{ + // CreatePreviewCharacter(); + //} } } @@ -331,7 +340,7 @@ namespace Subsurface if (Character.Controlled != null && characterInfo == Character.Controlled.Info) return false; - CreatePreviewCharacter(); + //CreatePreviewCharacter(); return false; } diff --git a/Subsurface/Screens/MainMenu.cs b/Subsurface/Screens/MainMenu.cs index 9e4ea13a3..dccb87f5f 100644 --- a/Subsurface/Screens/MainMenu.cs +++ b/Subsurface/Screens/MainMenu.cs @@ -15,8 +15,7 @@ namespace Subsurface private GUIListBox saveList; - private GUITextBox nameBox; - private GUITextBox ipBox; + private GUITextBox nameBox, ipBox; private Game1 game; @@ -61,8 +60,8 @@ namespace Subsurface new GUITextBlock(new Rectangle(0, 0, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]); - new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", null, null, Alignment.Left, GUI.style, menuTabs[(int)Tabs.NewGame]); - mapList = new GUIListBox(new Rectangle(0, 60, 200, 400), GUI.style, menuTabs[(int)Tabs.NewGame]); + new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", null, null, Alignment.Left, GUI.style, menuTabs[(int)Tabs.NewGame]); + mapList = new GUIListBox(new Rectangle(0, 60, 200, 360), GUI.style, menuTabs[(int)Tabs.NewGame]); foreach (Submarine map in Submarine.SavedSubmarines) { @@ -77,7 +76,7 @@ namespace Subsurface if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]); - button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.Right | Alignment.Bottom, GUI.style, menuTabs[(int)Tabs.NewGame]); + button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.BottomRight, GUI.style, menuTabs[(int)Tabs.NewGame]); button.OnClicked = StartGame; //---------------------------------------------------------------------- @@ -137,6 +136,13 @@ namespace Subsurface GUIButton joinButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Join", Alignment.BottomCenter, GUI.style, menuTabs[(int)Tabs.JoinServer]); joinButton.OnClicked = JoinServer; + //---------------------------------------------------------------------- + + for (int i = 1; i < 4; i++ ) + { + button = new GUIButton(new Rectangle(0, 0, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]); + button.OnClicked = PreviousTab; + } this.game = game; @@ -193,6 +199,13 @@ namespace Subsurface return true; } + private bool PreviousTab(GUIButton button, object obj) + { + selectedTab = (int)Tabs.Main; + + return true; + } + private bool LoadGame(GUIButton button, object obj) { diff --git a/Subsurface/Screens/NetLobbyScreen.cs b/Subsurface/Screens/NetLobbyScreen.cs index d009d6be7..9d68dfe97 100644 --- a/Subsurface/Screens/NetLobbyScreen.cs +++ b/Subsurface/Screens/NetLobbyScreen.cs @@ -21,9 +21,9 @@ namespace Subsurface private GUIListBox jobList; - private GUITextBox textBox; + private GUITextBox textBox, seedBox; - private GUITextBox seedBox; + GUIFrame previewPlayer; private GUIScrollBar durationBar; @@ -31,8 +31,8 @@ namespace Subsurface private float camAngle; - private Body previewPlatform; - private Hull previewHull; + //private Body previewPlatform; + //private Hull previewHull; public bool IsServer; @@ -136,17 +136,17 @@ namespace Subsurface { textBox.Deselect(); - if (previewPlatform!=null) - { - Game1.World.RemoveBody(previewPlatform); - previewPlatform = null; - } + //if (previewPlatform!=null) + //{ + // Game1.World.RemoveBody(previewPlatform); + // previewPlatform = null; + //} - if (previewHull!=null) - { - previewHull.Remove(); - previewHull = null; - } + //if (previewHull!=null) + //{ + // previewHull.Remove(); + // previewHull = null; + //} } public override void Select() @@ -159,9 +159,6 @@ namespace Subsurface textBox.Select(); - //int oldMapIndex = 0; - //if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex; - new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", GUI.style, infoFrame); subList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, GUI.style, infoFrame); subList.OnSelected = SelectMap; @@ -238,30 +235,28 @@ namespace Subsurface { int x = playerFrame.Rect.Width / 2; - new GUITextBlock(new Rectangle(x, 0, 200, 30), "Name: ", GUI.style, playerFrame); - GUITextBox playerName = new GUITextBox(new Rectangle(x, 30, 0, 20), Alignment.TopLeft, GUI.style, playerFrame); playerName.Text = Game1.Client.CharacterInfo.Name; playerName.OnEnter += ChangeCharacterName; - new GUITextBlock(new Rectangle(x,70,200, 30), "Gender: ", GUI.style, playerFrame); + new GUITextBlock(new Rectangle(x, 70, 200, 30), "Gender: ", GUI.style, playerFrame); GUIButton maleButton = new GUIButton(new Rectangle(x, 100, 70, 20), "Male", Alignment.TopLeft, GUI.style,playerFrame); maleButton.UserData = Gender.Male; maleButton.OnClicked += SwitchGender; - GUIButton femaleButton = new GUIButton(new Rectangle(x+150, 100, 70, 20), "Female", + GUIButton femaleButton = new GUIButton(new Rectangle(x+90, 100, 70, 20), "Female", Alignment.TopLeft, GUI.style, playerFrame); femaleButton.UserData = Gender.Female; femaleButton.OnClicked += SwitchGender; - new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.style, playerFrame); + new GUITextBlock(new Rectangle(x, 150, 200, 30), "Job preferences:", GUI.style, playerFrame); - jobList = new GUIListBox(new Rectangle(0, 180, 200, 0), GUI.style, playerFrame); + jobList = new GUIListBox(new Rectangle(x, 180, 200, 0), GUI.style, playerFrame); foreach (JobPrefab job in JobPrefab.List) { @@ -279,6 +274,8 @@ namespace Subsurface UpdateJobPreferences(jobList); + UpdatePreviewPlayer(Game1.Client.CharacterInfo); + } base.Select(); @@ -358,30 +355,32 @@ namespace Subsurface menu.Draw(spriteBatch); + if (previewPlayer!=null) previewPlayer.Draw(spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, null); spriteBatch.End(); - if (Game1.Client != null) - { - if (Game1.Client.Character != null) - { - Vector2 position = new Vector2(playerFrame.Rect.X + playerFrame.Rect.Width * 0.25f, playerFrame.Rect.Y + 25.0f); + //if (Game1.Client != null) + //{ + // if (Game1.Client.Character != null) + // { + // Vector2 position = new Vector2(playerFrame.Rect.X + playerFrame.Rect.Width * 0.25f, playerFrame.Rect.Y + 25.0f); - Vector2 pos = Game1.Client.Character.Position; - pos.Y = -pos.Y; - Matrix transform = Matrix.CreateTranslation(new Vector3(-pos + position, 0.0f)); + // Vector2 pos = Game1.Client.Character.Position; + // pos.Y = -pos.Y; + // Matrix transform = Matrix.CreateTranslation(new Vector3(-pos + position, 0.0f)); - spriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, transform); - Game1.Client.Character.Draw(spriteBatch); - spriteBatch.End(); - } - else - { - CreatePreviewCharacter(); - } - } + // spriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, transform); + // Game1.Client.Character.Draw(spriteBatch); + // spriteBatch.End(); + // } + // else + // { + // CreatePreviewCharacter(); + // } + //} } @@ -412,43 +411,15 @@ namespace Subsurface return true; } - private void CreatePreviewCharacter() + private void UpdatePreviewPlayer(CharacterInfo characterInfo) { - if (Game1.Client.Character != null) Game1.Client.Character.Remove(); + previewPlayer = new GUIFrame( + new Rectangle(playerFrame.Rect.X + 20, playerFrame.Rect.Y + 20, 230, 300), + new Color(0.0f, 0.0f, 0.0f, 0.8f), GUI.style); + previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); + characterInfo.CreateInfoFrame(previewPlayer); - Vector2 pos = new Vector2(1000.0f, 1000.0f); - - Character character = new Character(Game1.Client.CharacterInfo, pos); - character.ID = int.MaxValue; - - Game1.Client.Character = character; - - character.AnimController.IsStanding = true; - - if (previewPlatform == null) - { - Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f); - platform.SetTransform(new Vector2(pos.X, pos.Y - 2.5f), 0.0f); - platform.IsStatic = true; - } - - if (previewHull == null) - { - pos = ConvertUnits.ToDisplayUnits(pos); - previewHull = new Hull(new Rectangle((int)pos.X - 100, (int)pos.Y + 100, 200, 200)); - previewHull.ID = int.MaxValue - 2; - } - - Physics.Alpha = 1.0f; - - for (int i = 0; i < 500; i++) - { - character.AnimController.Update((float)Physics.step); - character.AnimController.UpdateAnim((float)Physics.step); - Game1.World.Step((float)Physics.step); - } - - Game1.Client.SendCharacterData(); + previewPlayer.UserData = characterInfo; } private bool SwitchGender(GUIButton button, object obj) @@ -458,7 +429,8 @@ namespace Subsurface Gender gender = (Gender)obj; Game1.Client.CharacterInfo.Gender = gender; Game1.Client.SendCharacterData(); - CreatePreviewCharacter(); + UpdatePreviewPlayer(Game1.Client.CharacterInfo); + //CreatePreviewCharacter(); } catch { @@ -491,6 +463,7 @@ namespace Subsurface Game1.Client.SendCharacterData(); textBox.Text = newName; + textBox.Selected = false; return true; } @@ -502,7 +475,7 @@ namespace Subsurface int index = jobList.children.IndexOf(jobText); int newIndex = index + (int)obj; - if (newIndex<0 || newIndex>jobList.children.Count-1) return false; + if (newIndex < 0 || newIndex > jobList.children.Count - 1) return false; GUIComponent temp = jobList.children[newIndex]; jobList.children[newIndex] = jobText; @@ -516,12 +489,12 @@ namespace Subsurface private void UpdateJobPreferences(GUIListBox listBox) { listBox.Deselect(); - for (int i = 1; i jp.Name == jobName); + client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName); + textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")"); + + if (clientID == Game1.Client.ID) + { + Game1.Client.CharacterInfo.Job = new Job(client.assignedJob); + Game1.Client.CharacterInfo.Name = client.name; + UpdatePreviewPlayer(Game1.Client.CharacterInfo); + } } } diff --git a/Subsurface/StyleCop.Cache b/Subsurface/StyleCop.Cache index b1a473fae..85b124af3 100644 --- a/Subsurface/StyleCop.Cache +++ b/Subsurface/StyleCop.Cache @@ -3671,256 +3671,6 @@ - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.07.02 08:53:08.295 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: dictionary. - 10 - False - - - The variable name 'aiTarget' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes. - 14 - False - - - Variable names and private field names must start with a lower-case letter: IDfound. - 47 - False - - - Variable names and private field names must start with a lower-case letter: ID. - 64 - False - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.07.02 21:17:30.467 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.28 00:13:32.575 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: isHorizontal. - 13 - False - - - The line contains unnecessary parenthesis. - 57 - 1344 - 1369 - 57 - 28 - 57 - 53 - False - - - The line contains unnecessary parenthesis. - 93 - 2169 - 2334 - 93 - 20 - 94 - 122 - False - - - The line contains unnecessary parenthesis. - 287 - 10017 - 10030 - 287 - 26 - 287 - 39 - False - - - The line contains unnecessary parenthesis. - 318 - 11811 - 11824 - 318 - 87 - 318 - 100 - False - - - The line contains unnecessary parenthesis. - 337 - 12834 - 12847 - 337 - 87 - 337 - 100 - False - - - The line contains unnecessary parenthesis. - 457 - 18162 - 18175 - 457 - 26 - 457 - 39 - False - - - The line contains unnecessary parenthesis. - 528 - 20654 - 20690 - 528 - 33 - 528 - 69 - False - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.27 14:19:50.999 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: hullList. - 15 - False - - - Public and internal fields must start with an upper-case letter: renderer. - 19 - False - - - Public and internal fields must start with an upper-case letter: properties. - 35 - False - - - Readonly variables that are not declared private must start with an upper-case letter: properties. - 35 - False - - - The line contains unnecessary parenthesis. - 99 - 2691 - 2716 - 99 - 26 - 99 - 51 - False - - - The line contains unnecessary parenthesis. - 128 - 3413 - 3445 - 128 - 29 - 128 - 61 - False - - - The line contains unnecessary parenthesis. - 153 - 4115 - 4282 - 153 - 20 - 154 - 124 - False - - - 2014.04.01 10:18:24.000 @@ -4004,170 +3754,6 @@ - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.07 19:30:43.145 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: viewPos. - 8 - False - - - Public and internal fields must start with an upper-case letter: fowEnabled. - 10 - False - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.26 20:27:37.513 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.30 21:39:36.517 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.23 17:50:40.207 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: mapEntityList. - 15 - False - - - Public and internal fields must start with an upper-case letter: linkedTo. - 30 - False - - - property names begin with an upper-case letter: sprite. - 48 - False - - - The line contains unnecessary parenthesis. - 120 - 3216 - 3255 - 120 - 20 - 120 - 59 - False - - - - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.07.02 21:12:45.629 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: list. - 12 - False - - - Public and internal fields must start with an upper-case letter: sprite. - 18 - False - - - 2014.04.01 10:18:24.000 @@ -4191,126 +3777,6 @@ - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.07.02 21:15:28.302 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: rect. - 20 - False - - - Public and internal fields must start with an upper-case letter: damage. - 21 - False - - - Public and internal fields must start with an upper-case letter: gap. - 22 - False - - - Public and internal fields must start with an upper-case letter: isHighLighted. - 24 - False - - - Public and internal fields must start with an upper-case letter: wallList. - 42 - False - - - property names begin with an upper-case letter: sprite. - 56 - False - - - The line contains unnecessary parenthesis. - 140 - 3498 - 3521 - 140 - 28 - 140 - 51 - False - - - The line contains unnecessary parenthesis. - 159 - 4271 - 4289 - 159 - 47 - 159 - 65 - False - - - The line contains unnecessary parenthesis. - 265 - 8282 - 8296 - 265 - 27 - 265 - 41 - False - - - The line contains unnecessary parenthesis. - 275 - 8843 - 8871 - 275 - 35 - 275 - 63 - False - - - The line contains unnecessary parenthesis. - 341 - 11249 - 11297 - 341 - 20 - 341 - 68 - False - - - The line contains unnecessary parenthesis. - 357 - 11676 - 11689 - 357 - 25 - 357 - 38 - False - - - 2014.04.01 10:18:24.000 @@ -4334,71 +3800,6 @@ - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.07.02 21:12:45.619 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - Public and internal fields must start with an upper-case letter: gridSize. - 31 - False - - - Readonly variables that are not declared private must start with an upper-case letter: gridSize. - 31 - False - - - Static readonly fields must start with an upper-case letter: gridSize. - 31 - False - - - Variable names and private field names must start with a lower-case letter: SaveFolder. - 36 - False - - - Variable names and private field names must start with a lower-case letter: Orin. - 193 - False - - - The line contains unnecessary parenthesis. - 280 - 8681 - 8794 - 280 - 20 - 281 - 66 - False - - - Field names must not start with an underscore. - 716 - False - - - 2014.04.01 10:18:24.000 @@ -4438,41 +3839,6 @@ - - - 2014.04.01 10:18:24.000 - 2015.07.02 21:22:42.115 - 2015.06.23 17:50:40.057 - 2014.04.01 10:18:24.000 - 2014.04.01 10:18:24.000 - -1945363787 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - 2014.04.01 10:18:24.000 - 0 - - - - The line contains unnecessary parenthesis. - 36 - 927 - 938 - 36 - 25 - 36 - 36 - False - - - 2014.04.01 10:18:24.000 @@ -6460,11 +5826,50 @@ DEBUG;TRACE;WINDOWS - + 2014.04.01 10:18:24.000 2015.07.02 21:22:42.115 - 2015.07.07 16:37:45.662 + 2015.07.09 17:27:35.264 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + The variable name 'aiTarget' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes. + 14 + False + + + Variable names and private field names must start with a lower-case letter: IDfound. + 51 + False + + + Variable names and private field names must start with a lower-case letter: ID. + 68 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.02 21:43:53.299 2014.04.01 10:18:24.000 2014.04.01 10:18:24.000 -1945363787 @@ -6483,4 +5888,585 @@ + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.02 21:43:53.335 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Public and internal fields must start with an upper-case letter: isHorizontal. + 13 + False + + + The line contains unnecessary parenthesis. + 57 + 1344 + 1369 + 57 + 28 + 57 + 53 + False + + + The line contains unnecessary parenthesis. + 93 + 2169 + 2334 + 93 + 20 + 94 + 122 + False + + + The line contains unnecessary parenthesis. + 287 + 9889 + 9902 + 287 + 26 + 287 + 39 + False + + + The line contains unnecessary parenthesis. + 318 + 11683 + 11696 + 318 + 87 + 318 + 100 + False + + + The line contains unnecessary parenthesis. + 337 + 12706 + 12719 + 337 + 87 + 337 + 100 + False + + + The line contains unnecessary parenthesis. + 457 + 18034 + 18047 + 457 + 26 + 457 + 39 + False + + + The line contains unnecessary parenthesis. + 528 + 20526 + 20562 + 528 + 33 + 528 + 69 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.09 18:42:41.485 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Public and internal fields must start with an upper-case letter: hullList. + 15 + False + + + Public and internal fields must start with an upper-case letter: renderer. + 19 + False + + + Public and internal fields must start with an upper-case letter: properties. + 33 + False + + + Readonly variables that are not declared private must start with an upper-case letter: properties. + 33 + False + + + The line contains unnecessary parenthesis. + 97 + 2658 + 2683 + 97 + 26 + 97 + 51 + False + + + The line contains unnecessary parenthesis. + 126 + 3369 + 3401 + 126 + 29 + 126 + 61 + False + + + The line contains unnecessary parenthesis. + 151 + 4071 + 4238 + 151 + 20 + 152 + 124 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.13 15:55:30.528 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.02 21:25:33.092 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.13 20:49:30.880 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.13 20:37:42.861 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + The line contains unnecessary parenthesis. + 147 + 5278 + 5326 + 147 + 40 + 147 + 88 + False + + + The variable name 'xCell' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes. + 265 + False + + + The variable name 'yCell' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes. + 266 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.07 15:18:16.892 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Public and internal fields must start with an upper-case letter: mapEntityList. + 15 + False + + + Public and internal fields must start with an upper-case letter: linkedTo. + 30 + False + + + property names begin with an upper-case letter: sprite. + 54 + False + + + The line contains unnecessary parenthesis. + 126 + 3311 + 3350 + 126 + 20 + 126 + 59 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.02 21:43:50.356 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Public and internal fields must start with an upper-case letter: list. + 12 + False + + + Public and internal fields must start with an upper-case letter: sprite. + 18 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.02 21:24:11.044 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Public and internal fields must start with an upper-case letter: rect. + 20 + False + + + Public and internal fields must start with an upper-case letter: damage. + 21 + False + + + Public and internal fields must start with an upper-case letter: gap. + 22 + False + + + Public and internal fields must start with an upper-case letter: isHighLighted. + 24 + False + + + Public and internal fields must start with an upper-case letter: wallList. + 42 + False + + + property names begin with an upper-case letter: sprite. + 56 + False + + + The line contains unnecessary parenthesis. + 140 + 3498 + 3521 + 140 + 28 + 140 + 51 + False + + + The line contains unnecessary parenthesis. + 159 + 4271 + 4289 + 159 + 47 + 159 + 65 + False + + + The line contains unnecessary parenthesis. + 265 + 8282 + 8296 + 265 + 27 + 265 + 41 + False + + + The line contains unnecessary parenthesis. + 275 + 8843 + 8871 + 275 + 35 + 275 + 63 + False + + + The line contains unnecessary parenthesis. + 341 + 11249 + 11297 + 341 + 20 + 341 + 68 + False + + + The line contains unnecessary parenthesis. + 357 + 11676 + 11689 + 357 + 25 + 357 + 38 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.12 18:28:30.334 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + Variable names and private field names must start with a lower-case letter: SaveFolder. + 37 + False + + + Variable names and private field names must start with a lower-case letter: Orin. + 208 + False + + + The line contains unnecessary parenthesis. + 295 + 9027 + 9140 + 295 + 20 + 296 + 66 + False + + + + + + 2014.04.01 10:18:24.000 + 2015.07.02 21:22:42.115 + 2015.07.08 18:18:15.091 + 2014.04.01 10:18:24.000 + 2014.04.01 10:18:24.000 + -1945363787 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + 2014.04.01 10:18:24.000 + 0 + + + + The line contains unnecessary parenthesis. + 64 + 1808 + 1819 + 64 + 25 + 64 + 36 + False + + + \ No newline at end of file diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index 8f447551c..71f9a4b30 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -53,6 +53,7 @@ + @@ -64,6 +65,7 @@ + @@ -130,14 +132,14 @@ - + - - + + @@ -269,6 +271,13 @@ PreserveNewest Designer + + PreserveNewest + + + Designer + PreserveNewest + PreserveNewest @@ -328,6 +337,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -379,9 +394,15 @@ PreserveNewest + + PreserveNewest + PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/ToolBox.cs b/Subsurface/ToolBox.cs index 637f19f90..5c795845e 100644 --- a/Subsurface/ToolBox.cs +++ b/Subsurface/ToolBox.cs @@ -193,8 +193,8 @@ namespace Subsurface return vector; } - float.TryParse(components[0], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.X); - float.TryParse(components[1], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.Y); + float.TryParse(components[0], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.X); + float.TryParse(components[1], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Y); return vector; } diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 323685529..d0c3c4db5 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ