Launcher bugfixes, fixed submarine position syncing, previewing the sub after round ends, wiring bugfix, slower reactor overheat, itemlabel, wifi components

This commit is contained in:
Regalis
2015-08-21 20:21:22 +03:00
parent c044d27071
commit d8904eaa56
43 changed files with 546 additions and 228 deletions

View File

@@ -17,7 +17,6 @@ namespace Launcher
{
public partial class LauncherMain : Form
{
public static string ContentPackageFolder = "Data/ContentPackages/";
private const string configPath = "config.xml";
private Subsurface.GameSettings settings;
@@ -42,7 +41,7 @@ namespace Launcher
{
InitializeComponent();
ContentPackage.LoadAll(LauncherMain.ContentPackageFolder);
ContentPackage.LoadAll(ContentPackage.Folder);
contentPackageBox.DataSource = ContentPackage.list;
supportedModes = new List<GraphicsMode>();

View File

@@ -102,6 +102,7 @@
this.itemList.Name = "itemList";
this.itemList.Size = new System.Drawing.Size(255, 134);
this.itemList.TabIndex = 8;
this.itemList.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.fileList_KeyPress);
//
// itemButton
//
@@ -161,6 +162,7 @@
this.structureList.Name = "structureList";
this.structureList.Size = new System.Drawing.Size(255, 121);
this.structureList.TabIndex = 8;
this.structureList.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.fileList_KeyPress);
//
// structureButton
//
@@ -189,6 +191,7 @@
this.jobList.Name = "jobList";
this.jobList.Size = new System.Drawing.Size(255, 134);
this.jobList.TabIndex = 11;
this.jobList.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.fileList_KeyPress);
//
// label4
//

View File

@@ -142,7 +142,7 @@ namespace Launcher
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "XML files (*.xml)|*.xml;*.XML";
//ofd.RestoreDirectory?
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
@@ -253,7 +253,7 @@ namespace Launcher
private void okButton_Click(object sender, EventArgs e)
{
if (selectedPackage!=null) selectedPackage.Save(LauncherMain.ContentPackageFolder);
if (selectedPackage!=null) selectedPackage.Save(ContentPackage.Folder);
this.Close();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

View File

@@ -185,7 +185,7 @@
linkable="true"
price="10">
<Sprite texture ="light.png" depth="0.8"/>
<Sprite texture ="regex.png" depth="0.8"/>
<RegExFindComponent canbeselected = "true"/>
@@ -203,5 +203,30 @@
</ConnectionPanel>
</Item>
<Item
name="Wifi Component"
Tags="smallitem"
pickdistance="150"
linkable="true"
price="20">
<Sprite texture ="wifi.png" depth="0.8"/>
<WifiComponent canbeselected = "true"/>
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
</ConnectionPanel>
</Item>
</Items>

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

View File

@@ -34,6 +34,8 @@
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<output name="power_out"/>
<output name="temperature_out"/>
<input name="shutdown"/>
</ConnectionPanel>
<ItemContainer capacity="5">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<Item
name="Label"
resizehorizontal="true"
resizevertical="true">
<Sprite texture ="blank.png" depth="0.85"/>
<ItemLabel/>
</Item>

View File

@@ -18,12 +18,13 @@ namespace Subsurface
private Vector2 position;
private float rotation;
private Vector2 prevPosition;
private float prevZoom;
public float Shake;
private Vector2 shakePosition;
private Vector2 shakeTargetPosition;
//the area of the world inside the camera view
private Rectangle worldView;
@@ -130,9 +131,9 @@ namespace Subsurface
private void UpdateTransform()
{
Vector2 interpolatedPosition = position;//Physics.Interpolate(prevPosition,position);
Vector2 interpolatedPosition = Physics.Interpolate(prevPosition, position);
float interpolatedZoom = zoom;// Physics.Interpolate(prevZoom, zoom);
float interpolatedZoom = Physics.Interpolate(prevZoom, zoom);
worldView.X = (int)(interpolatedPosition.X - worldView.Width / 2.0);
worldView.Y = (int)(interpolatedPosition.Y + worldView.Height / 2.0);
@@ -154,13 +155,19 @@ namespace Subsurface
{
float moveSpeed = 20.0f/zoom;
prevPosition = position;
prevZoom = zoom;
Vector2 moveCam = Vector2.Zero;
if (targetPos == Vector2.Zero)
{
if (Keyboard.GetState().IsKeyDown(Keys.A)) moveCam.X -= moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.D)) moveCam.X += moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.S)) moveCam.Y -= moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.W)) moveCam.Y += moveSpeed;
if (PlayerInput.KeyDown(Keys.A)) moveCam.X -= moveSpeed;
if (PlayerInput.KeyDown(Keys.D)) moveCam.X += moveSpeed;
if (PlayerInput.KeyDown(Keys.S)) moveCam.Y -= moveSpeed;
if (PlayerInput.KeyDown(Keys.W)) moveCam.Y += moveSpeed;
moveCam = moveCam * deltaTime * 60.0f;
Zoom = MathHelper.Clamp(Zoom + PlayerInput.ScrollWheelSpeed / 1000.0f, 0.1f, 2.0f);
}
@@ -179,15 +186,26 @@ namespace Subsurface
float newZoom = Math.Min(DefaultZoom - Math.Min(offset.Length() / resolution.Y, 1.0f),1.0f);
Zoom += (newZoom - zoom) / ZoomSmoothness;
moveCam = (targetPos + offset - position) / MoveSmoothness;
Vector2 diff = (targetPos + offset) - position;
if (diff == Vector2.Zero)
{
moveCam = Vector2.Zero;
}
else
{
float dist = diff == Vector2.Zero ? 0.0f : diff.Length();
moveCam = Vector2.Normalize(diff) * Math.Min(dist, (dist * deltaTime * 60.0f) / MoveSmoothness);
}
}
shakeTargetPosition = Rand.Vector(Shake);
shakePosition = Vector2.Lerp(shakePosition, shakeTargetPosition, 0.5f);
Shake = MathHelper.Lerp(Shake, 0.0f, 0.03f);
Translate((moveCam+shakePosition)*deltaTime*60.0f);
Translate(moveCam+shakePosition);
}
public Vector2 Position

