fixed railgun, fixed repairtools radar ping & improved rendering, waypoint bugfixes, inventory bugfixes, syncing wires between clients

This commit is contained in:
Regalis
2015-07-15 23:34:13 +03:00
parent 44b9a63c94
commit 237df18765
39 changed files with 461 additions and 405 deletions

View File

@@ -116,7 +116,7 @@ namespace Subsurface
if (startNode == null || endNode == null)
{
DebugConsole.ThrowError("Pathfinding error, couldn't find pathnodes");
return null;
return new SteeringPath();
}
return FindPath(startNode,endNode);
@@ -141,7 +141,7 @@ namespace Subsurface
if (startNode==null || endNode==null)
{
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
return null;
return new SteeringPath();;
}
}

View File

@@ -86,9 +86,12 @@ namespace Subsurface
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower() != "skill") continue;
string skillName = ToolBox.GetAttributeString(subElement, "name", "");
if (string.IsNullOrEmpty(name)) continue;
skills.Add(
subElement.Name.ToString(),
new Skill(subElement.Name.ToString(), ToolBox.GetAttributeInt(subElement, "level", 0)));
skillName,
new Skill(skillName, ToolBox.GetAttributeInt(subElement, "level", 0)));
}
}
@@ -115,7 +118,7 @@ namespace Subsurface
foreach (KeyValuePair<string, Skill> skill in skills)
{
jobElement.Add(new XElement(skill.Key, new XAttribute("level", skill.Value.Level)));
jobElement.Add(new XElement("skill", new XAttribute("name", skill.Value.Name), new XAttribute("level", skill.Value.Level)));
}
parentElement.Add(jobElement);

View File

@@ -609,7 +609,7 @@ namespace Subsurface
float dist = Vector2.Distance(limbPos, gapPos);
force += Vector2.Normalize(gap.FlowForce)*(Math.Max(gap.FlowForce.Length() - dist, 0.0f)/500.0f);
force += Vector2.Normalize(gap.FlowForce)*(Math.Max(gap.FlowForce.Length() - dist, 0.0f)/1000.0f);
}
if (force.Length() > 20.0f) return force;

View File

@@ -31,6 +31,7 @@
</Steering>
<Radar canbeselected = "true">
<sound file="radarPing.ogg" type="OnUse" range="4000.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.0"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>

Binary file not shown.

View File

@@ -3,7 +3,8 @@
name="Railgun"
focusonselected="true"
offsetonselected="500"
linkable="true">
linkable="true"
pickdistance="150">
<Sprite texture ="railgunbase.png"/>
@@ -12,6 +13,13 @@
powerconsumption="500.0">
<Sound file="railgun.ogg" type="OnUse"/>
</Turret>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="power_in"/>
<input name="position_in"/>
<input name="trigger_in"/>
</ConnectionPanel>
</Item>
<Item
@@ -28,7 +36,13 @@
<limbposition limb="RightHand" position="38,-125"/>
</Controller>
<trigger x="-50" y="-87" width="200" height ="153"/>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="power_in"/>
<output name="position_out"/>
<output name="trigger_out"/>
</ConnectionPanel>
</Item>
<Item
@@ -54,7 +68,9 @@
<Holdable holdpos="30,-15" handle1="0,20" handle2="0,-20"/>
<Pickable slots="RightHand"/>
<Projectile launchimpulse="80.0"/>
<Projectile launchimpulse="80.0">
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
</Projectile>
</Item>
</Items>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -3,7 +3,7 @@
<MonsterEvent name="Under attack" description=""
characterfile="Content/Characters/Crawler/Crawler.xml"
commonness="10"
difficulty="30"
difficulty="10"
minamount="2" maxamount="3"
starttimemin="15" starttimemax="20"
musictype="monster"/>
@@ -14,4 +14,19 @@
difficulty="50"
starttimemin="15" starttimemax="20"
musictype="monster"/>
<MonsterEvent name="Under attack" description=""
characterfile="Content/Characters/Moloch/moloch.xml"
commonness="10"
difficulty="30"
starttimemin="15" starttimemax="20"
musictype="monster"/>
<MonsterEvent name="Under attack" description=""
characterfile="Content/Characters/Mantis/mantis.xml"
commonness="10"
difficulty="10"
minamount="2" maxamount="3"
starttimemin="15" starttimemax="20"
musictype="monster"/>
</Randomevents>

View File

@@ -265,20 +265,18 @@ namespace Subsurface
public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam)
{
spriteBatch.DrawString(font,
"FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond,
"FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond
+ " - Physics: " + Game1.World.UpdateTime
+ " - bodies: " + Game1.World.BodyList.Count,
new Vector2(10, 10), Color.White);
spriteBatch.DrawString(font,
"Physics: " + Game1.World.UpdateTime
+ " - bodies: " + Game1.World.BodyList.Count,
new Vector2(10, 30), Color.White);
spriteBatch.DrawString(font,
"Camera pos: " + Game1.GameScreen.Cam.Position,
new Vector2(10, 50), Color.White);
new Vector2(10, 30), Color.White);
if (Character.Controlled != null && cam!=null) Character.Controlled.DrawHud(spriteBatch, cam);
if (Game1.NetworkMember != null) Game1.NetworkMember.Draw(spriteBatch);
DrawMessages(spriteBatch, (float)deltaTime);

View File

