assigning jobs when a round starts, crew tab in multiplayer, repairtool particles light & sounds, attachable buttons, increased repairtool range & limbdamage, captain's uniform, wearable sprite bugfixes

This commit is contained in:
Regalis
2015-08-03 23:25:22 +03:00
parent 01b1dfe0df
commit 9149408b36
44 changed files with 674 additions and 324 deletions

View File

@@ -7,14 +7,14 @@
stepsize="42.0, 12.0">
<!-- head -->
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="3.0">
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2" impacttolerance="4.0">
<sprite texture="Content/Characters/Human/[GENDER]head[HEADID].png" sourcerect="1,1,37,38" depth="0.04" origin="0.5,0.5"/>
</limb>
<!-- body -->
<limb id = "1" radius="14" height="21" mass = "20" type="Torso" attackpriority="3" impacttolerance="5.0">
<limb id = "1" radius="14" height="21" mass = "20" type="Torso" attackpriority="3" impacttolerance="6.0">
<sprite texture="Content/Characters/Human/[GENDER]torso.png" sourcerect="0,0,29,58" depth="0.05" origin="0.5,0.6"/>
</limb>
<limb id = "12" radius="13" mass = "20" type="Waist" impacttolerance="5.0">
<limb id = "12" radius="13" mass = "20" type="Waist" impacttolerance="6.0">
<sprite texture="Content/Characters/Human/[GENDER]legs.png" sourcerect="0,0,32,29" depth="0.045" origin="0.5,0.5"/>
</limb>

View File

@@ -6,8 +6,10 @@
price="10">
<Sprite texture ="button.png" depth="0.8"/>
<Controller userpos="0" direction ="None" canbepicked = "true">
<Body width="32" height="32"/>
<Controller userpos="0" direction ="None" canbepicked = "true" msg="Open [E]">
<RequiredItem name="ID Card" type="Picked" msg="UNAUTHORIZED ACCESS"/>
</Controller>
@@ -15,5 +17,10 @@
<RequiredItem name="Screwdriver" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
<Holdable slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" attachedbydefault="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
</Item>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,14 +1,54 @@
<Items>
<Item
name="Captain's Cap"
pickdistance="150">
pickdistance="150"
tags="smallitem">
<Sprite texture ="captainhat.png" depth="0.4"/>
<Body radius="8" density="5"/>
<Wearable limbtype="Head" slots="Any,Head">
<sprite texture="captainhat.png" limb="Head" origin="0.4,0.94"/>
<sprite texture="captainhat.png" limb="Head" origin="0.5,0.9"/>
</Wearable>
</Item>
<Item
name="Captain's Jacket"
pickdistance="150"
tags="smallitem">
<Sprite texture ="captainTorso.png" depth="0.4"/>
<Body radius="8" density="5"/>
<Wearable slots="Torso">
<sprite texture="captainTorso.png" limb="Torso" sourcerect="0,3,30,58" origin="0.5,0.45" depth="0.01"/>
<sprite texture="captainTorso.png" limb="RightHand" sourcerect="47,0,15,39" origin="0.45,0.6"/>
<sprite texture="captainTorso.png" limb="LeftHand" sourcerect="47,0,15,39" origin="0.45,0.6" depth="0.14"/>
<sprite texture="captainTorso.png" limb="RightArm" sourcerect="30,0,17,42" origin="0.5,0.5" depth="0.005" hidelimb="true"/>
<sprite texture="captainTorso.png" limb="LeftArm" sourcerect="30,0,17,42" origin="0.5,0.5" depth="0.13" hidelimb="true"/>
</Wearable>
</Item>
<Item
name="Captain's Trousers"
pickdistance="150"
tags="smallitem">
<Sprite texture ="captainLegs.png" depth="0.4"/>
<Body radius="8" density="5"/>
<Wearable slots="Legs">
<sprite texture="captainLegs.png" limb="Waist" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="RightThigh" sourcerect="52,34,28,46" origin="0.5,0.5" depth="0.10" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="LeftThigh" sourcerect="52,34,28,46" origin="0.5,0.5" depth="0.14" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="RightLeg" sourcerect="31,0,21,49" origin="0.5,0.5" depth="0.11" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="LeftLeg" sourcerect="31,0,21,49" origin="0.5,0.5" depth="0.15" hidelimb="true"/>
</Wearable>
</Item>

View File

@@ -6,7 +6,7 @@
pickdistance="150"
price="50">
<Sprite texture ="oxygentank.png" depth="0.05"/>
<Sprite texture ="oxygentank.png" depth="0.5"/>
<Body radius="6" height="22" density="5"/>
@@ -46,7 +46,7 @@
<Body width="37" height="113" density="5"/>
<Wearable slots="Head,Torso">
<Wearable slots="Head,Torso,Legs">
<sprite texture="DivingSuit.png" limb="Head" sourcerect="1,94,32,33" origin="0.5,0.5" depth="0.02"/>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="40,0,38,65" origin="0.5,0.33" depth="0.01"/>

Binary file not shown.

View File

@@ -15,10 +15,12 @@
<Holdable slots="Any,BothHands"
aimpos="50,0" handle1="-17,0" handle2="8,0"/>
<RepairTool structurefixamount="50.0" range="80" barrelpos="19,8">
<RepairTool structurefixamount="5.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="weld">
<!-- the item must contain a welding fuel tank for it to work -->
<RequiredItems name="Welding Fuel Tank" type="Contained" msg="Welding fuel required"/>
<sound file="weldingTool.ogg" type="OnUse" range="500.0"/>
<!-- when using, the contained welding fuel tank will detoriate (= lose fuel) -->
<StatusEffect type="OnUse" target="Contained" targetnames="Welding Fuel Tank" Condition="-0.7"/>
@@ -34,6 +36,10 @@
<StatusEffect type="OnFailure" target="Contained" targetnames="Welding Fuel Tank,Oxygen Tank" Condition="-100.0" sound="Content/Items/Weapons/stunGrenade.ogg">
<Explosion range="5" damage="20" stun="10" force="5.0"/>
</StatusEffect>
<LightComponent color="1.0,0.9,0.7,1.0" Flicker="0.5">
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/>
</LightComponent>
</RepairTool>
<!-- one welding fuel or oxygen tank can be contained inside the welding tool -->
@@ -56,11 +62,13 @@
<Holdable slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-12,4"/>
<RepairTool structurefixamount="-10.0" range="50" barrelpos="19,8">
<RepairTool structurefixamount="-2.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="plasma">
<RequiredItems name="Oxygen Tank" type="Contained" msg="Oxygen tank required"/>
<StatusEffect type="OnUse" target="Contained" targetnames="Oxygen Tank" Condition="-0.7"/>
<StatusEffect type="OnUse" target="UseTarget" targetnames="Door,Windowed Door" Stuck="-10.0"/>
<sound file="plasmaCutter.ogg" type="OnUse" range="500.0"/>
<Fixable name="structure"/>
<RequiredSkill name="Construction" level="30"/>
@@ -68,6 +76,10 @@
<StatusEffect type="OnFailure" target="Contained" targetnames="Welding Fuel Tank,Oxygen Tank" Condition="-100.0" sound="Content/Items/Weapons/stunGrenade.ogg">
<Explosion range="5" damage="20" stun="10" force="5.0"/>
</StatusEffect>
<LightComponent color="1.0,1.0,1.0,1.0" Flicker="0.5">
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/>
</LightComponent>
</RepairTool>
<ItemContainer capacity="1" hideitems="false" itempos="9,-15">

