Quests, new sounds, explosives, bugfixes, asdfasdf

This commit is contained in:
Regalis
2015-07-29 23:40:26 +03:00
parent 7155f1cef0
commit 5d0a453e23
81 changed files with 1374 additions and 819 deletions

View File

@@ -18,6 +18,12 @@ namespace Subsurface
private Vector2 position;
private float rotation;
public float Shake;
private Vector2 shakePosition;
private Vector2 shakeTargetPosition;
//the area of the world inside the camera view
private Rectangle worldView;
@@ -151,10 +157,10 @@ namespace Subsurface
Vector2 moveCam = Vector2.Zero;
if (targetPos == Vector2.Zero)
{
if (Keyboard.GetState().IsKeyDown(Keys.Left)) moveCam.X -= moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.Right)) moveCam.X += moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.Down)) moveCam.Y -= moveSpeed;
if (Keyboard.GetState().IsKeyDown(Keys.Up)) moveCam.Y += moveSpeed;
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;
Zoom = MathHelper.Clamp(Zoom + PlayerInput.ScrollWheelSpeed / 1000.0f, 0.1f, 2.0f);
}
@@ -177,7 +183,11 @@ namespace Subsurface
moveCam = (targetPos + offset - position) / MoveSmoothness;
}
Translate(moveCam*deltaTime*60.0f);
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);
}
public Vector2 Position

View File

@@ -392,11 +392,6 @@ namespace Subsurface
AnimController.FindHull();
//if (info.ID >= 0)
//{
// ID = info.ID;
//}
CharacterList.Add(this);
}
@@ -764,7 +759,7 @@ namespace Subsurface
if (Controlled.Inventory != null) Controlled.Inventory.Draw(spriteBatch);
if (closestItem!=null)
if (closestItem != null && selectedConstruction==null)
{
Color color = Color.Orange;
@@ -882,12 +877,12 @@ namespace Subsurface
for (int i = 0; i < 10; i++)
{
Particle p = Game1.particleManager.CreateParticle("waterblood",
Particle p = Game1.ParticleManager.CreateParticle("waterblood",
torso.SimPosition + new Vector2(Rand.Range(-0.5f, 0.5f), Rand.Range(-0.5f, 0.5f)),
Vector2.Zero);
if (p!=null) p.Size *= 2.0f;
Game1.particleManager.CreateParticle("bubbles",
Game1.ParticleManager.CreateParticle("bubbles",
torso.SimPosition,
new Vector2(Rand.Range(-0.5f, 0.5f), Rand.Range(-1.0f,0.5f)));
}
@@ -1047,6 +1042,7 @@ namespace Subsurface
if (Game1.Client != null && controlled == this)
{
Game1.Client.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
Game1.LightManager.LosEnabled = false;
}
return;
}

View File

@@ -12,7 +12,7 @@ namespace Subsurface
private float timer;
private Vector2 position;
private Entity entity;
private List<IPropertyObject> targets;
@@ -27,12 +27,12 @@ namespace Subsurface
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
}
public override void Apply(ActionType type, float deltaTime, Vector2 position, List<IPropertyObject> targets)
public override void Apply(ActionType type, float deltaTime, Entity entity, List<IPropertyObject> targets)
{
if (this.type != type) return;
timer = delay;
this.position = position;
this.entity = entity;
this.targets = targets;
@@ -45,7 +45,7 @@ namespace Subsurface
if (timer > 0.0f) return;
base.Apply(1.0f, position, targets);
base.Apply(1.0f, entity, targets);
List.Remove(this);
}

View File

@@ -210,7 +210,6 @@ namespace Subsurface
Limb torso = GetLimb(LimbType.Torso);
Limb head = GetLimb(LimbType.Head);
if (torso!=null)
{
colliderLimb = torso;
@@ -223,7 +222,7 @@ namespace Subsurface
colliderLimb = head;
colliderHeight = HeadPosition;
colliderLimb.body.SmoothRotate(HeadAngle*Dir, 100.0f);
if (onGround) colliderLimb.body.SmoothRotate(HeadAngle*Dir, 100.0f);
}
Vector2 colliderPos = colliderLimb.SimPosition;
@@ -269,18 +268,19 @@ namespace Subsurface
onFloorTimer -= deltaTime;
}
if (!onGround) return;
if (closestFraction == 1) //raycast didn't hit anything
floorY = (currentHull == null || onGround) ? -1000.0f : ConvertUnits.ToSimUnits(currentHull.Rect.Y - currentHull.Rect.Height);
floorY = (currentHull == null) ? -1000.0f : ConvertUnits.ToSimUnits(currentHull.Rect.Y - currentHull.Rect.Height);
else
floorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
if (Math.Abs(colliderPos.Y - floorY)<colliderHeight*1.2f && onGround)
if (Math.Abs(colliderPos.Y - floorY) < colliderHeight * 1.2f)
{
colliderLimb.Move(new Vector2(colliderPos.X + movement.X * 0.2f, floorY + colliderHeight), 5.0f);
}
//colliderLimb.body.SetTransform(Vector2.Zero, colliderLimb.Rotation);
float walkCycleSpeed = head.LinearVelocity.X * 0.05f;
walkPos -= walkCycleSpeed;

View File

@@ -326,14 +326,14 @@ namespace Subsurface
Vector2 particleVel = SimPosition - position;
if (particleVel != Vector2.Zero) particleVel = Vector2.Normalize(particleVel);
Game1.particleManager.CreateParticle("blood",
Game1.ParticleManager.CreateParticle("blood",
SimPosition,
particleVel * Rand.Range(1.0f, 3.0f));
}
for (int i = 0; i < bloodAmount / 2; i++)
{
Game1.particleManager.CreateParticle("waterblood", SimPosition, Vector2.Zero);
Game1.ParticleManager.CreateParticle("waterblood", SimPosition, Vector2.Zero);
}
return new AttackResult(amount, bleedingAmount, hitArmor);

View File