@@ -44,6 +44,17 @@ namespace Subsurface
}
}
public float BarScroll
{
get { return scrollBar.BarScroll; }
set { scrollBar.BarScroll = value; }
}
public float BarSize
{
get { return scrollBar.BarSize; }
}
public int Spacing
{
get { return spacing; }
@@ -173,14 +184,16 @@ namespace Subsurface
{
base.AddChild(child);
float oldScroll = scrollBar.BarScroll;
float oldSize = scrollBar.BarSize;
//float oldScroll = scrollBar.BarScroll;
//float oldSize = scrollBar.BarSize;
UpdateScrollBarSize();
if (scrollBar.BarSize < 1.0f && oldScroll == 1.0f)
{
scrollBar.BarScroll = 1.0f;
}
//if (oldSize == 1.0f && scrollBar.BarScroll == 0.0f) scrollBar.BarScroll = 1.0f;
//if (scrollBar.BarSize < 1.0f && oldScroll == 1.0f)
//{
// scrollBar.BarScroll = 1.0f;
//}
}

View File

@@ -107,9 +107,10 @@ namespace Subsurface
private void UpdateRect()
{
bar.Rect = new Rectangle(
frame.Rect.X,
frame.Rect.Y,
bar.Rect.X,
bar.Rect.Y,
isHorizontal ? (int)(frame.Rect.Width * barSize) : frame.Rect.Width,
isHorizontal ? frame.Rect.Height : (int)(frame.Rect.Height * barSize));

View File

@@ -120,7 +120,7 @@ namespace Subsurface
{
if (!isRunning) return;
if (duration!=TimeSpan.Zero)
if (duration != TimeSpan.Zero)
{
double elapsedTime = (DateTime.Now - startTime).TotalSeconds;
timerBar.BarSize = (float)(elapsedTime / duration.TotalSeconds);

View File

@@ -134,14 +134,6 @@ 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);
}
@@ -227,7 +219,7 @@ namespace Subsurface
//double elapsedTime = (DateTime.Now-startTime).TotalSeconds;
//timerBar.BarSize = (float)(elapsedTime / Math.Max(duration, 1.0));
if (PlayerInput.KeyHit(Keys.Tab))
if (PlayerInput.KeyHit(Keys.Tab) && textBox!=null)
{
if (textBox.Selected)
{

View File

@@ -25,6 +25,12 @@ namespace Subsurface
this.character = character;
}
protected override void DropItem(Item item)
{
item.Drop(character);
item.body.SetTransform(character.SimPosition, 0.0f);
}
public int FindLimbSlot(LimbSlot limbSlot)
{
for (int i = 0; i < items.Length; i++)
@@ -232,7 +238,7 @@ namespace Subsurface
else
{
draggingItem.body.SetTransform(character.SimPosition, 0.0f);
draggingItem.Drop(character);
DropItem(draggingItem);
//draggingItem = null;
}
}

View File

@@ -129,7 +129,7 @@ namespace Subsurface.Items.Components
targetStructure.HighLightSection(sectionIndex);
targetStructure.AddDamage(sectionIndex, -structureFixAmount);
}
else if ((targetLimb = (targetBody.UserData as Limb)) != null)

View File

@@ -284,6 +284,11 @@ namespace Subsurface
{
return false;
}
public virtual bool Select(Character character)
{
return CanBeSelected;
}
/// <summary>a character has dropped the item</summary>
public virtual void Drop(Character dropper) { }
@@ -395,40 +400,31 @@ namespace Subsurface
return true;
}
public bool HasRequiredEquippedItems(Character character, bool addMessage)
public bool HasRequiredItems(Character character, bool addMessage)
{
if (!requiredItems.Any()) return true;
foreach (RelatedItem ri in requiredItems)
{
if (!ri.Type.HasFlag(RelatedItem.RelationType.Equipped) && !ri.Type.HasFlag(RelatedItem.RelationType.Picked)) continue;
bool hasItem = false;
if (ri.Type.HasFlag(RelatedItem.RelationType.Equipped))
{
for (int i = 0; i < character.SelectedItems.Length; i++ )
{
Item selectedItem = character.SelectedItems[i];
if (selectedItem !=null && selectedItem.Condition>0.0f && ri.MatchesItem(selectedItem ))
{
return true;
}
}
//if (addMessage && !String.IsNullOrEmpty(ri.Msg)) GUI.AddMessage(ri.Msg, Color.Red);
return false;
if (character.SelectedItems.FirstOrDefault(it => it != null && it.Condition > 0.0f && ri.MatchesItem(it)) != null) hasItem = true;
}
else if (ri.Type.HasFlag(RelatedItem.RelationType.Picked))
if (!hasItem && 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)
{
//if (addMessage && !String.IsNullOrEmpty(ri.Msg)) GUI.AddMessage(ri.Msg, Color.Red);
return false;
}
if (character.Inventory.items.FirstOrDefault(x => x!=null && x.Condition>0.0f && ri.MatchesItem(x))!=null) hasItem = true;
}
if (!hasItem) return false;
}
return true;
}
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null)
{
foreach (StatusEffect effect in statusEffects)

View File

@@ -10,11 +10,11 @@ namespace Subsurface.Items.Components
{
}
public override bool Pick(Character picker = null)
public override bool Select(Character character = null)
{
if (picker == null) return false;
if (character == null) return false;
picker.AnimController.Anim = AnimController.Animation.Climbing;
character.AnimController.Anim = AnimController.Animation.Climbing;
//picker.SelectedConstruction = item;
return true;

View File

@@ -23,6 +23,8 @@ namespace Subsurface.Items.Components
//the x-position where the user walks to when using the controller
float userPos;
Camera cam;
Character character;
[HasDefaultValue(1.0f,false)]
@@ -38,19 +40,6 @@ namespace Subsurface.Items.Components
dir = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "direction", "None"), true);
//userPos = ToolBox.GetAttributeInt(element, "userpos", 1);
//string allowedIdString = ToolBox.GetAttributeString(element, "allowedids", "");
//if (allowedIdString!="")
//{
// string[] splitIds = allowedIdString.Split(',');
// allowedIDs = new string[splitIds.Length];
// for (int i = 0; i<splitIds.Length; i++)
// {
// allowedIDs[i] = allowedIDs[i].Trim();
// }
//}
foreach (XElement el in element.Elements())
{
if (el.Name != "limbposition") continue;
@@ -75,6 +64,8 @@ namespace Subsurface.Items.Components
public override void Update(float deltaTime, Camera cam)
{
this.cam = cam;
if (character == null || character.SelectedConstruction != item)
{
if (character != null)
@@ -126,25 +117,29 @@ namespace Subsurface.Items.Components
fmj.WorldAnchorB = position;
}
foreach (MapEntity e in item.linkedTo)
{
Item linkedItem = e as Item;
if (linkedItem == null) continue;
linkedItem.Update(cam, deltaTime);
}
//foreach (MapEntity e in item.linkedTo)
//{
// Item linkedItem = e as Item;
// if (linkedItem == null) continue;
// linkedItem.Update(cam, deltaTime);
//}
item.SendSignal(ToolBox.Vector2ToString(character.CursorPosition), "position_out");
}
public override bool Use(float deltaTime, Character activator = null)
{
character = activator;
foreach (MapEntity e in item.linkedTo)
{
Item linkedItem = e as Item;
if (linkedItem == null) continue;
linkedItem.Use(deltaTime, activator);
}
//character = activator;
//foreach (MapEntity e in item.linkedTo)
//{
// Item linkedItem = e as Item;
// if (linkedItem == null) continue;
// linkedItem.Use(deltaTime, activator);
//}
ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
item.SendSignal("1", "trigger_out");
ApplyStatusEffects(ActionType.OnUse, 1.0f, activator);
return true;
}
@@ -153,15 +148,43 @@ namespace Subsurface.Items.Components
{
if (character == null) return;
foreach (MapEntity e in item.linkedTo)
foreach (Connection c in item.Connections)
{
Item linkedItem = e as Item;
if (linkedItem == null) continue;
linkedItem.SecondaryUse(deltaTime, character);
if (c.Name != "position_out") continue;
foreach (Connection c2 in c.Recipients)
{
if (c2 == null || c2.Item==null || !c2.Item.Prefab.FocusOnSelected) continue;
Vector2 centerPos = c2.Item.Position;
if (character == Character.Controlled && cam != null)
{
Lights.LightManager.ViewPos = centerPos;
cam.TargetPos = c2.Item.Position;
}
break;
}
}
//foreach (MapEntity e in item.linkedTo)
//{
// Item linkedItem = e as Item;
// if (linkedItem == null) continue;
// linkedItem.SecondaryUse(deltaTime, character);
//}
}
public override bool Pick(Character activator = null)
public override bool Pick(Character picker)
{
item.SendSignal("1", "signal_out");
return true;
}
public override bool Select(Character activator = null)
{
if (character!=null && character.SelectedConstruction == item)
{

View File

@@ -51,10 +51,19 @@ namespace Subsurface.Items.Components
{
base.Update(deltaTime, cam);
pingState = (pingState + deltaTime * 0.5f) % 1.0f;
pingState = (pingState + deltaTime * 0.5f);
if (pingState>1.0f)
{
item.Use(deltaTime,null);
pingState = 0.0f;
}
angle = (angle + deltaTime) % MathHelper.TwoPi;
//angle = (angle + deltaTime) % MathHelper.TwoPi;
}
public override bool Use(float deltaTime, Character character = null)
{
return true;
}
public override void DrawHUD(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Character character)

View File

@@ -34,45 +34,37 @@ namespace Subsurface.Items.Components
{
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);
if (autoPilot || true)
if (autoPilot)
{
steeringPath.GetNode(Vector2.Zero, 5.0f);
if (steeringPath==null)
{
PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
steeringPath = pathFinder.FindPath(
ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
}
steeringPath.GetNode(Vector2.Zero, 20.0f);
if (steeringPath.CurrentNode!=null)
{
Vector2 targetSpeed = steeringPath.CurrentNode.Position;
float prediction = 10.0f;
float dist = targetSpeed.Length();
Vector2 futurePosition = Submarine.Loaded.Speed * prediction;
Vector2 targetSpeed = (steeringPath.CurrentNode.Position - futurePosition);
//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);
TargetVelocity = targetSpeed*100.0f;
}
}
@@ -91,6 +83,13 @@ namespace Subsurface.Items.Components
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
{
autoPilot = !autoPilot;
item.NewComponentEvent(this, true);
}
GUI.DrawLine(spriteBatch,
new Vector2(velRect.Center.X,velRect.Center.Y),
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),
@@ -113,10 +112,10 @@ namespace Subsurface.Items.Components
{
targetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
targetVelocity.Y = -targetVelocity.Y;
item.NewComponentEvent(this, true);
}
}
item.NewComponentEvent(this, true);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
@@ -131,14 +130,19 @@ namespace Subsurface.Items.Components
{
message.Write(targetVelocity.X);
message.Write(targetVelocity.Y);
message.Write(autoPilot);
}
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
{
Vector2 newTargetVelocity = Vector2.Zero;
Vector2 newTargetVelocity = Vector2.Zero;
bool newAutoPilot = false;
try
{
newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
newAutoPilot = message.ReadBoolean();
}
catch
@@ -147,6 +151,7 @@ namespace Subsurface.Items.Components
}
TargetVelocity = newTargetVelocity;
autoPilot = newAutoPilot;
}
}
}