View File

@@ -36,7 +36,7 @@ namespace Subsurface
private CharacterInventory inventory;
public double LastNetworkUpdate;
public float LastNetworkUpdate;
public int LargeUpdateTimer;
@@ -1037,7 +1037,7 @@ namespace Subsurface
message.Write(secondaryKeyDown.Dequeue);
//}
message.Write(NetTime.Now);
message.Write((float)NetTime.Now);
// Write byte = move direction
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -10.0f, 10.0f), -10.0f, 10.0f, 8);
@@ -1132,7 +1132,7 @@ namespace Subsurface
bool actionKeyState = false;
bool secondaryKeyState = false;
double sendingTime = 0.0f;
float sendingTime = 0.0f;
Vector2 targetMovement = Vector2.Zero;
bool targetDir = false;
Vector2 cursorPos = Vector2.Zero;
@@ -1142,7 +1142,7 @@ namespace Subsurface
actionKeyState = message.ReadBoolean();
secondaryKeyState = message.ReadBoolean();
sendingTime = message.ReadDouble();
sendingTime = message.ReadFloat();
targetMovement = new Vector2(message.ReadRangedSingle(-10.0f, 10.0f, 8), message.ReadRangedSingle(-10.0f, 10.0f, 8));
targetMovement.X = MathUtils.Round(targetMovement.X, 0.1f);

View File