@@ -520,7 +520,7 @@ namespace Subsurface
{
//create a splash particle
Subsurface.Particles.Particle splash = Game1.particleManager.CreateParticle("watersplash",
Subsurface.Particles.Particle splash = Game1.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.SimPosition.X, ConvertUnits.ToSimUnits(limbHull.Surface)),
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 0.1f)),
0.0f);
@@ -530,7 +530,7 @@ namespace Subsurface
limbHull.Rect.Y,
limbHull.Rect.Y - limbHull.Rect.Height));
Game1.particleManager.CreateParticle("bubbles",
Game1.ParticleManager.CreateParticle("bubbles",
new Vector2(limb.SimPosition.X, ConvertUnits.ToSimUnits(limbHull.Surface)),
limb.LinearVelocity*0.001f,
0.0f);

View File

@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -148,26 +149,26 @@ namespace Subsurface
// if (this.type == type) Apply(deltaTime, character, item);
//}
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
public virtual void Apply(ActionType type, float deltaTime, Entity entity, IPropertyObject target)
{
if (targetNames == null && !targetNames.Contains(target.Name)) return;
if (targetNames != null && !targetNames.Contains(target.Name)) return;
List<IPropertyObject> targets = new List<IPropertyObject>();
targets.Add(target);
if (this.type == type) Apply(deltaTime, position, targets);
if (this.type == type) Apply(deltaTime, entity, targets);
}
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, List<IPropertyObject> targets)
public virtual void Apply(ActionType type, float deltaTime, Entity entity, List<IPropertyObject> targets)
{
if (this.type == type) Apply(deltaTime, position, targets);
if (this.type == type) Apply(deltaTime, entity, targets);
}
protected virtual void Apply(float deltaTime, Vector2 position, List<IPropertyObject> targets)
{
if (explosion != null) explosion.Explode(position);
if (sound != null) sound.Play(1.0f, 1000.0f, position);
protected virtual void Apply(float deltaTime, Entity entity, List<IPropertyObject> targets)
{
if (explosion != null) explosion.Explode(entity.SimPosition);
if (sound != null) sound.Play(1.0f, 1000.0f, ConvertUnits.ToDisplayUnits(entity.SimPosition));
for (int i = 0; i < propertyNames.Count(); i++)
{

View File

@@ -3,10 +3,10 @@
<sound file="Content/Characters/Crawler/attack.ogg" state="Attack" range="500"/>
<ragdoll headposition="80" headangle="-70"
<ragdoll headposition="120" headangle="-90"
waveamplitude="50.0" wavelength="2500"
swimspeed="2.0" walkspeed="0.5"
stepsize ="30.0,10.0"
stepsize ="30.0,20.0"
stepoffset="30.0,0.0"
legtorque="10"
footrotation ="180.0"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 886 KiB

After

Width:  |  Height:  |  Size: 978 KiB

View File

@@ -14,47 +14,47 @@
</limb>
<limb id = "1" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.025" origin="0.5,0.5"/>
<limb id = "1" width="50" height="440" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="865,7,117,448" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "2" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.026" origin="0.5,0.5"/>
<limb id = "2" width="40" height="274" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="739,734,82,287" depth="0.026" origin="0.5,0.5"/>
</limb>
<limb id = "3" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.027" origin="0.5,0.5"/>
<limb id = "3" width="77" height="540" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="867,474,101,550" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "4" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.025" origin="0.5,0.5"/>
<limb id = "4" width="50" height="440" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="865,7,117,448" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "5" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.026" origin="0.5,0.5"/>
<limb id = "5" width="40" height="274" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="739,734,82,287" depth="0.026" origin="0.5,0.5"/>
</limb>
<limb id = "6" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.027" origin="0.5,0.5"/>
<limb id = "6" width="77" height="540" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="867,474,101,550" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "7" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.025" origin="0.5,0.5"/>
<limb id = "7" width="50" height="440" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="865,7,117,448" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "8" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.026" origin="0.5,0.5"/>
<limb id = "8" width="40" height="274" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="739,734,82,287" depth="0.026" origin="0.5,0.5"/>
</limb>
<limb id = "9" width="51" height="435" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="643,10,51,217" depth="0.028" origin="0.5,0.5"/>
<limb id = "9" width="77" height="540" flip="true">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="867,474,101,550" depth="0.025" origin="0.5,0.5"/>
</limb>
<joint limb1="0" limb1anchor="112,77" limb2="1" limb2anchor="0,-100" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="1" limb1anchor="0,100" limb2="2" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="2" limb1anchor="0,100" limb2="3" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="0" limb1anchor="112,77" limb2="1" limb2anchor="0,-190" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="1" limb1anchor="0,190" limb2="2" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="2" limb1anchor="0,100" limb2="3" limb2anchor="-15,-250" lowerlimit="-50" upperlimit="0"/>
<joint limb1="0" limb1anchor="0,0" limb2="4" limb2anchor="0,-100" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="4" limb1anchor="0,100" limb2="5" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="5" limb1anchor="0,100" limb2="6" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="0" limb1anchor="0,0" limb2="4" limb2anchor="0,-190" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="4" limb1anchor="0,190" limb2="5" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="5" limb1anchor="0,100" limb2="6" limb2anchor="-15,-250" lowerlimit="-50" upperlimit="0"/>
<joint limb1="0" limb1anchor="-53,-164" limb2="7" limb2anchor="0,-100" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="7" limb1anchor="0,100" limb2="8" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="8" limb1anchor="0,100" limb2="9" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="0" limb1anchor="-53,-164" limb2="7" limb2anchor="0,-190" lowerlimit="-180" upperlimit="-90"/>
<joint limb1="7" limb1anchor="0,190" limb2="8" limb2anchor="0,-100" lowerlimit="-50" upperlimit="0"/>
<joint limb1="8" limb1anchor="0,100" limb2="9" limb2anchor="-15,-250" lowerlimit="-50" upperlimit="0"/>
</ragdoll>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Item
name="Skyholder Artifact"
pickdistance="150"
price="100">
<Sprite texture="artifact.png" depth="0.8"/>
<Body width="36" height="60" density="5"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
</Item>
</Items>

View File

@@ -43,7 +43,6 @@
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
</ConnectionPanel>
</Item>
</Items>

View File

@@ -14,9 +14,8 @@
<Body radius="15"/>
<Holdable handle1="0,0"/>
<Holdable slots="Any,RightHand,LeftHand" handle1="0,0"/>
<Pickable slots="Any,RightHand,LeftHand"/>
<Wire/>
</Item>
@@ -33,13 +32,11 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
@@ -63,11 +60,10 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"/>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
@@ -91,11 +87,10 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"/>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
@@ -120,11 +115,9 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"/>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
@@ -147,11 +140,10 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"/>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
@@ -159,6 +151,33 @@
</ConnectionPanel>
</Item>
<Item
name="Signal Check Component"
Tags="smallitem"
pickdistance="150"
linkable="true"
price="10">
<Sprite texture ="light.png" depth="0.8"/>
<SignalCheckComponent canbeselected = "true"/>
<Body width="16" height="16"/>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<input name="set_output"/>
<input name="set_targetsignal"/>
<output name="signal_out"/>
</ConnectionPanel>
</Item>
<Item
name="RegEx Find Component"
Tags="smallitem"
@@ -172,11 +191,10 @@
<Body width="16" height="16"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"/>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
</Holdable>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>

Binary file not shown.

View File

@@ -10,6 +10,7 @@
<Engine minvoltage="0.5" powerperforce="10.0" maxforce="500" canbeselected = "true">
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
<sound file="engine.ogg" type="OnActive" range="3000.0" volume="CurrentVolume"/>
</Engine>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">

View File

@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Item
name="Syringe"
name="Medical Syringe"
Tags="smallitem"
pickdistance="150">
<Sprite texture ="med.png" sourcerect="0,0,24,5"/>
<Sprite texture ="med.png" sourcerect="0,0,24,5" depth="0.6"/>
<Body width="24" height="5"/>
<Pickable slots="Any,RightHand,LeftHand"/>
<Holdable RemoveOnUse="true">
<Holdable slots="Any,RightHand,LeftHand" RemoveOnUse="true">
<StatusEffect type="OnUse" target="This, Character" Condition="-100.0" health="30.0" disabledeltatime="true"/>
</Holdable>
</Item>
@@ -21,13 +19,11 @@
Tags="smallitem"
pickdistance="150">
<Sprite texture ="med.png" sourcerect="0,14,14,18"/>
<Sprite texture ="med.png" sourcerect="0,14,14,18" depth="0.6"/>
<Body width="9" height="15"/>
<Pickable slots="Any,RightHand,LeftHand"/>
<Holdable RemoveOnUse="true">
<Holdable slots="Any,RightHand,LeftHand" RemoveOnUse="true">
<StatusEffect type="OnUse" target="This, Character" Condition="-100.0" bleeding="-10.0" disabledeltatime="true"/>
</Holdable>
</Item>

View File

@@ -1,23 +0,0 @@
<Item
name="Oxygen Generator"
linkable="true">
<Sprite texture ="battery.png" depth="0.8"/>
<OxygenGenerator powerconsumption="2000.0" minvoltage="0.5" canbeselected = "true">
<StatusEffect type="OnActive" target="Contained" targetnames="Oxygen Tank" Condition="2.0"/>
</OxygenGenerator>
<trigger/>
<ItemContainer capacity="5" canbeselected = "true" msg="Insert oxygen tank to refill it">
<Containable name="Oxygen Tank"/>
</ItemContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
</Item>

View File

@@ -0,0 +1,37 @@
<Items>
<Item
name="Oxygen Generator"
linkable="true">
<Sprite texture ="battery.png" depth="0.8"/>
<OxygenGenerator powerconsumption="1000.0" minvoltage="0.5" canbeselected = "true">
<StatusEffect type="OnActive" target="Contained" targetnames="Oxygen Tank" Condition="2.0"/>
<sound file="oxygengenerator.ogg" type="OnActive" range="2000.0" volume="PowerConsumption" volumemultiplier="0.001f"/>
</OxygenGenerator>
<trigger/>
<ItemContainer capacity="5" canbeselected = "true" msg="Insert oxygen tank to refill it">
<Containable name="Oxygen Tank"/>
</ItemContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
</Item>
<Item
name="Vent"
linkable="true">
<Sprite texture ="vent.png" depth="0.8"/>
<Vent>
<sound file="ventilation.ogg" type="OnActive" range="600.0" volume="OxygenFlow" volumemultiplier="0.001f"/>
</Vent>
</Item>
</Items>

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

View File

@@ -4,8 +4,11 @@
pickdistance="200">
<Sprite texture ="pump.png" depth="0.08"/>
<Pump maxflow="500" PowerConsumption="300.0" MinVoltage="0.3"/>
<Pump canbeselected = "true" maxflow="500" PowerConsumption="300.0" MinVoltage="0.3">
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
<sound file="pump.ogg" type="OnActive" range="800.0" volume="PowerConsumption" volumemultiplier="0.003"/>
</Pump>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>

Binary file not shown.

View File

@@ -21,10 +21,14 @@
<Sprite texture ="reactor.png" depth="0.8"/>
<Reactor canbeselected = "true">
<GuiFrame rect="0,0,0.8,0.8" alignment="Center" color="0.0,0.0,0.0,0.8"/>
<GuiFrame rect="0,0,0.6,0.7" alignment="Center" color="0.0,0.0,0.0,0.8"/>
<requireditem name="Fuel Rod" type="Contained" msg="Fuel required to run the engine"/>
<StatusEffect type="OnActive" target="Contained" targetnames="Fuel Rod, Heat Absorber, Temperature Control Circuit" Condition="-0.1" />
<sound file="reactor.ogg" type="OnActive" range="1000.0" volume="FissionRate"/>
<sound file="reactor.ogg" type="OnActive" range="2000.0" volume="FissionRate" volumemultiplier="0.02f"/>
<StatusEffect type="OnBroken" target="This" FissionRate="0.0" disabledeltatime="true" sound="Content/Items/Reactor/explosion.ogg">
<Explosion range ="6.0" damage="500" structuredamage="600" stun="5.0" force="5.0"/>
</StatusEffect>
</Reactor>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">

View File

@@ -11,7 +11,8 @@
<Body width="39" height="18" density="5"/>
<!-- the character will hold the item 50 pixels in front of him, with his hands at the handle1 and handle2 positions -->
<Holdable aimpos="50,0" handle1="-17,0" handle2="8,0"/>
<Holdable slots="Any,BothHands"
aimpos="50,0" handle1="-17,0" handle2="8,0"/>
<RepairTool structurefixamount="50.0" range="80" barrelpos="19,8">
<!-- the item must contain a welding fuel tank for it to work -->
@@ -34,8 +35,6 @@
</StatusEffect>
</RepairTool>
<Pickable slots="Any,BothHands"/>
<!-- one welding fuel or oxygen tank can be contained inside the welding tool -->
<ItemContainer capacity="1" hideitems="false" itempos="-17,-21">
<Containable name="Welding Fuel Tank"/>
@@ -52,7 +51,8 @@
<Body width="39" height="18" density="5"/>
<Holdable aimpos="50,0" handle1="-12,4"/>
<Holdable slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-12,4"/>
<RepairTool structurefixamount="-10.0" range="50" barrelpos="19,8">
<RequiredItems name="Oxygen Tank" type="Contained" msg="Oxygen tank required"/>
@@ -68,8 +68,6 @@
</StatusEffect>
</RepairTool>
<Pickable slots="Any,RightHand,LeftHand"/>
<ItemContainer capacity="1" hideitems="false" itempos="9,-15">
<Containable name="Welding Fuel Tank"/>
<Containable name="Oxygen Tank"/>
@@ -85,8 +83,8 @@
<Body radius="6" height="22" density="5"/>
<Holdable holdpos="30,-15" handle1="0,5" handle2="0,-5"/>
<Pickable slots="RightHand,Any"/>
<Holdable slots="RightHand,Any"
holdpos="30,-15" handle1="0,5" handle2="0,-5"/>
</Item>
<Item
@@ -98,9 +96,9 @@
<Body width="30" height="8" density="20"/>
<Holdable holdangle="30" handle1="0,0"/>
<Holdable slots="Any,RightHand,LeftHand"
holdangle="30" handle1="0,0"/>
<Pickable slots="Any,RightHand,LeftHand"/>
</Item>
<Item
@@ -112,9 +110,9 @@
<Body width="30" height="8" density="20"/>
<Holdable holdangle="30" handle1="0,0"/>
<Holdable slots="Any,RightHand,LeftHand"
holdangle="30" handle1="0,0"/>
<Pickable slots="Any,RightHand,LeftHand"/>
</Item>
</Items>

View File

@@ -1,10 +0,0 @@
<Item
name="Vent"
linkable="true">
<Sprite texture ="vent.png" depth="0.8"/>
<Vent/>
</Item>

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Item
name="C-4 Block"
Tags="smallitem,explosive"
pickdistance="150"
price="50">
<Sprite texture="explosives.png" depth="0.8" sourcerect="0,0,16,7"/>
<Body width="16" height="7"/>
<Pickable slots="Any">
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Weapons/stunGrenade.ogg">
<Explosion range="10.0" structuredamage="600" damage="100" stun="5" force="20.0"/>
</StatusEffect>
</Pickable>
</Item>
<Item
name="Detonator"
Tags="smallitem"
pickdistance="150"
price="50">
<Sprite texture="explosives.png" depth="0.8" sourcerect="0,7,16,9"/>
<Body width="16" height="9"/>
<Holdable aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<Pickable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Pickable>
<ItemContainer capacity="1" itempos="0,0" hideitems="false">
<Containable name="explosive"/>
</ItemContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="activate">
<StatusEffect type="OnUse" target="Contained" Condition="-100.0"/>
</input>
</ConnectionPanel>
</Item>
</Items>

View File

@@ -42,7 +42,6 @@
<output name="position_out"/>
<output name="trigger_out"/>
</ConnectionPanel>
</Item>
<Item
@@ -66,8 +65,8 @@
<Body radius="14" height="63" density="15"/>
<Holdable holdpos="30,-15" handle1="0,20" handle2="0,-20"/>
<Pickable slots="RightHand"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,20" handle2="0,-20"/>
<Projectile launchimpulse="80.0">
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
</Projectile>

View File

@@ -23,10 +23,8 @@
<Body width="90" height="30" density="10"/>
<Holdable holdpos="35,-10" aimpos="35,-10" handle1="-15,-6" handle2="26,7"/>
<Holdable slots="Any,BothHands" holdpos="35,-10" aimpos="35,-10" handle1="-15,-6" handle2="26,7"/>
<Pickable slots="Any,BothHands"/>
<RangedWeapon barrelpos="49,10">
<Sound file="harpoon1.ogg" type="OnUse"/>
<Sound file="harpoon2.ogg" type="OnUse"/>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Quests>
<SalvageQuest
name="Salvaging an artifact"
description="Researchers 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."
reward="1000"
successmessage="You have successfully retrieved the artifact."
itemname="Skyholder Artifact">
</SalvageQuest>
</Quests>

View File

@@ -26,6 +26,9 @@
<damagesound file="Content/Sounds/Damage/implode.ogg" damagerange="0.0,100.0" damagesoundtype="Implode"/>
<damagesound file="Content/Sounds/Damage/implode.ogg" damagerange="0.0,100.0" damagesoundtype="Implode"/>
<music file="Content\Sounds\Music\Simplex.ogg" type="default"/>
<music file="Content\Sounds\Music\Enter The Maze.ogg" type="repair" priorityrange="40,100"/>
<music file="Content\Sounds\Music\Unseen Horrors.ogg" type="monster" priorityrange="40,100"/>

View File

@@ -163,10 +163,10 @@ namespace Subsurface
}
break;
case "startserver":
if (Game1.Server==null)
Game1.NetworkMember = new GameServer();
break;
//case "startserver":
// if (Game1.Server==null)
// Game1.NetworkMember = new GameServer();
// break;
case "kick":
if (Game1.Server == null) break;
Game1.Server.KickPlayer(commands[1]);
@@ -219,10 +219,13 @@ namespace Subsurface
it.Condition = 100.0f;
}
break;
case "fowenabled":
case "fow":
case "drawfow":
Game1.LightManager.FowEnabled = !Game1.LightManager.FowEnabled;
case "shake":
Game1.GameScreen.Cam.Shake = 10.0f;
break;
case "losenabled":
case "los":
case "drawlos":
Game1.LightManager.LosEnabled = !Game1.LightManager.LosEnabled;
break;
case "lighting":
case "lightingenabled":

View File

@@ -1,106 +0,0 @@
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//namespace Subsurface
//{
// static class EventManager
// {
// static Event activeEvent;
// static GUIFrame infoPanel;
// const int MaxPreviousEvents = 6;
// const float PreviouslyUsedWeight = 10.0f;
// static List<Event> previousEvents = new List<Event>();
// public static Event ActiveEvent
// {
// get { return activeEvent; }
// }
// public static void StartShift()
// {
// int eventCount = Event.list.Count();
// //create an array where the probability of an event being selected will be calculated
// float[] eventProbability = new float[eventCount];
// float probabilitySum = 0.0f;
// for (int i = 0; i < eventCount; i++)
// {
// eventProbability[i] = Event.list[i].Commonness;
// //if the event has been previously selected, it's less likely to be selected now
// int previousEventIndex = previousEvents.FindIndex(x => x == Event.list[i]);
// if (previousEventIndex>=0)
// {
// //how many shifts ago was the event last selected
// int eventDist = eventCount - previousEventIndex;
// float weighting = (1.0f / eventDist) * PreviouslyUsedWeight;
// eventProbability[i] *= weighting;
// }
// probabilitySum += eventProbability[i];
// }
// float randomNumber = (float)Game1.random.NextDouble()*probabilitySum;
// for (int i = 0; i < eventCount; i++)
// {
// if (randomNumber <= eventProbability[i])
// {
// SelectEvent(Event.list[i]);
// return;
// }
// randomNumber -= eventProbability[i];
// }
// }
// public static void SelectEvent(Event selectedEvent)
// {
// if (selectedEvent == null) return;
// activeEvent = selectedEvent;
// previousEvents.Add(activeEvent);
// activeEvent.Init();
// }
// public static void Update(GameTime gameTime)
// {
// if (activeEvent==null) return;
// activeEvent.Update(gameTime);
// }
// public static void DrawInfo(SpriteBatch spriteBatch)
// {
// if (activeEvent==null || !activeEvent.IsStarted) return;
// if (infoPanel == null)
// {
// infoPanel = new GUIFrame(new Rectangle(Game1.GraphicsWidth - 320, 20, 300, 100), Color.White * 0.8f);
// infoPanel.Padding = GUI.style.smallPadding;
// infoPanel.AddChild(new GUITextBlock(new Rectangle(0, 0, 200, 20), activeEvent.Name, Color.Transparent, Color.Black));
// infoPanel.AddChild(new GUITextBlock(new Rectangle(0, 0, 200, 50), activeEvent.Description, Color.Transparent, Color.Black));
// }
// //infoPanel.Draw(spriteBatch);
// }
// public static void EventFinished(Event e)
// {
// if (e != activeEvent) return;
// infoPanel.AddChild(new GUITextBlock(new Rectangle(0, 0, 200, 80), "Finished!", Color.Transparent, Color.Black));
// }
// }
//}

View File

@@ -0,0 +1,155 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
{
class Quest
{
private static List<Quest> list = new List<Quest>();
private static string configFile = "Content/Quests.xml";
private string name;
private string description;
protected bool completed;
private string successMessage;
private string failureMessage;
private int reward;
public string Name
{
get { return name; }
}
public string Description
{
get { return description; }
}
public int Reward
{
get { return reward; }
}
public bool Completed
{
get { return completed; }
}
public virtual string RadarLabel
{
get { return ""; }
}
public virtual Vector2 RadarPosition
{
get { return Vector2.Zero; }
}
public Quest(XElement element)
{
name = ToolBox.GetAttributeString(element, "name", "");
description = ToolBox.GetAttributeString(element, "description", "");
reward = ToolBox.GetAttributeInt(element, "reward", 1);
successMessage = ToolBox.GetAttributeString(element, "successmessage", "");
failureMessage = ToolBox.GetAttributeString(element, "failuremessage", "");
}
public static Quest LoadRandom(Random rand)
{
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return null;
int eventCount = doc.Root.Elements().Count();
//int[] commonness = new int[eventCount];
float[] eventProbability = new float[eventCount];
float probabilitySum = 0.0f;
int i = 0;
foreach (XElement element in doc.Root.Elements())
{
eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1);
probabilitySum += eventProbability[i];
i++;
}
float randomNumber = (float)rand.NextDouble() * probabilitySum;
i = 0;
foreach (XElement element in doc.Root.Elements())
{
if (randomNumber <= eventProbability[i])
{
Type t;
string type = element.Name.ToString();
try
{
t = Type.GetType("Subsurface." + type + ", Subsurface", true, true);
if (t == null)
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a quest class of the type ''" + type + "''.");
continue;
}
}
catch
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a an event class of the type ''" + type + "''.");
continue;
}
ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) });
object instance = constructor.Invoke(new object[] { element });
return (Quest)instance;
}
randomNumber -= eventProbability[i];
i++;
}
return null;
}
public virtual void Start(Level level)
{
}
/// <summary>
/// End the quest and give a reward if it was completed successfully
/// </summary>
/// <returns>whether the quest was completed or not</returns>
public virtual void End()
{
completed = true;
GiveReward();
}
public void GiveReward()
{
var mode = Game1.GameSession.gameMode as SinglePlayerMode;
mode.Money += reward;
if (!string.IsNullOrWhiteSpace(successMessage))
{
new GUIMessageBox("Quest completed", successMessage);
}
}
}
}