Binary file not shown.

View File

@@ -27,14 +27,10 @@
<Body width="16" height="9"/>
<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>
<ItemContainer capacity="1" itempos="0,0" hideitems="false">
<Containable name="explosive"/>
</ItemContainer>

View File

@@ -61,11 +61,11 @@
name="Railgun Shell"
pickdistance="200">
<Sprite texture ="railgunshell.png"/>
<Sprite texture ="railgunshell.png" depth ="0.5"/>
<Body radius="14" height="63" density="15"/>
<Body radius="9" height="67"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,20" handle2="0,-20"/>
<Holdable slots="BothHands" holdpos="0,-50" handle1="-10,0" handle2="10,0" aimable="false"/>
<Projectile launchimpulse="80.0">
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -2,6 +2,10 @@
<Jobs>
<Captain description="The Commanding Officer with authority over the entire crew." minnumber="1" maxnumber="1">
<Item name="ID Card"/>
<Item name="Captain's Cap" equip="true"/>
<Item name="Captain's Jacket" equip="true"/>
<Item name="Captain's Trousers" equip="true"/>
<Skills>
<Skill name="Weapons" level="50,60"/>
<Skill name="Construction" level="10,20"/>

View File

@@ -5,6 +5,40 @@
<smallhorizontalback sprite="Content/Map/testroom.png" sourcerect="0,64,896,32" depth ="0.4"
width = "128" height ="32" resizehorizontal="true"/>
<largeverticalback sprite="Content/Map/testroom.png" sourcerect="0,96,64,448" depth ="0.4"
width = "64" height ="128" resizevertical="true"/>
<largeverticalback2 sprite="Content/Map/testroom.png" sourcerect="64,96,64,448" depth ="0.4"
width = "64" height ="128" resizevertical="true"/>
<smallverticalback sprite="Content/Map/testroom.png" sourcerect="128,96,32,352" depth ="0.85"
width = "32" height ="128" resizevertical="true"/>
<smallverticalback2 sprite="Content/Map/testroom.png" sourcerect="160,96,32,352" depth ="0.85"
width = "32" height ="128" resizevertical="true"/>
<engineeringLabel sprite="Content/Map/testroom.png" sourcerect="464,336,153,16" depth ="0.99"
width = "153" height ="16"/>
<commandLabel sprite="Content/Map/testroom.png" sourcerect="464,352,128,16" depth ="0.99"
width = "128" height ="16"/>
<airlockLabel sprite="Content/Map/testroom.png" sourcerect="464,368,199,16" depth ="0.99"
width = "99" height ="16"/>
<cabinsLabel sprite="Content/Map/testroom.png" sourcerect="464,384,83,16" depth ="0.99"
width = "83" height ="16"/>
<arrowUp sprite="Content/Map/testroom.png" sourcerect="592,367,16,16" depth ="0.99"
width = "16" height ="16"/>
<arrowDown sprite="Content/Map/testroom.png" sourcerect="608,367,16,16" depth ="0.99"
width = "16" height ="16"/>
<arrowLeft sprite="Content/Map/testroom.png" sourcerect="592,383,16,16" depth ="0.99"
width = "16" height ="16"/>
<arrowRight sprite="Content/Map/testroom.png" sourcerect="608,383,16,16" depth ="0.99"
width = "16" height ="16"/>
<leftwall sprite="Content/Map/testroom.png" sourcerect="688,368,32,496" depth ="0.05" castshadow="true"
width = "32" height ="64" resizevertical="true" fliphorizontal="true" body="true" health="500"/>
@@ -32,16 +66,6 @@
<platform sprite="Content/Map/testroom.png" sourcerect="896,64,128,32" depth ="0.9"
width = "64" height ="32" resizehorizontal="true" body="true" platform="true"/>
<largeverticalback sprite="Content/Map/testroom.png" sourcerect="0,96,64,448" depth ="0.4"
width = "64" height ="128" resizevertical="true"/>
<largeverticalback2 sprite="Content/Map/testroom.png" sourcerect="64,96,64,448" depth ="0.4"
width = "64" height ="128" resizevertical="true"/>
<smallverticalback sprite="Content/Map/testroom.png" sourcerect="128,96,32,352" depth ="0.85"
width = "32" height ="128" resizevertical="true"/>
<smallverticalback2 sprite="Content/Map/testroom.png" sourcerect="160,96,32,352" depth ="0.85"
width = "32" height ="128" resizevertical="true"/>
<roughbgwall sprite="Content/Map/testroom.png" sourcerect="200,104,240,240" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 KiB

After

Width:  |  Height:  |  Size: 684 KiB

View File

