Better UI scaling, quest tweaking, contentpackage hash bugfix, misc bugfixes
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
|
||||
public double LastNetworkUpdate;
|
||||
|
||||
public float LargeUpdateTimer;
|
||||
public int LargeUpdateTimer;
|
||||
|
||||
public readonly Dictionary<string, ObjectProperty> Properties;
|
||||
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||
@@ -898,6 +898,19 @@ namespace Subsurface
|
||||
{
|
||||
if (isDead) return;
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (Game1.Client != null)
|
||||
{
|
||||
if (networkMessage)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
isDead = true;
|
||||
AnimController.movement = Vector2.Zero;
|
||||
AnimController.TargetMovement = Vector2.Zero;
|
||||
@@ -923,20 +936,6 @@ namespace Subsurface
|
||||
joint.MaxMotorTorque = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (Game1.Client != null)
|
||||
{
|
||||
if (networkMessage)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Game1.Server != null)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, false);
|
||||
@@ -999,6 +998,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
message.Write(AnimController.StunTimer);
|
||||
message.Write((byte)health);
|
||||
|
||||
LargeUpdateTimer = 5;
|
||||
}
|
||||
@@ -1021,18 +1021,23 @@ namespace Subsurface
|
||||
{
|
||||
if (type == NetworkEventType.PickItem)
|
||||
{
|
||||
int itemId = message.ReadInt32();
|
||||
int itemId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
itemId = message.ReadInt32();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = FindEntityByID(itemId) as Item;
|
||||
if (item != null)
|
||||
{
|
||||
Debug.WriteLine("pickitem "+itemId );
|
||||
item.Pick(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
//DebugConsole.ThrowError("pickitem");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1088,21 +1093,25 @@ namespace Subsurface
|
||||
{
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
{
|
||||
Vector2 pos = Vector2.Zero;
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
|
||||
float rotation = 0.0f, angularVel = 0.0f;
|
||||
|
||||
Vector2 vel = Vector2.Zero;
|
||||
vel.X = message.ReadFloat();
|
||||
vel.Y = message.ReadFloat();
|
||||
try
|
||||
{
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
|
||||
float rotation = message.ReadFloat();
|
||||
float angularVel = message.ReadFloat();
|
||||
vel.X = message.ReadFloat();
|
||||
vel.Y = message.ReadFloat();
|
||||
|
||||
//if (vel != Vector2.Zero && vel.Length() > 100.0f) { }
|
||||
rotation = message.ReadFloat();
|
||||
angularVel = message.ReadFloat();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if (pos != Vector2.Zero && pos.Length() > 100.0f) { }
|
||||
|
||||
if (limb.body != null)
|
||||
{
|
||||
limb.body.TargetVelocity = vel;
|
||||
@@ -1113,15 +1122,31 @@ namespace Subsurface
|
||||
|
||||
}
|
||||
|
||||
AnimController.StunTimer = message.ReadFloat();
|
||||
float newStunTimer = 0.0f, newHealth = 0.0f;
|
||||
|
||||
try
|
||||
{
|
||||
newStunTimer = message.ReadFloat();
|
||||
newHealth = message.ReadByte();
|
||||
}
|
||||
catch { return; }
|
||||
|
||||
AnimController.StunTimer = newStunTimer;
|
||||
Health = newHealth;
|
||||
|
||||
LargeUpdateTimer = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 pos = Vector2.Zero;
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
try
|
||||
{
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
}
|
||||
|
||||
catch { return; }
|
||||
|
||||
|
||||
Limb torso = AnimController.GetLimb(LimbType.Torso);
|
||||
torso.body.TargetPosition = pos;
|
||||
|
||||
@@ -320,10 +320,11 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
avgVelocity = avgVelocity / limbs.Count();
|
||||
|
||||
|
||||
|
||||
float impact = Vector2.Dot((f1.Body.LinearVelocity + avgVelocity) / 2.0f, -normal);
|
||||
|
||||
if (Game1.Server != null) impact = impact / 2.0f;
|
||||
|
||||
Limb l = (Limb)f1.Body.UserData;
|
||||
|
||||
if (impact > 1.0f && l.HitSound != null && l.soundTimer <= 0.0f) l.HitSound.Play(Math.Min(impact / 5.0f, 1.0f), impact * 100.0f, l.body.FarseerBody);
|
||||
@@ -335,10 +336,8 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
{
|
||||
foreach (Limb limb in limbs)
|
||||
{
|
||||
limb.Draw(spriteBatch);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.8"/>
|
||||
</Steering>
|
||||
|
||||
<Radar canbeselected = "true">
|
||||
<Radar canbeselected = "true" powerconsumption="100">
|
||||
<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"/>
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||
<requireditem name="Screwdriver" type="Equipped"/>
|
||||
<input name="power_in"/>
|
||||
<input name="velocity_in"/>
|
||||
<output name="velocity_x_out"/>
|
||||
<output name="velocity_y_out"/>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 13 KiB |
@@ -5,7 +5,9 @@
|
||||
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
|
||||
commonness="10"
|
||||
reward="1000"
|
||||
successmessage="You have successfully retrieved the artifact."
|
||||
radarlabel="Infrasonic signal"
|
||||
failuremessage="fail"
|
||||
successmessage="The artifact has been succesfully retrived"
|
||||
itemname="Skyholder Artifact">
|
||||
</SalvageQuest>
|
||||
|
||||
@@ -14,7 +16,9 @@
|
||||
description="A particularly aggressive Moloch has been terrorizing vessels traveling between [location1] and [location2]. A reward of 1000 credits has been promised to those who kill the creature."
|
||||
commonness="10"
|
||||
reward="1000"
|
||||
successmessage="You have successfully killed the Moloch."
|
||||
radarlabel="Moloch"
|
||||
failuremessage="fail"
|
||||
successmessage="The Moloch has been killed."
|
||||
monsterfile="Content/Characters/Moloch/moloch.xml">
|
||||
</MonsterQuest>
|
||||
|
||||
@@ -23,7 +27,9 @@
|
||||
description="A particularly aggressive Tiger Thresher has been terrorizing vessels traveling between [location1] and [location2]. A reward of 800 credits has been promised to those who kill the creature."
|
||||
commonness="10"
|
||||
reward="800"
|
||||
successmessage="You have successfully killed the Tiger Thresher."
|
||||
radarlabel="Tiger Thresher"
|
||||
failuremessage="fail"
|
||||
successmessage="The Tiger Thresher has been killed."
|
||||
monsterfile="Content/Characters/TigerThresher/tigerthresher.xml">
|
||||
</MonsterQuest>
|
||||
|
||||
@@ -32,6 +38,7 @@
|
||||
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
|
||||
commonness="5"
|
||||
reward="1000"
|
||||
radarlabel="Infrasonic signal"
|
||||
failuremessage="It turns out the signal picked up by [location1] was emitted by a Moloch."
|
||||
successmessage="It turns out the signal was emitted by a Moloch. The researchers of [location1] have agreed to pay you the reward nevertheless for killing the Moloch."
|
||||
monsterfile="Content/Characters/Moloch/moloch.xml">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -120,17 +121,36 @@ namespace Subsurface
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<byte[]> hashes = new List<byte[]>();
|
||||
|
||||
//foreach (ContentFile file in files)
|
||||
//{
|
||||
// if (file.path.EndsWith(".xml", true, System.Globalization.CultureInfo.InvariantCulture))
|
||||
// {
|
||||
// XDocument doc = ToolBox.TryLoadXml(file.path);
|
||||
// sb.Append(doc.ToString());
|
||||
// }
|
||||
//}
|
||||
var md5 = MD5.Create();
|
||||
foreach (ContentFile file in files)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file.path);
|
||||
|
||||
sb.Append(doc.ToString());
|
||||
using (var stream = File.OpenRead(file.path))
|
||||
{
|
||||
hashes.Add(md5.ComputeHash(stream));
|
||||
}
|
||||
}
|
||||
string str = sb.ToString();
|
||||
byte[] bytes = new byte[str.Length * sizeof(char)];
|
||||
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
|
||||
md5Hash = new Md5Hash(bytes);
|
||||
|
||||
|
||||
//string str = sb.ToString();
|
||||
byte[] bytes = new byte[hashes.Count()*16];
|
||||
for (int i = 0; i < hashes.Count; i++ )
|
||||
{
|
||||
hashes[i].CopyTo(bytes, i*16);
|
||||
}
|
||||
//System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
|
||||
md5Hash = new Md5Hash(bytes);
|
||||
}
|
||||
|
||||
public List<string> GetFilesOfType(ContentType type)
|
||||
|
||||
@@ -246,12 +246,12 @@ namespace Subsurface
|
||||
break;
|
||||
case "savemap":
|
||||
if (commands.Length < 2) break;
|
||||
Submarine.SaveCurrent("Content/SavedMaps/" + commands[1]);
|
||||
Submarine.SaveCurrent("Content/SavedMaps/" + string.Join(" ", commands.Skip(1)));
|
||||
NewMessage("map saved", Color.Green);
|
||||
break;
|
||||
case "loadmap":
|
||||
if (commands.Length < 2) break;
|
||||
Submarine.Load("Content/SavedMaps/" + commands[1]);
|
||||
Submarine.Load("Content/SavedMaps/" + string.Join(" ", commands.Skip(1)));
|
||||
break;
|
||||
case "savegame":
|
||||
SaveUtil.SaveGame(SaveUtil.SaveFolder+"save");
|
||||
|
||||
@@ -16,14 +16,6 @@ namespace Subsurface
|
||||
|
||||
Character monster;
|
||||
|
||||
public override string RadarLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return monster.SpeciesName;
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 RadarPosition
|
||||
{
|
||||
get
|
||||
@@ -35,7 +27,6 @@ namespace Subsurface
|
||||
public MonsterQuest(XElement element)
|
||||
: base(element)
|
||||
{
|
||||
//monsterName = ToolBox.GetAttributeString(element, "monstername", "");
|
||||
monsterFile = ToolBox.GetAttributeString(element, "monsterfile", "");
|
||||
}
|
||||
|
||||
@@ -48,7 +39,11 @@ namespace Subsurface
|
||||
|
||||
public override void End()
|
||||
{
|
||||
if (!monster.IsDead) return;
|
||||
if (!monster.IsDead)
|
||||
{
|
||||
new GUIMessageBox("Quest failed", failureMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
GiveReward();
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ namespace Subsurface
|
||||
|
||||
protected bool completed;
|
||||
|
||||
private string successMessage;
|
||||
private string failureMessage;
|
||||
protected string successMessage;
|
||||
protected string failureMessage;
|
||||
|
||||
protected string radarLabel;
|
||||
|
||||
private int reward;
|
||||
|
||||
@@ -47,7 +49,7 @@ namespace Subsurface
|
||||
|
||||
public virtual string RadarLabel
|
||||
{
|
||||
get { return ""; }
|
||||
get { return radarLabel; }
|
||||
}
|
||||
|
||||
public virtual Vector2 RadarPosition
|
||||
@@ -65,6 +67,8 @@ namespace Subsurface
|
||||
|
||||
successMessage = ToolBox.GetAttributeString(element, "successmessage", "");
|
||||
failureMessage = ToolBox.GetAttributeString(element, "failuremessage", "");
|
||||
|
||||
radarLabel = ToolBox.GetAttributeString(element, "radarlabel", "");
|
||||
}
|
||||
|
||||
public static Quest LoadRandom(Location[] locations, Random rand)
|
||||
|
||||
@@ -13,14 +13,6 @@ namespace Subsurface
|
||||
|
||||
Item item;
|
||||
|
||||
public override string RadarLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Infrasonic signal";
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 RadarPosition
|
||||
{
|
||||
get
|
||||
@@ -52,8 +44,11 @@ namespace Subsurface
|
||||
|
||||
public override void End()
|
||||
{
|
||||
if (item.CurrentHull == null) return;
|
||||
|
||||
if (item.CurrentHull == null)
|
||||
{
|
||||
new GUIMessageBox("Quest failed", failureMessage);
|
||||
return;
|
||||
}
|
||||
item.Remove();
|
||||
|
||||
GiveReward();
|
||||
|
||||
@@ -297,6 +297,9 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
DebugConsole.Draw(spriteBatch);
|
||||
|
||||
|
||||
if (GUIComponent.MouseOn != null && !string.IsNullOrWhiteSpace(GUIComponent.MouseOn.ToolTip)) GUIComponent.MouseOn.DrawToolTip(spriteBatch);
|
||||
}
|
||||
|
||||
public static void Update(float deltaTime)
|
||||
|
||||
@@ -42,6 +42,14 @@ namespace Subsurface
|
||||
set;
|
||||
}
|
||||
|
||||
public string ToolTip
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private GUITextBlock toolTipBlock;
|
||||
|
||||
//protected float alpha;
|
||||
|
||||
public GUIComponent Parent
|
||||
@@ -222,6 +230,20 @@ namespace Subsurface
|
||||
//DrawChildren(spriteBatch);
|
||||
}
|
||||
|
||||
public void DrawToolTip(SpriteBatch spriteBatch)
|
||||
{
|
||||
int width = 200;
|
||||
if (toolTipBlock==null || (string)toolTipBlock.userData != ToolTip)
|
||||
{
|
||||
string wrappedText = ToolBox.WrapText(ToolTip, width, GUI.SmallFont);
|
||||
toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, wrappedText.Split('\n').Length*15), ToolTip, GUI.style, null, true);
|
||||
toolTipBlock.userData = ToolTip;
|
||||
}
|
||||
|
||||
toolTipBlock.rect = new Rectangle((int)PlayerInput.MousePosition.X, (int)PlayerInput.MousePosition.Y, toolTipBlock.rect.Width, toolTipBlock.rect.Height);
|
||||
toolTipBlock.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
if (CanBeFocused)
|
||||
|
||||
@@ -111,9 +111,10 @@ namespace Subsurface
|
||||
if (parent != null)
|
||||
parent.AddChild(this);
|
||||
|
||||
scrollBarHidden = true;
|
||||
|
||||
scrollBar = new GUIScrollBar(
|
||||
new Rectangle(this.rect.X + this.rect.Width, this.rect.Y, 20, this.rect.Height), color, 1.0f, style);
|
||||
new Rectangle(this.rect.X + this.rect.Width-20, this.rect.Y, 20, this.rect.Height), color, 1.0f, style);
|
||||
|
||||
frame = new GUIFrame(Rectangle.Empty, style, this);
|
||||
if (style != null) style.Apply(frame, this);
|
||||
@@ -214,14 +215,15 @@ namespace Subsurface
|
||||
|
||||
private void ShowScrollBar()
|
||||
{
|
||||
if (scrollBarHidden) Rect = new Rectangle(rect.X, rect.Y, rect.Width - scrollBar.Rect.Width, rect.Height);
|
||||
scrollBarHidden = false;
|
||||
Rect = new Rectangle(rect.X, rect.Y, rect.Width - scrollBar.Rect.Width, rect.Height);
|
||||
|
||||
}
|
||||
|
||||
private void HideScrollBar()
|
||||
{
|
||||
if (!scrollBarHidden) Rect = new Rectangle(rect.X, rect.Y, rect.Width + scrollBar.Rect.Width, rect.Height);
|
||||
scrollBarHidden = true;
|
||||
Rect = new Rectangle(rect.X, rect.Y, rect.Width + scrollBar.Rect.Width, rect.Height);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
|
||||
@@ -193,6 +193,7 @@ namespace Subsurface
|
||||
new Vector2((int)caretPos.X + 2, caretPos.Y + Font.MeasureString("I").Y - 3),
|
||||
textBlock.TextColor * (textBlock.TextColor.A / 255.0f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ReceiveTextInput(char inputChar)
|
||||
|
||||
@@ -81,7 +81,17 @@ namespace Subsurface
|
||||
titlePos, null,
|
||||
Color.White * Math.Min((state - 3.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), scale, SpriteEffects.None, 0.0f);
|
||||
|
||||
string loadText = (loadState<100.0f) ? "Loading... "+(int)loadState+" %" : "Press any key to continue";
|
||||
string loadText = "";
|
||||
if (loadState == 100.0f)
|
||||
{
|
||||
loadText = "Press any key to continue";
|
||||
|
||||
}
|
||||
else if (loadState > 0.0f)
|
||||
{
|
||||
loadText = "Loading... " + (int)loadState + " %";
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, loadText, new Vector2(Game1.GraphicsWidth/2.0f - 50.0f, Game1.GraphicsHeight*0.8f), Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -196,6 +196,8 @@ namespace Subsurface
|
||||
loadState = 70.0f;
|
||||
yield return Status.Running;
|
||||
|
||||
GameMode.Init();
|
||||
|
||||
Submarine.Preload("Content/SavedMaps");
|
||||
loadState = 80.0f;
|
||||
yield return Status.Running;
|
||||
@@ -214,7 +216,6 @@ namespace Subsurface
|
||||
ParticleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
|
||||
yield return Status.Running;
|
||||
|
||||
GameMode.Init();
|
||||
GUIComponent.Init(Window);
|
||||
DebugConsole.Init(Window);
|
||||
yield return Status.Running;
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
AnimController ac = picker.AnimController;
|
||||
|
||||
item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
|
||||
//item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
|
||||
|
||||
ac.HoldItem(deltaTime, cam, item, handlePos, holdPos, aimPos, holdAngle);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Label(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
|
||||
@@ -59,9 +59,7 @@ namespace Subsurface.Items.Components
|
||||
else
|
||||
{
|
||||
pingState = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
@@ -84,7 +82,7 @@ namespace Subsurface.Items.Components
|
||||
int radius = GuiFrame.Rect.Height / 2 - 10;
|
||||
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
||||
|
||||
voltage = 0.0f;
|
||||
//voltage = 0.0f;
|
||||
}
|
||||
|
||||
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
|
||||
@@ -198,8 +196,6 @@ namespace Subsurface.Items.Components
|
||||
quest.RadarLabel,
|
||||
quest.RadarPosition, displayScale, center, (rect.Width * 0.55f));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,8 +214,7 @@ namespace Subsurface.Items.Components
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, label, new Vector2(markerPos.X + 10, markerPos.Y), Color.LightGreen);
|
||||
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (float.IsNaN(value.X) || float.IsNaN(value.Y))
|
||||
{
|
||||
targetVelocity = Vector2.Zero;
|
||||
return;
|
||||
}
|
||||
targetVelocity.X = MathHelper.Clamp(value.X, -100.0f, 100.0f);
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace Subsurface.Items.Components
|
||||
if (Wires[i]!=null)
|
||||
{
|
||||
Wires[i].Item.body.Enabled = false;
|
||||
Wires[i].Connect(this, false);
|
||||
Wires[i].Connect(this, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,11 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
}
|
||||
|
||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
||||
{
|
||||
foreach (Connection c in connections)
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Subsurface.Items.Components
|
||||
if (connection == connections[1]) connections[1] = null;
|
||||
}
|
||||
|
||||
public void Connect(Connection newConnection, bool addNode = true)
|
||||
public void Connect(Connection newConnection, bool addNode = true, bool loading = false)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -85,7 +85,6 @@ namespace Subsurface.Items.Components
|
||||
Nodes.Add(newConnection.Item.Position);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -110,7 +109,7 @@ namespace Subsurface.Items.Components
|
||||
CleanNodes();
|
||||
}
|
||||
|
||||
Item.NewComponentEvent(this, true);
|
||||
if (!loading) Item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
public override void Equip(Character character)
|
||||
|
||||
@@ -287,10 +287,19 @@ namespace Subsurface
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
{
|
||||
int itemId = message.ReadInt32();
|
||||
if (itemId == -1) return;
|
||||
int itemId=-1, slotIndex = -1;
|
||||
|
||||
int slotIndex = message.ReadInt32();
|
||||
try
|
||||
{
|
||||
itemId = message.ReadInt32();
|
||||
slotIndex = message.ReadInt32();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemId == -1) return;
|
||||
|
||||
Item item = FindEntityByID(itemId) as Item;
|
||||
if (item == null) return;
|
||||
|
||||
@@ -1184,7 +1184,7 @@ namespace Subsurface
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
|
||||
//sprite.Remove();
|
||||
if (body != null) body.Remove();
|
||||
|
||||
@@ -1194,6 +1194,14 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
itemList.Remove(this);
|
||||
|
||||
foreach (Item it in itemList)
|
||||
{
|
||||
if (it.linkedTo.Contains(this))
|
||||
{
|
||||
it.linkedTo.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
@@ -40,6 +41,13 @@ namespace Subsurface
|
||||
shortHash = GetShortHash(hash);
|
||||
}
|
||||
|
||||
public Md5Hash(FileStream fileStream)
|
||||
{
|
||||
hash = CalculateHash(fileStream);
|
||||
|
||||
shortHash = GetShortHash(hash);
|
||||
}
|
||||
|
||||
public Md5Hash(XDocument doc)
|
||||
{
|
||||
string docString = Regex.Replace(doc.ToString(), @"\s+", "");
|
||||
@@ -51,6 +59,20 @@ namespace Subsurface
|
||||
shortHash = GetShortHash(hash);
|
||||
}
|
||||
|
||||
private string CalculateHash(FileStream stream)
|
||||
{
|
||||
MD5 md5 = MD5.Create();
|
||||
byte[] byteHash = md5.ComputeHash(stream);
|
||||
// step 2, convert byte array to hex string
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < byteHash.Length; i++)
|
||||
{
|
||||
sb.Append(byteHash[i].ToString("X2"));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string CalculateHash(byte[] bytes)
|
||||
{
|
||||
MD5 md5 = MD5.Create();
|
||||
|
||||
@@ -162,12 +162,13 @@ namespace Subsurface
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server port:", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer]);
|
||||
portBox = new GUITextBox(new Rectangle(0, 130, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, null, menuTabs[(int)Tabs.HostServer]);
|
||||
portBox.Text = NetworkMember.DefaultPort.ToString();
|
||||
portBox.ToolTip = "Server port";
|
||||
|
||||
GUIButton hostButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomCenter, GUI.style, menuTabs[(int)Tabs.HostServer]);
|
||||
hostButton.OnClicked = HostServerClicked;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
for (int i = 1; i < 4; i++ )
|
||||
for (int i = 1; i < 5; i++ )
|
||||
{
|
||||
button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]);
|
||||
button.OnClicked = PreviousTab;
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Subsurface
|
||||
public bool IsServer;
|
||||
public string ServerName, ServerMessage;
|
||||
|
||||
private GUITextBox serverMessage;
|
||||
|
||||
public Submarine SelectedMap
|
||||
{
|
||||
get { return subList.SelectedData as Submarine; }
|
||||
@@ -101,10 +103,12 @@ namespace Subsurface
|
||||
|
||||
public NetLobbyScreen()
|
||||
{
|
||||
Rectangle panelRect = new Rectangle(
|
||||
40, 40, Game1.GraphicsWidth - 80, Game1.GraphicsHeight - 80);
|
||||
int width = Math.Min(Game1.GraphicsWidth - 80, 1500);
|
||||
int height = Math.Min(Game1.GraphicsHeight - 80, 800);
|
||||
|
||||
menu = new GUIFrame(panelRect, Color.Transparent);
|
||||
Rectangle panelRect = new Rectangle(0,0,width,height);
|
||||
|
||||
menu = new GUIFrame(panelRect, Color.Transparent, Alignment.Center);
|
||||
//menu.Padding = GUI.style.smallPadding;
|
||||
|
||||
//server info panel ------------------------------------------------------------
|
||||
@@ -139,28 +143,15 @@ namespace Subsurface
|
||||
GUI.style, menu);
|
||||
|
||||
playerList = new GUIListBox(new Rectangle(0,0,0,0), null, GUI.style, playerListFrame);
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
textBox.Deselect();
|
||||
}
|
||||
//submarine list ------------------------------------------------------------------
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
int columnWidth = infoFrame.Rect.Width / 3 - 30;
|
||||
int columnX = 0;
|
||||
|
||||
infoFrame.ClearChildren();
|
||||
|
||||
textBox.Select();
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 110, 0, 30), "Selected submarine:", GUI.style, infoFrame);
|
||||
subList = new GUIListBox(new Rectangle(0, 140, 200, 200), Color.White, GUI.style, infoFrame);
|
||||
new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Selected submarine:", GUI.style, infoFrame);
|
||||
subList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, 200), Color.White, GUI.style, infoFrame);
|
||||
subList.OnSelected = SelectMap;
|
||||
subList.Enabled = (Game1.Server != null);
|
||||
|
||||
if (Submarine.SavedSubmarines.Count > 0)
|
||||
{
|
||||
@@ -181,10 +172,13 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(220, 110, 0, 30), "Selected game mode: ", GUI.style, infoFrame);
|
||||
modeList = new GUIListBox(new Rectangle(220, 140, 200, 200), GUI.style, infoFrame);
|
||||
modeList.Enabled = (Game1.Server != null);
|
||||
columnX += columnWidth + 20;
|
||||
|
||||
//gamemode ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Selected game mode: ", GUI.style, infoFrame);
|
||||
modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, 200), GUI.style, infoFrame);
|
||||
|
||||
foreach (GameModePreset mode in GameModePreset.list)
|
||||
{
|
||||
if (mode.IsSinglePlayer) continue;
|
||||
@@ -198,40 +192,72 @@ namespace Subsurface
|
||||
textBlock.UserData = mode;
|
||||
}
|
||||
|
||||
GUITextBlock durationText = new GUITextBlock(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 110, 100, 20),
|
||||
columnX += columnWidth + 20;
|
||||
|
||||
//duration ------------------------------------------------------------------
|
||||
|
||||
GUITextBlock durationText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 20),
|
||||
"Game duration: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
|
||||
durationText.TextGetter = DurationText;
|
||||
|
||||
durationBar = new GUIScrollBar(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 140, 180, 20),
|
||||
durationBar = new GUIScrollBar(new Rectangle(columnX, 150, columnWidth, 20),
|
||||
GUI.style, 0.1f, infoFrame);
|
||||
durationBar.BarSize = 0.1f;
|
||||
durationBar.Enabled = (Game1.Server != null);
|
||||
|
||||
new GUITextBlock(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 180, 100, 20),
|
||||
//seed ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 190, columnWidth, 20),
|
||||
"Level Seed: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
|
||||
|
||||
seedBox = new GUITextBox(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 210, 180, 20),
|
||||
seedBox = new GUITextBox(new Rectangle(columnX, 220, columnWidth, 20),
|
||||
Alignment.TopLeft, GUI.style, infoFrame);
|
||||
seedBox.OnEnter = SelectSeed;
|
||||
seedBox.Enabled = (Game1.Server != null);
|
||||
seedBox.OnTextChanged = SelectSeed;
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
//server info ------------------------------------------------------------------
|
||||
|
||||
var serverName = new GUITextBox(new Rectangle(0, 0, 200, 20), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
|
||||
serverName.TextGetter = GetServerName;
|
||||
serverName.Enabled = Game1.Server != null;
|
||||
serverName.OnTextChanged = ChangeServerName;
|
||||
ServerName = (Game1.Server==null) ? "Server" : Game1.Server.Name;
|
||||
|
||||
var serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
|
||||
serverMessage.Enabled = Game1.Server != null;
|
||||
|
||||
serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
|
||||
serverMessage.Wrap = true;
|
||||
serverMessage.TextGetter = GetServerMessage;
|
||||
serverMessage.OnTextChanged = UpdateServerMessage;
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
textBox.Deselect();
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
|
||||
//infoFrame.ClearChildren();
|
||||
|
||||
textBox.Select();
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
subList.Enabled = Game1.Server != null;
|
||||
modeList.Enabled = Game1.Server != null;
|
||||
durationBar.Enabled = Game1.Server != null;
|
||||
seedBox.Enabled = Game1.Server != null;
|
||||
serverMessage.Enabled = Game1.Server != null;
|
||||
ServerName = (Game1.Server==null) ? "Server" : Game1.Server.Name;
|
||||
|
||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton"));
|
||||
|
||||
if (IsServer && Game1.Server != null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.TopRight, GUI.style, infoFrame);
|
||||
startButton.OnClicked = Game1.Server.StartGame;
|
||||
startButton.UserData = "startButton";
|
||||
|
||||
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
|
||||
modeList.OnSelected = Game1.Server.UpdateNetLobby;
|
||||
@@ -244,6 +270,8 @@ namespace Subsurface
|
||||
{
|
||||
int x = playerFrame.Rect.Width / 2;
|
||||
|
||||
playerFrame.ClearChildren();
|
||||
|
||||
new GUITextBlock(new Rectangle(x, 0, 200, 30), "Name: ", GUI.style, playerFrame);
|
||||
|
||||
GUITextBox playerName = new GUITextBox(new Rectangle(x, 30, 0, 20),
|
||||
@@ -462,7 +490,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
//textBox.Text = LevelSeed;
|
||||
textBox.Selected = false;
|
||||
//textBox.Selected = false;
|
||||
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(null);
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user