View File

@@ -0,0 +1,64 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
{
class SalvageQuest : Quest
{
ItemPrefab itemPrefab;
Item item;
public override string RadarLabel
{
get
{
return "Infrasonic signal";
}
}
public override Vector2 RadarPosition
{
get
{
return item.Position;
}
}
public SalvageQuest(XElement element)
: base(element)
{
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Error in salvagequest: couldn't find an item prefab with the name "+itemName);
}
}
public override void Start(Level level)
{
Vector2 position = level.PositionsOfInterest[Rand.Int(level.PositionsOfInterest.Count)];
item = new Item(itemPrefab, position+level.Position);
//item.MoveWithLevel = true;
}
public override void End()
{
if (item.CurrentHull == null) return;
item.Remove();
GiveReward();
completed = true;
}
}
}

View File

@@ -140,13 +140,13 @@ namespace Subsurface
t = Type.GetType("Subsurface." + type + ", Subsurface", true, true);
if (t == null)
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a an event class of the type ''" + type + "''.");
DebugConsole.ThrowError("Error in " + configFile + "! Could not find an event class of the type ''" + type + "''.");
continue;
}
}
catch
{
DebugConsole.ThrowError("Error in " + configFile + "! Could not find a an event class of the type ''" + type + "''.");
DebugConsole.ThrowError("Error in " + configFile + "! Could not find an event class of the type ''" + type + "''.");
continue;
}

View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
namespace Subsurface
{
@@ -15,55 +15,6 @@ namespace Subsurface
BottomRight = (Bottom | Right), BottomLeft = (Bottom | Left), BottomCenter = (CenterX | Bottom)
}
class GUIMessage
{
ColoredText coloredText;
Vector2 pos;
float lifeTime;
Vector2 size;
public string Text
{
get { return coloredText.text; }
}
public Color Color
{
get { return coloredText.color; }
}
public Vector2 Pos
{
get { return pos; }
set { pos = value; }
}
public Vector2 Size
{
get { return size; }
}
public float LifeTime
{
get { return lifeTime; }
set { lifeTime = value; }
}
public GUIMessage(string text, Color color, Vector2 position, float lifeTime)
{
coloredText = new ColoredText(text, color);
pos = position;
this.lifeTime = lifeTime;
size = GUI.Font.MeasureString(text);
}
}
class GUI
{
public static GUIStyle style;
@@ -71,15 +22,19 @@ namespace Subsurface
static Texture2D t;
public static SpriteFont Font, SmallFont;
private static GraphicsDevice graphicsDevice;
private static GraphicsDevice graphicsDevice;
private static List<GUIMessage> messages = new List<GUIMessage>();
private static Sound[] sounds;
private static bool pauseMenuOpen;
private static GUIFrame pauseMenu;
public static bool PauseMenuOpen
{
get { return pauseMenuOpen; }
}
public static void LoadContent(GraphicsDevice graphics)
{
@@ -96,6 +51,51 @@ namespace Subsurface
style = new GUIStyle("Content/UI/style.xml");
}
public static void TogglePauseMenu()
{
if (Screen.Selected == Game1.MainMenuScreen) return;
TogglePauseMenu(null, null);
if (pauseMenuOpen)
{
pauseMenu = new GUIFrame(new Rectangle(0,0,200,300), null, Alignment.Center, style);
int y = 0;
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, GUI.style, pauseMenu);
button.OnClicked = TogglePauseMenu;
y += 60;
if (Screen.Selected == Game1.GameScreen)
{
SinglePlayerMode spMode = Game1.GameSession.gameMode as SinglePlayerMode;
if (spMode!=null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, GUI.style, pauseMenu);
button.OnClicked += TogglePauseMenu;
button.OnClicked += Game1.GameSession.LoadPrevious;
y += 60;
}
}
button = new GUIButton(new Rectangle(0, y, 0, 30), "Quit", Alignment.CenterX, GUI.style, pauseMenu);
button.UserData = (int)MainMenuScreen.Tabs.Main;
button.OnClicked += Game1.MainMenuScreen.SelectTab;
button.OnClicked += TogglePauseMenu;
}
}
private static bool TogglePauseMenu(GUIButton button, object obj)
{
pauseMenuOpen = !pauseMenuOpen;
return true;
}
public static void DrawLine(SpriteBatch sb, Vector2 start, Vector2 end, Color clr, float depth = 0.0f)
{
Vector2 edge = end - start;
@@ -266,15 +266,18 @@ namespace Subsurface
public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam)
{
spriteBatch.DrawString(Font,
"FPS: " + (int)Game1.FrameCounter.AverageFramesPerSecond
+ " - Physics: " + Game1.World.UpdateTime
+ " - bodies: " + Game1.World.BodyList.Count,
"FPS: " + (int)Game1.FrameCounter.AverageFramesPerSecond,
new Vector2(10, 10), Color.White);
spriteBatch.DrawString(Font,
"Camera pos: " + Game1.GameScreen.Cam.Position,
new Vector2(10, 30), Color.White);
if (Game1.DebugDraw)
{
spriteBatch.DrawString(Font,
"Physics: " + Game1.World.UpdateTime
+ " - bodies: " + Game1.World.BodyList.Count
+ "Camera pos: " + Game1.GameScreen.Cam.Position,
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);
@@ -287,6 +290,11 @@ namespace Subsurface
if (messageBox != null) messageBox.Draw(spriteBatch);
}
if (pauseMenuOpen)
{
pauseMenu.Update(1.0f);
pauseMenu.Draw(spriteBatch);
}
DebugConsole.Draw(spriteBatch);
}

View File

@@ -0,0 +1,56 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
{
class GUIMessage
{
ColoredText coloredText;
Vector2 pos;
float lifeTime;
Vector2 size;
public string Text
{
get { return coloredText.text; }
}
public Color Color
{
get { return coloredText.color; }
}
public Vector2 Pos
{
get { return pos; }
set { pos = value; }
}
public Vector2 Size
{
get { return size; }
}
public float LifeTime
{
get { return lifeTime; }
set { lifeTime = value; }
}
public GUIMessage(string text, Color color, Vector2 position, float lifeTime)
{
coloredText = new ColoredText(text, color);
pos = position;
this.lifeTime = lifeTime;
size = GUI.Font.MeasureString(text);
}
}
}

View File

@@ -9,6 +9,7 @@ using Subsurface.Networking;
using Subsurface.Particles;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;
namespace Subsurface
{
@@ -46,7 +47,7 @@ namespace Subsurface
public static NetworkMember NetworkMember;
public static ParticleManager particleManager;
public static ParticleManager ParticleManager;
public static TextureLoader TextureLoader;
@@ -210,7 +211,7 @@ namespace Subsurface
EditCharacterScreen = new EditCharacterScreen();
yield return Status.Running;
particleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
ParticleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
yield return Status.Running;
GameMode.Init();
@@ -250,11 +251,11 @@ namespace Subsurface
if (loadState >= 100.0f && !titleScreenOpen)
{
//if (PlayerInput.KeyDown(Keys.Escape)) Quit();
if (PlayerInput.KeyHit(Keys.Escape)) GUI.TogglePauseMenu();
DebugConsole.Update(this, (float)deltaTime);
if (!DebugConsole.IsOpen || NetworkMember != null) Screen.Selected.Update(deltaTime);
if ((!DebugConsole.IsOpen && !GUI.PauseMenuOpen) || NetworkMember != null) Screen.Selected.Update(deltaTime);
GUI.Update((float)deltaTime);

View File

@@ -23,7 +23,7 @@ namespace Subsurface
private GUIFrame guiRoot;
//private GUIListBox chatBox;
private GUITextBox textBox;
//private GUITextBox textBox;
private string savePath;
@@ -44,8 +44,7 @@ namespace Subsurface
return (mode == null) ? null : mode.map;
}
}
public Submarine Submarine
{
get { return submarine; }
@@ -70,35 +69,8 @@ namespace Subsurface
guiRoot = new GUIFrame(new Rectangle(0,0,Game1.GraphicsWidth,Game1.GraphicsWidth), Color.Transparent);
//int width = 350, height = 100;
//if (Game1.NetworkMember!=null)
//{
// chatBox = new GUIListBox(new Rectangle(
// Game1.GraphicsWidth - 20 - width,
// Game1.GraphicsHeight - 40 - 25 - height,
// width, height),
// Color.White * 0.5f, GUI.style, guiRoot);
// textBox = new GUITextBox(
// new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
// Color.White * 0.5f, Color.Black, Alignment.Bottom, Alignment.Left, GUI.style, guiRoot);
// textBox.OnEnter = EnterChatMessage;
//}
this.gameMode = gameMode;
//if (gameMode != null && !gameMode.IsSinglePlayer)
//{
// gameMode.Start(Game1.NetLobbyScreen.GameDuration);
//}
//startTime = DateTime.Now;
//endTime = startTime + gameDuration;
this.submarine = selectedSub;
//if (!save) return;
//CreateSaveFile(selectedMapFile);
}
@@ -108,10 +80,6 @@ namespace Subsurface
XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return;
//gameMode = GameModePreset.list.Find(gm => gm.Name == "Single Player").Instantiate();
//day = ToolBox.GetAttributeInt(doc.Root,"day",1);
foreach (XElement subElement in doc.Root.Elements())
{
if (subElement.Name.ToString().ToLower() != "gamemode") continue;
@@ -131,20 +99,22 @@ namespace Subsurface
public void StartShift(TimeSpan duration, Level level, bool reloadSub = true)
{
Game1.LightManager.FowEnabled = (Game1.Server==null);
Game1.LightManager.LosEnabled = (Game1.Server==null);
this.level = level;
if (reloadSub || Submarine.Loaded != submarine) submarine.Load();
if (gameMode!=null) gameMode.Start(duration);
if (level != null)
{
level.Generate(submarine == null ? 100.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height));
submarine.SetPosition(level.StartPosition - new Vector2(0.0f, 2000.0f));
}
if (gameMode!=null) gameMode.Start(duration);
taskManager.StartShift(level);
}
@@ -177,85 +147,27 @@ namespace Subsurface
public bool LoadPrevious(GUIButton button, object obj)
{
SaveUtil.LoadGame(savePath);
Game1.LobbyScreen.Select();
return true;
}
//public bool EnterChatMessage(GUITextBox textBox, string message)
//{
// if (string.IsNullOrWhiteSpace(message)) return false;
// else if (Game1.NetworkMember != null)
// {
// Game1.NetworkMember.SendChatMessage(Game1.NetworkMember.Name + ": " + message);
// }
// textBox.Deselect();
// return true;
//}
//public void NewChatMessage(string text, Color color)
//{
// GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, 0, 20), text,
// ((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f, color,
// 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.First());
// }
//}
public void Update(float deltaTime)
{
taskManager.Update(deltaTime);
//if (endShiftButton!=null) endShiftButton.Enabled = !taskManager.CriticalTasks;
//endShiftButton.Enabled = true;
guiRoot.Update(deltaTime);
//endShiftButton.Update(deltaTime);
//textBox.Update(deltaTime);
if (gameMode != null) gameMode.Update(deltaTime);
//double duration = (endTime - startTime).TotalSeconds;
//double elapsedTime = (DateTime.Now-startTime).TotalSeconds;
//timerBar.BarSize = (float)(elapsedTime / Math.Max(duration, 1.0));
if (PlayerInput.KeyHit(Keys.Tab) && textBox!=null)
{
if (textBox.Selected)
{
textBox.Deselect();
textBox.Text = "";
}
else
{
textBox.Select();
}
}
}
public void Draw(SpriteBatch spriteBatch)
{
guiRoot.Draw(spriteBatch);
//crewManager.Draw(spriteBatch);
taskManager.Draw(spriteBatch);
if (gameMode!=null) gameMode.Draw(spriteBatch);
//chatBox.Draw(spriteBatch);
//textBox.Draw(spriteBatch);
//timerBar.Draw(spriteBatch);
//if (Game1.Client == null) endShiftButton.Draw(spriteBatch);
if (gameMode != null) gameMode.Draw(spriteBatch);
}
public void Save(string filePath)
@@ -265,10 +177,6 @@ namespace Subsurface
((SinglePlayerMode)gameMode).Save(doc.Root);
//doc.Root.Add(new XAttribute("day", day));
//crewManager.Save(doc.Root);
try
{
doc.Save(filePath);

View File

@@ -18,6 +18,8 @@ namespace Subsurface
private GUIButton endShiftButton;
public readonly CargoManager CargoManager;
private Quest quest;
public Map map;
@@ -26,6 +28,12 @@ namespace Subsurface
private bool savedOnStart;
public int Money
{
get { return crewManager.Money; }
set { crewManager.Money = value; }
}
public SinglePlayerMode(GameModePreset preset)
: base(preset)
{
@@ -78,13 +86,15 @@ namespace Subsurface
public void GenerateMap(string seed)
{
map = new Map(seed.GetHashCode(), 500);
map = new Map(seed, 500);
}
public override void Start(TimeSpan duration)
{
CargoManager.CreateItems();
Game1.GameSession.Map.SelectedConnection.Quest.Start(Level.Loaded);
if (!savedOnStart)
{
SaveUtil.SaveGame(Game1.GameSession.SavePath);
@@ -166,6 +176,8 @@ namespace Subsurface
{
base.End(endMessage);
quest.End();
StringBuilder sb = new StringBuilder();
List<Character> casualties = crewManager.characters.FindAll(c => c.IsDead);
@@ -208,9 +220,6 @@ namespace Subsurface
Character.CharacterList[i].Remove();
}
//SaveUtil.SaveGame(Game1.GameSession.SavePath);
Game1.GameSession.EndShift("");
}

View File

@@ -125,6 +125,8 @@ namespace Subsurface
}
}
if (allowedSlots.HasFlag(LimbSlot.BothHands)) TryPutItem(item, 3, createNetworkEvent);
return false;
}