@@ -1,84 +1,109 @@
<?xml version="1.0" encoding="utf-8" ?>
<prefabs>
<watersplash sprite="Content/Particles/spatter.png"
startsizemin="0.15,0.15" startsizemax="0.3,0.3"
sizechangemin="0.9,0.9" sizechangemax="1.2,1.2"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="0.8"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="3"
deleteonhit="true"
velocitychange="0.0, -9.8"/>
<mist sprite="Content/Particles/spatter.png"
startsizemin="0.4,0.4" startsizemax="0.5,0.5"
sizechangemin="0.25,0.25" sizechangemax="0.3,0.3"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="0.5"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="3"
velocitychange="0.0, -0.05"/>
<dustcloud sprite="Content/Particles/spatter.png"
startsizemin="0.8,0.8" startsizemax="1.0,1.0"
sizechangemin="0.0,0.0" sizechangemax="0.0,0.0"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="0.2, 0.2, 0.2" startalpha="0.5"
colorchange="0.0, 0.0, 0.0, -0.3"
lifetime="3"
velocitychange="0.0, -5.0"/>
<bubbles sprite="Content/Particles/bubbles.png"
startsizemin="0.4,0.4" startsizemax="0.5,0.5"
sizechangemin="0.0,0.0" sizechangemax="0.1,0.1"
startrotationmin ="0.0" startrotationmax="3.14"
startcolor="1.0, 1.0, 1.0" startalpha="0.8"
colorchange="0.0, 0.0, 0.0, -0.5"
lifetime="3"
deleteonhit="true"
inwater="true"
velocitychange="0.0, 0.1"/>
<blood sprite="Content/Particles/blood.png"
startsizemin="0.05,0.05" startsizemax="0.6,0.6"
sizechangemin="0.3,0.2" sizechangemax="0.4,0.2"
startrotationmin ="0.0" startrotationmax="0.0"
startcolor="0.5, 0.0, 0.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -1.0"
lifetime="2"
deleteonhit="true"
rotatetodirection="true"
velocitychange="0.0, -9.8"/>
<waterblood sprite="Content/Particles/spatter.png"
startsizemin="0.1,0.1" startsizemax="0.1,0.1"
sizechangemin="0.15,0.15" sizechangemax="0.2,0.2"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="0.5, 0.0, 0.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="5.0"
inwater="true"
velocitychange="0.0, 0.0"/>
<explosionfire sprite="Content/Particles/explosion.png"
startsizemin="1.5,1.5" startsizemax="3.0,3.0"
sizechangemin="0.5,0.5" sizechangemax="0.6,0.6"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="-0.4, -0.4, -0.4, -0.3"
lifetime="5.0"
inwater="false"
deleteonhit="true"
velocitychange="0.0, 0.5"/>
<weld sprite="Content/Particles/explosion.png"
startsizemin="0.1,0.1" startsizemax="0.2,0.2"
sizechangemin="0.5,0.5" sizechangemax="0.7,0.7"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, -1.0, -5.0"
lifetime="1.0"
inwater="false"
deleteonhit="true"
velocitychange="0.0, 0.0"/>
</prefabs>
<?xml version="1.0" encoding="utf-8" ?>
<prefabs>
<watersplash
startsizemin="0.15,0.15" startsizemax="0.3,0.3"
sizechangemin="0.9,0.9" sizechangemax="1.2,1.2"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="0.8"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="3"
deleteonhit="true"
velocitychange="0.0, -9.8">
<sprite texture="Content/Particles/spatter.png"/>
</watersplash>
<mist
startsizemin="0.4,0.4" startsizemax="0.5,0.5"
sizechangemin="0.25,0.25" sizechangemax="0.3,0.3"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="0.5"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="3"
velocitychange="0.0, -0.05">
<sprite texture="Content/Particles/spatter.png"/>
</mist>
<dustcloud
startsizemin="0.8,0.8" startsizemax="1.0,1.0"
sizechangemin="0.0,0.0" sizechangemax="0.0,0.0"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="0.2, 0.2, 0.2" startalpha="0.5"
colorchange="0.0, 0.0, 0.0, -0.3"
lifetime="3"
velocitychange="0.0, -5.0">
<sprite texture="Content/Particles/spatter.png"/>
</dustcloud>
<bubbles
startsizemin="0.4,0.4" startsizemax="0.5,0.5"
sizechangemin="0.0,0.0" sizechangemax="0.1,0.1"
startrotationmin ="0.0" startrotationmax="3.14"
startcolor="1.0, 1.0, 1.0" startalpha="0.8"
colorchange="0.0, 0.0, 0.0, -0.5"
lifetime="3"
deleteonhit="true"
inwater="true"
velocitychange="0.0, 0.1">
<sprite texture="Content/Particles/bubbles.png"/>
</bubbles>
<blood
startsizemin="0.05,0.05" startsizemax="0.6,0.6"
sizechangemin="0.3,0.2" sizechangemax="0.4,0.2"
startrotationmin ="0.0" startrotationmax="0.0"
startcolor="0.5, 0.0, 0.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -1.0"
lifetime="2"
deleteonhit="true"
rotatetodirection="true"
velocitychange="0.0, -9.8">
<sprite texture="Content/Particles/blood.png"/>
</blood>
<waterblood
startsizemin="0.1,0.1" startsizemax="0.1,0.1"
sizechangemin="0.15,0.15" sizechangemax="0.2,0.2"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="0.5, 0.0, 0.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -0.25"
lifetime="5.0"
inwater="true"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/spatter.png"/>
</waterblood>
<explosionfire
startsizemin="1.5,1.5" startsizemax="3.0,3.0"
sizechangemin="0.5,0.5" sizechangemax="0.6,0.6"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="-0.4, -0.4, -0.4, -0.3"
lifetime="5.0"
inwater="false"
deleteonhit="true"
velocitychange="0.0, 0.5">
<sprite texture="Content/Particles/explosion.png"/>
</explosionfire>
<weld
startsizemin="0.9,0.9" startsizemax="1.1,1.1"
sizechangemin="-0.1,-0.1" sizechangemax="0.1,0.1"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, -1.0, -5.0"
lifetime="0.5"
inwater="false"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,0,128,64" origin="0.15,0.5"/>
</weld>
<plasma
startsizemin="0.9,0.9" startsizemax="1.1,1.1"
sizechangemin="-0.1,-0.1" sizechangemax="0.1,0.1"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, -1.0, -5.0"
lifetime="0.5"
inwater="false"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,64,128,64" origin="0.15,0.5"/>
</plasma>
</prefabs>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@@ -418,10 +418,12 @@ namespace Subsurface
public void GiveJobItems(WayPoint spawnPoint)
{
if (Info == null || Info.Job == null) return;
foreach (string itemName in Info.Job.SpawnItemNames)
if (info == null || info.Job == null) return;
for (int i = 0; i < info.Job.SpawnItemNames.Count; i++ )
{
string itemName = info.Job.SpawnItemNames[i];
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null)
{
@@ -431,14 +433,18 @@ namespace Subsurface
Item item = new Item(itemPrefab, Position);
inventory.TryPutItem(item, item.AllowedSlots, false);
if (item.Prefab.Name == "ID Card" && spawnPoint!=null)
if (info.Job.EquipSpawnItem[i])
{
item.Equip(this);
}
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
{
foreach (string s in spawnPoint.IdCardTags)
{
item.AddTag(s);
}
}
}
}
}
@@ -476,8 +482,7 @@ namespace Subsurface
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
if (actionKeyDown.State) selectedItems[i].Use(deltaTime, this);
if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
}
if (selectedConstruction != null)
@@ -906,6 +911,8 @@ namespace Subsurface
}
}
health = 0.0f;
isDead = true;
AnimController.movement = Vector2.Zero;
AnimController.TargetMovement = Vector2.Zero;
@@ -914,7 +921,6 @@ namespace Subsurface
{
if (selectedItems[i] != null) selectedItems[i].Drop(this);
}
aiTarget.Remove();
aiTarget = null;

View File