View File

@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -28,26 +29,13 @@ namespace Subsurface.Items.Components
break;
}
}
isActive = true;
}
//public override void Move(Vector2 amount)
//{
// base.Move(amount);
// foreach (Connection c in connections)
// {
// foreach (Wire w in c.wires)
// {
// if (w == null) continue;
// w.Move
// }
// }
//}
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
if (user!=character) return;
if (character != Character.Controlled || character != user) return;
Connection.DrawConnections(spriteBatch, this, character);
}
@@ -76,7 +64,7 @@ namespace Subsurface.Items.Components
if (user != null && user.SelectedConstruction != item) user = null;
}
public override bool Pick(Character picker)
public override bool Select(Character picker)
{
user = picker;
isActive = true;
@@ -107,10 +95,12 @@ namespace Subsurface.Items.Components
{
foreach (Connection c in connections)
{
int wireCount = c.Wires.Length;
for (int i = 0 ; i < wireCount; i++)
Wire[] wires = Array.FindAll(c.Wires, w => w != null);
message.Write((byte)wires.Length);
for (int i = 0 ; i < c.Wires.Length; i++)
{
message.Write(c.Wires[i]==null ? -1 : c.Wires[i].Item.ID);
if (c.Wires[i] == null) continue;
message.Write(c.Wires[i].Item.ID);
}
}
}
@@ -120,23 +110,28 @@ namespace Subsurface.Items.Components
System.Diagnostics.Debug.WriteLine("connectionpanel update");
foreach (Connection c in connections)
{
int wireCount = c.Wires.Length;
//int wireCount = c.Wires.Length;
c.ClearConnections();
for (int i = 0; i < wireCount; i++)
try
{
int wireId = message.ReadInt32();
if (wireId == -1) continue;
byte wireCount = message.ReadByte();
Item wireItem = MapEntity.FindEntityByID(wireId) as Item;
if (wireItem == null) continue;
for (int i = 0; i < wireCount; i++)
{
int wireId = message.ReadInt32();
Item wireItem = MapEntity.FindEntityByID(wireId) as Item;
if (wireItem == null) continue;
Wire wireComponent = wireItem.GetComponent<Wire>();
if (wireComponent == null) continue;
Wire wireComponent = wireItem.GetComponent<Wire>();
if (wireComponent == null) continue;
c.Wires[i] = wireComponent;
wireComponent.Connect(c, false);
c.Wires[i] = wireComponent;
wireComponent.Connect(c, false);
}
}
catch { }
}
}
}