View File

@@ -132,8 +132,8 @@ namespace Subsurface.Items.Components
foreach (StatusEffect effect in ri.statusEffects)
{
if (effect.Targets.HasFlag(StatusEffect.TargetType.This)) effect.Apply(ActionType.OnContaining, deltaTime, item.SimPosition, item.AllPropertyObjects);
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained)) effect.Apply(ActionType.OnContaining, deltaTime, item.SimPosition, contained.AllPropertyObjects);
if (effect.Targets.HasFlag(StatusEffect.TargetType.This)) effect.Apply(ActionType.OnContaining, deltaTime, item, item.AllPropertyObjects);
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained)) effect.Apply(ActionType.OnContaining, deltaTime, item, contained.AllPropertyObjects);
}
contained.ApplyStatusEffects(ActionType.OnContained, deltaTime);

View File

@@ -4,12 +4,12 @@ using Microsoft.Xna.Framework;
namespace Subsurface.Items.Components
{
class Holdable : ItemComponent
class Holdable : Pickable
{
//the position(s) in the item that the character grabs
protected Vector2[] handlePos;
protected Character picker;
//protected Character picker;
//the distance from the holding characters elbow to center of the physics body of the item
protected Vector2 holdPos;
@@ -154,6 +154,8 @@ namespace Subsurface.Items.Components
public override bool Pick(Character picker)
{
if (!base.Pick(picker)) return false;
if (!attachable) return false;
//if (item.body==null)

View File

@@ -37,10 +37,6 @@ namespace Subsurface.Items.Components
if (picker == null) return false;
if (picker.Inventory == null) return false;
//this.picker = picker;
if (picker.Inventory.TryPutItem(item, allowedSlots))
{
if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false;

View File

@@ -151,7 +151,7 @@ namespace Subsurface.Items.Components
foreach (StatusEffect effect in statusEffects)
{
//if (Array.IndexOf(effect.TargetNames, targetItem.Name) == -1) continue;
effect.Apply(ActionType.OnUse, deltaTime, item.SimPosition, targetItem.AllPropertyObjects);
effect.Apply(ActionType.OnUse, deltaTime, item, targetItem.AllPropertyObjects);
//targetItem.ApplyStatusEffect(effect, ActionType.OnUse, deltaTime);
}
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
@@ -182,7 +182,7 @@ namespace Subsurface.Items.Components
(float)Math.Cos(item.body.Rotation),
(float)Math.Sin(item.body.Rotation)) *item.body.Dir * 5.0f;
Game1.particleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed);
Game1.ParticleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed);
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);

View File

@@ -7,11 +7,10 @@ using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Networking;
using Subsurface.Items.Components;
using System.IO;
using System.Globalization;
namespace Subsurface
namespace Subsurface.Items.Components
{
class ItemSound
{
@@ -20,6 +19,8 @@ namespace Subsurface
public string VolumeProperty;
public float VolumeMultiplier;
public readonly float Range;
public ItemSound(Sound sound, ActionType type, float range)
@@ -207,10 +208,10 @@ namespace Subsurface
guiFrame = new GUIFrame(
new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Z, (int)rect.W),
new Color(color.X, color.Y, color.Z, color.W), alignment);
new Color(color.X, color.Y, color.Z, color.W), alignment, GUI.style);
//guiFrame.Alpha = color.W;
break;
break;
case "sound":
string filePath = ToolBox.GetAttributeString(subElement, "file", "");
if (filePath=="") continue;
@@ -236,6 +237,7 @@ namespace Subsurface
float range = ToolBox.GetAttributeFloat(subElement, "range", 800.0f);
ItemSound itemSound = new ItemSound(sound, type, range);
itemSound.VolumeProperty = ToolBox.GetAttributeString(subElement, "volume", "");
itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f);
sounds.Add(itemSound);
break;
}
@@ -245,7 +247,7 @@ namespace Subsurface
private ItemSound loopingSound;
private int loopingSoundIndex;
public void PlaySound(ActionType type, float volume, Vector2 position, bool loop=false)
public void PlaySound(ActionType type, Vector2 position, bool loop=false)
{
ItemSound itemSound = null;
if (!loop || !Sounds.SoundManager.IsPlaying(loopingSoundIndex))
@@ -254,19 +256,9 @@ namespace Subsurface
if (matchingSounds.Count == 0) return;
int index = Rand.Int(matchingSounds.Count);
itemSound = sounds[index];
itemSound = matchingSounds[index];
if (itemSound.VolumeProperty != "")
{
ObjectProperty op = null;
if (properties.TryGetValue(itemSound.VolumeProperty.ToLower(), out op))
{
float newVolume = 0.0f;
float.TryParse(op.GetValue().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out newVolume);
volume = MathHelper.Clamp(newVolume, 0.0f, 1.0f);
}
}
if (loop) loopingSound = itemSound;
}
@@ -274,16 +266,33 @@ namespace Subsurface
if (loop)
{
//if (loopingSound != null && loopingSound.volumeProperty != "") volume = float.Parse(properties[loopingSound.volumeProperty].GetValue().ToString());
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, volume, position, loopingSound.Range);
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range);
}
else
{
itemSound.Sound.Play(volume, itemSound.Range, position);
itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position);
}
}
private float GetSoundVolume(ItemSound sound)
{
if (sound.VolumeProperty == "") return 1.0f;
ObjectProperty op = null;
if (properties.TryGetValue(sound.VolumeProperty.ToLower(), out op))
{
float newVolume = 0.0f;
float.TryParse(op.GetValue().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out newVolume);
newVolume *= sound.VolumeMultiplier;
return MathHelper.Clamp(newVolume, 0.0f, 1.0f);
}
return 0.0f;
}
public virtual void Move(Vector2 amount) { }
/// <summary>a character has picked the item</summary>
@@ -347,7 +356,17 @@ namespace Subsurface
return false;
}
public virtual void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0.0f) { }
public virtual void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0.0f)
{
switch (connection.Name)
{
case "activate":
case "use":
item.Use(1.0f);
break;
}
}
public virtual bool Combine(Item item)
{
@@ -459,12 +478,12 @@ namespace Subsurface
}
}
public void ApplyStatusEffects(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
public void ApplyStatusEffects(ActionType type, float deltaTime, IPropertyObject target)
{
foreach (StatusEffect effect in statusEffects)
{
if (effect.type != type) continue;
effect.Apply(type, deltaTime, position, target);
effect.Apply(type, deltaTime, item, target);
}
}
@@ -569,7 +588,7 @@ namespace Subsurface
ConstructorInfo constructor;
try
{
if (!t.IsSubclassOf(typeof(ItemComponent))) return null;
if (t!=typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null;
constructor = t.GetConstructor(new Type[] { typeof(Item), typeof(XElement) });
if (constructor == null)
{

View File

@@ -50,7 +50,11 @@ namespace Subsurface.Items.Components
: base(item, element)
{
isActive = true;
}
public float CurrentVolume
{
get { return Math.Abs((force / 100.0f) * (voltage / minVoltage)); }
}
public override void Update(float deltaTime, Camera cam)
@@ -68,7 +72,7 @@ namespace Subsurface.Items.Components
for (int i = 0; i < 5; i++)
{
Game1.particleManager.CreateParticle("bubbles", item.SimPosition,
Game1.ParticleManager.CreateParticle("bubbles", item.SimPosition,
-currForce/500.0f + new Vector2(Rand.Range(-1.0f, 1.0f), Rand.Range(-0.5f, 0.5f)));
}
}

View File

@@ -1,4 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.Xml.Linq;
@@ -16,6 +18,16 @@ namespace Subsurface.Items.Components
Hull hull1, hull2;
private float FlowPercentage
{
get { return flowPercentage; }
set
{
if (float.IsNaN(flowPercentage)) return;
flowPercentage = MathHelper.Clamp(value,-100.0f,100.0f);
}
}
[HasDefaultValue(100.0f, false)]
public float MaxFlow
{
@@ -26,7 +38,7 @@ namespace Subsurface.Items.Components
public Pump(Item item, XElement element)
: base(item, element)
{
//maxFlow = ToolBox.GetAttributeFloat(element, "maxflow", 100.0f);
flowPercentage = 100.0f;
item.linkedTo.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
{ GetHulls(); };
@@ -34,7 +46,7 @@ namespace Subsurface.Items.Components
public override void Update(float deltaTime, Camera cam)
{
currPowerConsumption = powerConsumption;
currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f);
if (voltage < minVoltage) return;
@@ -56,52 +68,17 @@ namespace Subsurface.Items.Components
}
hull1.Volume += deltaVolume;
if (hull2 != null) hull2.Volume -= deltaVolume;
if (hull1.Volume > hull1.FullVolume) hull1.Pressure += 0.5f;
if (hull2 != null)
{
hull2.Volume -= deltaVolume;
if (hull2.Volume > hull1.FullVolume) hull2.Pressure += 0.5f;
}
voltage = 0.0f;
}
//public override void DrawHUD(SpriteBatch spriteBatch, Character character)
//{
// int width = 300, height = 200;
// int x = Game1.GraphicsWidth / 2 - width / 2;
// int y = Game1.GraphicsHeight / 2 - height / 2;
// GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
// spriteBatch.DrawString(GUI.font, "Pumping direction: " + ((flowIn) ? "in" : "out"), new Vector2(x + 30, y + 30), Color.White);
// if (GUI.DrawButton(spriteBatch, new Rectangle(x + 30, y + 50, 80, 40), "TOGGLE")) flowIn = !flowIn;
// if (GUI.DrawButton(spriteBatch, new Rectangle(x + 30, y + 150, 100, 40), (isActive) ? "TURN OFF" : "TURN ON")) IsActive = !isActive;
//}
//public override bool Pick(Character activator = null)
//{
// //isActive = !isActive;
// hull1 = null;
// hull2 = null;
// foreach (MapEntity e in item.linkedTo)
// {
// Hull hull = e as Hull;
// if (hull == null) continue;
// if (hull1 == null)
// {
// hull1 = hull;
// }
// else if (hull2 == null && hull != hull1)
// {
// hull2 = hull;
// break;
// }
// }
// return true;
//}
private void GetHulls()
{
hull1 = null;
@@ -124,34 +101,33 @@ namespace Subsurface.Items.Components
}
}
//public override void OnMapLoaded()
//{
// hull1 = null;
// hull2 = null;
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
// foreach (MapEntity e in item.linkedTo)
// {
// Hull hull = e as Hull;
// if (hull == null) continue;
GuiFrame.Draw(spriteBatch);
// if (hull1 == null)
// {
// hull1 = hull;
// }
// else if (hull2 == null && hull != hull1)
// {
// hull2 = hull;
// break;
// }
// }
//}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 100, 40), ((isActive) ? "TURN OFF" : "TURN ON")))
{
targetLevel = null;
isActive = !isActive;
}
spriteBatch.DrawString(GUI.Font, "Flow percentage: " + (int)flowPercentage + " %", new Vector2(x + 20, y + 80), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "+", true)) FlowPercentage += 1.0f;
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "-", true)) FlowPercentage -= 1.0f;
item.NewComponentEvent(this, true);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
base.ReceiveSignal(signal, connection, sender, power);
isActive = true;
if (connection.Name == "toggle")
{
isActive = !isActive;
@@ -176,8 +152,6 @@ namespace Subsurface.Items.Components
targetLevel = MathHelper.Clamp(tempTarget, 0.0f, 100.0f);
}
}
}
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
@@ -193,13 +167,13 @@ namespace Subsurface.Items.Components
try
{
newFlow = MathHelper.Clamp(message.ReadFloat(), -100.0f, 100.0f);
newFlow = message.ReadFloat();
newActive = message.ReadBoolean();
}
catch { return; }
flowPercentage = newFlow;
FlowPercentage = newFlow;
isActive = newActive;
}
}