@@ -172,22 +172,27 @@ namespace Subsurface
int x = 0, y = 0;
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Name, GUI.style, frame);
y += 20;
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Job.Name, GUI.style, frame);
y += 30;
var skills = Job.Skills;
skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level));
new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", GUI.style, frame);
y += 20;
foreach (Skill skill in skills)
if (Job!=null)
{
Color textColor = Color.White * (0.5f + skill.Level/200.0f);
new GUITextBlock(new Rectangle(x+20, y, 200, 20), skill.Name, Color.Transparent, textColor, Alignment.Left, GUI.style, frame);
new GUITextBlock(new Rectangle(x + 20, y, 200, 20), skill.Level.ToString(), Color.Transparent, textColor, Alignment.Right, GUI.style, frame);
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Job.Name, GUI.style, frame);
y += 30;
var skills = Job.Skills;
skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level));
new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", GUI.style, frame);
y += 20;
foreach (Skill skill in skills)
{
Color textColor = Color.White * (0.5f + skill.Level/200.0f);
new GUITextBlock(new Rectangle(x+20, y, 200, 20), skill.Name, Color.Transparent, textColor, Alignment.Left, GUI.style, frame);
new GUITextBlock(new Rectangle(x + 20, y, 200, 20), skill.Level.ToString(), Color.Transparent, textColor, Alignment.Right, GUI.style, frame);
y += 20;
}
}
return frame;
}

View File

@@ -56,6 +56,11 @@ namespace Subsurface
get { return prefab.ItemNames; }
}
public List<bool> EquipSpawnItem
{
get { return prefab.EquipItem; }
}
public List<Skill> Skills
{
get { return skills.Values.ToList(); }

View File

@@ -28,6 +28,7 @@ namespace Subsurface
//names of the items the character spawns with
public List<string> ItemNames;
public List<bool> EquipItem;
public Dictionary<string, Vector2> Skills;
@@ -63,6 +64,7 @@ namespace Subsurface
AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false);
ItemNames = new List<string>();
EquipItem = new List<bool>();
Skills = new Dictionary<string, Vector2>();
@@ -72,7 +74,12 @@ namespace Subsurface
{
case "item":
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
if (!string.IsNullOrEmpty(itemName)) ItemNames.Add(itemName);
bool equipItem = ToolBox.GetAttributeBool(subElement, "equip", false);
if (!string.IsNullOrEmpty(itemName))
{
ItemNames.Add(itemName);
EquipItem.Add(equipItem);
}
break;
case "skills":
LoadSkills(subElement);

View File

@@ -5,6 +5,7 @@ using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Items.Components;
namespace Subsurface
{
@@ -60,7 +61,7 @@ namespace Subsurface
private Direction dir;
private Item wearingItem;
private Sprite wearingItemSprite;
private WearableSprite wearingItemSprite;
private Vector2 animTargetPos;
@@ -154,7 +155,7 @@ namespace Subsurface
set { wearingItem = value; }
}
public Sprite WearingItemSprite
public WearableSprite WearingItemSprite
{
get { return wearingItemSprite; }
set { wearingItemSprite = value; }
@@ -184,7 +185,7 @@ namespace Subsurface
body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc;
}
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 8.0f);
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f);
body.UserData = this;
@@ -398,16 +399,28 @@ namespace Subsurface
Color color = Color.White;// new Color(1.0f, 1.0f - damage / maxHealth, 1.0f - damage / maxHealth);
body.Dir = Dir;
body.Draw(spriteBatch, sprite, color);
if (wearingItem == null || !wearingItemSprite.HideLimb)
{
body.Draw(spriteBatch, sprite, color);
}
else
{
body.UpdateDrawPosition();
}
if (wearingItem != null)
{
SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
wearingItemSprite.Draw(spriteBatch,
Vector2 origin = wearingItemSprite.Sprite.Origin;
if (body.Dir == -1.0f) origin.X = wearingItemSprite.Sprite.SourceRect.Width - origin.X;
wearingItemSprite.Sprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color,
color, origin,
-body.DrawRotation,
1.0f, spriteEffect);
1.0f, spriteEffect, sprite.Depth - 0.000001f);
}
if (!Game1.DebugDraw) return;

View File

@@ -238,7 +238,7 @@ namespace Subsurface
}
float startDepth = 0.1f;
float increment = 0.0001f;
float increment = 0.001f;
foreach (Character otherCharacter in Character.CharacterList)
{
@@ -248,7 +248,7 @@ namespace Subsurface
foreach (Limb limb in limbs)
{
limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.00001f;
limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f;
}
}

View File

@@ -339,6 +339,16 @@ namespace Subsurface
if (children.Contains(child)) children.Remove(child);
}
public GUIComponent FindChild(object userData)
{
foreach (GUIComponent child in children)
{
if (child.userData == userData) return child;
}
return null;
}
public virtual void ClearChildren()
{
children.Clear();

View File

@@ -213,7 +213,7 @@ namespace Subsurface
EditCharacterScreen = new EditCharacterScreen();
yield return Status.Running;
ParticleManager = new ParticleManager("Content/Particles/prefabs.xml", Cam);
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
yield return Status.Running;
GUIComponent.Init(Window);
@@ -262,7 +262,7 @@ namespace Subsurface
if (NetworkMember != null)
{
NetworkMember.Update();
NetworkMember.Update((float)deltaTime);
}
else
{
@@ -298,8 +298,6 @@ namespace Subsurface
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch);
}
//renderTimeElapsed = (int)renderTimer.Elapsed.Ticks;
//renderTimer.Stop();
if (sw.Elapsed.TotalSeconds < Physics.step)
{
System.Threading.Thread.Sleep((int)((Physics.step - sw.Elapsed.TotalSeconds)*1000.0));

View File

@@ -14,8 +14,6 @@ namespace Subsurface.Items.Components
string prevMsg;
//protected Character picker;
//the distance from the holding characters elbow to center of the physics body of the item
protected Vector2 holdPos;
@@ -23,8 +21,7 @@ namespace Subsurface.Items.Components
protected bool aimable;
private bool attachable;
private bool attached;
private bool attachable, attached, attachedByDefault;
private PhysicsBody body;
//the angle in which the character holds the item
@@ -51,6 +48,13 @@ namespace Subsurface.Items.Components
set { attachable = value; }
}
[HasDefaultValue(false, false)]
public bool AttachedByDefault
{
get { return attachedByDefault; }
set { attachedByDefault = value; }
}
[HasDefaultValue("0.0,0.0", false)]
public string HoldPos
{
@@ -97,6 +101,8 @@ namespace Subsurface.Items.Components
Msg = "";
}
if (attachedByDefault) Use(1.0f);
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
//holdAngle = MathHelper.ToRadians(holdAngle);

View File