View File

@@ -15,12 +15,12 @@ namespace Subsurface.Items.Components
static Sprite wireSprite;
List<Vector2> nodes;
public List<Vector2> Nodes;
Connection[] connections;
private Vector2 newNodePos;
public Wire(Item item, XElement element)
: base(item, element)
{
@@ -30,7 +30,7 @@ namespace Subsurface.Items.Components
wireSprite.Depth = 0.85f;
}
nodes = new List<Vector2>();
Nodes = new List<Vector2>();
connections = new Connection[2];
}
@@ -38,9 +38,9 @@ namespace Subsurface.Items.Components
public override void Move(Vector2 amount)
{
amount = FarseerPhysics.ConvertUnits.ToDisplayUnits(amount);
for (int i = 0; i<nodes.Count; i++)
for (int i = 0; i<Nodes.Count; i++)
{
nodes[i] += amount;
Nodes[i] += amount;
}
}
@@ -76,11 +76,11 @@ namespace Subsurface.Items.Components
if (i == 0)
{
nodes.Insert(0, newConnection.Item.Position);
Nodes.Insert(0, newConnection.Item.Position);
}
else
{
nodes.Add(newConnection.Item.Position);
Nodes.Add(newConnection.Item.Position);
}
@@ -97,8 +97,7 @@ namespace Subsurface.Items.Components
CleanNodes();
}
//new Networking.NetworkEvent(item.ID, true);
Item.NewComponentEvent(this, true);
}
public override void Equip(Character character)
@@ -117,7 +116,7 @@ namespace Subsurface.Items.Components
public override void Update(float deltaTime, Camera cam)
{
if (nodes.Count == 0) return;
if (Nodes.Count == 0) return;
item.FindHull();
@@ -153,9 +152,9 @@ namespace Subsurface.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (newNodePos!= Vector2.Zero && nodes.Count>0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
if (newNodePos!= Vector2.Zero && Nodes.Count>0 && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
{
nodes.Add(newNodePos);
Nodes.Add(newNodePos);
newNodePos = Vector2.Zero;
}
@@ -166,9 +165,9 @@ namespace Subsurface.Items.Components
public override void SecondaryUse(float deltaTime, Character character = null)
{
if (nodes.Count > 1)
if (Nodes.Count > 1)
{
nodes.RemoveAt(nodes.Count - 1);
Nodes.RemoveAt(Nodes.Count - 1);
item.NewComponentEvent(this, true);
}
}
@@ -182,7 +181,7 @@ namespace Subsurface.Items.Components
private void ClearConnections()
{
nodes.Clear();
Nodes.Clear();
for (int i = 0; i < 2; i++)
{
@@ -198,14 +197,14 @@ namespace Subsurface.Items.Components
private void CleanNodes()
{
for (int i = nodes.Count - 2; i > 0; i--)
for (int i = Nodes.Count - 2; i > 0; i--)
{
if ((nodes[i - 1].X == nodes[i].X || nodes[i - 1].Y == nodes[i].Y) &&
(nodes[i + 1].X == nodes[i].X || nodes[i + 1].Y == nodes[i].Y))
if ((Nodes[i - 1].X == Nodes[i].X || Nodes[i - 1].Y == Nodes[i].Y) &&
(Nodes[i + 1].X == Nodes[i].X || Nodes[i + 1].Y == Nodes[i].Y))
{
if (Vector2.Distance(nodes[i - 1], nodes[i]) == Vector2.Distance(nodes[i + 1], nodes[i]))
if (Vector2.Distance(Nodes[i - 1], Nodes[i]) == Vector2.Distance(Nodes[i + 1], Nodes[i]))
{
nodes.RemoveAt(i);
Nodes.RemoveAt(i);
}
}
}
@@ -214,12 +213,12 @@ namespace Subsurface.Items.Components
do
{
removed = false;
for (int i = nodes.Count - 2; i > 0; i--)
for (int i = Nodes.Count - 2; i > 0; i--)
{
if ((nodes[i - 1].X == nodes[i].X && nodes[i + 1].X == nodes[i].X)
|| (nodes[i - 1].Y == nodes[i].Y && nodes[i + 1].Y == nodes[i].Y))
if ((Nodes[i - 1].X == Nodes[i].X && Nodes[i + 1].X == Nodes[i].X)
|| (Nodes[i - 1].Y == Nodes[i].Y && Nodes[i + 1].Y == Nodes[i].Y))
{
nodes.RemoveAt(i);
Nodes.RemoveAt(i);
removed = true;
}
}
@@ -231,21 +230,21 @@ namespace Subsurface.Items.Components
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (nodes.Count == 0) return;
if (Nodes.Count == 0) return;
//for (int i = 0; i < nodes.Count; i++)
//{
// GUI.DrawRectangle(spriteBatch, new Rectangle((int)nodes[i].X, (int)-nodes[i].Y, 5, 5), Color.DarkGray, true, wireSprite.Depth - 0.01f);
//}
for (int i = 1; i < nodes.Count; i++)
for (int i = 1; i < Nodes.Count; i++)
{
DrawSection(spriteBatch, nodes[i], nodes[i - 1], i, Color.White);
DrawSection(spriteBatch, Nodes[i], Nodes[i - 1], i, Color.White);
}
if (isActive && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
if (isActive && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
{
DrawSection(spriteBatch, nodes[nodes.Count - 1], newNodePos, nodes.Count, Color.White * 0.5f);
DrawSection(spriteBatch, Nodes[Nodes.Count - 1], newNodePos, Nodes.Count, Color.White * 0.5f);
//nodes.Add(newNodePos);
}
@@ -269,13 +268,13 @@ namespace Subsurface.Items.Components
{
XElement componentElement = base.Save(parentElement);
if (nodes == null || nodes.Count == 0) return componentElement;
if (Nodes == null || Nodes.Count == 0) return componentElement;
string[] nodeCoords = new string[nodes.Count() * 2];
for (int i = 0; i < nodes.Count(); i++)
string[] nodeCoords = new string[Nodes.Count() * 2];
for (int i = 0; i < Nodes.Count(); i++)
{
nodeCoords[i * 2] = nodes[i].X.ToString(CultureInfo.InvariantCulture);
nodeCoords[i * 2 + 1] = nodes[i].Y.ToString(CultureInfo.InvariantCulture);
nodeCoords[i * 2] = Nodes[i].X.ToString(CultureInfo.InvariantCulture);
nodeCoords[i * 2 + 1] = Nodes[i].Y.ToString(CultureInfo.InvariantCulture);
}
componentElement.Add(new XAttribute("nodes", string.Join(";", nodeCoords)));
@@ -307,28 +306,28 @@ namespace Subsurface.Items.Components
}
catch { y = 0.0f; }
nodes.Add(new Vector2(x, y));
Nodes.Add(new Vector2(x, y));
}
}
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
{
message.Write(nodes.Count);
for (int i = 0; i < nodes.Count; i++)
message.Write(Nodes.Count);
for (int i = 0; i < Nodes.Count; i++)
{
message.Write(nodes[i].X);
message.Write(nodes[i].Y);
message.Write(Nodes[i].X);
message.Write(Nodes[i].Y);
}
}
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
{
nodes.Clear();
Nodes.Clear();
int nodeCount = message.ReadInt32();
for (int i = 0; i < nodeCount; i++)
{
nodes.Add(new Vector2(message.ReadFloat(), message.ReadFloat()));
Nodes.Add(new Vector2(message.ReadFloat(), message.ReadFloat()));
}
}
}

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FarseerPhysics;
namespace Subsurface.Items.Components
{
@@ -13,14 +14,11 @@ namespace Subsurface.Items.Components
Vector2 barrelPos;
float targetRotation;
float rotation;
float rotation, targetRotation;
float reload;
float reloadTime;
float reload, reloadTime;
float minRotation;
float maxRotation;
float minRotation, maxRotation;
float launchImpulse;
@@ -53,12 +51,16 @@ namespace Subsurface.Items.Components
set { reloadTime = value; }
}
[HasDefaultValue("0.0,0.0", false)]
[HasDefaultValue("0.0,0.0", true)]
public string RotationLimits
{
get
{
return ToolBox.Vector2ToString(barrelPos);
Vector2 limits = new Vector2(minRotation, maxRotation);
limits.X = MathHelper.ToDegrees(limits.X);
limits.Y = MathHelper.ToDegrees(limits.Y);
return ToolBox.Vector2ToString(limits);
}
set
{
@@ -75,35 +77,15 @@ namespace Subsurface.Items.Components
barrelSprite = new Sprite(Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\" +element.Attribute("barrelsprite").Value,
ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero));
//barrelPos = ToolBox.GetAttributeVector2(element, "BarrelPos", Vector2.Zero);
//launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 0.0f);
//minRotation = ToolBox.GetAttributeFloat(element, "MinimumRotation", 0.0f);
//maxRotation = ToolBox.GetAttributeFloat(element, "MaximumRotation", MathHelper.TwoPi);
//reloadTime = ToolBox.GetAttributeFloat(element, "reload", 5.0f);
}
public override void Draw(SpriteBatch spriteBatch)
{
barrelSprite.Draw(spriteBatch, new Vector2(item.Rect.X, -item.Rect.Y) + barrelPos, rotation + MathHelper.PiOver2, 1.0f);
//GUI.DrawRectangle(spriteBatch,
// new Rectangle((int)(rect.X + barrelPos.X), (int)(-rect.Y + barrelPos.Y), 10, 10),
// Color.White, true);
}
public override void Update(float deltaTime, Camera cam)
{
//if (character == null || character.SelectedConstruction != item)
//{
// character = null;
// isActive = false;
// return;
//}
this.cam = cam;
if (reload>0.0f) reload -= deltaTime;
@@ -117,30 +99,22 @@ namespace Subsurface.Items.Components
}
rotation = MathUtils.CurveAngle(rotation, targetRotation, 0.05f);
//if (!prefab.FocusOnSelected) return;
//cam.OffsetAmount = prefab.OffsetOnSelected;
}
public override void SecondaryUse(float deltaTime, Character character = null)
{
if (character == null) return;
Vector2 centerPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
//public override void SecondaryUse(float deltaTime, Character character = null)
//{
// if (character == null) return;
// Vector2 centerPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
Vector2 offset = character.CursorPosition - centerPos;
offset.Y = -offset.Y;
targetRotation = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(offset));
isActive = true;
if (character == Character.Controlled && cam!=null)
{
Lights.LightManager.ViewPos = centerPos;
cam.TargetPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
}
}
// if (character == Character.Controlled && cam!=null)
// {
// Lights.LightManager.ViewPos = centerPos;
// cam.TargetPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
// }
//}
public override bool Use(float deltaTime, Character character = null)
{
@@ -148,23 +122,25 @@ namespace Subsurface.Items.Components
Projectile projectileComponent = null;
currPowerConsumption = powerConsumption;
//currPowerConsumption = powerConsumption;
float availablePower = 0.0f;
//List<PowerContainer> batteries = new List<PowerContainer>();
foreach (MapEntity e in item.linkedTo)
foreach (Connection c in item.Connections)
{
Item battery = e as Item;
if (battery == null) continue;
foreach (Connection c2 in c.Recipients)
{
if (c2 == null || c2.Item == null) continue;
PowerContainer batteryComponent = battery.GetComponent<PowerContainer>();
if (batteryComponent == null) continue;
PowerContainer batteryComponent = c2.Item.GetComponent<PowerContainer>();
if (batteryComponent == null) continue;
float batteryPower = Math.Min(batteryComponent.Charge, batteryComponent.MaxOutPut);
float takePower = Math.Min(currPowerConsumption - availablePower, batteryPower);
float batteryPower = Math.Min(batteryComponent.Charge, batteryComponent.MaxOutPut);
float takePower = Math.Min(currPowerConsumption - availablePower, batteryPower);
batteryComponent.Charge -= takePower;
availablePower += takePower;
batteryComponent.Charge -= takePower;
availablePower += takePower;
}
}
reload = reloadTime;
@@ -198,7 +174,7 @@ namespace Subsurface.Items.Components
projectile.body.ResetDynamics();
projectile.body.Enabled = true;
projectile.SetTransform(item.SimPosition, rotation);
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y)), -rotation);
//if (useSounds.Count() > 0) useSounds[Game1.localRandom.Next(useSounds.Count())].Play(1.0f, 800.0f, item.body.FarseerBody);
@@ -207,6 +183,29 @@ namespace Subsurface.Items.Components
return true;
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
{
switch (connection.Name)
{
case "position_in":
Vector2 receivedPos = ToolBox.ParseToVector2(signal, false);
Vector2 centerPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
Vector2 offset = receivedPos - centerPos;
offset.Y = -offset.Y;
targetRotation = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(offset));
isActive = true;
break;
case "trigger_in":
item.Use((float)Physics.step, null);
break;
}
}
}
}