View File

@@ -96,6 +96,7 @@ namespace Subsurface.Items.Components
float scale = 0.015f;
float displayScale = ConvertUnits.ToDisplayUnits(scale);
if (Level.Loaded != null)
{
@@ -109,12 +110,11 @@ namespace Subsurface.Items.Components
center + (edges[i][1] - offset) * scale, Color.White);
}
scale = ConvertUnits.ToDisplayUnits(scale);
for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
{
Vector2 start = Submarine.Loaded.HullVertices[i] * scale;
Vector2 start = Submarine.Loaded.HullVertices[i] * displayScale;
start.Y = -start.Y;
Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * scale;
Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * displayScale;
end.Y = -end.Y;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.White);
@@ -127,7 +127,7 @@ namespace Subsurface.Items.Components
if (c.SimPosition != Vector2.Zero && c.SimPosition.Length() < 7 * Level.GridCellWidth)
{
int width = (int)Math.Min(c.Mass / 5, 30);
int width = (int)MathHelper.Clamp(c.Mass / 20, 1, 10);
Vector2 pos = c.Position * scale;
pos.Y = -pos.Y;
@@ -141,6 +141,74 @@ namespace Subsurface.Items.Components
{
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
}
//if (Level.Loaded != null)
//{
// for (int i = 0; i < 2; i++)
// {
// Vector2 targetPos = (i == 0) ? Level.Loaded.StartPosition : Level.Loaded.EndPosition;
// targetPos += Level.Loaded.Position;
// float dist = targetPos.Length();
// targetPos.Y = -targetPos.Y;
// Vector2 markerPos = Vector2.Normalize(targetPos) * (rect.Width * 0.55f);
// markerPos += center;
// GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen);
// string label;
// if (Game1.GameSession.Map!=null)
// {
// label = (i == 0) ? Game1.GameSession.Map.CurrentLocation.Name : Game1.GameSession.Map.SelectedLocation.Name;
// }
// else
// {
// label = (i == 0) ? "Start" : "End";
// }
// 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);
// }
DrawMarker(spriteBatch,
(Game1.GameSession.Map == null) ? "Start" : Game1.GameSession.Map.CurrentLocation.Name,
Level.Loaded.StartPosition + Level.Loaded.Position, center, (rect.Width * 0.55f));
DrawMarker(spriteBatch,
(Game1.GameSession.Map == null) ? "End" : Game1.GameSession.Map.SelectedLocation.Name,
Level.Loaded.EndPosition + Level.Loaded.Position, center, (rect.Width * 0.55f));
if (Game1.GameSession.Map != null && Game1.GameSession.Map.SelectedConnection.Quest!=null)
{
var quest = Game1.GameSession.Map.SelectedConnection.Quest;
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
{
DrawMarker(spriteBatch,
quest.RadarLabel,
quest.RadarPosition, center, (rect.Width * 0.55f));
}
}
}
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, Vector2 center, float radius)
{
//position += Level.Loaded.Position;
float dist = position.Length();
position.Y = -position.Y;
Vector2 markerPos = center + Vector2.Normalize(position) * radius;
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);
}
private void UpdateRendertarget()

View File

@@ -101,6 +101,8 @@ namespace Subsurface.Items.Components
meltDownTemp = 9000.0f;
shutDownTemp = 500.0f;
powerPerTemp = 1.0f;
isActive = true;
@@ -227,39 +229,14 @@ namespace Subsurface.Items.Components
new RepairTask(item, 60.0f, "Reactor meltdown!");
item.Condition = 0.0f;
fissionRate = 0.0f;
coolingRate = 0.0f;
//fissionRate = 0.0f;
//coolingRate = 0.0f;
new Explosion(item.SimPosition, 6.0f, 500.0f, 600.0f, 10.0f, 2.0f).Explode();
//List<Structure> structureList = new List<Structure>();
//float dist = 600.0f;
//foreach (MapEntity entity in MapEntity.mapEntityList)
//{
// Structure structure = entity as Structure;
// if (structure == null) continue;
// if (structure.HasBody && Vector2.Distance(structure.Position, item.Position)<dist*3.0f)
// {
// structureList.Add(structure);
// }
//}
//foreach (Structure structure in structureList)
//{
// for (int i = 0; i < structure.SectionCount; i++)
// {
// float damage = dist - Vector2.Distance(structure.SectionPosition(i), item.Position);
// if (damage > 0.0f) structure.AddDamage(i, damage);
// }
//}
//if (item.currentHull!=null)
//{
// item.currentHull.WaveVel[item.currentHull.GetWaveIndex(item.SimPosition)] = 100.0f;
//}
//PlaySound(ActionType.OnFailure, item.Position);
//item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, null);
//new Explosion(item.SimPosition, 6.0f, 500.0f, 600.0f, 10.0f, 2.0f).Explode();
if (item.ContainedItems!=null)
{
foreach (Item containedItem in item.ContainedItems)
@@ -274,11 +251,7 @@ namespace Subsurface.Items.Components
public override bool Pick(Character picker)
{
if (picker == null) return false;
//picker.SelectedConstruction = (picker.SelectedConstruction==item) ? null : item;
return true;
return (picker != null);
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
@@ -331,10 +304,10 @@ namespace Subsurface.Items.Components
y = y - 260;
spriteBatch.DrawString(GUI.Font, "Autotemp: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON"))) autoTemp = !autoTemp;
spriteBatch.DrawString(GUI.Font, "Max temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true)) shutDownTemp += 100.0f;
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true)) shutDownTemp -= 100.0f;
@@ -378,7 +351,7 @@ namespace Subsurface.Items.Components
Vector2 lastPoint = new Vector2(x,
y + height - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.Red);
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.White);
}
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message)

View File

@@ -12,12 +12,33 @@ namespace Subsurface.Items.Components
{
class Steering : ItemComponent
{
Vector2 currVelocity;
Vector2 targetVelocity;
private Vector2 currVelocity;
private Vector2 targetVelocity;
bool autoPilot;
private bool autoPilot;
SteeringPath steeringPath;
private SteeringPath steeringPath;
private static PathFinder pathFinder;
bool AutoPilot
{
get { return autoPilot; }
set
{
if (value == autoPilot) return;
autoPilot = value;
if (autoPilot)
{
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
steeringPath = pathFinder.FindPath(
ConvertUnits.ToSimUnits(Level.Loaded.Position),
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
}
}
}
private Vector2 TargetVelocity
{
@@ -43,18 +64,16 @@ namespace Subsurface.Items.Components
public override void Update(float deltaTime, Camera cam)
{
base.Update(deltaTime, cam);
if (autoPilot)
{
if (steeringPath==null)
{
PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
steeringPath = pathFinder.FindPath(
ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
}
//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);
@@ -90,7 +109,7 @@ namespace Subsurface.Items.Components
if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
{
autoPilot = !autoPilot;
AutoPilot = !AutoPilot;
item.NewComponentEvent(this, true);
}
@@ -156,7 +175,7 @@ namespace Subsurface.Items.Components
}
TargetVelocity = newTargetVelocity;
autoPilot = newAutoPilot;
AutoPilot = newAutoPilot;
}
}
}

View File

@@ -7,9 +7,9 @@ namespace Subsurface.Items.Components
{
class PowerContainer : Powered
{
//[power/min]
float capacity;
//[power/min]
float charge;
//how fast the battery can be recharged
@@ -21,12 +21,6 @@ namespace Subsurface.Items.Components
float maxOutput;
//public override float Charge
//{
// get { return charge; }
// set { Math.Max(Math.Min(charge = value, capacity), 0.0f); }
//}
[Editable, HasDefaultValue(10.0f, true)]
public float MaxOutPut
{
@@ -46,13 +40,14 @@ namespace Subsurface.Items.Components
}
[HasDefaultValue(10.0f, false)]
[HasDefaultValue(10.0f, false), Editable]
public float Capacity
{
get { return capacity; }
set { capacity = Math.Max(value,1.0f); }
}
[HasDefaultValue(10.0f, false), Editable]
public float RechargeSpeed
{
get { return rechargeSpeed; }
@@ -63,7 +58,7 @@ namespace Subsurface.Items.Components
}
}
[HasDefaultValue(10.0f, false)]
[HasDefaultValue(10.0f, false), Editable]
public float MaxRechargeSpeed
{
get { return maxRechargeSpeed; }

View File

@@ -26,6 +26,8 @@ namespace Subsurface.Items.Components
private static Item draggingConnected;
private List<StatusEffect> effects;
int[] wireId;
public List<Connection> Recipients
@@ -67,21 +69,31 @@ namespace Subsurface.Items.Components
IsOutput = (element.Name.ToString() == "output");
Name = ToolBox.GetAttributeString(element, "name", (IsOutput) ? "output" : "input");
effects = new List<StatusEffect>();
wireId = new int[MaxLinked];
foreach (XElement subElement in element.Elements())
{
int index = -1;
for (int i = 0; i < MaxLinked; i++)
switch (subElement.Name.ToString().ToLower())
{
if (wireId[i]<1) index = i;
case "link":
int index = -1;
for (int i = 0; i < MaxLinked; i++)
{
if (wireId[i]<1) index = i;
}
if (index == -1) break;
wireId[index] = ToolBox.GetAttributeInt(subElement, "w", -1);
break;
case "statuseffect":
effects.Add(StatusEffect.Load(subElement));
break;
}
if (index == -1) break;
wireId[index] = ToolBox.GetAttributeInt(subElement, "w", -1);
}
}
public int FindEmptyIndex()
@@ -149,6 +161,13 @@ namespace Subsurface.Items.Components
{
ic.ReceiveSignal(signal, recipient, sender, power);
}
foreach (StatusEffect effect in recipient.effects)
{
//effect.Apply(ActionType.OnUse, 1.0f, recipient.item, recipient.item);
recipient.item.ApplyStatusEffect(effect, ActionType.OnUse, 1.0f);
}
}
}

View File

@@ -28,7 +28,7 @@ namespace Subsurface.Items.Components
{
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0.0f)
{
switch (connection.Name)
{

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class SignalCheckComponent : ItemComponent
{
private string output;
private string targetSignal;
[InGameEditable, HasDefaultValue("1", true)]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, HasDefaultValue("", true)]
public string TargetSignal
{
get { return targetSignal; }
set { targetSignal = value; }
}
public SignalCheckComponent(Item item, XElement element)
: base(item, element)
{
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
switch (connection.Name)
{
case "signal_in":
item.SendSignal((signal == targetSignal) ? output : "0", "signal_out");
break;
case "set_output":
output = signal;
break;
case "set_targetsignal":
targetSignal = signal;
break;
}
}
}
}

View File

@@ -51,7 +51,7 @@ namespace Subsurface.Items.Components
set { reloadTime = value; }
}
[HasDefaultValue("0.0,0.0", true)]
[HasDefaultValue("0.0,0.0", true), Editable]
public string RotationLimits
{
get

View File

@@ -17,7 +17,7 @@ namespace Subsurface
public enum ActionType
{
OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure
OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken
}
class Item : MapEntity, IDamageable, IPropertyObject
@@ -69,8 +69,9 @@ namespace Subsurface
float prev = condition;
condition = MathHelper.Clamp(value, 0.0f, 100.0f);
if (condition==0.0f && prev>0.0f)
if (condition == 0.0f && prev>0.0f)
{
ApplyStatusEffects(ActionType.OnBroken, 1.0f, null);
foreach (FixRequirement req in FixRequirements)
{
req.Fixed = false;
@@ -369,7 +370,7 @@ namespace Subsurface
public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null)
{
if (condition == 0.0f) return;
if (condition == 0.0f && effect.type != ActionType.OnBroken) return;
bool hasTargets = (effect.TargetNames == null);
@@ -424,7 +425,7 @@ namespace Subsurface
// //container.ApplyStatusEffect(effect, type, deltaTime, container);
//}
effect.Apply(type, deltaTime, SimPosition, targets);
effect.Apply(type, deltaTime, this, targets);
}
}
@@ -446,7 +447,7 @@ namespace Subsurface
{
ic.Update(deltaTime, cam);
ic.PlaySound(ActionType.OnActive, 1.0f, Position, true);
ic.PlaySound(ActionType.OnActive, Position, true);
ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
}
else
@@ -596,8 +597,8 @@ namespace Subsurface
requiredItemCount += ic.requiredItems.Count;
}
}
editingHUD = new GUIFrame(new Rectangle(x, y, width, 110 + (editableProperties.Count()+requiredItemCount) * 30), Color.Black * 0.5f);
editingHUD = new GUIFrame(new Rectangle(x, y, width, 110 + (editableProperties.Count() + requiredItemCount) * 30), Color.Black * 0.5f);
editingHUD.Padding = new Vector4(10, 10, 0, 0);
editingHUD.UserData = this;
@@ -662,6 +663,7 @@ namespace Subsurface
editingHUD = CreateEditingHUD(true);
}
editingHUD.Update((float)Physics.step);
editingHUD.Draw(spriteBatch);
foreach (ItemComponent ic in components)
@@ -764,7 +766,7 @@ namespace Subsurface
if (tempRequiredSkill != null) requiredSkill = tempRequiredSkill;
if (!ic.HasRequiredItems(picker, picker == Character.Controlled) && !forcePick) continue;
if (!forcePick && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue;
if ((ic.CanBePicked && ic.Pick(picker)) || (ic.CanBeSelected && ic.Select(picker)))
{
picked = true;
@@ -805,7 +807,7 @@ namespace Subsurface
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
if (ic.Use(deltaTime, character))
{
ic.PlaySound(ActionType.OnUse, 1.0f, Position);
ic.PlaySound(ActionType.OnUse, Position);
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character);
@@ -902,14 +904,19 @@ namespace Subsurface
object prevValue = objectProperty.GetValue();
textBox.Selected = false;
if (objectProperty.TrySetValue(text))
{
textBox.Text = text;
new NetworkEvent(NetworkEventType.UpdateProperty, ID, true, objectProperty.Name);
return true;
}
else
{
if (prevValue!=null)
if (prevValue != null)
{
textBox.Text = prevValue.ToString();
}
@@ -1075,6 +1082,42 @@ namespace Subsurface
case NetworkEventType.UpdateComponent:
message.Write((int)data);
components[(int)data].FillNetworkData(type, message);
break;
case NetworkEventType.UpdateProperty:
var allProperties = GetProperties<InGameEditable>();
ObjectProperty objectProperty = allProperties.Find(op => op.Name == (string)data);
if (objectProperty != null)
{
message.Write((string)data);
object value = objectProperty.GetValue();
if (value is string)
{
message.Write((byte)0);
message.Write((string)value);
}
else if (value is float)
{
message.Write((byte)1);
message.Write((float)value);
}
else if (value is int)
{
message.Write((byte)2);
message.Write((int)value);
}
else if (value is bool)
{
message.Write((byte)3);
message.Write((bool)value);
}
else
{
message.Write((byte)200);
}
}
break;
}
}
@@ -1093,6 +1136,47 @@ namespace Subsurface
int componentIndex = message.ReadInt32();
if (componentIndex < 0 || componentIndex > components.Count - 1) return;
components[componentIndex].ReadNetworkData(type, message);
break;
case NetworkEventType.UpdateProperty:
string propertyName = "";
try
{
propertyName = message.ReadString();
}
catch
{
return;
}
var allProperties = GetProperties<InGameEditable>();
ObjectProperty property = allProperties.Find(op => op.Name == propertyName);
if (property == null) return;
try
{
switch (message.ReadByte())
{
case 0:
property.TrySetValue(message.ReadString());
break;
case 1:
property.TrySetValue(message.ReadFloat());
break;
case 2:
property.TrySetValue(message.ReadInt32());
break;
case 3:
property.TrySetValue(message.ReadBoolean());
break;
}
}
catch
{
return;
}
break;
}
}