@@ -19,6 +19,8 @@ namespace Subsurface.Items.Components
Vector2 barrelPos;
private string particles;
float structureFixAmount, limbFixAmount;
[HasDefaultValue(0.0f, false)]
@@ -42,6 +44,13 @@ namespace Subsurface.Items.Components
set { limbFixAmount = value; }
}
[HasDefaultValue("", false)]
public string Particles
{
get { return particles; }
set { particles = value; }
}
[HasDefaultValue("0.0,0.0", false)]
public string BarrelPos
{
@@ -178,12 +187,17 @@ namespace Subsurface.Items.Components
{
if (!isActive) return;
Vector2 particleSpeed = new Vector2(
(float)Math.Cos(item.body.Rotation),
(float)Math.Sin(item.body.Rotation)) *item.body.Dir * 5.0f;
//Vector2 particleSpeed = new Vector2(
// (float)Math.Cos(item.body.Rotation),
// (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f;
Game1.ParticleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed);
if (!string.IsNullOrWhiteSpace(particles))
{
Game1.ParticleManager.CreateParticle(particles, TransformedBarrelPos,
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), 0.0f);
}
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));

View File

@@ -22,12 +22,16 @@ namespace Subsurface.Items.Components
public float VolumeMultiplier;
public readonly float Range;
public readonly bool Loop;
public ItemSound(Sound sound, ActionType type, float range)
public ItemSound(Sound sound, ActionType type, float range, bool loop = true)
{
this.Sound = sound;
this.Type = type;
this.Range = range;
this.Loop = loop;
}
}
@@ -47,6 +51,8 @@ namespace Subsurface.Items.Components
protected bool canBePicked;
protected bool canBeSelected;
public bool WasUsed;
public List<StatusEffect> statusEffects;
protected bool updated;
@@ -59,6 +65,8 @@ namespace Subsurface.Items.Components
private GUIFrame guiFrame;
public ItemComponent Parent;
public readonly Dictionary<string, ObjectProperty> properties;
public Dictionary<string, ObjectProperty> ObjectProperties
{
@@ -217,9 +225,6 @@ namespace Subsurface.Items.Components
if (filePath=="") continue;
if (!filePath.Contains("\\")) filePath = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\"+filePath;
//int index = item.Prefab.sounds.FindIndex(x => x.FilePath == filePath);
ActionType type;
try
@@ -240,6 +245,13 @@ namespace Subsurface.Items.Components
itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f);
sounds.Add(itemSound);
break;
default:
ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false);
if (ic == null) break;
ic.Parent = this;
item.components.Add(ic);
break;
}
}
@@ -247,34 +259,52 @@ namespace Subsurface.Items.Components
private ItemSound loopingSound;
private int loopingSoundIndex;
public void PlaySound(ActionType type, Vector2 position, bool loop=false)
public void PlaySound(ActionType type, Vector2 position)
{
ItemSound itemSound = null;
if (!loop || !Sounds.SoundManager.IsPlaying(loopingSoundIndex))
if (!Sounds.SoundManager.IsPlaying(loopingSoundIndex))
{
List<ItemSound> matchingSounds = sounds.FindAll(x => x.Type == type);
if (matchingSounds.Count == 0) return;
int index = Rand.Int(matchingSounds.Count);
itemSound = matchingSounds[index];
if (loop) loopingSound = itemSound;
}
if (loop)
if (loopingSound!=null)
{
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range);
}
else
else if (itemSound!=null)
{
itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position);
if (itemSound.Loop)
{
loopingSound = itemSound;
}
else
{
itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position);
}
}
}
public void StopSounds(ActionType type)
{
if (loopingSoundIndex <= 0) return;
if (loopingSound == null) return;
if (loopingSound.Type != type) return;
if (Sounds.SoundManager.IsPlaying(loopingSoundIndex))
{
Sounds.SoundManager.Stop(loopingSoundIndex);
loopingSound = null;
loopingSoundIndex = -1;
}
}
private float GetSoundVolume(ItemSound sound)
{
if (sound.VolumeProperty == "") return 1.0f;
@@ -326,13 +356,7 @@ namespace Subsurface.Items.Components
//called when isActive is true and condition == 0.0f
public virtual void UpdateBroken(float deltaTime, Camera cam)
{
if (loopingSoundIndex <= 0) return;
if (Sounds.SoundManager.IsPlaying(loopingSoundIndex))
{
Sounds.SoundManager.Stop(loopingSoundIndex);
}
StopSounds(ActionType.OnActive);
}
//called when the item is equipped and left mouse button is pressed
@@ -565,30 +589,30 @@ namespace Subsurface.Items.Components
public virtual void OnMapLoaded() { }
public static ItemComponent Load(XElement element, Item item, string file)
public static ItemComponent Load(XElement element, Item item, string file, bool errorMessages = true)
{
Type t;
string type = element.Name.ToString().ToLower();
try
{
// Get the type of a specified class.
t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", true, true);
// Get the type of a specified class.
t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", false, true);
if (t == null)
{
DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")");
if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")");
return null;
}
}
catch (Exception e)
{
DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e);
if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e);
return null;
}
ConstructorInfo constructor;
try
{
if (t!=typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null;
if (t != typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null;
constructor = t.GetConstructor(new Type[] { typeof(Item), typeof(XElement) });
if (constructor == null)
{

View File

@@ -136,27 +136,8 @@ namespace Subsurface.Items.Components
private bool OnProjectileCollision(Fixture f1, Fixture f2, Contact contact)
{
//doesn't collide with items
//if (f2.Body.UserData is Item) return false;
if (ignoredBodies.Contains(f2.Body)) return false;
//Structure structure = f1.Body.UserData as Structure;
//if (structure!=null && (structure.IsPlatform || structure.StairDirection != Direction.None)) return false;
//Vector2 force = f1.Body.LinearVelocity * f1.Body.Mass;
//float forceLength = force.Length();
//if (forceLength > 20.0f)
//{
// force = force / forceLength * 20.0f;
//}
//f2.Body.ApplyLinearImpulse(force);
//f1.Body.ApplyLinearImpulse(-f1.Body.LinearVelocity * f1.Body.Mass);
//float damage = f1.Body.LinearVelocity.Length();
AttackResult attackResult = new AttackResult(0.0f, 0.0f);
if (attack!=null)
{
@@ -195,6 +176,11 @@ namespace Subsurface.Items.Components
if (Vector2.Dot(f1.Body.LinearVelocity, normal)<0 ) return StickToTarget(f2.Body, dir);
}
foreach (Item contained in item.ContainedItems)
{
contained.Condition = 0.0f;
}
return true;
}

View File

@@ -22,6 +22,8 @@ namespace Subsurface.Items.Components
float lightBrightness;
private float flicker;
[Editable, HasDefaultValue(100.0f, true)]
public float Range
{
@@ -31,6 +33,16 @@ namespace Subsurface.Items.Components
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
}
}
[HasDefaultValue(0.0f, false)]
public float Flicker
{
get { return flicker; }
set
{
flicker = MathHelper.Clamp(value, 0.0f, 1.0f);
}
}
[InGameEditable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
public string LightColor
@@ -61,7 +73,7 @@ namespace Subsurface.Items.Components
string dir = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\";
for (int i = 0; i<4; i++)
{
sparkSounds[i] = Sound.Load(dir+"zap"+(i+1)+".ogg");
sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap"+(i+1)+".ogg");
}
}
@@ -89,7 +101,7 @@ namespace Subsurface.Items.Components
}
Pickable pickable = item.GetComponent<Pickable>();
if (item.container!= null || (pickable!=null && pickable.Picker!=null))
if (item.container!= null)
{
light.Color = Color.Transparent;
return;
@@ -114,7 +126,7 @@ namespace Subsurface.Items.Components
lightBrightness = MathHelper.Lerp(lightBrightness, Math.Min(voltage, 1.0f), 0.1f);
}
light.Color = lightColor * lightBrightness;
light.Color = lightColor * lightBrightness * (1.0f-Rand.Range(0.0f,Flicker));
light.Range = range * (float)Math.Sqrt(lightBrightness);

View File

@@ -5,9 +5,21 @@ using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class WearableSprite
{
public Sprite Sprite;
public bool HideLimb;
public WearableSprite(Sprite sprite, bool hideLimb)
{
Sprite = sprite;
HideLimb = hideLimb;
}
}
class Wearable : Pickable
{
Sprite[] sprite;
WearableSprite[] wearableSprite;
LimbType[] limbType;
Limb[] limb;
@@ -18,7 +30,7 @@ namespace Subsurface.Items.Components
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
int spriteCount = sprites.Count();
sprite = new Sprite[spriteCount];
wearableSprite = new WearableSprite[spriteCount];
limbType = new LimbType[spriteCount];
limb = new Limb[spriteCount];
@@ -40,7 +52,8 @@ namespace Subsurface.Items.Components
string spritePath = subElement.Attribute("texture").Value;
spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"\\"+spritePath;
sprite[i] = new Sprite(subElement, "", spritePath);
var sprite = new Sprite(subElement, "", spritePath);
wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false));
//sprite[i].origin = new Vector2(sourceRect.Width / 2.0f, sourceRect.Height / 2.0f);
limbType[i] = (LimbType)Enum.Parse(typeof(LimbType),
@@ -53,7 +66,7 @@ namespace Subsurface.Items.Components
public override void Equip(Character character)
{
picker = character;
for (int i = 0; i < sprite.Length; i++ )
for (int i = 0; i < wearableSprite.Length; i++ )
{
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
if (equipLimb == null) continue;
@@ -64,7 +77,7 @@ namespace Subsurface.Items.Components
equipLimb.WearingItem.Unequip(character);
}
sprite[i].Depth = equipLimb.sprite.Depth - 0.001f;
//sprite[i].Depth = equipLimb.sprite.Depth - 0.001f;
item.body.Enabled = false;
@@ -72,7 +85,7 @@ namespace Subsurface.Items.Components
limb[i] = equipLimb;
equipLimb.WearingItem = item;
equipLimb.WearingItemSprite = sprite[i];
equipLimb.WearingItemSprite = wearableSprite[i];
}
}
@@ -89,7 +102,7 @@ namespace Subsurface.Items.Components
public override void Unequip(Character character)
{
if (picker == null) return;
for (int i = 0; i < sprite.Length; i++)
for (int i = 0; i < wearableSprite.Length; i++)
{
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
if (equipLimb == null) continue;

View File

@@ -134,6 +134,11 @@ namespace Subsurface
get { return prefab; }
}
public string ConfigFile
{
get { return prefab.ConfigFile; }
}
//which type of inventory slots (head, torso, any, etc) the item can be placed in
public LimbSlot AllowedSlots
{
@@ -443,12 +448,22 @@ namespace Subsurface
{
foreach (ItemComponent ic in components)
{
if (!ic.IsActive) continue;
if (ic.Parent != null) ic.IsActive = ic.Parent.IsActive;
if (!ic.WasUsed) ic.StopSounds(ActionType.OnUse);
ic.WasUsed = false;
if (!ic.IsActive)
{
ic.StopSounds(ActionType.OnActive);
continue;
}
if (condition > 0.0f)
{
ic.Update(deltaTime, cam);
ic.PlaySound(ActionType.OnActive, Position, true);
ic.PlaySound(ActionType.OnActive, Position);
ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
}
else
@@ -462,7 +477,6 @@ namespace Subsurface
if (body.LinearVelocity.Length()>0.001f) FindHull();
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.Position);
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
@@ -618,7 +632,6 @@ namespace Subsurface
{
foreach (RelatedItem relatedItem in ic.requiredItems)
{
new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", GUI.style, editingHUD);
GUITextBox namesBox = new GUITextBox(new Rectangle(0, y, 200, 20), Alignment.Right, GUI.style, editingHUD);
@@ -809,6 +822,8 @@ namespace Subsurface
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
if (ic.Use(deltaTime, character))
{
ic.WasUsed = true;
ic.PlaySound(ActionType.OnUse, Position);
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character);

View File

@@ -44,6 +44,7 @@ namespace Subsurface.Networking
name = newName;
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
characterInfo.Job = null;
otherClients = new List<Client>();
@@ -121,6 +122,7 @@ namespace Subsurface.Networking
private bool RetryConnection(GUIButton button, object obj)
{
if (client != null) client.Shutdown("Disconnecting");
ConnectToServer(serverIP);
return true;
}
@@ -175,6 +177,7 @@ namespace Subsurface.Networking
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
Game1.NetLobbyScreen.AddPlayer(otherClient);
otherClients.Add(otherClient);
}
//add the name of own client to the lobby screen
@@ -230,20 +233,9 @@ namespace Subsurface.Networking
yield return Status.Success;
}
public override void Update()
public override void Update(float deltaTime)
{
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K))
//{
// SendRandomData();
//}
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.L))
//{
// ConnectToServer(serverIP);
//}
if (gameStarted) inGameHUD.Update((float)Physics.step);
base.Update(deltaTime);
if (!connected || updateTimer > DateTime.Now) return;
@@ -341,17 +333,15 @@ namespace Subsurface.Networking
//myCharacter = ReadCharacterData(inc);
//Character.Controlled = myCharacter;
List<Character> crew = new List<Character>();
int count = inc.ReadInt32();
for (int n = 0; n < count; n++)
{
int id = inc.ReadInt32();
Character newCharacter = ReadCharacterData(inc);
Character newCharacter = ReadCharacterData(inc, id == myID);
if (id == myID)
{
myCharacter = newCharacter;
Character.Controlled = myCharacter;
}
crew.Add(newCharacter);
}
gameStarted = true;
@@ -360,6 +350,8 @@ namespace Subsurface.Networking
AddChatMessage("Press TAB to chat", ChatMessageType.Server);
CreateCrewFrame(crew);
break;
case (byte)PacketTypes.EndGame:
string endMessage = inc.ReadString();
@@ -370,6 +362,7 @@ namespace Subsurface.Networking
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
Game1.NetLobbyScreen.AddPlayer(otherClient);
otherClients.Add(otherClient);
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
@@ -459,7 +452,7 @@ namespace Subsurface.Networking
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
}
private Character ReadCharacterData(NetIncomingMessage inc)
private Character ReadCharacterData(NetIncomingMessage inc, bool isMyCharacter)
{
string newName = inc.ReadString();
int ID = inc.ReadInt32();
@@ -494,16 +487,20 @@ namespace Subsurface.Networking
}
Character character = (closestWaypoint == null) ?
new Character(ch, position) :
new Character(ch, closestWaypoint);
new Character(ch, position, true) :
new Character(ch, closestWaypoint, true);
character.ID = ID;
character.Inventory.ID = inventoryID;
character.IsNetworkPlayer = true;
character.GiveJobItems(closestWaypoint);
if (isMyCharacter)
{
myCharacter = character;
Character.Controlled = character;
}
return character;
}