View File

@@ -134,20 +134,17 @@ namespace Subsurface
}
}
//protected virtual void DropItem(Item item)
//{
// for (int i = 0; i < capacity; i++)
// {
// if (items[i] == item) items[i] = null;
// }
// item.Drop();
// return;
//}
//public void DropItem(int i)
//{
// items[i].Drop();
// items[i] = null;
//}
protected virtual void DropItem(Item item)
{
item.Drop(null, false);
return;
}
public void DropItem(int i)
{
items[i].Drop();
items[i] = null;
}
public virtual void Draw(SpriteBatch spriteBatch)
{
@@ -188,12 +185,10 @@ namespace Subsurface
}
else
{
draggingItem.Drop(null, false);
int[] data = { draggingItem.ID, -1 };
new NetworkEvent(NetworkEventType.InventoryUpdate, ID, true, data);
//draggingItem = null;
DropItem(draggingItem);
}
}
}

View File

@@ -734,9 +734,8 @@ namespace Subsurface
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))
if (!ic.HasRequiredItems(picker, picker == Character.Controlled) && !forcePick) continue;
if ((ic.CanBePicked && ic.Pick(picker)) || (ic.CanBeSelected && ic.Select(picker)))
{
picked = true;
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);

View File

@@ -13,6 +13,13 @@ namespace Subsurface
this.container = container;
}
protected override void DropItem(Item item)
{
item.Drop();
item.body.Enabled = true;
item.body.SetTransform(container.Item.SimPosition, 0.0f);
}
public override int FindAllowedSlot(Item item)
{
for (int i = 0; i < capacity; i++)

View File

@@ -13,7 +13,7 @@ namespace Subsurface
None = 0,
Contained = 1,
Equipped = 2,
Picked = 3
Picked = 4
}
string[] names;