View File

@@ -1,5 +1,6 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Subsurface.Lights;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -8,29 +9,34 @@ namespace Subsurface
{
class Explosion
{
Vector2 position;
private Vector2 position;
private float range;
private float damage;
private float structureDamage;
private float stun;
float range;
float damage;
float structureDamage;
float stun;
private float force;
float force;
private LightSource light;
public Explosion(Vector2 position, float range, float damage, float structureDamage, float stun=0.0f, float force=0.0f)
public float CameraShake;
public Explosion(Vector2 position, float range, float damage, float structureDamage, float stun = 0.0f, float force = 0.0f)
{
this.position = position;
this.range = Math.Max(range,1.0f);
this.range = Math.Max(range, 1.0f);
this.damage = damage;
this.structureDamage = structureDamage;
this.stun = stun;
this.force = force;
CameraShake = range*10.0f;
}
public Explosion(XElement element)
{
range = Math.Max(ToolBox.GetAttributeFloat(element, "range", 1.0f),1.0f);
range = Math.Max(ToolBox.GetAttributeFloat(element, "range", 1.0f), 1.0f);
damage = ToolBox.GetAttributeFloat(element, "damage", 0.0f);
structureDamage = ToolBox.GetAttributeFloat(element, "structuredamage", 0.0f);
stun = ToolBox.GetAttributeFloat(element, "stun", 0.0f);
@@ -43,18 +49,25 @@ namespace Subsurface
Explode(position);
}
public void Explode(Vector2 position)
public void Explode(Vector2 simPosition)
{
for (int i = 0; i<range*10; i++)
for (int i = 0; i < range * 10; i++)
{
Game1.particleManager.CreateParticle("explosionfire", position,
Game1.ParticleManager.CreateParticle("explosionfire", simPosition,
Rand.Vector(Rand.Range(3.0f, 4.0f)), 0.0f);
}
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(position);
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(simPosition);
float displayRange = ConvertUnits.ToDisplayUnits(range);
if (structureDamage>0.0f)
light = new LightSource(displayPosition, displayRange, Color.LightYellow);
CoroutineManager.StartCoroutine(DimLight());
float cameraDist = Vector2.Distance(Game1.GameScreen.Cam.Position, displayPosition)/2.0f;
Game1.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist)/displayRange, 0.0f);
if (structureDamage > 0.0f)
{
List<Structure> structureList = new List<Structure>();
@@ -84,7 +97,7 @@ namespace Subsurface
foreach (Character c in Character.CharacterList)
{
float dist = Vector2.Distance(c.SimPosition, position);
float dist = Vector2.Distance(c.SimPosition, simPosition);
if (dist > range) continue;
@@ -92,16 +105,36 @@ namespace Subsurface
foreach (Limb limb in c.AnimController.limbs)
{
distFactor = 1.0f - Vector2.Distance(limb.SimPosition, position)/range;
distFactor = 1.0f - Vector2.Distance(limb.SimPosition, simPosition)/range;
c.AddDamage(limb.SimPosition, DamageType.None, damage / c.AnimController.limbs.Length * distFactor, 0.0f, stun * distFactor);
if (force>0.0f)
{
limb.body.ApplyLinearImpulse(Vector2.Normalize(limb.SimPosition-position)*distFactor*force);
limb.body.ApplyLinearImpulse(Vector2.Normalize(limb.SimPosition - simPosition) * distFactor * force);
}
}
}
}
private IEnumerable<Status> DimLight()
{
float currBrightness= 1.0f;
float startRange = light.Range;
while (light.Color.A > 0.0f)
{
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
light.Range = startRange * currBrightness;
currBrightness -= 0.1f;
yield return Status.Running;
}
light.Remove();
yield return Status.Success;
}
}
}

View File