View File

@@ -58,12 +58,9 @@ namespace Subsurface.Networking
DebugConsole.NewMessage("Server started", Color.Green);
}
public override void Update()
public override void Update(float deltaTime)
{
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K))
//{
// SendRandomData();
//}
base.Update(deltaTime);
if (gameStarted) inGameHUD.Update((float)Physics.step);
@@ -208,7 +205,7 @@ namespace Subsurface.Networking
}
else
{
AssignJobs();
//AssignJobs();
Game1.NetLobbyScreen.AddPlayer(sender);
@@ -346,6 +343,8 @@ namespace Subsurface.Networking
{
int seed = DateTime.Now.Millisecond;
Rand.SetSyncedSeed(seed);
AssignJobs();
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
@@ -369,9 +368,12 @@ namespace Subsurface.Networking
}
characterInfos.Add(client.characterInfo);
client.characterInfo.Job = new Job(client.assignedJob);
//client.character = new Character(client.characterInfo, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition, true);
}
List<Character> crew = new List<Character>();
WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos);
for (int i = 0; i < connectedClients.Count; i++ )
@@ -379,6 +381,8 @@ namespace Subsurface.Networking
connectedClients[i].character = new Character(
connectedClients[i].characterInfo, assignedWayPoints[i], true);
connectedClients[i].character.GiveJobItems(assignedWayPoints[i]);
crew.Add(connectedClients[i].character);
}
//todo: fix
@@ -427,6 +431,9 @@ namespace Subsurface.Networking
Game1.GameScreen.Select();
CreateCrewFrame(crew);
return true;
}
@@ -685,7 +692,7 @@ namespace Subsurface.Networking
}
}
UpdateNetLobby(null);
//UpdateNetLobby(null);
}