View File

@@ -74,7 +74,7 @@ namespace Subsurface
public Vector2 Position
{
get { return ConvertUnits.ToDisplayUnits(cells[1].body.Position); }
get { return ConvertUnits.ToDisplayUnits(cells[0].body.Position); }
}
public string Seed
@@ -546,11 +546,10 @@ int currentTargetIndex = 1;
List<Vector2> tempVertices = new List<Vector2>();
List<Vector2> bodyPoints = new List<Vector2>();
int n = 0;
foreach (VoronoiCell cell in cells)
for (int n = cells.Count - 1; n >= 0; n-- )
{
n = (n + 30) % 255;
VoronoiCell cell = cells[n];
bodyPoints.Clear();
tempVertices.Clear();
foreach (GraphEdge ge in cell.edges)
@@ -568,14 +567,18 @@ int currentTargetIndex = 1;
if (!bodyPoints.Contains(ge.point2)) bodyPoints.Add(ge.point2);
}
if (tempVertices.Count < 3) continue;
if (tempVertices.Count < 3 || bodyPoints.Count < 2)
{
cells.RemoveAt(n);
continue;
}
var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
for (int i = 0; i < triangles.Count; i++ )
for (int i = 0; i < triangles.Count; i++)
{
foreach (Vector2 vertex in triangles[i])
{
verticeList.Add(new VertexPositionColor(new Vector3(vertex, 0.0f), new Color(n,(n*2)%255,(n*3)%255)*0.5f));
verticeList.Add(new VertexPositionColor(new Vector3(vertex, 0.0f), new Color(n*30, (n * 60) % 255, (n * 90) % 255) * 0.5f));
}
}
@@ -584,7 +587,7 @@ int currentTargetIndex = 1;
if (bodyPoints.Count < 3)
{
foreach(Vector2 vertex in tempVertices)
foreach (Vector2 vertex in tempVertices)
{
if (bodyPoints.Contains(vertex)) continue;
bodyPoints.Add(vertex);
@@ -608,7 +611,7 @@ int currentTargetIndex = 1;
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);
FixtureFactory.AttachPolygon(bodyVertices, 5.0f, edgeBody);
}
edgeBody.UserData = cell;
@@ -655,8 +658,8 @@ int currentTargetIndex = 1;
Item item = mapEntity as Item;
if (item == null)
{
if (!mapEntity.MoveWithLevel) continue;
mapEntity.Move(amount);
//if (!mapEntity.MoveWithLevel) continue;
//mapEntity.Move(amount);
}
else if (item.body != null)
{
@@ -692,8 +695,8 @@ int currentTargetIndex = 1;
Item item = mapEntity as Item;
if (item == null)
{
if (!mapEntity.MoveWithLevel) continue;
mapEntity.Move(velocity);
//if (!mapEntity.MoveWithLevel) continue;
//mapEntity.Move(velocity);
}
else if (item.body!=null)
{

View File

@@ -61,13 +61,16 @@ namespace Subsurface
get { return false; }
}
public Vector2 Position
public virtual Vector2 Position
{
get
{
return new Vector2(
Vector2 rectPos = new Vector2(
rect.X + rect.Width / 2.0f,
rect.Y - rect.Height / 2.0f);
if (MoveWithLevel) rectPos += Level.Loaded.Position;
return rectPos;
}
}

View File

@@ -40,7 +40,6 @@ namespace Subsurface
Vector2 speed;
Vector2 targetPosition;
Vector2 targetSpeed;
private Rectangle borders;
@@ -417,7 +416,7 @@ namespace Subsurface
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, Position) > 5.0f)
{
translateAmount += (targetPosition - Position) * 0.05f;
translateAmount += (targetPosition - Position) * 0.01f;
}
else
{
@@ -583,6 +582,7 @@ namespace Subsurface
return;
}
newTargetPosition = newTargetPosition + newSpeed * (float)(NetTime.Now - sendingTime);
targetPosition = newTargetPosition;
speed = newSpeed;
@@ -818,20 +818,16 @@ namespace Subsurface
hullBody.GravityScale = 0.0f;
hullBody.OnCollision += OnCollision;
hullBody.OnSeparation += OnSeparation;
//body.IsSensor = true;
//body.SetTransform();
//HullBody hullBody = new HullBody();
//hullBody.body = body;
////hullBody.shapeTexture = GUI.CreateRectangle(borders.Width, borders.Height);
//hullBodies = new List<HullBody>();
//hullBodies.Add(hullBody);
MapEntity.LinkAll();
foreach (Item item in Item.itemList)
{
foreach (ItemComponent ic in item.components)
{
ic.OnMapLoaded();
}
}
ID = int.MaxValue-10;