@@ -249,12 +249,12 @@ namespace Subsurface
{
pos.Y = ConvertUnits.ToSimUnits(MathHelper.Clamp(lowerSurface, rect.Y-rect.Height, rect.Y));
Game1.particleManager.CreateParticle("watersplash",
Game1.ParticleManager.CreateParticle("watersplash",
new Vector2(pos.X, pos.Y - Rand.Range(0.0f, 0.1f)),
new Vector2(flowForce.X * Rand.Range(0.005f, 0.007f), flowForce.Y * Rand.Range(0.005f, 0.007f)));
pos.Y = ConvertUnits.ToSimUnits(Rand.Range(lowerSurface, rect.Y - rect.Height));
Game1.particleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
Game1.ParticleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
}
else
{
@@ -262,12 +262,12 @@ namespace Subsurface
for (int i = 0; i < rect.Width; i += (int)Rand.Range(80, 100))
{
pos.X = ConvertUnits.ToSimUnits(Rand.Range(rect.X, rect.X+rect.Width));
Subsurface.Particles.Particle splash = Game1.particleManager.CreateParticle("watersplash", pos,
Subsurface.Particles.Particle splash = Game1.ParticleManager.CreateParticle("watersplash", pos,
new Vector2(flowForce.X * Rand.Range(0.005f, 0.008f), flowForce.Y * Rand.Range(0.005f, 0.008f)));
if (splash!=null) splash.Size = splash.Size * MathHelper.Clamp(rect.Width / 50.0f, 0.8f, 4.0f);
Game1.particleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
Game1.ParticleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
}
}

View File

@@ -210,7 +210,7 @@ namespace Subsurface
float maxDelta = Math.Max(Math.Abs(rightDelta[i]), Math.Abs(leftDelta[i]));
if (maxDelta > Rand.Range(0.2f,10.0f))
{
Game1.particleManager.CreateParticle("mist",
Game1.ParticleManager.CreateParticle("mist",
ConvertUnits.ToSimUnits(new Vector2(rect.X + WaveWidth * i,surface + waveY[i])),
new Vector2(0.0f, -0.5f));
}

View File

@@ -38,9 +38,9 @@ namespace Subsurface
//List<Body> bodies;
private List<VoronoiCell> cells;
private BasicEffect basicEffect;
private static BasicEffect basicEffect;
private VertexPositionColor[] vertices;
private VertexPositionTexture[] vertices;
private VertexBuffer vertexBuffer;
private Vector2 startPosition;
@@ -50,6 +50,8 @@ namespace Subsurface
private List<Body> bodies = new List<Body>();
private List<Vector2> positionsOfInterest;
public Vector2 StartPosition
{
get { return startPosition; }
@@ -77,6 +79,11 @@ namespace Subsurface
get { return ConvertUnits.ToDisplayUnits(cells[0].body.Position); }
}
public List<Vector2> PositionsOfInterest
{
get { return positionsOfInterest; }
}
public string Seed
{
get { return seed; }
@@ -92,12 +99,24 @@ namespace Subsurface
{
if (shaftTexture == null) shaftTexture = Game1.TextureLoader.FromFile("Content/Map/shaft.png");
if (basicEffect==null)
{
basicEffect = new BasicEffect(Game1.CurrGraphicsDevice);
basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true;
basicEffect.Texture = Game1.TextureLoader.FromFile("Content/Map/iceSurface.png");
}
this.seed = seed;
this.siteInterval = siteInterval;
this.Difficulty = difficulty;
positionsOfInterest = new List<Vector2>();
borders = new Rectangle(0, 0, width, height);
}
@@ -237,7 +256,7 @@ namespace Subsurface
endPosition = pathCells[pathCells.Count - 1].Center;
//generate a couple of random paths
for (int i = 0; i < rand.Next() % 3; i++)
for (int i = 0; i <= rand.Next() % 3; i++)
{
//pathBorders = new Rectangle(
//borders.X + siteInterval * 2, borders.Y - siteInterval * 2,
@@ -252,10 +271,14 @@ namespace Subsurface
Vector2 end = new Vector2(x, y);
pathCells.AddRange
(
GeneratePath(rand, new List<Vector2> { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror)
);
var newPathCells = GeneratePath(rand, new List<Vector2> { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror);
for (int n = 1; n < newPathCells.Count; n += 3)
{
positionsOfInterest.Add(newPathCells[n].Center);
}
pathCells.AddRange(newPathCells);
}
Debug.WriteLine("path: " + sw2.ElapsedMilliseconds + " ms");
@@ -329,13 +352,9 @@ namespace Subsurface
Debug.WriteLine("Generatelevel: " + sw2.ElapsedMilliseconds + " ms");
sw2.Restart();
vertexBuffer = new VertexBuffer(Game1.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
vertexBuffer = new VertexBuffer(Game1.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices);
basicEffect = new BasicEffect(Game1.CurrGraphicsDevice);
basicEffect.VertexColorEnabled = true;
if (mirror)
{
Vector2 temp = startPosition;
@@ -555,7 +574,7 @@ int currentTargetIndex = 1;
private void GeneratePolygons(List<VoronoiCell> cells, List<VoronoiCell> emptyCells)
{
List<VertexPositionColor> verticeList = new List<VertexPositionColor>();
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
//bodies = new List<Body>();
List<Vector2> tempVertices = new List<Vector2>();
@@ -593,7 +612,7 @@ int currentTargetIndex = 1;
{
foreach (Vector2 vertex in triangles[i])
{
verticeList.Add(new VertexPositionColor(new Vector3(vertex, 0.0f), new Color(n*30, (n * 60) % 255, (n * 90) % 255) * 0.5f));
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 0.0f), vertex/1000.0f));
}
}
@@ -775,31 +794,31 @@ int currentTargetIndex = 1;
Vector2 observerPosition;
public void SetObserverPosition(Vector2 position)
{
observerPosition = position - this.Position;
int gridPosX = (int)Math.Floor(observerPosition.X / GridCellWidth);
int gridPosY = (int)Math.Floor(observerPosition.Y / GridCellWidth);
int searchOffset = 2;
//observerPosition = position - this.Position;
//int gridPosX = (int)Math.Floor(observerPosition.X / GridCellWidth);
//int gridPosY = (int)Math.Floor(observerPosition.Y / GridCellWidth);
//int searchOffset = 2;
int startX = Math.Max(gridPosX - searchOffset, 0);
int endX = Math.Min(gridPosX + searchOffset, cellGrid.GetLength(0) - 1);
//int startX = Math.Max(gridPosX - searchOffset, 0);
//int endX = Math.Min(gridPosX + searchOffset, cellGrid.GetLength(0) - 1);
int startY = Math.Max(gridPosY - searchOffset, 0);
int endY = Math.Min(gridPosY + searchOffset, cellGrid.GetLength(1) - 1);
//int startY = Math.Max(gridPosY - searchOffset, 0);
//int endY = Math.Min(gridPosY + searchOffset, cellGrid.GetLength(1) - 1);
for (int x = 0; x < cellGrid.GetLength(0); x++)
{
for (int y = 0; y < cellGrid.GetLength(1); y++)
{
for (int i = 0; i < cellGrid[x, y].Count; i++)
{
//foreach (Body b in cellGrid[x, y][i].bodies)
//{
if (cellGrid[x, y][i].body == null) continue;
cellGrid[x, y][i].body.Enabled = true;// (x >= startX && x <= endX && y >= startY && y <= endY);
//}
}
}
}
//for (int x = 0; x < cellGrid.GetLength(0); x++)
//{
// for (int y = 0; y < cellGrid.GetLength(1); y++)
// {
// for (int i = 0; i < cellGrid[x, y].Count; i++)
// {
// //foreach (Body b in cellGrid[x, y][i].bodies)
// //{
// if (cellGrid[x, y][i].body == null) continue;
// cellGrid[x, y][i].body.Enabled = true;// (x >= startX && x <= endX && y >= startY && y <= endY);
// //}
// }
// }
//}
}
@@ -897,11 +916,12 @@ int currentTargetIndex = 1;
basicEffect.World = Matrix.CreateTranslation(new Vector3(Position, 0.0f)) * cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
basicEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, (int)Math.Floor(vertices.Length / 3.0f));
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, (int)Math.Floor(vertices.Length / 3.0f));
}
private void Unload()

View File

@@ -8,7 +8,7 @@ namespace Subsurface.Lights
class ConvexHull
{
public static List<ConvexHull> list = new List<ConvexHull>();
static BasicEffect fowEffect;
static BasicEffect losEffect;
static BasicEffect shadowEffect;
private VertexPositionColor[] vertices;
@@ -87,14 +87,14 @@ namespace Subsurface.Lights
// }
//}
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool fow = true)
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool los = true)
{
if (!Enabled) return;
if (fowEffect == null)
if (losEffect == null)
{
fowEffect = new BasicEffect(graphicsDevice);
fowEffect.VertexColorEnabled = true;
losEffect = new BasicEffect(graphicsDevice);
losEffect.VertexColorEnabled = true;
}
if (shadowEffect==null)
{
@@ -140,7 +140,7 @@ namespace Subsurface.Lights
VertexPositionTexture[] penumbraVertices = new VertexPositionTexture[6];
if (fow)
if (los)
{
for (int n = 0; n < 4; n+=3)
{
@@ -162,26 +162,18 @@ namespace Subsurface.Lights
vertexDir = penumbraStart - (new Vector3(lightSourcePos, 0) - normal * 20.0f);
vertexDir.Normalize();
penumbraVertices[n + i + 1].Position = new Vector3(lightSourcePos, 0) + vertexDir * 9000;
if (i==0)
{
//penumbraVertices[n].Position -= normal*2.0f;
}
if (fow)
if (los)
{
penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(0.05f, 0.0f) : new Vector2(1.0f, 0.0f);
}
else
{
penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(1.0f, 0.0f):Vector2.Zero;
penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(1.0f, 0.0f) : Vector2.Zero;
}
//penumbraVertices[i+1].Color = Color.Black;
}
if (n>0)
if (n > 0)
{
var temp = penumbraVertices[4];
penumbraVertices[4] = penumbraVertices[5];
@@ -210,12 +202,12 @@ namespace Subsurface.Lights
//one vertex on the hull
shadowVertices[svCount] = new VertexPositionColor();
shadowVertices[svCount].Color = fow ? Color.Black : Color.Transparent;
shadowVertices[svCount].Color = los ? Color.Black : Color.Transparent;
shadowVertices[svCount].Position = vertexPos;
//one extruded by the light direction
shadowVertices[svCount + 1] = new VertexPositionColor();
shadowVertices[svCount + 1].Color = fow ? Color.Black : Color.Transparent;
shadowVertices[svCount + 1].Color = los ? Color.Black : Color.Transparent;
Vector3 L2P = vertexPos - new Vector3(lightSourcePos, 0);
L2P.Normalize();
shadowVertices[svCount + 1].Position = new Vector3(lightSourcePos, 0) + L2P * 9000;
@@ -224,13 +216,13 @@ namespace Subsurface.Lights
currentIndex = (currentIndex + 1) % primitiveCount;
}
fowEffect.World = cam.ShaderTransform
losEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
fowEffect.CurrentTechnique.Passes[0].Apply();
losEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
if (fow)
if (los)
{
shadowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;

View File

@@ -16,7 +16,7 @@ namespace Subsurface.Lights
private List<LightSource> lights;
public bool FowEnabled = true;
public bool LosEnabled = true;
public bool LightingEnabled = true;
@@ -54,9 +54,9 @@ namespace Subsurface.Lights
lights.Remove(light);
}
public void DrawFow(GraphicsDevice graphics, Camera cam, Vector2 pos)
public void DrawLOS(GraphicsDevice graphics, Camera cam, Vector2 pos)
{
if (!FowEnabled) return;
if (!LosEnabled) return;
foreach (ConvexHull convexHull in ConvexHull.list)
{
convexHull.DrawShadows(graphics, cam, pos);

View File

@@ -19,7 +19,7 @@ namespace Subsurface
private List<LocationConnection> connections;
private int seed;
private string seed;
private int size;
private static Sprite iceTexture;
@@ -29,6 +29,8 @@ namespace Subsurface
private Location currentLocation;
private Location selectedLocation;
private LocationConnection selectedConnection;
public Location CurrentLocation
{
get { return currentLocation; }
@@ -44,12 +46,17 @@ namespace Subsurface
get { return selectedLocation; }
}
public int Seed
public LocationConnection SelectedConnection
{
get { return selectedConnection; }
}
public string Seed
{
get { return seed; }
}
public Map(int seed, int size)
public Map(string seed, int size)
{
this.seed = seed;
@@ -65,7 +72,7 @@ namespace Subsurface
if (iceCraters == null) iceCraters = Game1.TextureLoader.FromFile("Content/Map/iceCraters.png");
if (iceCrack == null) iceCrack = Game1.TextureLoader.FromFile("Content/Map/iceCrack.png");
Rand.SetSyncedSeed(this.seed);
Rand.SetSyncedSeed(this.seed.GetHashCode());
GenerateLocations();
@@ -288,9 +295,9 @@ namespace Subsurface
if (PlayerInput.LeftButtonClicked()&&
selectedLocation != highlightedLocation && highlightedLocation != null)
{
//currentLocation = highlightedLocation;
Game1.LobbyScreen.SelectLocation(highlightedLocation, connection);
selectedLocation = highlightedLocation;
selectedConnection = connection;
selectedLocation = highlightedLocation;
Game1.LobbyScreen.SelectLocation(highlightedLocation, connection);
}
}
@@ -368,14 +375,34 @@ namespace Subsurface
private Level level;
public float Difficulty;
public List<Vector2[]> CrackSegments;
private int questsCompleted;
private Quest quest;
public Quest Quest
{
get
{
if (quest==null || quest.Completed)
{
if (quest !=null && quest.Completed) questsCompleted++;
Random rand = new Random(GetHashCode() + questsCompleted);
quest = Quest.LoadRandom(rand);
}
return quest;
}
}
public Location[] Locations
{
get { return locations; }
}
public Level Level
{
get { return level; }
@@ -385,8 +412,8 @@ namespace Subsurface
public LocationConnection(Location location1, Location location2)
{
locations = new Location[] { location1, location2 };
//location1.connections.Add(this);
//location2.connections.Add(this);
questsCompleted = 0;
}
public Location OtherLocation(Location location)

View File

@@ -371,8 +371,6 @@ namespace Subsurface
if (Game1.Client==null)
SetDamage(sectionIndex, sections[sectionIndex].damage + damage);
}
public int FindSectionIndex(Vector2 pos)
@@ -408,9 +406,9 @@ namespace Subsurface
int i = FindSectionIndex(ConvertUnits.ToDisplayUnits(position));
if (i == -1) return new AttackResult(0.0f, 0.0f);
Game1.particleManager.CreateParticle("dustcloud", ConvertUnits.ToSimUnits(SectionPosition(i)), 0.0f, 0.0f);
Game1.ParticleManager.CreateParticle("dustcloud", ConvertUnits.ToSimUnits(SectionPosition(i)), 0.0f, 0.0f);
if (playSound)
if (playSound && !SectionHasHole(i))
{
DamageSoundType damageSoundType = (damageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash;
AmbientSoundManager.PlayDamageSound(damageSoundType, amount, position);

View File

@@ -8,6 +8,7 @@ using FarseerPhysics.Factories;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Items.Components;
using System;
using System.Collections.Generic;
using System.IO;

View File

@@ -161,6 +161,10 @@ namespace Subsurface.Networking
if (packetType == (byte)PacketTypes.LoggedIn)
{
myID = inc.ReadInt32();
if (inc.ReadBoolean())
{
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
}
Game1.NetLobbyScreen.ClearPlayers();

View File

@@ -19,16 +19,16 @@ namespace Subsurface.Networking
Client myClient;
public GameServer()
public GameServer(string name, int port)
{
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 170-120, 20, 150, 25), "End round", Alignment.TopLeft, GUI.style, inGameHUD);
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
name = "Server";
this.name = name;
Config = new NetPeerConfiguration("subsurface");
Config.Port = 14242;
Config.Port = port;
//Config.SimulatedLoss = 0.2f;
//Config.SimulatedMinimumLatency = 0.25f;
@@ -215,6 +215,8 @@ namespace Subsurface.Networking
outmsg.Write(sender.ID);
outmsg.Write(gameStarted);
//notify the client about other clients already logged in
outmsg.Write((myClient == null) ? connectedClients.Count - 1 : connectedClients.Count);
foreach (Client c in connectedClients)

View File

@@ -10,7 +10,8 @@ namespace Subsurface.Networking
UpdateComponent = 2,
DropItem = 3,
InventoryUpdate = 4,
PickItem = 5
PickItem = 5,
UpdateProperty = 6
}
class NetworkEvent

View File

@@ -38,8 +38,6 @@ namespace Subsurface
{
base.Select();
//if (Game1.gameSession == null) Game1.gameSession = new GameSession("",false, TimeSpan.Zero);
foreach (MapEntity entity in MapEntity.mapEntityList)
entity.IsHighlighted = false;
}
@@ -73,10 +71,9 @@ namespace Subsurface
Character.UpdateAll(cam, (float)deltaTime);
Game1.particleManager.Update((float)deltaTime);
Game1.ParticleManager.Update((float)deltaTime);
StatusEffect.UpdateAll((float)deltaTime);
//Physics.updated = false;
cam.MoveCamera((float)deltaTime);
@@ -108,24 +105,15 @@ namespace Subsurface
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{
//if (!Physics.updated) return;
DrawMap(graphics, spriteBatch);
//----------------------------------------------------------------------------------------
//2. draw the HUD on top of everything
//----------------------------------------------------------------------------------------
spriteBatch.Begin();
if (Game1.GameSession != null) Game1.GameSession.Draw(spriteBatch);
//EventManager.DrawInfo(spriteBatch);
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
{
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
@@ -215,7 +203,7 @@ namespace Subsurface
BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
Game1.particleManager.Draw(spriteBatch, true);
Game1.ParticleManager.Draw(spriteBatch, true);
spriteBatch.End();
@@ -233,7 +221,7 @@ namespace Subsurface
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
Game1.particleManager.Draw(spriteBatch, false);
Game1.ParticleManager.Draw(spriteBatch, false);
spriteBatch.End();
graphics.SetRenderTarget(null);
@@ -253,6 +241,12 @@ namespace Subsurface
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
if (Game1.GameSession != null && Game1.GameSession.Level != null)
{
Game1.GameSession.Level.Render(graphics, cam);
Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
if (Game1.LightManager.LightingEnabled)
{
//multiply scene with lightmap
@@ -264,7 +258,7 @@ namespace Subsurface
//----------------------------------------------------------------------------------------
//3. draw the sections of the map that are on top of the water
//----------------------------------------------------------------------------------------
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
@@ -279,20 +273,10 @@ namespace Subsurface
Game1.GameSession.Level.Draw(spriteBatch);
//Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
spriteBatch.End();
if (Game1.GameSession != null && Game1.GameSession.Level != null)
{
Game1.GameSession.Level.Render(graphics, cam);
Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
else if (Game1.Level != null)
{
Game1.Level.Render(graphics, cam);
}
Game1.LightManager.DrawFow(graphics,cam,LightManager.ViewPos);
Game1.LightManager.DrawLOS(graphics, cam, LightManager.ViewPos);
}
}

View File

@@ -21,7 +21,7 @@ namespace Subsurface
GUIListBox characterList;
GUIListBox hireList;
GUIListBox selectedItemList;
GUIListBox selectedItemList, itemList;
SinglePlayerMode gameMode;
@@ -31,9 +31,9 @@ namespace Subsurface
Level selectedLevel;
private string SelectedItemCost()
private string CostTextGetter()
{
return selectedItemCost.ToString();
return "Cost: "+selectedItemCost.ToString();
}
private int selectedItemCost
@@ -55,7 +55,7 @@ namespace Subsurface
{
Rectangle panelRect = new Rectangle(
40, 40,
(int)(Game1.GraphicsWidth * 0.3f) - 60,
180,
Game1.GraphicsHeight - 80);
leftPanel = new GUIFrame(panelRect, GUI.style);
@@ -122,14 +122,15 @@ namespace Subsurface
rightPanel[(int)PanelTab.Store] = new GUIFrame(panelRect, GUI.style);
selectedItemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, GUI.style, rightPanel[(int)PanelTab.Store]);
selectedItemList.OnSelected = DeselectItem;
var costText = new GUITextBlock(new Rectangle(0, 0, 200, 25), "Cost: ", Color.Transparent, Color.White, Alignment.BottomLeft, GUI.style, rightPanel[(int)PanelTab.Store]);
costText.TextGetter = SelectedItemCost;
var costText = new GUITextBlock(new Rectangle(0, 0, 200, 25), "Cost: ", GUI.style, Alignment.BottomLeft, Alignment.TopLeft, rightPanel[(int)PanelTab.Store]);
costText.TextGetter = CostTextGetter;
buyButton = new GUIButton(new Rectangle(15, 0, 100, 25), "Buy", Alignment.Bottom, GUI.style, rightPanel[(int)PanelTab.Store]);
buyButton = new GUIButton(new Rectangle(150, 0, 100, 25), "Buy", Alignment.Bottom, GUI.style, rightPanel[(int)PanelTab.Store]);
buyButton.OnClicked = BuyItems;
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, Alignment.TopRight, GUI.style, rightPanel[(int)PanelTab.Store]);
itemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, Alignment.TopRight, GUI.style, rightPanel[(int)PanelTab.Store]);
itemList.OnSelected = SelectItem;
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
@@ -196,10 +197,22 @@ namespace Subsurface
if (locationPanel != null) rightPanel[(int)PanelTab.Map].RemoveChild(locationPanel);
locationPanel = new GUIFrame(new Rectangle(0, 0, rightPanel[(int)PanelTab.Map].Rect.Width / 2 - 40, 190), Color.Transparent, null, rightPanel[(int)PanelTab.Map]);
locationPanel = new GUIFrame(new Rectangle(0, 0, 200, 190), Color.Transparent, Alignment.TopRight, null, rightPanel[(int)PanelTab.Map]);
locationPanel.UserData = "selectedlocation";
new GUITextBlock(new Rectangle(0,0,100,20), location.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0,0,0,0), location.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
if (Game1.GameSession.Map.SelectedConnection != null && Game1.GameSession.Map.SelectedConnection.Quest != null)
{
var quest = Game1.GameSession.Map.SelectedConnection.Quest;
new GUITextBlock(new Rectangle(0, 40, 0, 20), "Quest: "+quest.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 60, 0, 20), "Reward: " + quest.Reward, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
new GUITextBlock(new Rectangle(0, 80, 0, 0), quest.Description, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel, true);
}
startButton.Enabled = true;
@@ -257,7 +270,6 @@ namespace Subsurface
private bool SelectItem(object obj)
{
MapEntityPrefab prefab = obj as MapEntityPrefab;
if (prefab == null) return false;
CreateItemFrame(prefab, selectedItemList);
@@ -267,6 +279,16 @@ namespace Subsurface
return false;
}
private bool DeselectItem(object obj)
{
MapEntityPrefab prefab = obj as MapEntityPrefab;
if (prefab == null) return false;
selectedItemList.RemoveChild(selectedItemList.children.Find(c => c.UserData == obj));
return false;
}
private bool BuyItems(GUIButton button, object obj)
{
int cost = selectedItemCost;
@@ -323,8 +345,8 @@ namespace Subsurface
Game1.GameSession.Map.Draw(spriteBatch, new Rectangle(
rightPanel[selectedRightPanel].Rect.X + 20,
rightPanel[selectedRightPanel].Rect.Y + 20,
rightPanel[selectedRightPanel].Rect.Width - 40,
rightPanel[selectedRightPanel].Rect.Height - 150), 3.0f);
rightPanel[selectedRightPanel].Rect.Width - 250,
rightPanel[selectedRightPanel].Rect.Height - 40), 3.0f);
}
if (rightPanel[(int)selectedRightPanel].UserData as Location != Game1.GameSession.Map.CurrentLocation)

View File

@@ -8,7 +8,7 @@ namespace Subsurface
{
class MainMenuScreen : Screen
{
enum Tabs { Main = 0, NewGame = 1, LoadGame = 2, JoinServer = 3 }
public enum Tabs { Main = 0, NewGame = 1, LoadGame = 2, JoinServer = 3, HostServer = 4 }
private GUIFrame[] menuTabs;
private GUIListBox mapList;
@@ -19,6 +19,8 @@ namespace Subsurface
private GUITextBox nameBox, ipBox;
private GUITextBox serverNameBox, portBox;
private Game1 game;
int selectedTab;
@@ -50,7 +52,8 @@ namespace Subsurface
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 180, 0, 30), "Host Server", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.OnClicked = HostServerClicked;
button.UserData = (int)Tabs.HostServer;
button.OnClicked = SelectTab;
//button.Enabled = false;
button = new GUIButton(new Rectangle(0, 240, 0, 30), "Quit", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
@@ -86,7 +89,7 @@ namespace Subsurface
seedBox.Text = ToolBox.RandomSeed(8);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.BottomRight, GUI.style, menuTabs[(int)Tabs.NewGame]);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.style, menuTabs[(int)Tabs.NewGame]);
button.OnClicked = StartGame;
//----------------------------------------------------------------------
@@ -94,7 +97,7 @@ namespace Subsurface
menuTabs[(int)Tabs.LoadGame] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.LoadGame].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", Color.Transparent, Color.Black, Alignment.CenterX, null, menuTabs[(int)Tabs.LoadGame]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.LoadGame]);
if (!Directory.Exists(SaveUtil.SaveFolder))
{
@@ -148,6 +151,22 @@ namespace Subsurface
//----------------------------------------------------------------------
menuTabs[(int)Tabs.HostServer] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.JoinServer].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Host Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Name:", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer]);
serverNameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, null, menuTabs[(int)Tabs.HostServer]);
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();
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++ )
{
button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]);
@@ -158,14 +177,28 @@ namespace Subsurface
}
private bool SelectTab(GUIButton button, object obj)
public bool SelectTab(GUIButton button, object obj)
{
selectedTab = (int)obj;
this.Select();
return true;
}
private bool HostServerClicked(GUIButton button, object obj)
{
string name = serverNameBox.Text;
if (string.IsNullOrEmpty(name)) name = "Server";
int port;
if (!int.TryParse(portBox.Text, out port))
{
DebugConsole.ThrowError("ERROR: "+portBox.Text+" is not a valid port. Using the default port "+NetworkMember.DefaultPort);
port = NetworkMember.DefaultPort;
}
Game1.NetworkMember = new GameServer(name, port);
Game1.NetLobbyScreen.IsServer = true;
Game1.NetLobbyScreen.Select();
return true;

View File

@@ -148,12 +148,10 @@ namespace Subsurface
public override void Select()
{
Game1.LightManager.FowEnabled = false;
Game1.LightManager.LosEnabled = false;
infoFrame.ClearChildren();
if (IsServer && Game1.Server == null) Game1.NetworkMember = new GameServer();
textBox.Select();
new GUITextBlock(new Rectangle(0, 110, 0, 30), "Selected submarine:", GUI.style, infoFrame);
@@ -219,9 +217,9 @@ namespace Subsurface
serverName.TextGetter = GetServerName;
serverName.Enabled = Game1.Server != null;
serverName.OnTextChanged = ChangeServerName;
ServerName = "Server";
var serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70),null,null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
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.Wrap = true;
serverMessage.TextGetter = GetServerMessage;
@@ -264,14 +262,14 @@ namespace Subsurface
new GUITextBlock(new Rectangle(x, 150, 200, 30), "Job preferences:", GUI.style, playerFrame);
jobList = new GUIListBox(new Rectangle(x, 180, 200, 0), GUI.style, playerFrame);
jobList = new GUIListBox(new Rectangle(x, 180, 150, 0), GUI.style, playerFrame);
foreach (JobPrefab job in JobPrefab.List)
{
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, GUI.style, jobList);
jobText.UserData = job;
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", GUI.style, jobText);
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 45, 0, 20, 20), "u", GUI.style, jobText);
upButton.UserData = -1;
upButton.OnClicked += ChangeJobPreference;
@@ -639,11 +637,14 @@ namespace Subsurface
textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
if (clientID == Game1.Client.ID)
if (client.assignedJob==null || jobName != client.assignedJob.Name)
{
Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
Game1.Client.CharacterInfo.Name = client.name;
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
if (clientID == Game1.Client.ID)
{
Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
Game1.Client.CharacterInfo.Name = client.name;
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
}
}
}
}