View File

@@ -1,6 +1,8 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace Subsurface.Networking
{
@@ -40,9 +42,14 @@ namespace Subsurface.Networking
protected GUIFrame inGameHUD;
protected GUIListBox chatBox;
protected GUITextBox chatMsgBox;
public int Port;
private bool crewFrameOpen;
private GUIButton crewButton;
private GUIFrame crewFrame;
protected bool gameStarted;
public string Name
@@ -72,13 +79,73 @@ namespace Subsurface.Networking
width, height),
Color.White * 0.5f, GUI.style, inGameHUD);
var textBox = new GUITextBox(
chatMsgBox = new GUITextBox(
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.style, inGameHUD);
textBox.Font = GUI.SmallFont;
textBox.OnEnter = EnterChatMessage;
chatMsgBox.Font = GUI.SmallFont;
chatMsgBox.OnEnter = EnterChatMessage;
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.style, inGameHUD);
crewButton.OnClicked = ToggleCrewFrame;
}
protected void CreateCrewFrame(List<Character> crew)
{
int width = 500, height = 400;
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.style, crewFrame);
crewList.OnSelected = SelectCharacter;
foreach (Character character in crew)
{
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList);
frame.UserData = character;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
frame.HoverColor = Color.LightGray * 0.5f;
frame.SelectedColor = Color.Gold * 0.5f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25),
character.Info.Name + " ("+character.Info.Job.Name+")",
Color.Transparent, Color.White,
Alignment.Left, Alignment.Left,
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame);
}
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.style, crewFrame);
closeButton.OnClicked = ToggleCrewFrame;
}
private bool SelectCharacter(object obj)
{
Character character = obj as Character;
if (obj == null) return false;
GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter");
if (existingFrame != null) crewFrame.RemoveChild(existingFrame);
var previewPlayer = new GUIFrame(
new Rectangle(0,0, 230, 300),
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.style, crewFrame);
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
previewPlayer.UserData = "selectedcharacter";
var infoFrame = character.Info.CreateInfoFrame(previewPlayer);
return true;
}
private bool ToggleCrewFrame(GUIButton button, object obj)
{
crewFrameOpen = !crewFrameOpen;
return true;
}
public bool EnterChatMessage(GUITextBox textBox, string message)
{
@@ -122,13 +189,36 @@ namespace Subsurface.Networking
public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { }
public virtual void Update() { }
public virtual void Update(float deltaTime)
{
if (gameStarted)
{
inGameHUD.Update(deltaTime);
if (crewFrameOpen) crewFrame.Update(deltaTime);
}
if (PlayerInput.KeyHit(Keys.Tab))
{
if (chatMsgBox.Selected)
{
chatMsgBox.Text = "";
chatMsgBox.Deselect();
}
else
{
chatMsgBox.Select();
}
}
}
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!gameStarted) return;
inGameHUD.Draw(spriteBatch);
if (crewFrameOpen) crewFrame.Draw(spriteBatch);
}
public virtual void Disconnect() { }

View File