@@ -15,6 +15,9 @@ namespace Subsurface
public class ContentPackage
{
public static string Folder = "Data/ContentPackages/";
public static List<ContentPackage> list = new List<ContentPackage>();
@@ -80,6 +83,7 @@ namespace Subsurface
{
ContentPackage newPackage = new ContentPackage();
newPackage.name = name;
newPackage.Path = Folder + name;
list.Add(newPackage);
return newPackage;

View File

@@ -136,11 +136,13 @@ namespace Subsurface
public static void ExecuteCommand(string command, Game1 game)
{
#if !DEBUG
if (Game1.Client!=null)
{
ThrowError("Console commands are disabled in multiplayer mode");
return;
}
#endif
if (command == "") return;
string[] commands = command.Split(' ');

View File

@@ -301,8 +301,16 @@ namespace Subsurface
spriteBatch.DrawString(Font,
"Physics: " + Game1.World.UpdateTime
+ " - bodies: " + Game1.World.BodyList.Count
+ "Camera pos: " + Game1.GameScreen.Cam.Position,
+ " Camera pos: " + Game1.GameScreen.Cam.Position,
new Vector2(10, 30), Color.White);
if (Submarine.Loaded!=null)
{
spriteBatch.DrawString(Font,
"Sub pos: " + Submarine.Loaded.Position,
new Vector2(10, 50), Color.White);
}
}

View File

@@ -15,6 +15,12 @@ namespace Subsurface
//GUIFrame frame;
public GUIButton[] Buttons;
public string Text
{
get { return (children[1] as GUITextBlock).Text; }
set { (children[1] as GUITextBlock).Text = value; }
}
public GUIMessageBox(string header, string text)
: this(header, text, new string[] {"OK"})
{

View File

@@ -120,11 +120,7 @@ namespace Subsurface
if (parent != null)
parent.AddChild(this);
//if (wrap)
//{
this.Wrap = wrap;
// this.text = ToolBox.WrapText(this.text, rect.Width);
//}
this.Wrap = wrap;
SetTextPos();
}
@@ -138,7 +134,7 @@ namespace Subsurface
if (Wrap && rect.Width>0)
{
//text = text.Replace("\n"," ");
text = ToolBox.WrapText(text, rect.Width, Font);
text = ToolBox.WrapText(text, rect.Width - padding.X - padding.Z, Font);
Vector2 newSize = MeasureText(text);

View File

@@ -146,6 +146,7 @@ namespace Subsurface
public void Deselect()
{
Selected = false;
if (keyboardDispatcher.Subscriber == this) keyboardDispatcher.Subscriber = null;
}

View File

@@ -265,7 +265,7 @@ namespace Subsurface
DebugConsole.Update(this, (float)deltaTime);
if ((!DebugConsole.IsOpen && !GUI.PauseMenuOpen) || NetworkMember != null) Screen.Selected.Update(deltaTime);
if ((!DebugConsole.IsOpen && !GUI.PauseMenuOpen) || (NetworkMember != null && NetworkMember.GameStarted)) Screen.Selected.Update(deltaTime);
GUI.Update((float)deltaTime);

View File

@@ -132,7 +132,7 @@ namespace Subsurface
if (Game1.Server!=null)
{
Game1.Server.EndGame(endMessage);
CoroutineManager.StartCoroutine(Game1.Server.EndGame(endMessage));
}
else if (Game1.Client==null)

View File

@@ -119,7 +119,6 @@ namespace Subsurface.Items.Components
(int)doorSprite.size.X,
(int)doorSprite.size.Y);
body = new PhysicsBody(BodyFactory.CreateRectangle(Game1.World,
ConvertUnits.ToSimUnits(Math.Max(doorRect.Width, 1)),
ConvertUnits.ToSimUnits(Math.Max(doorRect.Height, 1)),

View File

@@ -101,7 +101,7 @@ namespace Subsurface.Items.Components
Msg = "";
}
if (attachedByDefault) Use(1.0f);
if (attachedByDefault || Screen.Selected == Game1.EditMapScreen) Use(1.0f);
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);

View File

@@ -0,0 +1,66 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class ItemLabel : ItemComponent
{
private GUITextBlock textBlock;
[HasDefaultValue("", true), Editable(100)]
public string Text
{
get { return textBlock.Text; }
set
{
if (value == TextBlock.Text || item.Rect.Width < 5) return;
TextBlock.Text = value;
}
}
private Color textColor;
[Editable, HasDefaultValue("0.0,0.0,0.0,1.0", true)]
public string TextColor
{
get { return ToolBox.Vector4ToString(textColor.ToVector4()); }
set
{
textColor = new Color(ToolBox.ParseToVector4(value));
}
}
private GUITextBlock TextBlock
{
get
{
if (textBlock==null)
{
textBlock = new GUITextBlock(new Rectangle(item.Rect.X,-item.Rect.Y,item.Rect.Width, item.Rect.Height), "",
Color.Transparent, Color.Black,
Alignment.TopLeft, Alignment.Center,
null, null, true);
textBlock.Font = GUI.SmallFont;
textBlock.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
}
return textBlock;
}
}
public override void Move(Vector2 amount)
{
textBlock.Rect = new Rectangle(item.Rect.X, -item.Rect.Y, item.Rect.Width, item.Rect.Height);
}
public ItemLabel(Item item, XElement element)
: base(item, element)
{
}
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch, editing);
textBlock.Draw(spriteBatch);
}
}
}