View File

@@ -17,7 +17,7 @@ namespace Subsurface
public virtual void Select()
{
if (selected != null) selected.Deselect();
if (selected != null && selected!=this) selected.Deselect();
selected = this;
}

View File

@@ -128,7 +128,7 @@ namespace Subsurface
{
this.texture = texture;
sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height);
sourceRect = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height);
offset = newOffset ?? Vector2.Zero;
@@ -148,7 +148,7 @@ namespace Subsurface
file = newFile;
texture = LoadTexture(file);
sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height);
sourceRect = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height);
offset = newOffset ?? Vector2.Zero;

View File

@@ -66,8 +66,12 @@
<Compile Include="Characters\AI\SteeringPath.cs" />
<Compile Include="ContentPackage.cs" />
<Compile Include="CoroutineManager.cs" />
<Compile Include="Events\Quests\Quest.cs" />
<Compile Include="Events\Quests\SalvageQuest.cs" />
<Compile Include="GameSession\CargoManager.cs" />
<Compile Include="GUI\GUIMessage.cs" />
<Compile Include="GUI\TitleScreen.cs" />
<Compile Include="Items\Components\Signal\SignalCheckComponent.cs" />
<Compile Include="Items\FixRequirement.cs" />
<Compile Include="Map\Lights\Light.cs" />
<Compile Include="Map\LocationType.cs" />
@@ -160,7 +164,6 @@
<Compile Include="EventInput\KeyboardDispatcher.cs" />
<Compile Include="Screens\EditMapScreen.cs" />
<Compile Include="Events\ScriptedEvent.cs" />
<Compile Include="Events\EventManager.cs" />
<Compile Include="Events\MonsterEvent.cs" />
<Compile Include="Screens\GameScreen.cs" />
<Compile Include="GUI\GUIButton.cs" />
@@ -280,6 +283,12 @@
<Content Include="Content\Characters\Human\torso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Artifacts\artifact.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Artifacts\artifacts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\lamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -294,6 +303,13 @@
<Content Include="Content\Items\Medical\med.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Weapons\explosives.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Weapons\explosives.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Content\Jobs.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
@@ -526,7 +542,7 @@
<Content Include="Content\Items\OxygenGenerator\battery.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\OxygenGenerator\item.xml">
<Content Include="Content\Items\OxygenGenerator\oxygengenerator.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Diving\oxygentank.png">
@@ -569,11 +585,7 @@
<Content Include="Content\Items\Tools\wrench.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Vent\item.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Content\Items\Vent\vent.png">
<Content Include="Content\Items\OxygenGenerator\vent.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Tools\tools.xml">
@@ -646,6 +658,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Content\Quests.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Icon.ico" />
<Content Include="OpenAL32.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -719,9 +734,24 @@
<None Include="Content\Items\Electricity\zap4.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Engine\engine.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Engine\radarPing.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\OxygenGenerator\oxygengenerator.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\OxygenGenerator\ventilation.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Pump\pump.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Reactor\explosion.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Reactor\reactor.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

Binary file not shown.