diff --git a/Subsurface/Content/Characters/Human/human.xml b/Subsurface/Content/Characters/Human/human.xml index 9bea35a49..435f4017e 100644 --- a/Subsurface/Content/Characters/Human/human.xml +++ b/Subsurface/Content/Characters/Human/human.xml @@ -7,14 +7,14 @@ stepsize="42.0, 12.0"> - + - + - + diff --git a/Subsurface/Content/Items/Button/button.xml b/Subsurface/Content/Items/Button/button.xml index 10d77ca8b..dd741add1 100644 --- a/Subsurface/Content/Items/Button/button.xml +++ b/Subsurface/Content/Items/Button/button.xml @@ -6,8 +6,10 @@ price="10"> - - + + + + @@ -15,5 +17,10 @@ + + + + \ No newline at end of file diff --git a/Subsurface/Content/Items/Clothes/captainLegs.png b/Subsurface/Content/Items/Clothes/captainLegs.png new file mode 100644 index 000000000..6b327f6b3 Binary files /dev/null and b/Subsurface/Content/Items/Clothes/captainLegs.png differ diff --git a/Subsurface/Content/Items/Clothes/captainTorso.png b/Subsurface/Content/Items/Clothes/captainTorso.png new file mode 100644 index 000000000..6174ec887 Binary files /dev/null and b/Subsurface/Content/Items/Clothes/captainTorso.png differ diff --git a/Subsurface/Content/Items/Clothes/captainhat.png b/Subsurface/Content/Items/Clothes/captainhat.png index 732da7578..c8832cd6b 100644 Binary files a/Subsurface/Content/Items/Clothes/captainhat.png and b/Subsurface/Content/Items/Clothes/captainhat.png differ diff --git a/Subsurface/Content/Items/Clothes/clothes.xml b/Subsurface/Content/Items/Clothes/clothes.xml index 0dfb9fcf3..edeadde3a 100644 --- a/Subsurface/Content/Items/Clothes/clothes.xml +++ b/Subsurface/Content/Items/Clothes/clothes.xml @@ -1,14 +1,54 @@  + pickdistance="150" + tags="smallitem"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index cf58c3f18..61308838c 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -6,7 +6,7 @@ pickdistance="150" price="50"> - + @@ -46,7 +46,7 @@ - + diff --git a/Subsurface/Content/Items/Tools/plasmaCutter.ogg b/Subsurface/Content/Items/Tools/plasmaCutter.ogg new file mode 100644 index 000000000..c7d38dc98 Binary files /dev/null and b/Subsurface/Content/Items/Tools/plasmaCutter.ogg differ diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index 1798c418c..b3dc02f3c 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -15,10 +15,12 @@ - + + + @@ -34,6 +36,10 @@ + + + + @@ -56,11 +62,13 @@ - + + + @@ -68,6 +76,10 @@ + + + + diff --git a/Subsurface/Content/Items/Tools/weldingTool.ogg b/Subsurface/Content/Items/Tools/weldingTool.ogg new file mode 100644 index 000000000..4e8d70ba1 Binary files /dev/null and b/Subsurface/Content/Items/Tools/weldingTool.ogg differ diff --git a/Subsurface/Content/Items/Weapons/explosives.xml b/Subsurface/Content/Items/Weapons/explosives.xml index d9ff27283..498457a59 100644 --- a/Subsurface/Content/Items/Weapons/explosives.xml +++ b/Subsurface/Content/Items/Weapons/explosives.xml @@ -27,14 +27,10 @@ - + - - - - diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml index 2aad02389..4284d886e 100644 --- a/Subsurface/Content/Items/Weapons/railgun.xml +++ b/Subsurface/Content/Items/Weapons/railgun.xml @@ -61,11 +61,11 @@ name="Railgun Shell" pickdistance="200"> - + - + - + diff --git a/Subsurface/Content/Items/Weapons/railgunshell.png b/Subsurface/Content/Items/Weapons/railgunshell.png index 23e4d5e7d..f03df6d36 100644 Binary files a/Subsurface/Content/Items/Weapons/railgunshell.png and b/Subsurface/Content/Items/Weapons/railgunshell.png differ diff --git a/Subsurface/Content/Jobs.xml b/Subsurface/Content/Jobs.xml index 0c4a58b35..a9fc829e4 100644 --- a/Subsurface/Content/Jobs.xml +++ b/Subsurface/Content/Jobs.xml @@ -2,6 +2,10 @@ + + + + diff --git a/Subsurface/Content/Map/StructurePrefabs.xml b/Subsurface/Content/Map/StructurePrefabs.xml index 0ed5aeb9e..fd28129fd 100644 --- a/Subsurface/Content/Map/StructurePrefabs.xml +++ b/Subsurface/Content/Map/StructurePrefabs.xml @@ -5,6 +5,40 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -32,16 +66,6 @@ - - - - - - diff --git a/Subsurface/Content/Map/testroom.png b/Subsurface/Content/Map/testroom.png index 945cbe7d9..cb88347e0 100644 Binary files a/Subsurface/Content/Map/testroom.png and b/Subsurface/Content/Map/testroom.png differ diff --git a/Subsurface/Content/Particles/prefabs.xml b/Subsurface/Content/Particles/ParticlePrefabs.xml similarity index 60% rename from Subsurface/Content/Particles/prefabs.xml rename to Subsurface/Content/Particles/ParticlePrefabs.xml index a977a81bb..578505a2c 100644 --- a/Subsurface/Content/Particles/prefabs.xml +++ b/Subsurface/Content/Particles/ParticlePrefabs.xml @@ -1,84 +1,109 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Subsurface/Content/Particles/flames.png b/Subsurface/Content/Particles/flames.png new file mode 100644 index 000000000..7198b11ef Binary files /dev/null and b/Subsurface/Content/Particles/flames.png differ diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 86fbf8737..39f86d427 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -418,10 +418,12 @@ namespace Subsurface public void GiveJobItems(WayPoint spawnPoint) { - if (Info == null || Info.Job == null) return; - - foreach (string itemName in Info.Job.SpawnItemNames) + if (info == null || info.Job == null) return; + + for (int i = 0; i < info.Job.SpawnItemNames.Count; i++ ) { + string itemName = info.Job.SpawnItemNames[i]; + ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab; if (itemPrefab == null) { @@ -431,14 +433,18 @@ namespace Subsurface Item item = new Item(itemPrefab, Position); inventory.TryPutItem(item, item.AllowedSlots, false); - - if (item.Prefab.Name == "ID Card" && spawnPoint!=null) + + if (info.Job.EquipSpawnItem[i]) + { + item.Equip(this); + } + + if (item.Prefab.Name == "ID Card" && spawnPoint != null) { foreach (string s in spawnPoint.IdCardTags) { - item.AddTag(s); - } + } } } } @@ -476,8 +482,7 @@ namespace Subsurface if (i == 1 && selectedItems[0] == selectedItems[1]) continue; if (actionKeyDown.State) selectedItems[i].Use(deltaTime, this); - if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); - + if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); } if (selectedConstruction != null) @@ -906,6 +911,8 @@ namespace Subsurface } } + health = 0.0f; + isDead = true; AnimController.movement = Vector2.Zero; AnimController.TargetMovement = Vector2.Zero; @@ -914,7 +921,6 @@ namespace Subsurface { if (selectedItems[i] != null) selectedItems[i].Drop(this); } - aiTarget.Remove(); aiTarget = null; diff --git a/Subsurface/Source/Characters/CharacterInfo.cs b/Subsurface/Source/Characters/CharacterInfo.cs index e8d68ccda..7fe039d16 100644 --- a/Subsurface/Source/Characters/CharacterInfo.cs +++ b/Subsurface/Source/Characters/CharacterInfo.cs @@ -172,22 +172,27 @@ namespace Subsurface 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) + if (Job!=null) { - 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); + 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; } diff --git a/Subsurface/Source/Characters/Jobs/Job.cs b/Subsurface/Source/Characters/Jobs/Job.cs index 984715e10..d6d5addd0 100644 --- a/Subsurface/Source/Characters/Jobs/Job.cs +++ b/Subsurface/Source/Characters/Jobs/Job.cs @@ -56,6 +56,11 @@ namespace Subsurface get { return prefab.ItemNames; } } + public List EquipSpawnItem + { + get { return prefab.EquipItem; } + } + public List Skills { get { return skills.Values.ToList(); } diff --git a/Subsurface/Source/Characters/Jobs/JobPrefab.cs b/Subsurface/Source/Characters/Jobs/JobPrefab.cs index 673a4627a..b5f3a58aa 100644 --- a/Subsurface/Source/Characters/Jobs/JobPrefab.cs +++ b/Subsurface/Source/Characters/Jobs/JobPrefab.cs @@ -28,6 +28,7 @@ namespace Subsurface //names of the items the character spawns with public List ItemNames; + public List EquipItem; public Dictionary Skills; @@ -63,6 +64,7 @@ namespace Subsurface AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false); ItemNames = new List(); + EquipItem = new List(); Skills = new Dictionary(); @@ -72,7 +74,12 @@ namespace Subsurface { case "item": string itemName = ToolBox.GetAttributeString(subElement, "name", ""); - if (!string.IsNullOrEmpty(itemName)) ItemNames.Add(itemName); + bool equipItem = ToolBox.GetAttributeBool(subElement, "equip", false); + if (!string.IsNullOrEmpty(itemName)) + { + ItemNames.Add(itemName); + EquipItem.Add(equipItem); + } break; case "skills": LoadSkills(subElement); diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index d83c447a4..dca870265 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -5,6 +5,7 @@ using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics.Joints; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Subsurface.Items.Components; namespace Subsurface { @@ -60,7 +61,7 @@ namespace Subsurface private Direction dir; private Item wearingItem; - private Sprite wearingItemSprite; + private WearableSprite wearingItemSprite; private Vector2 animTargetPos; @@ -154,7 +155,7 @@ namespace Subsurface set { wearingItem = value; } } - public Sprite WearingItemSprite + public WearableSprite WearingItemSprite { get { return wearingItemSprite; } set { wearingItemSprite = value; } @@ -184,7 +185,7 @@ namespace Subsurface body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc; } - impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 8.0f); + impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f); body.UserData = this; @@ -398,16 +399,28 @@ namespace Subsurface Color color = Color.White;// new Color(1.0f, 1.0f - damage / maxHealth, 1.0f - damage / maxHealth); body.Dir = Dir; - body.Draw(spriteBatch, sprite, color); + + if (wearingItem == null || !wearingItemSprite.HideLimb) + { + body.Draw(spriteBatch, sprite, color); + } + else + { + body.UpdateDrawPosition(); + } if (wearingItem != null) { SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - wearingItemSprite.Draw(spriteBatch, + + Vector2 origin = wearingItemSprite.Sprite.Origin; + if (body.Dir == -1.0f) origin.X = wearingItemSprite.Sprite.SourceRect.Width - origin.X; + + wearingItemSprite.Sprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), - color, + color, origin, -body.DrawRotation, - 1.0f, spriteEffect); + 1.0f, spriteEffect, sprite.Depth - 0.000001f); } if (!Game1.DebugDraw) return; diff --git a/Subsurface/Source/Characters/Ragdoll.cs b/Subsurface/Source/Characters/Ragdoll.cs index 5d1c09d1a..0efc2b6b3 100644 --- a/Subsurface/Source/Characters/Ragdoll.cs +++ b/Subsurface/Source/Characters/Ragdoll.cs @@ -238,7 +238,7 @@ namespace Subsurface } float startDepth = 0.1f; - float increment = 0.0001f; + float increment = 0.001f; foreach (Character otherCharacter in Character.CharacterList) { @@ -248,7 +248,7 @@ namespace Subsurface foreach (Limb limb in limbs) { - limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.00001f; + limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f; } } diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs index fec02c78a..37a1650c5 100644 --- a/Subsurface/Source/GUI/GUIComponent.cs +++ b/Subsurface/Source/GUI/GUIComponent.cs @@ -339,6 +339,16 @@ namespace Subsurface if (children.Contains(child)) children.Remove(child); } + public GUIComponent FindChild(object userData) + { + foreach (GUIComponent child in children) + { + if (child.userData == userData) return child; + } + + return null; + } + public virtual void ClearChildren() { children.Clear(); diff --git a/Subsurface/Source/Game1.cs b/Subsurface/Source/Game1.cs index 1b0dea347..2a4c72cdb 100644 --- a/Subsurface/Source/Game1.cs +++ b/Subsurface/Source/Game1.cs @@ -213,7 +213,7 @@ namespace Subsurface EditCharacterScreen = new EditCharacterScreen(); yield return Status.Running; - ParticleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam); + ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam); yield return Status.Running; GUIComponent.Init(Window); @@ -262,7 +262,7 @@ namespace Subsurface if (NetworkMember != null) { - NetworkMember.Update(); + NetworkMember.Update((float)deltaTime); } else { @@ -298,8 +298,6 @@ namespace Subsurface Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch); } - //renderTimeElapsed = (int)renderTimer.Elapsed.Ticks; - //renderTimer.Stop(); if (sw.Elapsed.TotalSeconds < Physics.step) { System.Threading.Thread.Sleep((int)((Physics.step - sw.Elapsed.TotalSeconds)*1000.0)); diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index a06616106..a13eb2748 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -14,8 +14,6 @@ namespace Subsurface.Items.Components string prevMsg; - //protected Character picker; - //the distance from the holding characters elbow to center of the physics body of the item protected Vector2 holdPos; @@ -23,8 +21,7 @@ namespace Subsurface.Items.Components protected bool aimable; - private bool attachable; - private bool attached; + private bool attachable, attached, attachedByDefault; private PhysicsBody body; //the angle in which the character holds the item @@ -51,6 +48,13 @@ namespace Subsurface.Items.Components set { attachable = value; } } + [HasDefaultValue(false, false)] + public bool AttachedByDefault + { + get { return attachedByDefault; } + set { attachedByDefault = value; } + } + [HasDefaultValue("0.0,0.0", false)] public string HoldPos { @@ -97,6 +101,8 @@ namespace Subsurface.Items.Components Msg = ""; } + if (attachedByDefault) Use(1.0f); + //holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f); //holdAngle = MathHelper.ToRadians(holdAngle); diff --git a/Subsurface/Source/Items/Components/Holdable/RepairTool.cs b/Subsurface/Source/Items/Components/Holdable/RepairTool.cs index 064377f7e..da2662189 100644 --- a/Subsurface/Source/Items/Components/Holdable/RepairTool.cs +++ b/Subsurface/Source/Items/Components/Holdable/RepairTool.cs @@ -19,6 +19,8 @@ namespace Subsurface.Items.Components Vector2 barrelPos; + private string particles; + float structureFixAmount, limbFixAmount; [HasDefaultValue(0.0f, false)] @@ -42,6 +44,13 @@ namespace Subsurface.Items.Components set { limbFixAmount = value; } } + [HasDefaultValue("", false)] + public string Particles + { + get { return particles; } + set { particles = value; } + } + [HasDefaultValue("0.0,0.0", false)] public string BarrelPos { @@ -178,12 +187,17 @@ namespace Subsurface.Items.Components { if (!isActive) return; - Vector2 particleSpeed = new Vector2( - (float)Math.Cos(item.body.Rotation), - (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 5.0f; + //Vector2 particleSpeed = new Vector2( + // (float)Math.Cos(item.body.Rotation), + // (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f; - Game1.ParticleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed); + if (!string.IsNullOrWhiteSpace(particles)) + { + Game1.ParticleManager.CreateParticle(particles, TransformedBarrelPos, + -item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), 0.0f); + } + //Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position); //Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition); //endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2)); diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index c0322fe98..2f8688e00 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -22,12 +22,16 @@ namespace Subsurface.Items.Components public float VolumeMultiplier; public readonly float Range; + + public readonly bool Loop; - public ItemSound(Sound sound, ActionType type, float range) + public ItemSound(Sound sound, ActionType type, float range, bool loop = true) { this.Sound = sound; this.Type = type; this.Range = range; + + this.Loop = loop; } } @@ -47,6 +51,8 @@ namespace Subsurface.Items.Components protected bool canBePicked; protected bool canBeSelected; + public bool WasUsed; + public List statusEffects; protected bool updated; @@ -59,6 +65,8 @@ namespace Subsurface.Items.Components private GUIFrame guiFrame; + public ItemComponent Parent; + public readonly Dictionary properties; public Dictionary ObjectProperties { @@ -217,9 +225,6 @@ namespace Subsurface.Items.Components if (filePath=="") continue; if (!filePath.Contains("\\")) filePath = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\"+filePath; - //int index = item.Prefab.sounds.FindIndex(x => x.FilePath == filePath); - - ActionType type; try @@ -240,6 +245,13 @@ namespace Subsurface.Items.Components itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f); sounds.Add(itemSound); break; + default: + ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false); + if (ic == null) break; + + ic.Parent = this; + item.components.Add(ic); + break; } } @@ -247,34 +259,52 @@ namespace Subsurface.Items.Components private ItemSound loopingSound; private int loopingSoundIndex; - public void PlaySound(ActionType type, Vector2 position, bool loop=false) + public void PlaySound(ActionType type, Vector2 position) { ItemSound itemSound = null; - if (!loop || !Sounds.SoundManager.IsPlaying(loopingSoundIndex)) + if (!Sounds.SoundManager.IsPlaying(loopingSoundIndex)) { List matchingSounds = sounds.FindAll(x => x.Type == type); if (matchingSounds.Count == 0) return; int index = Rand.Int(matchingSounds.Count); itemSound = matchingSounds[index]; - - - - if (loop) loopingSound = itemSound; } - - if (loop) + + if (loopingSound!=null) { loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range); } - else + else if (itemSound!=null) { - - itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position); + if (itemSound.Loop) + { + loopingSound = itemSound; + } + else + { + itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position); + } } } + public void StopSounds(ActionType type) + { + if (loopingSoundIndex <= 0) return; + + if (loopingSound == null) return; + + if (loopingSound.Type != type) return; + + if (Sounds.SoundManager.IsPlaying(loopingSoundIndex)) + { + Sounds.SoundManager.Stop(loopingSoundIndex); + loopingSound = null; + loopingSoundIndex = -1; + } + } + private float GetSoundVolume(ItemSound sound) { if (sound.VolumeProperty == "") return 1.0f; @@ -326,13 +356,7 @@ namespace Subsurface.Items.Components //called when isActive is true and condition == 0.0f public virtual void UpdateBroken(float deltaTime, Camera cam) { - if (loopingSoundIndex <= 0) return; - - if (Sounds.SoundManager.IsPlaying(loopingSoundIndex)) - { - Sounds.SoundManager.Stop(loopingSoundIndex); - } - + StopSounds(ActionType.OnActive); } //called when the item is equipped and left mouse button is pressed @@ -565,30 +589,30 @@ namespace Subsurface.Items.Components public virtual void OnMapLoaded() { } - public static ItemComponent Load(XElement element, Item item, string file) + public static ItemComponent Load(XElement element, Item item, string file, bool errorMessages = true) { Type t; string type = element.Name.ToString().ToLower(); try { - // Get the type of a specified class. - t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", true, true); + // Get the type of a specified class. + t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", false, true); if (t == null) { - DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")"); + if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")"); return null; } } catch (Exception e) { - DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e); + if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e); return null; } ConstructorInfo constructor; try { - if (t!=typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null; + if (t != typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null; constructor = t.GetConstructor(new Type[] { typeof(Item), typeof(XElement) }); if (constructor == null) { diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index d595e72af..6643d3cf1 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -136,27 +136,8 @@ namespace Subsurface.Items.Components private bool OnProjectileCollision(Fixture f1, Fixture f2, Contact contact) { - //doesn't collide with items - //if (f2.Body.UserData is Item) return false; - if (ignoredBodies.Contains(f2.Body)) return false; - //Structure structure = f1.Body.UserData as Structure; - //if (structure!=null && (structure.IsPlatform || structure.StairDirection != Direction.None)) return false; - - //Vector2 force = f1.Body.LinearVelocity * f1.Body.Mass; - //float forceLength = force.Length(); - - //if (forceLength > 20.0f) - //{ - // force = force / forceLength * 20.0f; - //} - - //f2.Body.ApplyLinearImpulse(force); - //f1.Body.ApplyLinearImpulse(-f1.Body.LinearVelocity * f1.Body.Mass); - - //float damage = f1.Body.LinearVelocity.Length(); - AttackResult attackResult = new AttackResult(0.0f, 0.0f); if (attack!=null) { @@ -195,6 +176,11 @@ namespace Subsurface.Items.Components if (Vector2.Dot(f1.Body.LinearVelocity, normal)<0 ) return StickToTarget(f2.Body, dir); } + foreach (Item contained in item.ContainedItems) + { + contained.Condition = 0.0f; + } + return true; } diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs index d10d2b8f9..09d3174ad 100644 --- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs @@ -22,6 +22,8 @@ namespace Subsurface.Items.Components float lightBrightness; + private float flicker; + [Editable, HasDefaultValue(100.0f, true)] public float Range { @@ -31,6 +33,16 @@ namespace Subsurface.Items.Components range = MathHelper.Clamp(value, 0.0f, 2048.0f); } } + + [HasDefaultValue(0.0f, false)] + public float Flicker + { + get { return flicker; } + set + { + flicker = MathHelper.Clamp(value, 0.0f, 1.0f); + } + } [InGameEditable, HasDefaultValue("1.0,1.0,1.0,1.0", true)] public string LightColor @@ -61,7 +73,7 @@ namespace Subsurface.Items.Components string dir = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\"; for (int i = 0; i<4; i++) { - sparkSounds[i] = Sound.Load(dir+"zap"+(i+1)+".ogg"); + sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap"+(i+1)+".ogg"); } } @@ -89,7 +101,7 @@ namespace Subsurface.Items.Components } Pickable pickable = item.GetComponent(); - if (item.container!= null || (pickable!=null && pickable.Picker!=null)) + if (item.container!= null) { light.Color = Color.Transparent; return; @@ -114,7 +126,7 @@ namespace Subsurface.Items.Components lightBrightness = MathHelper.Lerp(lightBrightness, Math.Min(voltage, 1.0f), 0.1f); } - light.Color = lightColor * lightBrightness; + light.Color = lightColor * lightBrightness * (1.0f-Rand.Range(0.0f,Flicker)); light.Range = range * (float)Math.Sqrt(lightBrightness); diff --git a/Subsurface/Source/Items/Components/Wearable.cs b/Subsurface/Source/Items/Components/Wearable.cs index 6333d6f92..57bcb7224 100644 --- a/Subsurface/Source/Items/Components/Wearable.cs +++ b/Subsurface/Source/Items/Components/Wearable.cs @@ -5,9 +5,21 @@ using System.Xml.Linq; namespace Subsurface.Items.Components { + class WearableSprite + { + public Sprite Sprite; + public bool HideLimb; + + public WearableSprite(Sprite sprite, bool hideLimb) + { + Sprite = sprite; + HideLimb = hideLimb; + } + } + class Wearable : Pickable { - Sprite[] sprite; + WearableSprite[] wearableSprite; LimbType[] limbType; Limb[] limb; @@ -18,7 +30,7 @@ namespace Subsurface.Items.Components var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList(); int spriteCount = sprites.Count(); - sprite = new Sprite[spriteCount]; + wearableSprite = new WearableSprite[spriteCount]; limbType = new LimbType[spriteCount]; limb = new Limb[spriteCount]; @@ -40,7 +52,8 @@ namespace Subsurface.Items.Components string spritePath = subElement.Attribute("texture").Value; spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"\\"+spritePath; - sprite[i] = new Sprite(subElement, "", spritePath); + var sprite = new Sprite(subElement, "", spritePath); + wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false)); //sprite[i].origin = new Vector2(sourceRect.Width / 2.0f, sourceRect.Height / 2.0f); limbType[i] = (LimbType)Enum.Parse(typeof(LimbType), @@ -53,7 +66,7 @@ namespace Subsurface.Items.Components public override void Equip(Character character) { picker = character; - for (int i = 0; i < sprite.Length; i++ ) + for (int i = 0; i < wearableSprite.Length; i++ ) { Limb equipLimb = character.AnimController.GetLimb(limbType[i]); if (equipLimb == null) continue; @@ -64,7 +77,7 @@ namespace Subsurface.Items.Components equipLimb.WearingItem.Unequip(character); } - sprite[i].Depth = equipLimb.sprite.Depth - 0.001f; + //sprite[i].Depth = equipLimb.sprite.Depth - 0.001f; item.body.Enabled = false; @@ -72,7 +85,7 @@ namespace Subsurface.Items.Components limb[i] = equipLimb; equipLimb.WearingItem = item; - equipLimb.WearingItemSprite = sprite[i]; + equipLimb.WearingItemSprite = wearableSprite[i]; } } @@ -89,7 +102,7 @@ namespace Subsurface.Items.Components public override void Unequip(Character character) { if (picker == null) return; - for (int i = 0; i < sprite.Length; i++) + for (int i = 0; i < wearableSprite.Length; i++) { Limb equipLimb = character.AnimController.GetLimb(limbType[i]); if (equipLimb == null) continue; diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 8b705094b..70070dbe6 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -134,6 +134,11 @@ namespace Subsurface get { return prefab; } } + public string ConfigFile + { + get { return prefab.ConfigFile; } + } + //which type of inventory slots (head, torso, any, etc) the item can be placed in public LimbSlot AllowedSlots { @@ -443,12 +448,22 @@ namespace Subsurface { foreach (ItemComponent ic in components) { - if (!ic.IsActive) continue; + if (ic.Parent != null) ic.IsActive = ic.Parent.IsActive; + + if (!ic.WasUsed) ic.StopSounds(ActionType.OnUse); + ic.WasUsed = false; + + + if (!ic.IsActive) + { + ic.StopSounds(ActionType.OnActive); + continue; + } if (condition > 0.0f) { ic.Update(deltaTime, cam); - ic.PlaySound(ActionType.OnActive, Position, true); + ic.PlaySound(ActionType.OnActive, Position); ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null); } else @@ -462,7 +477,6 @@ namespace Subsurface if (body.LinearVelocity.Length()>0.001f) FindHull(); - Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.Position); rect.X = (int)(displayPos.X - rect.Width / 2.0f); @@ -618,7 +632,6 @@ namespace Subsurface { foreach (RelatedItem relatedItem in ic.requiredItems) { - new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", GUI.style, editingHUD); GUITextBox namesBox = new GUITextBox(new Rectangle(0, y, 200, 20), Alignment.Right, GUI.style, editingHUD); @@ -809,6 +822,8 @@ namespace Subsurface if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue; if (ic.Use(deltaTime, character)) { + ic.WasUsed = true; + ic.PlaySound(ActionType.OnUse, Position); ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character); diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 0554968e8..adb5c3250 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -44,6 +44,7 @@ namespace Subsurface.Networking name = newName; characterInfo = new CharacterInfo(Character.HumanConfigFile, name); + characterInfo.Job = null; otherClients = new List(); @@ -121,6 +122,7 @@ namespace Subsurface.Networking private bool RetryConnection(GUIButton button, object obj) { + if (client != null) client.Shutdown("Disconnecting"); ConnectToServer(serverIP); return true; } @@ -175,6 +177,7 @@ namespace Subsurface.Networking Client otherClient = new Client(inc.ReadString(), inc.ReadInt32()); Game1.NetLobbyScreen.AddPlayer(otherClient); + otherClients.Add(otherClient); } //add the name of own client to the lobby screen @@ -230,20 +233,9 @@ namespace Subsurface.Networking yield return Status.Success; } - public override void Update() + public override void Update(float deltaTime) { - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - //if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K)) - //{ - // SendRandomData(); - //} - //if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.L)) - //{ - // ConnectToServer(serverIP); - //} - - - if (gameStarted) inGameHUD.Update((float)Physics.step); + base.Update(deltaTime); if (!connected || updateTimer > DateTime.Now) return; @@ -341,17 +333,15 @@ namespace Subsurface.Networking //myCharacter = ReadCharacterData(inc); //Character.Controlled = myCharacter; + List crew = new List(); + int count = inc.ReadInt32(); for (int n = 0; n < count; n++) { int id = inc.ReadInt32(); - Character newCharacter = ReadCharacterData(inc); + Character newCharacter = ReadCharacterData(inc, id == myID); - if (id == myID) - { - myCharacter = newCharacter; - Character.Controlled = myCharacter; - } + crew.Add(newCharacter); } gameStarted = true; @@ -360,6 +350,8 @@ namespace Subsurface.Networking AddChatMessage("Press TAB to chat", ChatMessageType.Server); + CreateCrewFrame(crew); + break; case (byte)PacketTypes.EndGame: string endMessage = inc.ReadString(); @@ -370,6 +362,7 @@ namespace Subsurface.Networking Client otherClient = new Client(inc.ReadString(), inc.ReadInt32()); Game1.NetLobbyScreen.AddPlayer(otherClient); + otherClients.Add(otherClient); AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server); @@ -459,7 +452,7 @@ namespace Subsurface.Networking client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered); } - private Character ReadCharacterData(NetIncomingMessage inc) + private Character ReadCharacterData(NetIncomingMessage inc, bool isMyCharacter) { string newName = inc.ReadString(); int ID = inc.ReadInt32(); @@ -494,16 +487,20 @@ namespace Subsurface.Networking } Character character = (closestWaypoint == null) ? - new Character(ch, position) : - new Character(ch, closestWaypoint); + new Character(ch, position, true) : + new Character(ch, closestWaypoint, true); character.ID = ID; character.Inventory.ID = inventoryID; - - character.IsNetworkPlayer = true; - + character.GiveJobItems(closestWaypoint); + if (isMyCharacter) + { + myCharacter = character; + Character.Controlled = character; + } + return character; } diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index d1f497177..331b465c0 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -58,12 +58,9 @@ namespace Subsurface.Networking DebugConsole.NewMessage("Server started", Color.Green); } - public override void Update() + public override void Update(float deltaTime) { - //if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K)) - //{ - // SendRandomData(); - //} + base.Update(deltaTime); if (gameStarted) inGameHUD.Update((float)Physics.step); @@ -208,7 +205,7 @@ namespace Subsurface.Networking } else { - AssignJobs(); + //AssignJobs(); Game1.NetLobbyScreen.AddPlayer(sender); @@ -346,6 +343,8 @@ namespace Subsurface.Networking { int seed = DateTime.Now.Millisecond; Rand.SetSyncedSeed(seed); + + AssignJobs(); Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine; @@ -369,9 +368,12 @@ namespace Subsurface.Networking } characterInfos.Add(client.characterInfo); + client.characterInfo.Job = new Job(client.assignedJob); + //client.character = new Character(client.characterInfo, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition, true); } + List crew = new List(); WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos); for (int i = 0; i < connectedClients.Count; i++ ) @@ -379,6 +381,8 @@ namespace Subsurface.Networking connectedClients[i].character = new Character( connectedClients[i].characterInfo, assignedWayPoints[i], true); connectedClients[i].character.GiveJobItems(assignedWayPoints[i]); + + crew.Add(connectedClients[i].character); } //todo: fix @@ -427,6 +431,9 @@ namespace Subsurface.Networking Game1.GameScreen.Select(); + + CreateCrewFrame(crew); + return true; } @@ -685,7 +692,7 @@ namespace Subsurface.Networking } } - UpdateNetLobby(null); + //UpdateNetLobby(null); } diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs index 1d5cea09a..188415b8c 100644 --- a/Subsurface/Source/Networking/NetworkMember.cs +++ b/Subsurface/Source/Networking/NetworkMember.cs @@ -1,6 +1,8 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using System.Collections.Generic; namespace Subsurface.Networking { @@ -40,9 +42,14 @@ namespace Subsurface.Networking protected GUIFrame inGameHUD; protected GUIListBox chatBox; + protected GUITextBox chatMsgBox; public int Port; + private bool crewFrameOpen; + private GUIButton crewButton; + private GUIFrame crewFrame; + protected bool gameStarted; public string Name @@ -72,13 +79,73 @@ namespace Subsurface.Networking width, height), Color.White * 0.5f, GUI.style, inGameHUD); - var textBox = new GUITextBox( + chatMsgBox = new GUITextBox( new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25), Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.style, inGameHUD); - textBox.Font = GUI.SmallFont; - textBox.OnEnter = EnterChatMessage; + chatMsgBox.Font = GUI.SmallFont; + chatMsgBox.OnEnter = EnterChatMessage; + + crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.style, inGameHUD); + crewButton.OnClicked = ToggleCrewFrame; } + protected void CreateCrewFrame(List crew) + { + int width = 500, height = 400; + + crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style); + crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); + + GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.style, crewFrame); + crewList.OnSelected = SelectCharacter; + + foreach (Character character in crew) + { + GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList); + frame.UserData = character; + frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); + frame.HoverColor = Color.LightGray * 0.5f; + frame.SelectedColor = Color.Gold * 0.5f; + + GUITextBlock textBlock = new GUITextBlock( + new Rectangle(40, 0, 0, 25), + character.Info.Name + " ("+character.Info.Job.Name+")", + Color.Transparent, Color.White, + Alignment.Left, Alignment.Left, + null, frame); + textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + + new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame); + } + + var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.style, crewFrame); + closeButton.OnClicked = ToggleCrewFrame; + } + + private bool SelectCharacter(object obj) + { + Character character = obj as Character; + if (obj == null) return false; + + GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter"); + if (existingFrame != null) crewFrame.RemoveChild(existingFrame); + + var previewPlayer = new GUIFrame( + new Rectangle(0,0, 230, 300), + new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.style, crewFrame); + previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); + previewPlayer.UserData = "selectedcharacter"; + + var infoFrame = character.Info.CreateInfoFrame(previewPlayer); + + return true; + } + + private bool ToggleCrewFrame(GUIButton button, object obj) + { + crewFrameOpen = !crewFrameOpen; + return true; + } public bool EnterChatMessage(GUITextBox textBox, string message) { @@ -122,13 +189,36 @@ namespace Subsurface.Networking public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { } - public virtual void Update() { } + public virtual void Update(float deltaTime) + { + if (gameStarted) + { + inGameHUD.Update(deltaTime); + + if (crewFrameOpen) crewFrame.Update(deltaTime); + } + + if (PlayerInput.KeyHit(Keys.Tab)) + { + if (chatMsgBox.Selected) + { + chatMsgBox.Text = ""; + chatMsgBox.Deselect(); + } + else + { + chatMsgBox.Select(); + } + } + } public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { if (!gameStarted) return; inGameHUD.Draw(spriteBatch); + + if (crewFrameOpen) crewFrame.Draw(spriteBatch); } public virtual void Disconnect() { } diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs index 971b7ec1d..686011341 100644 --- a/Subsurface/Source/Particles/Particle.cs +++ b/Subsurface/Source/Particles/Particle.cs @@ -82,7 +82,14 @@ namespace Subsurface.Particles color = prefab.startColor; alpha = prefab.startAlpha; - velocityChange = prefab.velocityChange; + velocityChange = prefab.velocityChange; + + if (prefab.rotateToDirection) + { + this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y)); + + prevRotation = rotation; + } } public bool Update(float deltaTime) @@ -93,7 +100,10 @@ namespace Subsurface.Particles if (prefab.rotateToDirection) { - rotation = MathUtils.VectorToAngle(velocity); + if (velocityChange != Vector2.Zero || angularVelocity != 0.0f) + { + rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y)); + } } else { @@ -153,15 +163,17 @@ namespace Subsurface.Particles drawPosition = ConvertUnits.ToDisplayUnits(drawPosition); - spriteBatch.Draw( - prefab.sprite.Texture, - drawPosition, - null, - color*alpha, - drawRotation, - prefab.sprite.origin, - size, - SpriteEffects.None, prefab.sprite.Depth); + prefab.sprite.Draw(spriteBatch, drawPosition, color*alpha, drawRotation, size.X, SpriteEffects.None, prefab.sprite.Depth); + + //spriteBatch.Draw( + // prefab.sprite.Texture, + // drawPosition, + // null, + // color*alpha, + // drawRotation, + // prefab.sprite.origin, + // size, + // SpriteEffects.None, prefab.sprite.Depth); prevPosition = position; prevRotation = rotation; diff --git a/Subsurface/Source/Particles/ParticlePrefab.cs b/Subsurface/Source/Particles/ParticlePrefab.cs index 433663ba6..a88028034 100644 --- a/Subsurface/Source/Particles/ParticlePrefab.cs +++ b/Subsurface/Source/Particles/ParticlePrefab.cs @@ -35,8 +35,12 @@ namespace Subsurface.Particles { name = element.Name.ToString(); - string spritePath = ToolBox.GetAttributeString(element, "sprite", ""); - sprite = new Sprite(spritePath, new Vector2(0.5f,0.5f)); + foreach (XElement subElement in element.Elements()) + { + if (subElement.Name.ToString().ToLower() != "sprite") continue; + + sprite = new Sprite(subElement); + } angularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f); angularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f); diff --git a/Subsurface/Source/Physics/PhysicsBody.cs b/Subsurface/Source/Physics/PhysicsBody.cs index 2d6c5a521..8af21e7f0 100644 --- a/Subsurface/Source/Physics/PhysicsBody.cs +++ b/Subsurface/Source/Physics/PhysicsBody.cs @@ -285,17 +285,22 @@ namespace Subsurface } } - public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null) + public void UpdateDrawPosition() { - if (!body.Enabled) return; - - SpriteEffects spriteEffect = (dir == 1.0f) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - drawPosition = Physics.Interpolate(prevPosition, body.Position); drawPosition = ConvertUnits.ToDisplayUnits(drawPosition); drawRotation = Physics.Interpolate(prevRotation, body.Rotation); + } + public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null) + { + if (!body.Enabled) return; + + UpdateDrawPosition(); + + SpriteEffects spriteEffect = (dir == 1.0f) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + sprite.Draw(spriteBatch, new Vector2(drawPosition.X, -drawPosition.Y), color, -drawRotation, 1.0f, spriteEffect, depth); //prevPosition = body.Position; diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index d757a2466..9625bd268 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -221,7 +221,6 @@ namespace Subsurface serverName.Enabled = Game1.Server != null; serverName.OnTextChanged = ChangeServerName; - serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame); serverMessage.Wrap = true; serverMessage.TextGetter = GetServerMessage; @@ -266,10 +265,10 @@ namespace Subsurface if (subList.CountChildren > 0) subList.Select(0); if (GameModePreset.list.Count > 0) modeList.Select(0); } - else + else if (playerFrame.children.Count==0) { int x = playerFrame.Rect.Width / 2; - + playerFrame.ClearChildren(); new GUITextBlock(new Rectangle(x, 0, 200, 30), "Name: ", GUI.style, playerFrame); @@ -312,7 +311,6 @@ namespace Subsurface UpdateJobPreferences(jobList); UpdatePreviewPlayer(Game1.Client.CharacterInfo); - } base.Select(); @@ -594,13 +592,13 @@ namespace Subsurface msg.Write(durationBar.BarScroll); msg.Write(LevelSeed); - msg.Write(playerList.CountChildren - 1); - for (int i = 1; i < playerList.CountChildren; i++) - { - Client client = playerList.children[i].UserData as Client; - msg.Write(client.ID); - msg.Write(client.assignedJob==null ? "" : client.assignedJob.Name); - } + //msg.Write(playerList.CountChildren - 1); + //for (int i = 1; i < playerList.CountChildren; i++) + //{ + // Client client = playerList.children[i].UserData as Client; + // msg.Write(client.ID); + // msg.Write(client.assignedJob==null ? "" : client.assignedJob.Name); + //} } @@ -642,48 +640,48 @@ namespace Subsurface LevelSeed = levelSeed; - try - { - int playerCount = msg.ReadInt32(); + //try + //{ + // int playerCount = msg.ReadInt32(); - for (int i = 0; i < playerCount; i++) - { - int clientID = msg.ReadInt32(); - string jobName = msg.ReadString(); + // for (int i = 0; i < playerCount; i++) + // { + // int clientID = msg.ReadInt32(); + // string jobName = msg.ReadString(); - Client client = null; - GUITextBlock textBlock = null; - foreach (GUIComponent child in playerList.children) - { - Client tempClient = child.UserData as Client; - if (tempClient == null || tempClient.ID != clientID) continue; + // Client client = null; + // GUITextBlock textBlock = null; + // foreach (GUIComponent child in playerList.children) + // { + // Client tempClient = child.UserData as Client; + // if (tempClient == null || tempClient.ID != clientID) continue; - client = tempClient; - textBlock = child as GUITextBlock; - break; - } - if (client == null) continue; + // client = tempClient; + // textBlock = child as GUITextBlock; + // break; + // } + // if (client == null) continue; - client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName); + // client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName); - textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")"); + // textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")"); - if (client.assignedJob==null || jobName != 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); - } - } - } - } + // if (client.assignedJob==null || jobName != 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); + // } + // } + // } + //} - catch - { - return; - } + //catch + //{ + // return; + //} } diff --git a/Subsurface/Source/Sounds/Sound.cs b/Subsurface/Source/Sounds/Sound.cs index 03d9341a5..1244d6c1e 100644 --- a/Subsurface/Source/Sounds/Sound.cs +++ b/Subsurface/Source/Sounds/Sound.cs @@ -172,13 +172,9 @@ namespace Subsurface } return sourceIndex; - } - - + } return SoundManager.Loop(this, sourceIndex, position, volume, volume); - - //return UpdatePosition(newIndex, position, range, volume); } diff --git a/Subsurface/Source/Sprite.cs b/Subsurface/Source/Sprite.cs index de96ee7d4..71c731ed8 100644 --- a/Subsurface/Source/Sprite.cs +++ b/Subsurface/Source/Sprite.cs @@ -188,7 +188,11 @@ namespace Subsurface public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, float rotate = 0.0f, float scale = 1.0f, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null) { spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth==null ? this.depth : (float)depth); - + } + + public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate = 0.0f, float scale = 1.0f, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null) + { + spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth); } public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Color color) diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index 28a8cb78a..11e83d44d 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -292,6 +292,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -469,6 +475,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -641,7 +650,7 @@ PreserveNewest - + PreserveNewest Designer @@ -770,6 +779,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 8fc1e8c16..5ee2b4a44 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