View File

@@ -140,7 +140,7 @@ namespace Subsurface.Items.Components
float heat = 100 * fissionRate * (AvailableFuel/2000.0f);
float heatDissipation = 50 * coolingRate + ExtraCooling;
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 1000.0f;
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
Temperature = temperature + deltaTemp;
if (temperature > meltDownTemp)
@@ -155,8 +155,7 @@ namespace Subsurface.Items.Components
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor");
}
}
item.Condition -= temperature * deltaTime * 0.00005f;
if (temperature > shutDownTemp)
@@ -201,8 +200,7 @@ namespace Subsurface.Items.Components
//fission rate can't be lowered below a certain amount if the core is too hot
FissionRate = Math.Max(fissionRate, heat / 200.0f);
//the power generated by the reactor is equal to the temperature
currPowerConsumption = -temperature*powerPerTemp;
@@ -216,6 +214,8 @@ namespace Subsurface.Items.Components
ExtraCooling = 0.0f;
AvailableFuel = 0.0f;
item.SendSignal(((int)temperature).ToString(), "temperature_out");
}
public override void UpdateBroken(float deltaTime, Camera cam)
@@ -402,6 +402,16 @@ namespace Subsurface.Items.Components
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.White);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
{
switch (connection.Name)
{
case "shutdown":
shutDownTemp = 0.0f;
break;
}
}
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message)
{
message.Write(autoTemp);

View File

@@ -319,14 +319,13 @@ namespace Subsurface.Items.Components
if (index>-1)
{
Wires[index].RemoveConnection(this);
Wires[index].Item.SetTransform(item.SimPosition, 0.0f);
Wires[index].Item.Drop();
Wires[index].Item.body.Enabled = true;
//Wires[index].Item.SetTransform(item.SimPosition, 0.0f);
//Wires[index].Item.Drop();
//Wires[index].Item.body.Enabled = true;
Wires[index] = null;
}
}
}
}
}

View File