View File

@@ -42,11 +42,6 @@ namespace Subsurface
}
}
public override Vector2 SimPosition
{
get { return ConvertUnits.ToSimUnits(new Vector2(rect.X, rect.Y)); }
}
public WayPoint(Rectangle newRect)
{
rect = newRect;
@@ -61,14 +56,16 @@ namespace Subsurface
{
//if (!editing) return;
Point pos = new Point((int)Position.X, (int)Position.Y);
Color clr = (isSelected) ? Color.Red : Color.LightGreen;
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr, true);
GUI.DrawRectangle(spriteBatch, new Rectangle(pos.X, -pos.Y, rect.Width, rect.Height), clr, true);
foreach (MapEntity e in linkedTo)
{
GUI.DrawLine(spriteBatch,
new Vector2(rect.X + rect.Width / 2, -rect.Y + rect.Height / 2),
new Vector2(e.Rect.X + e.Rect.Width / 2, -e.Rect.Y + e.Rect.Height / 2),
new Vector2(pos.X, -pos.Y),
new Vector2(e.Position.X + e.Rect.Width / 2, -e.Position.Y + e.Rect.Height / 2),
Color.Green);
}
}

View File

@@ -132,7 +132,8 @@ namespace Subsurface.Networking
{
// All manually sent messages are type of "Data"
case NetIncomingMessageType.Data:
if (inc.ReadByte() == (byte)PacketTypes.LoggedIn)
byte packetType = inc.ReadByte();
if (packetType == (byte)PacketTypes.LoggedIn)
{
myID = inc.ReadInt32();
@@ -152,7 +153,7 @@ namespace Subsurface.Networking
CanStart = true;
}
else if (inc.ReadByte() == (byte)PacketTypes.KickedOut)
else if (packetType == (byte)PacketTypes.KickedOut)
{
string msg = inc.ReadString();
DebugConsole.ThrowError(msg);
@@ -199,6 +200,7 @@ namespace Subsurface.Networking
SendRandomData();
}
if (gameStarted) inGameHUD.Update((float)Physics.step);
if (!connected || updateTimer > DateTime.Now) return;

View File

@@ -21,6 +21,9 @@ namespace Subsurface.Networking
public GameServer()
{
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 170-120, 20, 150, 25), "End round", Alignment.TopLeft, GUI.style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
name = "Server";
Config = new NetPeerConfiguration("subsurface");
@@ -49,13 +52,11 @@ namespace Subsurface.Networking
updateInterval = new TimeSpan(0, 0, 0, 0, 30);
DebugConsole.NewMessage("Server started", Color.Green);
}
public override void Update()
{
// Server.ReadMessage() Returns new messages, that have not yet been read.
// If "inc" is null -> ReadMessage returned null -> Its null, so dont do this :)
if (gameStarted) inGameHUD.Update((float)Physics.step);
NetIncomingMessage inc = Server.ReadMessage();
if (inc != null)
@@ -84,6 +85,30 @@ namespace Subsurface.Networking
}
}
private void SparseUpdate()
{
foreach (Character c in Character.CharacterList)
{
bool isClient = false;
foreach (Client client in connectedClients)
{
if (client.character != c) continue;
isClient = true;
break;
}
if (!isClient)
{
c.LargeUpdateTimer = 0;
new NetworkEvent(c.ID, false);
}
}
new NetworkEvent(Submarine.Loaded.ID, false);
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
}
private void ReadMessage(NetIncomingMessage inc)
{
NetOutgoingMessage outmsg;
@@ -224,30 +249,6 @@ namespace Subsurface.Networking
}
}
private void SparseUpdate()
{
foreach (Character c in Character.CharacterList)
{
bool isClient = false;
foreach (Client client in connectedClients)
{
if (client.character != c) continue;
isClient = true;
break;
}
if (!isClient)
{
c.LargeUpdateTimer = 0;
new NetworkEvent(c.ID, false);
}
}
new NetworkEvent(Submarine.Loaded.ID, false);
sparseUpdateTimer = DateTime.Now + SparseUpdateInterval;
}
private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection)
{
List<NetConnection> recipients = new List<NetConnection>();
@@ -296,7 +297,6 @@ namespace Subsurface.Networking
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
//selectedMap.Load();
Game1.GameSession = new GameSession(selectedMap, Game1.NetLobbyScreen.SelectedMode);
@@ -378,6 +378,13 @@ namespace Subsurface.Networking
return true;
}
private bool EndButtonHit(GUIButton button, object obj)
{
Game1.GameSession.gameMode.End("The round has ended");
return true;
}
public void EndGame(string endMessage)
{
Submarine.Unload();

View File

@@ -1,5 +1,6 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface.Networking
{
@@ -93,12 +94,17 @@ namespace Subsurface.Networking
Alignment.Left, null, null, true);
msg.Padding = new Vector4(20.0f, 0, 0, 0);
chatBox.AddChild(msg);
while (chatBox.CountChildren > 20)
{
chatBox.RemoveChild(chatBox.children[0]);
}
//float prevScroll = chatBox.BarScroll;
//chatBox.AddChild(msg);
//while (chatBox.CountChildren > 20)
//{
// chatBox.RemoveChild(chatBox.children[0]);
//}
//if (prevScroll == 1.0f) chatBox.BarScroll = 1.0f;
GUI.PlayMessageSound();
}
@@ -107,6 +113,13 @@ namespace Subsurface.Networking
public virtual void Update() { }
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!gameStarted) return;
inGameHUD.Draw(spriteBatch);
}
public virtual void Disconnect() { }
}