@@ -82,7 +82,14 @@ namespace Subsurface.Particles
color = prefab.startColor;
alpha = prefab.startAlpha;
velocityChange = prefab.velocityChange;
velocityChange = prefab.velocityChange;
if (prefab.rotateToDirection)
{
this.rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));
prevRotation = rotation;
}
}
public bool Update(float deltaTime)
@@ -93,7 +100,10 @@ namespace Subsurface.Particles
if (prefab.rotateToDirection)
{
rotation = MathUtils.VectorToAngle(velocity);
if (velocityChange != Vector2.Zero || angularVelocity != 0.0f)
{
rotation = MathUtils.VectorToAngle(new Vector2(velocity.X, -velocity.Y));
}
}
else
{
@@ -153,15 +163,17 @@ namespace Subsurface.Particles
drawPosition = ConvertUnits.ToDisplayUnits(drawPosition);
spriteBatch.Draw(
prefab.sprite.Texture,
drawPosition,
null,
color*alpha,
drawRotation,
prefab.sprite.origin,
size,
SpriteEffects.None, prefab.sprite.Depth);
prefab.sprite.Draw(spriteBatch, drawPosition, color*alpha, drawRotation, size.X, SpriteEffects.None, prefab.sprite.Depth);
//spriteBatch.Draw(
// prefab.sprite.Texture,
// drawPosition,
// null,
// color*alpha,
// drawRotation,
// prefab.sprite.origin,
// size,
// SpriteEffects.None, prefab.sprite.Depth);
prevPosition = position;
prevRotation = rotation;

View File

@@ -35,8 +35,12 @@ namespace Subsurface.Particles
{
name = element.Name.ToString();
string spritePath = ToolBox.GetAttributeString(element, "sprite", "");
sprite = new Sprite(spritePath, new Vector2(0.5f,0.5f));
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower() != "sprite") continue;
sprite = new Sprite(subElement);
}
angularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f);
angularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f);

View File

@@ -285,17 +285,22 @@ namespace Subsurface
}
}
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null)
public void UpdateDrawPosition()
{
if (!body.Enabled) return;
SpriteEffects spriteEffect = (dir == 1.0f) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
drawPosition = Physics.Interpolate(prevPosition, body.Position);
drawPosition = ConvertUnits.ToDisplayUnits(drawPosition);
drawRotation = Physics.Interpolate(prevRotation, body.Rotation);
}
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null)
{
if (!body.Enabled) return;
UpdateDrawPosition();
SpriteEffects spriteEffect = (dir == 1.0f) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
sprite.Draw(spriteBatch, new Vector2(drawPosition.X, -drawPosition.Y), color, -drawRotation, 1.0f, spriteEffect, depth);
//prevPosition = body.Position;

View File

@@ -221,7 +221,6 @@ namespace Subsurface
serverName.Enabled = Game1.Server != null;
serverName.OnTextChanged = ChangeServerName;
serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
serverMessage.Wrap = true;
serverMessage.TextGetter = GetServerMessage;
@@ -266,10 +265,10 @@ namespace Subsurface
if (subList.CountChildren > 0) subList.Select(0);
if (GameModePreset.list.Count > 0) modeList.Select(0);
}
else
else if (playerFrame.children.Count==0)
{
int x = playerFrame.Rect.Width / 2;
playerFrame.ClearChildren();
new GUITextBlock(new Rectangle(x, 0, 200, 30), "Name: ", GUI.style, playerFrame);
@@ -312,7 +311,6 @@ namespace Subsurface
UpdateJobPreferences(jobList);
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
}
base.Select();
@@ -594,13 +592,13 @@ namespace Subsurface
msg.Write(durationBar.BarScroll);
msg.Write(LevelSeed);
msg.Write(playerList.CountChildren - 1);
for (int i = 1; i < playerList.CountChildren; i++)
{
Client client = playerList.children[i].UserData as Client;
msg.Write(client.ID);
msg.Write(client.assignedJob==null ? "" : client.assignedJob.Name);
}
//msg.Write(playerList.CountChildren - 1);
//for (int i = 1; i < playerList.CountChildren; i++)
//{
// Client client = playerList.children[i].UserData as Client;
// msg.Write(client.ID);
// msg.Write(client.assignedJob==null ? "" : client.assignedJob.Name);
//}
}
@@ -642,48 +640,48 @@ namespace Subsurface
LevelSeed = levelSeed;
try
{
int playerCount = msg.ReadInt32();
//try
//{
// int playerCount = msg.ReadInt32();
for (int i = 0; i < playerCount; i++)
{
int clientID = msg.ReadInt32();
string jobName = msg.ReadString();
// for (int i = 0; i < playerCount; i++)
// {
// int clientID = msg.ReadInt32();
// string jobName = msg.ReadString();
Client client = null;
GUITextBlock textBlock = null;
foreach (GUIComponent child in playerList.children)
{
Client tempClient = child.UserData as Client;
if (tempClient == null || tempClient.ID != clientID) continue;
// Client client = null;
// GUITextBlock textBlock = null;
// foreach (GUIComponent child in playerList.children)
// {
// Client tempClient = child.UserData as Client;
// if (tempClient == null || tempClient.ID != clientID) continue;
client = tempClient;
textBlock = child as GUITextBlock;
break;
}
if (client == null) continue;
// client = tempClient;
// textBlock = child as GUITextBlock;
// break;
// }
// if (client == null) continue;
client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName);
// client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName);
textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
// textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
if (client.assignedJob==null || jobName != client.assignedJob.Name)
{
if (clientID == Game1.Client.ID)
{
Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
Game1.Client.CharacterInfo.Name = client.name;
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
}
}
}
}
// if (client.assignedJob==null || jobName != client.assignedJob.Name)
// {
// if (clientID == Game1.Client.ID)
// {
// Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
// Game1.Client.CharacterInfo.Name = client.name;
// UpdatePreviewPlayer(Game1.Client.CharacterInfo);
// }
// }
// }
//}
catch
{
return;
}
//catch
//{
// return;
//}
}

View File

@@ -172,13 +172,9 @@ namespace Subsurface
}
return sourceIndex;
}
}
return SoundManager.Loop(this, sourceIndex, position, volume, volume);
//return UpdatePosition(newIndex, position, range, volume);
}

View File

@@ -188,7 +188,11 @@ namespace Subsurface
public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, float rotate = 0.0f, float scale = 1.0f, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null)
{
spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth==null ? this.depth : (float)depth);
}
public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate = 0.0f, float scale = 1.0f, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null)
{
spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth);
}
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Color color)

View File

@@ -292,6 +292,12 @@
<Content Include="Content\Items\Artifacts\artifacts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Clothes\captainLegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Clothes\captainTorso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\lamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -469,6 +475,9 @@
<Content Include="Content\Map\locationTypes.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Particles\flames.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\UI\caret.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -641,7 +650,7 @@
<Content Include="Content\Particles\explosion.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Particles\prefabs.xml">
<Content Include="Content\Particles\ParticlePrefabs.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
@@ -770,6 +779,12 @@
<None Include="Content\Items\Reactor\reactor.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Tools\plasmaCutter.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Tools\weldingTool.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Items\Weapons\harpoon1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

Binary file not shown.