@@ -9,6 +9,8 @@ namespace Subsurface.Items.Components
private string expression;
private string receivedSignal;
[InGameEditable, HasDefaultValue("1", true)]
public string Output
{
@@ -26,6 +28,27 @@ namespace Subsurface.Items.Components
public RegExFindComponent(Item item, XElement element)
: base(item, element)
{
isActive = true;
}
public override void Update(float deltaTime, Camera cam)
{
if (string.IsNullOrWhiteSpace(expression)) return;
bool success = false;
try
{
Regex regex = new Regex(@expression);
Match match = regex.Match(receivedSignal);
success = match.Success;
}
catch
{
item.SendSignal("ERROR", "signal_out");
return;
}
item.SendSignal(success ? output : "0", "signal_out");
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0.0f)
@@ -33,22 +56,7 @@ namespace Subsurface.Items.Components
switch (connection.Name)
{
case "signal_in":
if (string.IsNullOrWhiteSpace(expression)) return;
bool success = false;
try
{
Regex regex = new Regex(@expression);
Match match = regex.Match(signal);
success = match.Success;
}
catch
{
item.SendSignal("ERROR", "signal_out");
return;
}
item.SendSignal(success ? output : "0", "signal_out");
receivedSignal = signal;
break;
case "set_output":

View File

@@ -0,0 +1,56 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class WifiComponent : ItemComponent
{
private static List<WifiComponent> list = new List<WifiComponent>();
private int channel;
[InGameEditable, HasDefaultValue(1, true)]
public int Channel
{
get { return channel; }
set
{
channel = MathHelper.Clamp(value, 0, 100);
}
}
public WifiComponent(Item item, XElement element)
: base (item, element)
{
list.Add(this);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
//prevent an ininite loop of wificomponents sending messages between each other
if (sender.GetComponent<WifiComponent>()!=null) return;
switch (connection.Name)
{
case "signal_in":
foreach (WifiComponent wifiComp in list)
{
if (wifiComp == this || wifiComp.channel != channel) continue;
wifiComp.item.SendSignal(signal, "signal_out");
}
break;
}
}
public override void Remove()
{
base.Remove();
list.Remove(this);
}
}
}

View File

@@ -551,15 +551,19 @@ namespace Subsurface
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
if (isHighlighted) color = Color.Orange;
if (body==null)
if (prefab.sprite!=null)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
}
else if (body.Enabled)
{
body.Draw(spriteBatch, prefab.sprite, color);
if (body==null)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
}
else if (body.Enabled)
{
body.Draw(spriteBatch, prefab.sprite, color);
}
}
foreach (ItemComponent component in components) component.Draw(spriteBatch, editing);
if (!editing || (body!=null && !body.Enabled))
@@ -670,7 +674,13 @@ namespace Subsurface
foreach (var objectProperty in editableProperties)
{
new GUITextBlock(new Rectangle(0, y, 100, 20), objectProperty.Name, Color.Transparent, Color.White, Alignment.Left, null, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.style, editingHUD);
int height = 20;
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault<Editable>();
if (editable != null) height = (int)(Math.Ceiling(editable.MaxLength / 20.0f) * 20.0f);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, height), GUI.style, editingHUD);
if (height>20) propertyBox.Wrap = true;
object value = objectProperty.GetValue();
if (value != null)
@@ -681,7 +691,7 @@ namespace Subsurface
propertyBox.UserData = objectProperty;
propertyBox.OnEnter = EnterProperty;
propertyBox.OnTextChanged = PropertyChanged;
y = y + 30;
y = y + height+10;
}
return editingHUD;
}
@@ -938,8 +948,8 @@ namespace Subsurface
if (objectProperty == null) return false;
object prevValue = objectProperty.GetValue();
textBox.Selected = false;
textBox.Deselect();
if (objectProperty.TrySetValue(text))
{

View File

@@ -106,7 +106,7 @@ namespace Subsurface
position = placePosition;
}
sprite.DrawTiled(spriteBatch, new Vector2(position.X, -position.Y), placeSize, Color.White);
if (sprite != null) sprite.DrawTiled(spriteBatch, new Vector2(position.X, -position.Y), placeSize, Color.White);
}
if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;

View File