View File

@@ -30,16 +30,7 @@ namespace Subsurface
this.isSaveable = isSaveable;
}
}
//[AttributeUsage(AttributeTargets.Property)]
//public class Saveable : Initable
//{
// public Saveable(object defaultValue)
// :base(defaultValue)
// {
// }
//}
class ObjectProperty
{
readonly PropertyDescriptor property;

View File

@@ -31,9 +31,6 @@ namespace Subsurface
private float camAngle;
//private Body previewPlatform;
//private Hull previewHull;
public bool IsServer;
public Submarine SelectedMap
@@ -112,7 +109,7 @@ namespace Subsurface
GUI.style, menu);
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 0, 0, 25), Alignment.Bottom, GUI.style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 25, 0, 25), Alignment.Bottom, GUI.style, chatFrame);
textBox.OnEnter = EnterChatMessage;
//player info panel ------------------------------------------------------------
@@ -135,18 +132,6 @@ namespace Subsurface
public override void Deselect()
{
textBox.Deselect();
//if (previewPlatform!=null)
//{
// Game1.World.RemoveBody(previewPlatform);
// previewPlatform = null;
//}
//if (previewHull!=null)
//{
// previewHull.Remove();
// previewHull = null;
//}
}
public override void Select()
@@ -186,7 +171,6 @@ namespace Subsurface
new GUITextBlock(new Rectangle(220, 30, 0, 30), "Selected game mode: ", GUI.style, infoFrame);
modeList = new GUIListBox(new Rectangle(220, 60, 200, 200), GUI.style, infoFrame);
modeList.Enabled = (Game1.Server != null);
//modeList.OnSelected = new GUIListBox.OnSelectedHandler(SelectEvent);
foreach (GameModePreset mode in GameModePreset.list)
{
@@ -324,7 +308,8 @@ namespace Subsurface
public override void Update(double deltaTime)
{
base.Update(deltaTime);
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
Vector2 pos = new Vector2(
@@ -342,7 +327,7 @@ namespace Subsurface
menu.Update((float)deltaTime);
durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f);
//durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f);
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
@@ -361,31 +346,13 @@ namespace Subsurface
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);
// 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();
// }
//}
}
public void NewChatMessage(string message, Color color)
{
float prevSize = chatBox.BarSize;
float oldScroll = chatBox.BarScroll;
GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, 0, 20),
message,
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
@@ -393,6 +360,8 @@ namespace Subsurface
msg.Padding = new Vector4(20, 0, 0, 0);
chatBox.AddChild(msg);
if ((prevSize == 1.0f && chatBox.BarScroll == 0.0f) || (prevSize < 1.0f && chatBox.BarScroll == 1.0f)) chatBox.BarScroll = 1.0f;
}

View File

@@ -659,6 +659,9 @@
<None Include="Content\effects.mgfx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Engine\radarPing.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Reactor\reactor.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@@ -9,6 +9,6 @@
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>

Binary file not shown.