@@ -50,7 +50,7 @@ namespace Subsurface
private string name;
private double lastNetworkUpdate;
private float lastNetworkUpdate;
//properties ----------------------------------------------------
@@ -564,7 +564,7 @@ namespace Subsurface
public override void FillNetworkData(Networking.NetworkEventType type, NetOutgoingMessage message, object data)
{
message.Write(NetTime.Now);
message.Write((float)NetTime.Now);
message.Write(Position.X);
message.Write(Position.Y);
@@ -575,11 +575,11 @@ namespace Subsurface
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message)
{
double sendingTime;
float sendingTime;
Vector2 newTargetPosition, newSpeed;
try
{
sendingTime = message.ReadDouble();
sendingTime = message.ReadFloat();
if (sendingTime <= lastNetworkUpdate) return;
@@ -595,7 +595,7 @@ namespace Subsurface
return;
}
if (!speed.IsValid() || targetPosition.IsValid()) return;
if (!newSpeed.IsValid() || !newTargetPosition.IsValid()) return;
//newTargetPosition = newTargetPosition + newSpeed * (float)(NetTime.Now - sendingTime);

View File

@@ -377,7 +377,7 @@ namespace Subsurface.Networking
break;
case (byte)PacketTypes.EndGame:
string endMessage = inc.ReadString();
EndGame(endMessage);
CoroutineManager.StartCoroutine(EndGame(endMessage));
break;
case (byte)PacketTypes.PlayerJoined:
@@ -429,19 +429,48 @@ namespace Subsurface.Networking
}
}
public void EndGame(string endMessage)
public IEnumerable<object> EndGame(string endMessage)
{
gameStarted = false;
var messageBox = new GUIMessageBox("The round has ended", endMessage);
Character.Controlled = null;
Game1.LightManager.LosEnabled = false;
float endPreviewLength = 10.0f;
DateTime endTime = DateTime.Now + new TimeSpan(0,0,0,0,(int)(1000.0f*endPreviewLength));
float secondsLeft = endPreviewLength;
do
{
secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds;
float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
Vector2 offset = (new Vector2(
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
yield return Status.Running;
} while (secondsLeft > 0.0f);
messageBox.Text = endMessage;
Submarine.Unload();
Game1.NetLobbyScreen.Select();
if (Game1.GameSession!=null) Game1.GameSession.EndShift("");
new GUIMessageBox("The round has ended", endMessage);
myCharacter = null;
gameStarted = false;
yield return Status.Success;
}
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)

View File

@@ -149,13 +149,7 @@ namespace Subsurface.Networking
yield return Status.Running;
}
yield return Status.Success;
}
private void MasterServerCallBack(IRestResponse response)
@@ -617,9 +611,10 @@ namespace Subsurface.Networking
return true;
}
public void EndGame(string endMessage)
public IEnumerable<object> EndGame(string endMessage)
{
gameStarted = false;
if (connectedClients.Count > 0)
{
@@ -639,13 +634,34 @@ namespace Subsurface.Networking
}
}
float endPreviewLength = 10.0f;
DateTime endTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, (int)(1000.0f * endPreviewLength));
float secondsLeft = endPreviewLength;
do
{
secondsLeft = (float)(endTime - DateTime.Now).TotalSeconds;
float camAngle = (float)((DateTime.Now - endTime).TotalSeconds / endPreviewLength) * MathHelper.TwoPi;
Vector2 offset = (new Vector2(
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
yield return Status.Running;
} while (secondsLeft > 0.0f);
Submarine.Unload();
gameStarted = false;
Game1.NetLobbyScreen.Select();
DebugConsole.ThrowError(endMessage);
yield return Status.Success;
}
private void DisconnectClient(NetConnection senderConnection)

View File

@@ -64,6 +64,11 @@ namespace Subsurface.Networking
}
}
public bool GameStarted
{
get { return gameStarted; }
}
public GUIFrame InGameHUD
{
get { return inGameHUD; }

View File

@@ -3,156 +3,156 @@ using Microsoft.Xna.Framework.Input;
namespace Subsurface
{
class Key
{
private bool state, stateQueue;
private bool canBeHeld;
public Key(bool canBeHeld)
{
this.canBeHeld = canBeHeld;
}
class Key
{
private bool state, stateQueue;
private bool canBeHeld;
public Key(bool canBeHeld)
{
this.canBeHeld = canBeHeld;
}
public bool State
{
get
{
return state;
}
set
{
//if (value == false) return;
state = value;
//if (value) stateQueue = value;
}
}
public bool State
{
get
{
return state;
}
set
{
//if (value == false) return;
state = value;
//if (value) stateQueue = value;
}
}
public void SetState(bool value)
{
state = value;
if (value) stateQueue = value;
}
public void SetState(bool value)
{
state = value;
if (value) stateQueue = value;
}
public bool Dequeue
{
get
{
bool value = stateQueue;
stateQueue = false;
return value;
}
//set
//{
// stateQueue = value;
//}
}
public bool Dequeue
{
get
{
bool value = stateQueue;
stateQueue = false;
return value;
}
//set
//{
// stateQueue = value;
//}
}
public void Reset()
{
if (!canBeHeld) state = false;
//stateQueue = false;
}
}
public void Reset()
{
if (!canBeHeld) state = false;
//stateQueue = false;
}
}
static class PlayerInput
{
static MouseState mouseState, oldMouseState;
static KeyboardState keyboardState, oldKeyboardState;
static class PlayerInput
{
static MouseState mouseState, oldMouseState;
static KeyboardState keyboardState, oldKeyboardState;
static double timeSinceClick;
static double timeSinceClick;
const double doubleClickDelay = 0.4;
const double doubleClickDelay = 0.4;
static bool doubleClicked;
static bool doubleClicked;
public static Keys selectKey = Keys.E;
public static Keys selectKey = Keys.E;
public static Vector2 MousePosition
{
get { return new Vector2(mouseState.Y, mouseState.X); }
}
public static Vector2 MousePosition
{
get { return new Vector2(mouseState.X, mouseState.Y); }
}
public static MouseState GetMouseState
{
get { return mouseState; }
}
public static MouseState GetOldMouseState
{
get { return oldMouseState; }
}
public static MouseState GetMouseState
{
get { return mouseState; }
}
public static MouseState GetOldMouseState
{
get { return oldMouseState; }
}
public static Vector2 MouseSpeed
{
get
{
public static Vector2 MouseSpeed
{
get
{
return MousePosition - new Vector2(oldMouseState.X, oldMouseState.Y);
}
}
}
}
public static KeyboardState GetKeyboardState
{
get { return keyboardState; }
}
public static KeyboardState GetKeyboardState
{
get { return keyboardState; }
}
public static KeyboardState GetOldKeyboardState
{
get { return oldKeyboardState; }
}
public static KeyboardState GetOldKeyboardState
{
get { return oldKeyboardState; }
}
public static int ScrollWheelSpeed
{
get { return mouseState.ScrollWheelValue - oldMouseState.ScrollWheelValue; }
}
public static int ScrollWheelSpeed
{
get { return mouseState.ScrollWheelValue - oldMouseState.ScrollWheelValue; }
}
public static bool LeftButtonDown()
{
return mouseState.LeftButton == ButtonState.Pressed;
}
public static bool LeftButtonDown()
{
return mouseState.LeftButton == ButtonState.Pressed;
}
public static bool LeftButtonClicked()
{
return (oldMouseState.LeftButton == ButtonState.Pressed
&& mouseState.LeftButton == ButtonState.Released);
}
public static bool LeftButtonClicked()
{
return (oldMouseState.LeftButton == ButtonState.Pressed
&& mouseState.LeftButton == ButtonState.Released);
}
public static bool RightButtonClicked()
{
return (oldMouseState.RightButton == ButtonState.Pressed
&& mouseState.RightButton == ButtonState.Released);
}
public static bool RightButtonClicked()
{
return (oldMouseState.RightButton == ButtonState.Pressed
&& mouseState.RightButton == ButtonState.Released);
}
public static bool DoubleClicked()
{
return doubleClicked;
}
public static bool DoubleClicked()
{
return doubleClicked;
}
public static bool KeyHit(Keys button)
{
return (oldKeyboardState.IsKeyDown(button) && keyboardState.IsKeyUp(button));
}
public static bool KeyHit(Keys button)
{
return (oldKeyboardState.IsKeyDown(button) && keyboardState.IsKeyUp(button));
}
public static bool KeyDown(Keys button)
{
return (keyboardState.IsKeyDown(button));
}
public static bool KeyDown(Keys button)
{
return (keyboardState.IsKeyDown(button));
}
public static void Update(double deltaTime)
{
timeSinceClick += deltaTime;
public static void Update(double deltaTime)
{
timeSinceClick += deltaTime;
oldMouseState = mouseState;
mouseState = Mouse.GetState();
oldMouseState = mouseState;
mouseState = Mouse.GetState();
oldKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
oldKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
doubleClicked = false;
if (LeftButtonClicked())
{
if (timeSinceClick < doubleClickDelay) doubleClicked = true;
timeSinceClick = 0.0;
}
}
}
doubleClicked = false;
if (LeftButtonClicked())
{
if (timeSinceClick < doubleClickDelay) doubleClicked = true;
timeSinceClick = 0.0;
}
}
}
}

View File

@@ -11,6 +11,12 @@ namespace Subsurface
[AttributeUsage(AttributeTargets.Property)]
public class Editable : System.Attribute
{
public int MaxLength;
public Editable(int maxLength = 20)
{
MaxLength = maxLength;
}
}
[AttributeUsage(AttributeTargets.Property)]

View File

@@ -176,7 +176,7 @@ namespace Subsurface
// CreateDummyCharacter();
//}
cam.MoveCamera((float)deltaTime);
if (GUIComponent.MouseOn==null) cam.MoveCamera((float)deltaTime);
cam.Zoom = MathHelper.Clamp(cam.Zoom + PlayerInput.ScrollWheelSpeed/1000.0f,0.1f, 2.0f);
if (characterMode)

View File

@@ -75,11 +75,12 @@ namespace Subsurface
StatusEffect.UpdateAll((float)deltaTime);
cam.MoveCamera((float)deltaTime);
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 4);
while (Physics.accumulator >= Physics.step)
{
cam.MoveCamera((float)Physics.step);
foreach (PhysicsBody pb in PhysicsBody.list)
{
pb.SetPrevTransform(pb.Position, pb.Rotation);

View File

@@ -5,7 +5,7 @@ namespace Subsurface
class Screen
{
private static Screen selected;
public static Screen Selected
{
get { return selected; }

View File

@@ -29,16 +29,14 @@ namespace Subsurface
public static bool IsValid(float value)
{
return (!float.IsInfinity(value) && !float.IsInfinity(value));
return (!float.IsInfinity(value) && !float.IsNaN(value));
}
public static bool IsValid(Vector2 vector)
{
return (!float.IsInfinity(vector.X) && !float.IsInfinity(vector.Y) && !float.IsNaN(vector.X) && !float.IsNaN(vector.Y));
return (IsValid(vector.X) && IsValid(vector.Y));
}
public static float CurveAngle(float from, float to, float step)
{

View File

@@ -36,9 +36,9 @@ namespace Subsurface
{
font = contentManager.Load<SpriteFont>(file);
}
catch
catch (Exception e)
{
DebugConsole.ThrowError("Loading font ''"+file+"'' failed");
DebugConsole.ThrowError("Loading font ''"+file+"'' failed", e);
}
return font;

View File

@@ -6336,9 +6336,6 @@
</timestamps>
<violations />
</sourcecode>
<project key="2115933639">
<configuration>DEBUG;TRACE;WINDOWS</configuration>
</project>
<sourcecode name="GameMode.cs" parser="StyleCop.CSharp.CsParser">
<timestamps>
<styleCop>2014.04.01 10:18:24.000</styleCop>
@@ -6464,4 +6461,30 @@
</timestamps>
<violations />
</sourcecode>
<project key="2115933639">
<configuration>DEBUG;TRACE;WINDOWS</configuration>
</project>
<sourcecode name="ItemLabel.cs" parser="StyleCop.CSharp.CsParser">
<timestamps>
<styleCop>2014.04.01 10:18:24.000</styleCop>
<settingsFile>2015.07.02 21:22:42.115</settingsFile>
<sourceFile>2015.08.21 17:49:13.627</sourceFile>
<parser>2014.04.01 10:18:24.000</parser>
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
</timestamps>
<violations />
</sourcecode>
</stylecopresultscache>

View File

@@ -76,7 +76,9 @@
<Compile Include="Source\GUI\GUIMessage.cs" />
<Compile Include="Source\GUI\TitleScreen.cs" />
<Compile Include="Source\Items\Components\Label.cs" />
<Compile Include="Source\Items\Components\Signal\WifiComponent.cs" />
<Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" />
<Compile Include="Source\Items\Components\ItemLabel.cs" />
<Compile Include="Source\Items\FixRequirement.cs" />
<Compile Include="Source\Map\Lights\Light.cs" />
<Compile Include="Source\Map\LocationType.cs" />
@@ -301,6 +303,9 @@
<Content Include="Content\Items\Artifacts\artifacts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\blank.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Clothes\captainLegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -310,6 +315,12 @@
<Content Include="Content\Items\Electricity\lamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\wifi.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\regex.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\lights.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -320,6 +331,9 @@
<Content Include="Content\Items\Electricity\monitors.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\itemlabel.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Medical\medical.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
@@ -557,7 +571,7 @@
<Content Include="Content\Items\Electricity\junctionbox.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Ladder\item.xml">
<Content Include="Content\Items\Ladder\ladder.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Ladder\ladder.png">

Binary file not shown.