misc UI stuff, gamesession additions, limbs don't have individual health anymore, background music
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Subsurface
|
||||
|
||||
|
||||
damage = ToolBox.GetAttributeFloat(element, "damage", 0.0f);
|
||||
structureDamage = ToolBox.GetAttributeFloat(element, "damage", 0.0f);
|
||||
structureDamage = ToolBox.GetAttributeFloat(element, "structuredamage", 0.0f);
|
||||
bleedingDamage = ToolBox.GetAttributeFloat(element, "bleedingdamage", 0.0f);
|
||||
|
||||
stun = ToolBox.GetAttributeFloat(element, "stun", 0.0f);
|
||||
|
||||
@@ -59,6 +59,9 @@ namespace Subsurface
|
||||
protected float oxygen;
|
||||
protected float drowningTime;
|
||||
|
||||
protected float health;
|
||||
protected float maxHealth;
|
||||
|
||||
protected Item closestItem;
|
||||
|
||||
protected bool isDead;
|
||||
@@ -73,6 +76,7 @@ namespace Subsurface
|
||||
protected float soundTimer;
|
||||
protected float soundInterval;
|
||||
|
||||
private float bleeding;
|
||||
private float blood;
|
||||
|
||||
private Sound[] sounds;
|
||||
@@ -122,13 +126,19 @@ namespace Subsurface
|
||||
{
|
||||
get
|
||||
{
|
||||
float totalHealth = 0.0f;
|
||||
foreach (Limb l in animController.limbs)
|
||||
{
|
||||
totalHealth += (l.MaxHealth - l.Damage);
|
||||
return health;
|
||||
//float totalHealth = 0.0f;
|
||||
//foreach (Limb l in animController.limbs)
|
||||
//{
|
||||
// totalHealth += (l.MaxHealth - l.Damage);
|
||||
|
||||
}
|
||||
return totalHealth/animController.limbs.Count();
|
||||
//}
|
||||
//return totalHealth/animController.limbs.Count();
|
||||
}
|
||||
set
|
||||
{
|
||||
health = MathHelper.Clamp(value, 0.0f, maxHealth);
|
||||
if (health==0.0f) Kill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,6 +311,9 @@ namespace Subsurface
|
||||
//limb.prevPosition = ConvertUnits.ToDisplayUnits(position);
|
||||
}
|
||||
|
||||
maxHealth = ToolBox.GetAttributeFloat(doc.Root, "health", 100.0f);
|
||||
health = maxHealth;
|
||||
|
||||
needsAir = ToolBox.GetAttributeBool(doc.Root, "needsair", false);
|
||||
drowningTime = ToolBox.GetAttributeFloat(doc.Root, "drowningtime", 10.0f);
|
||||
|
||||
@@ -543,10 +556,10 @@ namespace Subsurface
|
||||
soundTimer = soundInterval;
|
||||
}
|
||||
|
||||
foreach (Limb limb in animController.limbs)
|
||||
{
|
||||
Blood = blood - limb.Bleeding * deltaTime * 0.1f;
|
||||
}
|
||||
//foreach (Limb limb in animController.limbs)
|
||||
//{
|
||||
Blood = blood - bleeding * deltaTime;
|
||||
//}
|
||||
|
||||
if (aiController != null) aiController.Update(deltaTime);
|
||||
}
|
||||
@@ -587,19 +600,25 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
private static GUIProgressBar drowningBar;
|
||||
private static GUIProgressBar drowningBar, bloodBar;
|
||||
public void DrawHud(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
if (drowningBar==null)
|
||||
{
|
||||
int width = 200, height = 20;
|
||||
drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f);
|
||||
int width = 100, height = 20;
|
||||
drowningBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight/2, width, height), Color.Blue, 1.0f);
|
||||
|
||||
bloodBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight / 2 + 30, width, height), Color.Red, 1.0f);
|
||||
}
|
||||
|
||||
drowningBar.BarSize = Controlled.Oxygen / 100.0f;
|
||||
if (drowningBar.BarSize < 1.0f)
|
||||
drowningBar.Draw(spriteBatch);
|
||||
|
||||
bloodBar.BarSize = Blood / 100.0f;
|
||||
if (bloodBar.BarSize < 1.0f)
|
||||
bloodBar.Draw(spriteBatch);
|
||||
|
||||
if (Controlled.Inventory != null)
|
||||
Controlled.Inventory.Draw(spriteBatch);
|
||||
|
||||
@@ -674,7 +693,11 @@ namespace Subsurface
|
||||
closestLimb.body.ApplyForce(pull*Math.Min(amount*100.0f, 100.0f));
|
||||
|
||||
|
||||
return closestLimb.AddDamage(position, damageType, amount, bleedingAmount, playSound);
|
||||
AttackResult attackResult = closestLimb.AddDamage(position, damageType, amount, bleedingAmount, playSound);
|
||||
health -= attackResult.damage;
|
||||
bleeding += attackResult.bleeding;
|
||||
|
||||
return attackResult;
|
||||
|
||||
}
|
||||
|
||||
@@ -705,12 +728,14 @@ namespace Subsurface
|
||||
|
||||
centerOfMass /= totalMass;
|
||||
|
||||
health = 0.0f;
|
||||
|
||||
foreach (Limb limb in animController.limbs)
|
||||
{
|
||||
Vector2 diff = centerOfMass - limb.SimPosition;
|
||||
if (diff == Vector2.Zero) continue;
|
||||
limb.body.ApplyLinearImpulse(diff * 10.0f);
|
||||
limb.Damage = 100.0f;
|
||||
// limb.Damage = 100.0f;
|
||||
}
|
||||
|
||||
AmbientSoundManager.PlayDamageSound(DamageSoundType.Implode, 50.0f, torso.body.FarseerBody);
|
||||
@@ -739,7 +764,7 @@ namespace Subsurface
|
||||
if (isDead) return;
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (Game1.client != null)
|
||||
if (Game1.Client != null)
|
||||
{
|
||||
if (networkMessage)
|
||||
{
|
||||
@@ -751,14 +776,14 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
if (Game1.server != null)
|
||||
if (Game1.Server != null)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, false);
|
||||
}
|
||||
|
||||
if (Game1.gameSession.crewManager!=null)
|
||||
if (Game1.GameSession.crewManager!=null)
|
||||
{
|
||||
Game1.gameSession.crewManager.KillCharacter(this);
|
||||
Game1.GameSession.crewManager.KillCharacter(this);
|
||||
}
|
||||
|
||||
isDead = true;
|
||||
@@ -876,9 +901,9 @@ namespace Subsurface
|
||||
else if (type == NetworkEventType.KillCharacter)
|
||||
{
|
||||
Kill(true);
|
||||
if (Game1.client != null && controlled == this)
|
||||
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.Client.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -970,7 +995,7 @@ namespace Subsurface
|
||||
|
||||
if (controlled == this) controlled = null;
|
||||
|
||||
if (Game1.client!=null && Game1.client.Character == this) Game1.client.Character = null;
|
||||
if (Game1.Client!=null && Game1.Client.Character == this) Game1.Client.Character = null;
|
||||
|
||||
if (aiTarget != null)
|
||||
aiTarget.Remove();
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Subsurface
|
||||
|
||||
public readonly bool ignoreCollisions;
|
||||
|
||||
private readonly float maxHealth;
|
||||
private float damage;
|
||||
private float bleeding;
|
||||
//private readonly float maxHealth;
|
||||
//private float damage;
|
||||
//private float bleeding;
|
||||
|
||||
public readonly float impactTolerance;
|
||||
|
||||
@@ -122,26 +122,26 @@ namespace Subsurface
|
||||
get { return refJointIndex; }
|
||||
}
|
||||
|
||||
public float Damage
|
||||
{
|
||||
get { return damage; }
|
||||
set
|
||||
{
|
||||
damage = Math.Max(value, 0.0f);
|
||||
if (damage >=maxHealth) character.Kill();
|
||||
}
|
||||
}
|
||||
//public float Damage
|
||||
//{
|
||||
// get { return damage; }
|
||||
// set
|
||||
// {
|
||||
// damage = Math.Max(value, 0.0f);
|
||||
// if (damage >=maxHealth) character.Kill();
|
||||
// }
|
||||
//}
|
||||
|
||||
public float MaxHealth
|
||||
{
|
||||
get { return maxHealth; }
|
||||
}
|
||||
//public float MaxHealth
|
||||
//{
|
||||
// get { return maxHealth; }
|
||||
//}
|
||||
|
||||
public float Bleeding
|
||||
{
|
||||
get { return bleeding; }
|
||||
set { bleeding = MathHelper.Clamp(value, 0.0f, 100.0f); }
|
||||
}
|
||||
//public float Bleeding
|
||||
//{
|
||||
// get { return bleeding; }
|
||||
// set { bleeding = MathHelper.Clamp(value, 0.0f, 100.0f); }
|
||||
//}
|
||||
|
||||
public Item WearingItem
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace Subsurface
|
||||
|
||||
steerForce = ToolBox.GetAttributeFloat(element, "steerforce", 0.0f);
|
||||
|
||||
maxHealth = Math.Max(ToolBox.GetAttributeFloat(element, "health", 100.0f),1.0f);
|
||||
//maxHealth = Math.Max(ToolBox.GetAttributeFloat(element, "health", 100.0f),1.0f);
|
||||
|
||||
armorSector = ToolBox.GetAttributeVector2(element, "armorsector", Vector2.Zero);
|
||||
armorSector.X = MathHelper.ToRadians(armorSector.X);
|
||||
@@ -277,7 +277,7 @@ namespace Subsurface
|
||||
{
|
||||
hitArmor = true;
|
||||
damageSoundType = DamageSoundType.LimbArmor;
|
||||
damage /= armorValue;
|
||||
amount /= armorValue;
|
||||
bleedingAmount /= armorValue;
|
||||
}
|
||||
}
|
||||
@@ -287,8 +287,8 @@ namespace Subsurface
|
||||
AmbientSoundManager.PlayDamageSound(damageSoundType, amount, position);
|
||||
}
|
||||
|
||||
Bleeding += bleedingAmount;
|
||||
Damage += amount;
|
||||
//Bleeding += bleedingAmount;
|
||||
//Damage += amount;
|
||||
|
||||
float bloodAmount = hitArmor ? 0 : (int)Math.Min((int)(amount * 2.0f), 20);
|
||||
//if (closestLimb.Damage>=100.0f)
|
||||
@@ -366,18 +366,18 @@ namespace Subsurface
|
||||
|
||||
soundTimer -= deltaTime;
|
||||
|
||||
if (ToolBox.RandomFloat(0.0f, 1000.0f) < Bleeding)
|
||||
{
|
||||
Game1.particleManager.CreateParticle(
|
||||
!inWater ? "blood" : "waterblood",
|
||||
SimPosition, Vector2.Zero);
|
||||
}
|
||||
//if (ToolBox.RandomFloat(0.0f, 1000.0f) < Bleeding)
|
||||
//{
|
||||
// Game1.particleManager.CreateParticle(
|
||||
// !inWater ? "blood" : "waterblood",
|
||||
// SimPosition, Vector2.Zero);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool debugDraw)
|
||||
{
|
||||
Color color = new Color(1.0f, 1.0f - damage / maxHealth, 1.0f - damage / maxHealth);
|
||||
Color color = Color.White;// new Color(1.0f, 1.0f - damage / maxHealth, 1.0f - damage / maxHealth);
|
||||
|
||||
body.Dir = Dir;
|
||||
body.Draw(spriteBatch, sprite, color);
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace Subsurface
|
||||
|
||||
if (impact > l.impactTolerance)
|
||||
{
|
||||
l.Damage += (impact-l.impactTolerance*0.1f);
|
||||
character.Health -= (impact-l.impactTolerance*0.1f);
|
||||
strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<limb id = "3" width="13" height="45" mass = "6" ignorecollisions="true" flip="true">
|
||||
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="65,131,36,50" depth="0.15" origin="0.4,0.5"/>
|
||||
<attack type="PinchCW" range="120" duration="0.5" damage="30" stun="0.1" bleedingdamage="20" structuredamage="350" damagetype="slash"/>
|
||||
<attack type="PinchCW" range="120" duration="0.5" damage="30" stun="0.1" bleedingdamage="20" structuredamage="50" damagetype="slash"/>
|
||||
</limb>
|
||||
|
||||
<limb id = "4" width="11" height="34" mass = "4" type="RightLeg" flip="true">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<Reactor canbeselected = "true">
|
||||
<requireditem name="Fuel Rod" type="Contained"/>
|
||||
<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"/>
|
||||
<sound file="reactor.ogg" type="OnActive" range="1000.0" volume="FissionRate"/>
|
||||
</Reactor>
|
||||
|
||||
<ConnectionPanel canbeselected = "true">
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<Body width="64" height="5" density="20"/>
|
||||
|
||||
<Pickable slots="Any"/>
|
||||
<Projectile launchimpulse="20.0" damage="20.0" bleedingdamage="20.0" doesstick="true">
|
||||
<Attack damage="20" bleeding="30" structuredamage="50" damagetype="Blunt"/>
|
||||
<Projectile launchimpulse="20.0" doesstick="true">
|
||||
<Attack damage="20" bleedingdamage="30" structuredamage="50" damagetype="Blunt"/>
|
||||
</Projectile>
|
||||
</Item>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
<Body width="11" height="24" density="15" friction="0.8f"/>
|
||||
|
||||
<Throwable holdpos="0,0" handle1="0,0" throwforce="5.0">
|
||||
<Throwable holdpos="0,0" handle1="0,0" throwforce="5.0" aimpos="35,-10">
|
||||
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stunGrenade.ogg">
|
||||
<Explosion range="5" damage="5" stun="10" force="0.1"/>
|
||||
</StatusEffect>
|
||||
|
||||
BIN
Subsurface/Content/Sounds/Music/Enter the Maze.ogg
Normal file
BIN
Subsurface/Content/Sounds/Music/Enter the Maze.ogg
Normal file
Binary file not shown.
BIN
Subsurface/Content/Sounds/Music/Unseen Horrors.ogg
Normal file
BIN
Subsurface/Content/Sounds/Music/Unseen Horrors.ogg
Normal file
Binary file not shown.
@@ -25,4 +25,8 @@
|
||||
<damagesound file="Content/Sounds/Damage/HitArmor3.ogg" damagerange="40.0,100.0" damagesoundtype="LimbArmor"/>
|
||||
|
||||
<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"/>
|
||||
</sounds>
|
||||
@@ -3,13 +3,15 @@
|
||||
<MonsterEvent name="Under attack" description=""
|
||||
characterfile="Content/Characters/Crawler/Crawler.xml"
|
||||
commonness="10"
|
||||
difficulty="10"
|
||||
minamount="2" maxamount="4"
|
||||
starttimemin="5" starttimemax="10"/>
|
||||
difficulty="30"
|
||||
minamount="2" maxamount="3"
|
||||
starttimemin="5" starttimemax="10"
|
||||
musictype="monster"/>
|
||||
|
||||
<MonsterEvent name="Under attack" description=""
|
||||
characterfile="Content/Characters/TigerThresher/tigerthresher.xml"
|
||||
commonness="10"
|
||||
difficulty="10"
|
||||
starttimemin="5" starttimemax="10"/>
|
||||
difficulty="50"
|
||||
starttimemin="5" starttimemax="10"
|
||||
musictype="monster"/>
|
||||
</Randomevents>
|
||||
@@ -148,8 +148,8 @@ namespace Subsurface
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(WayPoint.SpawnType.Human);
|
||||
Character.Controlled = new Character("Content/Characters/Human/human.xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
if (Game1.gameSession != null) Game1.gameSession.crewManager.AddCharacter(Character.Controlled);
|
||||
if (Game1.gameSession != null) Game1.gameSession.crewManager.SelectCharacter(Character.Controlled);
|
||||
if (Game1.GameSession != null) Game1.GameSession.crewManager.AddCharacter(Character.Controlled);
|
||||
if (Game1.GameSession != null) Game1.GameSession.crewManager.SelectCharacter(Character.Controlled);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,42 +159,42 @@ namespace Subsurface
|
||||
|
||||
break;
|
||||
case "startserver":
|
||||
if (Game1.server==null)
|
||||
Game1.server = new GameServer();
|
||||
if (Game1.Server==null)
|
||||
Game1.Server = new GameServer();
|
||||
break;
|
||||
case "kick":
|
||||
if (Game1.server == null) break;
|
||||
Game1.server.KickPlayer(commands[1]);
|
||||
if (Game1.Server == null) break;
|
||||
Game1.Server.KickPlayer(commands[1]);
|
||||
break;
|
||||
case "startclient":
|
||||
if (commands.Length == 1) return;
|
||||
if (Game1.client == null)
|
||||
if (Game1.Client == null)
|
||||
{
|
||||
Game1.client = new GameClient("Name");
|
||||
Game1.client.ConnectToServer(commands[1]);
|
||||
Game1.Client = new GameClient("Name");
|
||||
Game1.Client.ConnectToServer(commands[1]);
|
||||
}
|
||||
break;
|
||||
case "mainmenuscreen":
|
||||
case "mainmenu":
|
||||
case "menu":
|
||||
Game1.mainMenuScreen.Select();
|
||||
Game1.MainMenuScreen.Select();
|
||||
break;
|
||||
case "gamescreen":
|
||||
case "game":
|
||||
Game1.gameScreen.Select();
|
||||
Game1.GameScreen.Select();
|
||||
break;
|
||||
case "editmapscreen":
|
||||
case "editmap":
|
||||
case "edit":
|
||||
Game1.editMapScreen.Select();
|
||||
Game1.EditMapScreen.Select();
|
||||
break;
|
||||
case "editcharacter":
|
||||
case "editchar":
|
||||
Game1.editCharacterScreen.Select();
|
||||
Game1.EditCharacterScreen.Select();
|
||||
break;
|
||||
case "editwater":
|
||||
case "water":
|
||||
if (Game1.client== null)
|
||||
if (Game1.Client== null)
|
||||
{
|
||||
Hull.EditWater = !Hull.EditWater;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace Subsurface
|
||||
break;
|
||||
case "lobbyscreen":
|
||||
case "lobby":
|
||||
Game1.lobbyScreen.Select();
|
||||
Game1.LobbyScreen.Select();
|
||||
break;
|
||||
case "savemap":
|
||||
Map.Loaded.SaveAs("Content/SavedMaps/" + commands[1]);
|
||||
@@ -215,6 +215,10 @@ namespace Subsurface
|
||||
case "loadmap":
|
||||
Map.Load("Content/SavedMaps/" + commands[1]);
|
||||
break;
|
||||
case "messagebox":
|
||||
if (commands.Length < 3) break;
|
||||
new GUIMessageBox(commands[1], commands[2]);
|
||||
break;
|
||||
case "debugdraw":
|
||||
Hull.DebugDraw = !Hull.DebugDraw;
|
||||
Ragdoll.DebugDraw = !Ragdoll.DebugDraw;
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
public delegate bool IsFinishedHandler();
|
||||
private IsFinishedHandler IsFinishedChecker;
|
||||
|
||||
public PropertyTask(TaskManager taskManager, Item item, IsFinishedHandler isFinished, float priority, string name)
|
||||
: base(taskManager, priority, name)
|
||||
public PropertyTask(Item item, IsFinishedHandler isFinished, float priority, string name)
|
||||
: base(priority, name)
|
||||
{
|
||||
if (taskManager == null) return;
|
||||
|
||||
this.item = item;
|
||||
IsFinishedChecker = isFinished;
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
{
|
||||
Item item;
|
||||
|
||||
public RepairTask(TaskManager taskManager, Item item, float priority, string name)
|
||||
: base(taskManager, priority, name)
|
||||
public RepairTask(Item item, float priority, string name)
|
||||
: base(priority, name)
|
||||
{
|
||||
if (taskManager == null) return;
|
||||
|
||||
this.item = item;
|
||||
|
||||
taskManager.TaskStarted(this);
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Subsurface
|
||||
|
||||
protected bool isStarted;
|
||||
protected bool isFinished;
|
||||
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
@@ -46,6 +46,12 @@ namespace Subsurface
|
||||
get { return commonness; }
|
||||
}
|
||||
|
||||
public string MusicType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool IsStarted
|
||||
{
|
||||
get { return isStarted; }
|
||||
@@ -69,6 +75,10 @@ namespace Subsurface
|
||||
difficulty = ToolBox.GetAttributeInt(element, "difficulty", 1);
|
||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
|
||||
|
||||
MusicType = ToolBox.GetAttributeString(element, "musictype", "default");
|
||||
|
||||
|
||||
if (element.Attribute("starttime") != null)
|
||||
{
|
||||
startTimeMax = ToolBox.GetAttributeInt(element, "starttime", 1);
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
|
||||
private bool prevStarted;
|
||||
|
||||
public ScriptedTask(TaskManager taskManager, ScriptedEvent scriptedEvent)
|
||||
: base(taskManager, scriptedEvent.Difficulty, scriptedEvent.Name)
|
||||
public ScriptedTask(ScriptedEvent scriptedEvent)
|
||||
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
||||
{
|
||||
if (taskManager == null) return;
|
||||
|
||||
this.musicType = scriptedEvent.MusicType;
|
||||
|
||||
this.scriptedEvent = scriptedEvent;
|
||||
scriptedEvent.Init();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Subsurface
|
||||
|
||||
private float priority;
|
||||
|
||||
protected string musicType;
|
||||
|
||||
protected TaskManager taskManager;
|
||||
|
||||
protected bool isFinished;
|
||||
@@ -22,14 +24,22 @@ namespace Subsurface
|
||||
get { return priority; }
|
||||
}
|
||||
|
||||
public string MusicType
|
||||
{
|
||||
get { return musicType; }
|
||||
}
|
||||
|
||||
public bool IsFinished
|
||||
{
|
||||
get { return isFinished; }
|
||||
}
|
||||
|
||||
public Task(TaskManager taskManager, float priority, string name)
|
||||
public Task(float priority, string name)
|
||||
{
|
||||
this.taskManager = taskManager;
|
||||
if (Game1.GameSession==null || Game1.GameSession.taskManager == null) return;
|
||||
|
||||
taskManager = Game1.GameSession.taskManager;
|
||||
musicType = "repair";
|
||||
this.priority = priority;
|
||||
this.name = name;
|
||||
|
||||
|
||||
@@ -6,10 +6,29 @@ namespace Subsurface
|
||||
{
|
||||
class TaskManager
|
||||
{
|
||||
const float CriticalPriority = 50.0f;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
private GUIListBox taskListBox;
|
||||
|
||||
public List<Task> Tasks
|
||||
{
|
||||
get { return tasks; }
|
||||
}
|
||||
|
||||
public bool CriticalTasks
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (Task task in tasks)
|
||||
{
|
||||
if (task.Priority >= CriticalPriority) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public TaskManager(GameSession session)
|
||||
{
|
||||
tasks = new List<Task>();
|
||||
@@ -45,7 +64,7 @@ namespace Subsurface
|
||||
for (int i = 0; i < scriptedEventCount; i++)
|
||||
{
|
||||
ScriptedEvent scriptedEvent = ScriptedEvent.LoadRandom();
|
||||
AddTask(new ScriptedTask(this, scriptedEvent));
|
||||
AddTask(new ScriptedTask(scriptedEvent));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -272,10 +272,26 @@ namespace Subsurface
|
||||
if (Character.Controlled != null) Character.Controlled.DrawHud(spriteBatch, cam);
|
||||
|
||||
DrawMessages(spriteBatch, (float)deltaTime);
|
||||
|
||||
if (GUIMessageBox.messageBoxes.Count>0)
|
||||
{
|
||||
var messageBox = GUIMessageBox.messageBoxes.Peek();
|
||||
if (messageBox != null) messageBox.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
|
||||
DebugConsole.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public static void Update(float deltaTime)
|
||||
{
|
||||
if (GUIMessageBox.messageBoxes.Count > 0)
|
||||
{
|
||||
var messageBox = GUIMessageBox.messageBoxes.Peek();
|
||||
if (messageBox != null) messageBox.Update(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddMessage(string message, Color color, float lifeTime = 3.0f)
|
||||
{
|
||||
Vector2 currPos = new Vector2(Game1.GraphicsWidth / 2.0f, Game1.GraphicsHeight * 0.7f);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (rect.Contains(PlayerInput.GetMouseState.Position) && Enabled)
|
||||
if (rect.Contains(PlayerInput.GetMouseState.Position) && Enabled && (MouseOn == this || IsParentOf(MouseOn)))
|
||||
{
|
||||
state = ComponentState.Hover;
|
||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
|
||||
@@ -66,8 +66,7 @@ namespace Subsurface
|
||||
if (OnClicked != null)
|
||||
{
|
||||
if (OnClicked(this, UserData)) state = ComponentState.Selected;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -87,7 +86,7 @@ namespace Subsurface
|
||||
|
||||
DrawChildren(spriteBatch);
|
||||
|
||||
if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f*alpha, true);
|
||||
if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,14 +142,27 @@ namespace Subsurface
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsParentOf(GUIComponent component)
|
||||
{
|
||||
foreach (GUIComponent child in children)
|
||||
{
|
||||
if (child == component) return true;
|
||||
if (child.IsParentOf(component)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Color newColor = color;
|
||||
if (state == ComponentState.Selected) newColor = selectedColor;
|
||||
if (state == ComponentState.Hover) newColor = hoverColor;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, newColor*alpha, true);
|
||||
DrawChildren(spriteBatch);
|
||||
|
||||
//Color newColor = color;
|
||||
//if (state == ComponentState.Selected) newColor = selectedColor;
|
||||
//if (state == ComponentState.Hover) newColor = hoverColor;
|
||||
|
||||
//GUI.DrawRectangle(spriteBatch, rect, newColor*alpha, true);
|
||||
//DrawChildren(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void Update(float deltaTime)
|
||||
|
||||
@@ -27,5 +27,17 @@ namespace Subsurface
|
||||
parent.AddChild(this);
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
Color newColor = color;
|
||||
if (state == ComponentState.Selected) newColor = selectedColor;
|
||||
if (state == ComponentState.Hover) newColor = hoverColor;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, newColor * alpha, true);
|
||||
DrawChildren(spriteBatch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Subsurface
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
|
||||
scrollBar.Update(deltaTime);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
base.Draw(spriteBatch);
|
||||
GUI.DrawRectangle(spriteBatch, rect, color*alpha, true);
|
||||
|
||||
int x = rect.X, y = rect.Y;
|
||||
@@ -206,7 +206,6 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < children.Count; i++ )
|
||||
{
|
||||
GUIComponent child = children[i];
|
||||
@@ -232,7 +231,7 @@ namespace Subsurface
|
||||
if (CheckSelected() != selected.UserData) selected = null;
|
||||
}
|
||||
}
|
||||
else if (child.Rect.Contains(PlayerInput.GetMouseState.Position) && enabled)
|
||||
else if (enabled && (MouseOn==this || ( MouseOn!=null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.GetMouseState.Position))
|
||||
{
|
||||
child.State = ComponentState.Hover;
|
||||
if (PlayerInput.LeftButtonClicked())
|
||||
|
||||
@@ -3,27 +3,29 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
class GUIMessageBox
|
||||
class GUIMessageBox : GUIFrame
|
||||
{
|
||||
public static Queue<GUIMessageBox> messageBoxes = new Queue<GUIMessageBox>();
|
||||
|
||||
const int DefaultWidth=400, DefaultHeight=200;
|
||||
|
||||
public delegate bool OnClickedHandler(GUIButton button, object obj);
|
||||
public OnClickedHandler OnClicked;
|
||||
//public delegate bool OnClickedHandler(GUIButton button, object obj);
|
||||
//public OnClickedHandler OnClicked;
|
||||
|
||||
GUIFrame frame;
|
||||
//GUIFrame frame;
|
||||
GUIButton[] buttons;
|
||||
|
||||
public GUIMessageBox(string header, string text)
|
||||
: this(header, text, new string[] {"OK"})
|
||||
{ }
|
||||
|
||||
public GUIMessageBox(string header, string text, string[] buttons, Alignment textAlignment = (Alignment.Left |Alignment.Top))
|
||||
{
|
||||
frame = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-DefaultWidth/2, Game1.GraphicsHeight/2-DefaultHeight/2, DefaultWidth, DefaultHeight),
|
||||
GUI.style.backGroundColor, Alignment.CenterX, GUI.style);
|
||||
frame.Padding = GUI.style.smallPadding;
|
||||
this.buttons[0].OnClicked = OkClicked;
|
||||
}
|
||||
|
||||
public GUIMessageBox(string header, string text, string[] buttons, Alignment textAlignment = (Alignment.Left | Alignment.Top))
|
||||
: base(new Rectangle(Game1.GraphicsWidth / 2 - DefaultWidth / 2, Game1.GraphicsHeight / 2 - DefaultHeight / 2, DefaultWidth, DefaultHeight),
|
||||
GUI.style.backGroundColor, Alignment.CenterX, GUI.style)
|
||||
{
|
||||
Padding = GUI.style.smallPadding;
|
||||
|
||||
if (buttons == null || buttons.Length == 0)
|
||||
{
|
||||
@@ -31,24 +33,25 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true);
|
||||
new GUITextBlock(new Rectangle(0,50,0,DefaultHeight-70),text, Color.Transparent, Color.White, textAlignment, frame, true);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, this, true);
|
||||
new GUITextBlock(new Rectangle(0, 30, 0, DefaultHeight - 70), text, Color.Transparent, Color.White, textAlignment, this, true);
|
||||
|
||||
int x = 0;
|
||||
this.buttons = new GUIButton[buttons.Length];
|
||||
for (int i=0; i<buttons.Length; i++)
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
this.buttons[i] = new GUIButton(new Rectangle(x,0,150,30), buttons[i], GUI.style, Alignment.Left, frame);
|
||||
this.buttons[i].OnClicked = ButtonClicked;
|
||||
this.buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], GUI.style, Alignment.Left | Alignment.Bottom, this);
|
||||
|
||||
x += this.buttons[i].Rect.Width + 20;
|
||||
}
|
||||
|
||||
messageBoxes.Enqueue(this);
|
||||
}
|
||||
|
||||
private bool ButtonClicked(GUIButton button, object obj)
|
||||
private bool OkClicked(GUIButton button, object obj)
|
||||
{
|
||||
if (OnClicked==null) return true;
|
||||
|
||||
return OnClicked(button, obj);
|
||||
messageBoxes.Dequeue();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ namespace Subsurface
|
||||
|
||||
public static readonly Version version = Assembly.GetEntryAssembly().GetName().Version;
|
||||
|
||||
public static GameScreen gameScreen;
|
||||
public static MainMenuScreen mainMenuScreen;
|
||||
public static LobbyScreen lobbyScreen;
|
||||
public static NetLobbyScreen netLobbyScreen;
|
||||
public static EditMapScreen editMapScreen;
|
||||
public static EditCharacterScreen editCharacterScreen;
|
||||
public static GameScreen GameScreen;
|
||||
public static MainMenuScreen MainMenuScreen;
|
||||
public static LobbyScreen LobbyScreen;
|
||||
public static NetLobbyScreen NetLobbyScreen;
|
||||
public static EditMapScreen EditMapScreen;
|
||||
public static EditCharacterScreen EditCharacterScreen;
|
||||
|
||||
public static GameSession gameSession;
|
||||
public static GameSession GameSession;
|
||||
|
||||
public static GameClient client;
|
||||
public static GameServer server;
|
||||
public static GameClient Client;
|
||||
public static GameServer Server;
|
||||
|
||||
public static ParticleManager particleManager;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Subsurface
|
||||
|
||||
public Camera Cam
|
||||
{
|
||||
get { return gameScreen.Cam; }
|
||||
get { return GameScreen.Cam; }
|
||||
}
|
||||
|
||||
public static int GraphicsWidth
|
||||
@@ -145,15 +145,15 @@ namespace Subsurface
|
||||
AmbientSoundManager.Init("Content/Sounds/Sounds.xml");
|
||||
|
||||
Map.PreloadMaps("Content/SavedMaps");
|
||||
gameScreen = new GameScreen(graphics.GraphicsDevice);
|
||||
mainMenuScreen = new MainMenuScreen(this);
|
||||
lobbyScreen = new LobbyScreen();
|
||||
netLobbyScreen = new NetLobbyScreen();
|
||||
editMapScreen = new EditMapScreen();
|
||||
editCharacterScreen = new EditCharacterScreen();
|
||||
GameScreen = new GameScreen(graphics.GraphicsDevice);
|
||||
MainMenuScreen = new MainMenuScreen(this);
|
||||
LobbyScreen = new LobbyScreen();
|
||||
NetLobbyScreen = new NetLobbyScreen();
|
||||
EditMapScreen = new EditMapScreen();
|
||||
EditCharacterScreen = new EditCharacterScreen();
|
||||
|
||||
|
||||
mainMenuScreen.Select();
|
||||
MainMenuScreen.Select();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -179,19 +179,22 @@ namespace Subsurface
|
||||
|
||||
PlayerInput.Update(deltaTime);
|
||||
|
||||
|
||||
//if (PlayerInput.KeyDown(Keys.Escape)) Quit();
|
||||
|
||||
DebugConsole.Update(this, (float)deltaTime);
|
||||
|
||||
if (!DebugConsole.IsOpen || server != null || client != null) Screen.Selected.Update(deltaTime);
|
||||
if (!DebugConsole.IsOpen || Server != null || Client != null) Screen.Selected.Update(deltaTime);
|
||||
|
||||
if (server != null)
|
||||
GUI.Update((float)deltaTime);
|
||||
|
||||
if (Server != null)
|
||||
{
|
||||
server.Update();
|
||||
Server.Update();
|
||||
}
|
||||
else if (client != null)
|
||||
else if (Client != null)
|
||||
{
|
||||
client.Update();
|
||||
Client.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -219,7 +222,7 @@ namespace Subsurface
|
||||
|
||||
protected override void OnExiting(object sender, EventArgs args)
|
||||
{
|
||||
if (client != null) client.Disconnect();
|
||||
if (Client != null) Client.Disconnect();
|
||||
|
||||
base.OnExiting(sender, args);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Subsurface
|
||||
|
||||
if (endMessage != "" || this.endMessage == null) this.endMessage = endMessage;
|
||||
|
||||
Game1.gameSession.EndShift(null, null);
|
||||
Game1.GameSession.EndShift(null, null);
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -65,7 +67,7 @@ namespace Subsurface
|
||||
textBox.OnEnter = EnterChatMessage;
|
||||
|
||||
this.gameMode = gameMode;
|
||||
if (this.gameMode != null) this.gameMode.Start(Game1.netLobbyScreen.GameDuration);
|
||||
if (this.gameMode != null) this.gameMode.Start(Game1.NetLobbyScreen.GameDuration);
|
||||
|
||||
startTime = DateTime.Now;
|
||||
endTime = startTime + gameDuration;
|
||||
@@ -105,22 +107,41 @@ namespace Subsurface
|
||||
|
||||
public bool EndShift(GUIButton button, object obj)
|
||||
{
|
||||
if (Game1.server!=null)
|
||||
if (Game1.Server!=null)
|
||||
{
|
||||
string endMessage = gameMode.EndMessage;
|
||||
|
||||
Game1.server.EndGame(endMessage);
|
||||
Game1.Server.EndGame(endMessage);
|
||||
|
||||
}
|
||||
else if (Game1.client==null)
|
||||
else if (Game1.Client==null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<Character> casualties = crewManager.characters.FindAll(c => c.IsDead);
|
||||
|
||||
if (casualties.Any())
|
||||
{
|
||||
sb.Append("Casualties: \n");
|
||||
foreach (Character c in casualties)
|
||||
{
|
||||
sb.Append(" - " + c.info.name + "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("No casualties!");
|
||||
}
|
||||
|
||||
new GUIMessageBox("Day #" + day + " is over!\n", sb.ToString());
|
||||
|
||||
|
||||
if (saveFile == null) return false;
|
||||
|
||||
Map.Loaded.SaveAs(Path.GetDirectoryName(saveFile) + "/"+ Path.GetFileName(saveFile));
|
||||
Map.Loaded.SaveAs(saveFile);
|
||||
|
||||
crewManager.EndShift();
|
||||
|
||||
Game1.lobbyScreen.Select();
|
||||
Game1.LobbyScreen.Select();
|
||||
|
||||
day++;
|
||||
}
|
||||
@@ -165,13 +186,13 @@ namespace Subsurface
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message)) return false;
|
||||
|
||||
if (Game1.server!=null)
|
||||
if (Game1.Server!=null)
|
||||
{
|
||||
Game1.server.SendChatMessage(message);
|
||||
Game1.Server.SendChatMessage(message);
|
||||
}
|
||||
else if (Game1.client!=null)
|
||||
else if (Game1.Client!=null)
|
||||
{
|
||||
Game1.client.SendChatMessage(Game1.client.Name + ": " + message);
|
||||
Game1.Client.SendChatMessage(Game1.Client.Name + ": " + message);
|
||||
}
|
||||
|
||||
textBox.Deselect();
|
||||
@@ -197,6 +218,9 @@ namespace Subsurface
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
taskManager.Update(deltaTime);
|
||||
endShiftButton.Enabled = !taskManager.CriticalTasks;
|
||||
|
||||
endShiftButton.Update(deltaTime);
|
||||
|
||||
textBox.Update(deltaTime);
|
||||
|
||||
@@ -230,7 +254,7 @@ namespace Subsurface
|
||||
|
||||
timerBar.Draw(spriteBatch);
|
||||
|
||||
if (Game1.client == null) endShiftButton.Draw(spriteBatch);
|
||||
if (Game1.Client == null) endShiftButton.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,21 +40,21 @@ namespace Subsurface
|
||||
|
||||
if (traitor==null || target ==null)
|
||||
{
|
||||
int clientCount = Game1.server.connectedClients.Count();
|
||||
int clientCount = Game1.Server.connectedClients.Count();
|
||||
if (clientCount < 2) return;
|
||||
|
||||
int traitorIndex = Game1.localRandom.Next(clientCount);
|
||||
traitor = Game1.server.connectedClients[traitorIndex];
|
||||
traitor = Game1.Server.connectedClients[traitorIndex];
|
||||
|
||||
int targetIndex = 0;
|
||||
while (targetIndex==traitorIndex)
|
||||
{
|
||||
targetIndex = Game1.localRandom.Next(clientCount);
|
||||
}
|
||||
target = Game1.server.connectedClients[targetIndex];
|
||||
target = Game1.Server.connectedClients[targetIndex];
|
||||
|
||||
|
||||
Game1.server.NewTraitor(traitor, target);
|
||||
Game1.Server.NewTraitor(traitor, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -175,6 +175,8 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
item.body.Enabled = true;
|
||||
|
||||
Matrix transform = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
|
||||
if (item.body.Dir==-1.0f)
|
||||
@@ -184,9 +186,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
transformedItemPos = Vector2.Transform(transformedItemPos, transform);
|
||||
transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
|
||||
|
||||
|
||||
|
||||
|
||||
transformedItemPos += ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
|
||||
currentRotation += item.body.Rotation;
|
||||
@@ -230,7 +230,7 @@ namespace Subsurface.Items.Components
|
||||
if (inventory.TryPutItem(item))
|
||||
{
|
||||
isActive = true;
|
||||
if (hideItems) item.body.Enabled = false;
|
||||
if (hideItems || (item.body!=null && !item.body.Enabled)) item.body.Enabled = false;
|
||||
|
||||
item.container = this.item;
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
base.Move(amount);
|
||||
|
||||
linkedGap.Move(amount);
|
||||
LinkedGap.Move(amount);
|
||||
|
||||
body.SetTransform(body.Position + ConvertUnits.ToSimUnits(amount), 0.0f);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using Subsurface.Networking;
|
||||
using Subsurface.Items.Components;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -17,6 +18,8 @@ namespace Subsurface
|
||||
public readonly Sound sound;
|
||||
public readonly ActionType type;
|
||||
|
||||
public string volumeProperty;
|
||||
|
||||
public readonly float range;
|
||||
|
||||
public ItemSound(Sound sound, ActionType type, float range)
|
||||
@@ -172,8 +175,9 @@ namespace Subsurface
|
||||
Sound sound = Sound.Load(filePath);
|
||||
|
||||
float range = ToolBox.GetAttributeFloat(subElement, "range", 800.0f);
|
||||
|
||||
sounds.Add(new ItemSound(sound, type, range));
|
||||
ItemSound itemSound = new ItemSound(sound, type, range);
|
||||
itemSound.volumeProperty = ToolBox.GetAttributeString(subElement, "volume", "");
|
||||
sounds.Add(itemSound);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -193,16 +197,30 @@ namespace Subsurface
|
||||
int index = Game1.localRandom.Next(matchingSounds.Count);
|
||||
itemSound = sounds[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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (loop)
|
||||
{
|
||||
//if (loopingSound != null && loopingSound.volumeProperty != "") volume = float.Parse(properties[loopingSound.volumeProperty].GetValue().ToString());
|
||||
loopingSoundIndex = loopingSound.sound.Loop(loopingSoundIndex, volume, position, loopingSound.range);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemSound.sound.Play(volume, itemSound.range, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,15 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
PropertyTask powerUpTask;
|
||||
|
||||
float powerDownTimer;
|
||||
|
||||
bool running;
|
||||
|
||||
List<Vent> ventList;
|
||||
|
||||
public bool IsRunning()
|
||||
{
|
||||
return running && item.Condition>0.0f;
|
||||
return (running && item.Condition>0.0f);
|
||||
}
|
||||
|
||||
public OxygenGenerator(Item item, XElement element)
|
||||
@@ -38,13 +40,18 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (voltage < minVoltage)
|
||||
{
|
||||
powerDownTimer += deltaTime;
|
||||
running = false;
|
||||
if (powerUpTask==null || powerUpTask.IsFinished)
|
||||
if ((powerUpTask==null || powerUpTask.IsFinished) && powerDownTimer>5.0f)
|
||||
{
|
||||
powerUpTask = new PropertyTask(Game1.gameSession.taskManager, item, IsRunning, 30.0f, "Turn on the oxygen generator");
|
||||
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Turn on the oxygen generator");
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
powerDownTimer = 0.0f;
|
||||
}
|
||||
|
||||
running = true;
|
||||
|
||||
@@ -53,9 +60,15 @@ namespace Subsurface.Items.Components
|
||||
|
||||
UpdateVents(deltaOxygen);
|
||||
|
||||
|
||||
voltage = 0.0f;
|
||||
}
|
||||
|
||||
public override void UpdateBroken(float deltaTime, Camera cam)
|
||||
{
|
||||
powerDownTimer += deltaTime;
|
||||
}
|
||||
|
||||
private void GetVents()
|
||||
{
|
||||
foreach (MapEntity entity in item.linkedTo)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface.Items.Components
|
||||
@@ -62,7 +63,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (connection.name=="power_in")
|
||||
{
|
||||
if (!float.TryParse(signal, out voltage))
|
||||
if (!float.TryParse(signal, NumberStyles.Any, CultureInfo.InvariantCulture, out voltage))
|
||||
{
|
||||
voltage = 0.0f;
|
||||
}
|
||||
|
||||
@@ -108,9 +108,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||
|
||||
|
||||
//ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||
|
||||
fissionRate = Math.Min(fissionRate, AvailableFuel);
|
||||
|
||||
float heat = 100 * fissionRate;
|
||||
@@ -128,7 +127,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (powerUpTask==null || powerUpTask.IsFinished)
|
||||
{
|
||||
powerUpTask = new PropertyTask(Game1.gameSession.taskManager, item, IsRunning, 20.0f, "Power up the reactor");
|
||||
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +207,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (item.Condition <= 0.0f) return;
|
||||
|
||||
new RepairTask(Game1.gameSession.taskManager, item, 50.0f, "Reactor meltdown!");
|
||||
new RepairTask(item, 60.0f, "Reactor meltdown!");
|
||||
item.Condition = 0.0f;
|
||||
fissionRate = 0.0f;
|
||||
coolingRate = 0.0f;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (character.SecondaryKeyDown.State)
|
||||
{
|
||||
targetLimb.Damage -= limbFixAmount;
|
||||
targetLimb.character.Health += limbFixAmount;
|
||||
isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (!item.body.Enabled) return;
|
||||
@@ -68,11 +68,11 @@ namespace Subsurface.Items.Components
|
||||
|
||||
AnimController ac = picker.animController;
|
||||
|
||||
ac.HoldItem(deltaTime, cam, item, handlePos, new Vector2(throwPos, 0.0f), Vector2.Zero, holdAngle);
|
||||
ac.HoldItem(deltaTime, cam, item, handlePos, new Vector2(throwPos, 0.0f), aimPos, holdAngle);
|
||||
|
||||
if (!throwing) return;
|
||||
|
||||
throwPos +=0.1f;
|
||||
throwPos += deltaTime*5.0f;
|
||||
|
||||
Vector2 throwVector = ConvertUnits.ToSimUnits(picker.CursorPosition) - item.body.Position;
|
||||
throwVector = Vector2.Normalize(throwVector);
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace Subsurface
|
||||
ic.Update(deltaTime, cam);
|
||||
|
||||
ic.PlaySound(ActionType.OnActive, 1.0f, Position, true);
|
||||
ic.ApplyStatusEffects(ActionType.OnActive, 1.0f, null);
|
||||
ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace Subsurface
|
||||
try
|
||||
{
|
||||
//string docString = doc.ToString();
|
||||
ToolBox.CompressStringToFile(filePath+".gz", doc.ToString());
|
||||
ToolBox.CompressStringToFile(filePath, doc.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -295,7 +295,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
doc.Save(filePath);
|
||||
//doc.Save(filePath);
|
||||
}
|
||||
|
||||
public static void PreloadMaps(string mapFolder)
|
||||
@@ -342,7 +342,15 @@ namespace Subsurface
|
||||
public Map(string filePath, string mapHash="")
|
||||
{
|
||||
this.filePath = filePath;
|
||||
name = Path.GetFileNameWithoutExtension(filePath);
|
||||
try
|
||||
{
|
||||
name = Path.GetFileNameWithoutExtension(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error loading map " + filePath + "!", e);
|
||||
}
|
||||
|
||||
|
||||
if (mapHash != "")
|
||||
{
|
||||
@@ -505,12 +513,12 @@ namespace Subsurface
|
||||
{
|
||||
filePath = "";
|
||||
|
||||
if (Game1.gameScreen.Cam != null) Game1.gameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
if (Game1.GameScreen.Cam != null) Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
Entity.RemoveAll();
|
||||
|
||||
if (Game1.gameSession!=null)
|
||||
Game1.gameSession.crewManager.EndShift();
|
||||
if (Game1.GameSession!=null)
|
||||
Game1.GameSession.crewManager.EndShift();
|
||||
|
||||
PhysicsBody.list.Clear();
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace Subsurface
|
||||
{
|
||||
if (!prefab.HasBody || prefab.IsPlatform) return;
|
||||
|
||||
if (Game1.client==null)
|
||||
if (Game1.Client==null)
|
||||
SetDamage(sectionIndex, sections[sectionIndex].damage + damage);
|
||||
|
||||
|
||||
|
||||
@@ -134,11 +134,11 @@ namespace Subsurface.Networking
|
||||
int existingClients = inc.ReadInt32();
|
||||
for (int i = 1; i <= existingClients; i++)
|
||||
{
|
||||
Game1.netLobbyScreen.AddPlayer(inc.ReadString());
|
||||
Game1.NetLobbyScreen.AddPlayer(inc.ReadString());
|
||||
}
|
||||
|
||||
//add the name of own client to the lobby screen
|
||||
Game1.netLobbyScreen.AddPlayer(name);
|
||||
Game1.NetLobbyScreen.AddPlayer(name);
|
||||
|
||||
CanStart = true;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Subsurface.Networking
|
||||
string msg = inc.ReadString();
|
||||
DebugConsole.ThrowError(msg);
|
||||
|
||||
Game1.mainMenuScreen.Select();
|
||||
Game1.MainMenuScreen.Select();
|
||||
}
|
||||
break;
|
||||
case NetIncomingMessageType.StatusChanged:
|
||||
@@ -172,8 +172,8 @@ namespace Subsurface.Networking
|
||||
if (myCharacter.IsDead)
|
||||
{
|
||||
Character.Controlled = null;
|
||||
Game1.gameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
Game1.gameScreen.Cam.Zoom = 1.0f;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
Game1.GameScreen.Cam.Zoom = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -228,7 +228,7 @@ namespace Subsurface.Networking
|
||||
string mapName = inc.ReadString();
|
||||
string mapHash = inc.ReadString();
|
||||
|
||||
Game1.netLobbyScreen.TrySelectMap(mapName, mapHash);
|
||||
Game1.NetLobbyScreen.TrySelectMap(mapName, mapHash);
|
||||
|
||||
|
||||
//Map.Load(mapFile);
|
||||
@@ -240,8 +240,8 @@ namespace Subsurface.Networking
|
||||
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
|
||||
|
||||
//int gameModeIndex = inc.ReadInt32();
|
||||
Game1.gameSession = new GameSession("", false, duration);
|
||||
Game1.gameSession.StartShift(1);
|
||||
Game1.GameSession = new GameSession("", false, duration);
|
||||
Game1.GameSession.StartShift(1);
|
||||
|
||||
myCharacter = ReadCharacterData(inc);
|
||||
Character.Controlled = myCharacter;
|
||||
@@ -254,7 +254,7 @@ namespace Subsurface.Networking
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
Game1.gameScreen.Select();
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
AddChatMessage("Press TAB to chat", ChatMessageType.Server);
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace Subsurface.Networking
|
||||
Client otherClient = new Client();
|
||||
otherClient.name = inc.ReadString();
|
||||
|
||||
Game1.netLobbyScreen.AddPlayer(otherClient.name);
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient.name);
|
||||
|
||||
//string newPlayerName = inc.ReadString();
|
||||
//int newPlayerID = inc.ReadInt32();
|
||||
@@ -285,7 +285,7 @@ namespace Subsurface.Networking
|
||||
string leavingName = inc.ReadString();
|
||||
|
||||
AddChatMessage(inc.ReadString(), ChatMessageType.Server);
|
||||
Game1.netLobbyScreen.RemovePlayer(leavingName);
|
||||
Game1.NetLobbyScreen.RemovePlayer(leavingName);
|
||||
break;
|
||||
|
||||
case (byte)PacketTypes.KickedOut:
|
||||
@@ -293,7 +293,7 @@ namespace Subsurface.Networking
|
||||
|
||||
DebugConsole.ThrowError(msg);
|
||||
|
||||
Game1.mainMenuScreen.Select();
|
||||
Game1.MainMenuScreen.Select();
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.Chatmessage:
|
||||
@@ -307,13 +307,13 @@ namespace Subsurface.Networking
|
||||
break;
|
||||
case (byte)PacketTypes.UpdateNetLobby:
|
||||
if (gameStarted) continue;
|
||||
Game1.netLobbyScreen.ReadData(inc);
|
||||
Game1.NetLobbyScreen.ReadData(inc);
|
||||
break;
|
||||
case (byte)PacketTypes.Traitor:
|
||||
string targetName = inc.ReadString();
|
||||
|
||||
Game1.gameSession.NewChatMessage("You are an agent of Ordo Europae", messageColor[(int)ChatMessageType.Server]);
|
||||
Game1.gameSession.NewChatMessage("Your secret task is to assassinate " + targetName + "!", messageColor[(int)ChatMessageType.Server]);
|
||||
Game1.GameSession.NewChatMessage("You are an agent of Ordo Europae", messageColor[(int)ChatMessageType.Server]);
|
||||
Game1.GameSession.NewChatMessage("Your secret task is to assassinate " + targetName + "!", messageColor[(int)ChatMessageType.Server]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -325,9 +325,9 @@ namespace Subsurface.Networking
|
||||
{
|
||||
Map.Unload();
|
||||
|
||||
Game1.netLobbyScreen.Select();
|
||||
Game1.NetLobbyScreen.Select();
|
||||
|
||||
if (Game1.gameSession!=null) Game1.gameSession.EndShift(null, null);
|
||||
if (Game1.GameSession!=null) Game1.GameSession.EndShift(null, null);
|
||||
|
||||
DebugConsole.ThrowError(endMessage);
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Subsurface.Networking
|
||||
else
|
||||
{
|
||||
|
||||
Game1.netLobbyScreen.AddPlayer(sender.name);
|
||||
Game1.NetLobbyScreen.AddPlayer(sender.name);
|
||||
|
||||
// Notify the client that they have logged in
|
||||
outmsg = Server.CreateMessage();
|
||||
@@ -271,12 +271,12 @@ namespace Subsurface.Networking
|
||||
int seed = DateTime.Now.Millisecond;
|
||||
Game1.random = new Random(seed);
|
||||
|
||||
Map selectedMap = Game1.netLobbyScreen.SelectedMap as Map;
|
||||
Map selectedMap = Game1.NetLobbyScreen.SelectedMap as Map;
|
||||
|
||||
selectedMap.Load();
|
||||
|
||||
Game1.gameSession = new GameSession("", false, Game1.netLobbyScreen.GameDuration, Game1.netLobbyScreen.SelectedMode);
|
||||
Game1.gameSession.StartShift(1);
|
||||
Game1.GameSession = new GameSession("", false, Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.SelectedMode);
|
||||
Game1.GameSession.StartShift(1);
|
||||
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
||||
|
||||
foreach (Client client in connectedClients)
|
||||
@@ -307,10 +307,10 @@ namespace Subsurface.Networking
|
||||
|
||||
msg.Write(seed);
|
||||
|
||||
msg.Write(Game1.netLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(Game1.netLobbyScreen.SelectedMap.MapHash.MD5Hash);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.MapHash.MD5Hash);
|
||||
|
||||
msg.Write(Game1.netLobbyScreen.GameDuration.TotalMinutes);
|
||||
msg.Write(Game1.NetLobbyScreen.GameDuration.TotalMinutes);
|
||||
|
||||
WriteCharacterData(msg, client.name, client.character);
|
||||
|
||||
@@ -331,9 +331,9 @@ namespace Subsurface.Networking
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
Game1.gameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
Game1.gameScreen.Select();
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ namespace Subsurface.Networking
|
||||
}
|
||||
}
|
||||
|
||||
Game1.netLobbyScreen.Select();
|
||||
Game1.NetLobbyScreen.Select();
|
||||
|
||||
DebugConsole.ThrowError(endMessage);
|
||||
}
|
||||
@@ -394,7 +394,7 @@ namespace Subsurface.Networking
|
||||
outmsg.Write(client.name);
|
||||
outmsg.Write(msg);
|
||||
|
||||
Game1.netLobbyScreen.RemovePlayer(client.name);
|
||||
Game1.NetLobbyScreen.RemovePlayer(client.name);
|
||||
|
||||
if (Server.Connections.Count > 0)
|
||||
{
|
||||
@@ -435,7 +435,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
NetOutgoingMessage msg = Server.CreateMessage();
|
||||
msg.Write((byte)PacketTypes.UpdateNetLobby);
|
||||
Game1.netLobbyScreen.WriteData(msg);
|
||||
Game1.NetLobbyScreen.WriteData(msg);
|
||||
|
||||
if (Server.Connections.Count > 0)
|
||||
{
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace Subsurface.Networking
|
||||
{
|
||||
if (isClient)
|
||||
{
|
||||
if (Game1.server != null) return;
|
||||
if (Game1.Server != null) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Game1.server == null) return;
|
||||
if (Game1.Server == null) return;
|
||||
}
|
||||
|
||||
eventType = type;
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Subsurface.Networking
|
||||
|
||||
public void AddChatMessage(string message, ChatMessageType messageType)
|
||||
{
|
||||
Game1.netLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
if (Game1.gameSession != null) Game1.gameSession.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
Game1.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
if (Game1.GameSession != null) Game1.GameSession.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
|
||||
GUI.PlayMessageSound();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
{
|
||||
base.Select();
|
||||
|
||||
if (Game1.gameSession == null) Game1.gameSession = new GameSession("",false, TimeSpan.Zero);
|
||||
//if (Game1.gameSession == null) Game1.gameSession = new GameSession("",false, TimeSpan.Zero);
|
||||
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
entity.IsHighlighted = false;
|
||||
@@ -57,7 +57,7 @@ namespace Subsurface
|
||||
|
||||
AmbientSoundManager.Update();
|
||||
|
||||
Game1.gameSession.Update((float)deltaTime);
|
||||
if (Game1.GameSession!=null) Game1.GameSession.Update((float)deltaTime);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
Character.UpdateAll(cam, (float)deltaTime);
|
||||
@@ -107,7 +107,7 @@ namespace Subsurface
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
spriteBatch.Begin();
|
||||
if (Game1.gameSession != null) Game1.gameSession.Draw(spriteBatch);
|
||||
if (Game1.GameSession != null) Game1.GameSession.Draw(spriteBatch);
|
||||
|
||||
//EventManager.DrawInfo(spriteBatch);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Subsurface
|
||||
private void UpdateCharacterLists()
|
||||
{
|
||||
characterList.ClearChildren();
|
||||
foreach (CharacterInfo c in Game1.gameSession.crewManager.characterInfos)
|
||||
foreach (CharacterInfo c in Game1.GameSession.crewManager.characterInfos)
|
||||
{
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
@@ -117,7 +117,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
hireList.ClearChildren();
|
||||
foreach (CharacterInfo c in Game1.gameSession.hireManager.availableCharacters)
|
||||
foreach (CharacterInfo c in Game1.GameSession.hireManager.availableCharacters)
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
@@ -144,18 +144,27 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
leftPanel.Update((float)deltaTime);
|
||||
rightPanel[selectedRightPanel].Update((float)deltaTime);
|
||||
shiftPanel.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
if (characterList.CountChildren != Game1.gameSession.crewManager.characterInfos.Count
|
||||
|| hireList.CountChildren != Game1.gameSession.hireManager.availableCharacters.Count)
|
||||
if (characterList.CountChildren != Game1.GameSession.crewManager.characterInfos.Count
|
||||
|| hireList.CountChildren != Game1.GameSession.hireManager.availableCharacters.Count)
|
||||
{
|
||||
UpdateCharacterLists();
|
||||
}
|
||||
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.gameScreen.DrawMap(graphics, spriteBatch);
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -182,20 +191,20 @@ namespace Subsurface
|
||||
|
||||
private string GetMoney()
|
||||
{
|
||||
return "Money: " + ((Game1.gameSession == null) ? "" : Game1.gameSession.crewManager.Money.ToString());
|
||||
return "Money: " + ((Game1.GameSession == null) ? "" : Game1.GameSession.crewManager.Money.ToString());
|
||||
}
|
||||
|
||||
private string GetDay()
|
||||
{
|
||||
|
||||
return "Day #" + ((Game1.gameSession == null) ? "" : Game1.gameSession.Day.ToString());
|
||||
return "Day #" + ((Game1.GameSession == null) ? "" : Game1.GameSession.Day.ToString());
|
||||
}
|
||||
|
||||
private float GetWeekProgress()
|
||||
{
|
||||
if (Game1.gameSession == null) return 0.0f;
|
||||
if (Game1.GameSession == null) return 0.0f;
|
||||
|
||||
return (float)((Game1.gameSession.Day - 1) % 7) / 7.0f;
|
||||
return (float)((Game1.GameSession.Day - 1) % 7) / 7.0f;
|
||||
}
|
||||
|
||||
private bool HireCharacter(object selection)
|
||||
@@ -206,20 +215,20 @@ namespace Subsurface
|
||||
|
||||
if (characterInfo == null) return false;
|
||||
|
||||
Game1.gameSession.TryHireCharacter(characterInfo);
|
||||
Game1.GameSession.TryHireCharacter(characterInfo);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool StartShift(GUIButton button, object selection)
|
||||
{
|
||||
Map.Load(Game1.gameSession.SaveFile);
|
||||
Map.Load(Game1.GameSession.SaveFile);
|
||||
|
||||
Game1.gameSession.StartShift();
|
||||
Game1.GameSession.StartShift();
|
||||
|
||||
//EventManager.StartShift();
|
||||
|
||||
Game1.gameScreen.Select();
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ namespace Subsurface
|
||||
|
||||
private bool HostServerClicked(GUIButton button, object obj)
|
||||
{
|
||||
Game1.netLobbyScreen.isServer = true;
|
||||
Game1.netLobbyScreen.Select();
|
||||
Game1.NetLobbyScreen.isServer = true;
|
||||
Game1.NetLobbyScreen.Select();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Subsurface
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.gameScreen.DrawMap(graphics, spriteBatch);
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -150,9 +150,9 @@ namespace Subsurface
|
||||
if (selectedMap == null) return false;
|
||||
|
||||
|
||||
Game1.gameSession = new GameSession(selectedMap.FilePath, true, TimeSpan.Zero);
|
||||
Game1.GameSession = new GameSession(selectedMap.FilePath, true, TimeSpan.Zero);
|
||||
|
||||
Game1.lobbyScreen.Select();
|
||||
Game1.LobbyScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -162,15 +162,15 @@ namespace Subsurface
|
||||
if (string.IsNullOrEmpty(nameBox.Text)) return false;
|
||||
if (string.IsNullOrEmpty(ipBox.Text)) return false;
|
||||
|
||||
Game1.client = new GameClient(nameBox.Text);
|
||||
if (Game1.client.ConnectToServer(ipBox.Text))
|
||||
Game1.Client = new GameClient(nameBox.Text);
|
||||
if (Game1.Client.ConnectToServer(ipBox.Text))
|
||||
{
|
||||
Game1.netLobbyScreen.Select();
|
||||
Game1.NetLobbyScreen.Select();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.client = null;
|
||||
Game1.Client = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Subsurface
|
||||
{
|
||||
infoFrame.ClearChildren();
|
||||
|
||||
if (isServer && Game1.server == null) Game1.server = new GameServer();
|
||||
if (isServer && Game1.Server == null) Game1.Server = new GameServer();
|
||||
|
||||
textBox.Select();
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Subsurface
|
||||
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
|
||||
mapList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, infoFrame);
|
||||
mapList.OnSelected = SelectMap;
|
||||
mapList.Enabled = (Game1.server!=null);
|
||||
mapList.Enabled = (Game1.Server!=null);
|
||||
|
||||
if (Map.SavedMaps.Count>0)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ namespace Subsurface
|
||||
|
||||
new GUITextBlock(new Rectangle(220, 30, 0, 30), "Selected game mode: ", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
|
||||
modeList = new GUIListBox(new Rectangle(220, 60, 200, 200), Color.White, infoFrame);
|
||||
modeList.Enabled = (Game1.server != null);
|
||||
modeList.Enabled = (Game1.Server != null);
|
||||
//modeList.OnSelected = new GUIListBox.OnSelectedHandler(SelectEvent);
|
||||
|
||||
foreach (GameMode mode in GameMode.list)
|
||||
@@ -180,16 +180,16 @@ namespace Subsurface
|
||||
durationBar = new GUIScrollBar(new Rectangle((int)(modeList.Rect.X + modeList.Rect.Width + GUI.style.smallPadding.X), modeList.Rect.Y + 30, 100, 20),
|
||||
Color.Gold, 0.1f, Alignment.Left, infoFrame);
|
||||
durationBar.BarSize = 0.1f;
|
||||
durationBar.Enabled = (Game1.server != null);
|
||||
durationBar.Enabled = (Game1.Server != null);
|
||||
|
||||
if (isServer && Game1.server!=null)
|
||||
if (isServer && Game1.Server!=null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0,0,200,30), "Start", Color.White, Alignment.Right | Alignment.Bottom, infoFrame);
|
||||
startButton.OnClicked = Game1.server.StartGame;
|
||||
startButton.OnClicked = Game1.Server.StartGame;
|
||||
|
||||
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
|
||||
modeList.OnSelected = Game1.server.UpdateNetLobby;
|
||||
durationBar.OnMoved = Game1.server.UpdateNetLobby;
|
||||
modeList.OnSelected = Game1.Server.UpdateNetLobby;
|
||||
durationBar.OnMoved = Game1.Server.UpdateNetLobby;
|
||||
|
||||
if (mapList.CountChildren > 0) mapList.Select(Map.SavedMaps[0]);
|
||||
if (GameMode.list.Count > 0) modeList.Select(GameMode.list[0]);
|
||||
@@ -199,7 +199,7 @@ namespace Subsurface
|
||||
int x = playerFrame.Rect.Width / 2;
|
||||
GUITextBox playerName = new GUITextBox(new Rectangle(x, 0, 0, 20), Color.White, Color.Black,
|
||||
Alignment.Left | Alignment.Top, Alignment.Left, playerFrame);
|
||||
playerName.Text = Game1.client.CharacterInfo.name;
|
||||
playerName.Text = Game1.Client.CharacterInfo.name;
|
||||
playerName.OnEnter += ChangeCharacterName;
|
||||
|
||||
new GUITextBlock(new Rectangle(x,40,200, 30), "Gender: ", Color.Transparent, Color.Black,
|
||||
@@ -240,7 +240,7 @@ namespace Subsurface
|
||||
|
||||
private bool SelectMap(object obj)
|
||||
{
|
||||
if (Game1.server != null) Game1.server.UpdateNetLobby(obj);
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(obj);
|
||||
|
||||
Map map = (Map)obj;
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Subsurface
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
Game1.gameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
Vector2 pos = new Vector2(
|
||||
Map.Borders.X + Map.Borders.Width / 2,
|
||||
@@ -288,7 +288,7 @@ namespace Subsurface
|
||||
|
||||
pos += offset * 0.8f;
|
||||
|
||||
Game1.gameScreen.Cam.TargetPos = pos;
|
||||
Game1.GameScreen.Cam.TargetPos = pos;
|
||||
|
||||
menu.Update((float)deltaTime);
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Subsurface
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.gameScreen.DrawMap(graphics, spriteBatch);
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -310,18 +310,18 @@ namespace Subsurface
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
if (Game1.client != null)
|
||||
if (Game1.Client != null)
|
||||
{
|
||||
if (Game1.client.Character != null)
|
||||
if (Game1.Client.Character != null)
|
||||
{
|
||||
Vector2 position = new Vector2(playerFrame.Rect.X + playerFrame.Rect.Width * 0.25f, playerFrame.Rect.Y + 25.0f);
|
||||
|
||||
Vector2 pos = Game1.client.Character.Position;
|
||||
Vector2 pos = Game1.Client.Character.Position;
|
||||
pos.Y = -pos.Y;
|
||||
Matrix transform = Matrix.CreateTranslation(new Vector3(-pos+position, 0.0f));
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, null,null,null,null,null,transform);
|
||||
Game1.client.Character.Draw(spriteBatch);
|
||||
Game1.Client.Character.Draw(spriteBatch);
|
||||
spriteBatch.End();
|
||||
}
|
||||
else
|
||||
@@ -346,7 +346,7 @@ namespace Subsurface
|
||||
|
||||
public bool StartGame(object obj)
|
||||
{
|
||||
Game1.server.StartGame(null, obj);
|
||||
Game1.Server.StartGame(null, obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -356,11 +356,11 @@ namespace Subsurface
|
||||
|
||||
if (isServer)
|
||||
{
|
||||
Game1.server.SendChatMessage("Server: " + message);
|
||||
Game1.Server.SendChatMessage("Server: " + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.client.SendChatMessage(Game1.client.Name + ": " + message);
|
||||
Game1.Client.SendChatMessage(Game1.Client.Name + ": " + message);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -368,13 +368,13 @@ namespace Subsurface
|
||||
|
||||
private void CreatePreviewCharacter()
|
||||
{
|
||||
if (Game1.client.Character != null) Game1.client.Character.Remove();
|
||||
if (Game1.Client.Character != null) Game1.Client.Character.Remove();
|
||||
|
||||
Vector2 pos = new Vector2(1000.0f, 1000.0f);
|
||||
|
||||
Character character = new Character(Game1.client.CharacterInfo, pos);
|
||||
Character character = new Character(Game1.Client.CharacterInfo, pos);
|
||||
|
||||
Game1.client.Character = character;
|
||||
Game1.Client.Character = character;
|
||||
|
||||
character.animController.isStanding = true;
|
||||
|
||||
@@ -406,8 +406,8 @@ namespace Subsurface
|
||||
try
|
||||
{
|
||||
Gender gender = (Gender)obj;
|
||||
Game1.client.CharacterInfo.gender = gender;
|
||||
Game1.client.SendCharacterData();
|
||||
Game1.Client.CharacterInfo.gender = gender;
|
||||
Game1.Client.SendCharacterData();
|
||||
CreatePreviewCharacter();
|
||||
}
|
||||
catch
|
||||
@@ -421,9 +421,9 @@ namespace Subsurface
|
||||
{
|
||||
if (string.IsNullOrEmpty(newName)) return false;
|
||||
|
||||
Game1.client.CharacterInfo.name = newName;
|
||||
Game1.client.Name = newName;
|
||||
Game1.client.SendCharacterData();
|
||||
Game1.Client.CharacterInfo.name = newName;
|
||||
Game1.Client.Name = newName;
|
||||
Game1.Client.SendCharacterData();
|
||||
|
||||
textBox.Text = newName;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Subsurface.Sounds;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -33,14 +34,36 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public class BackgroundMusic
|
||||
{
|
||||
public readonly string file;
|
||||
public readonly string type;
|
||||
|
||||
public readonly Vector2 priorityRange;
|
||||
|
||||
public BackgroundMusic(string file, string type, Vector2 priorityRange)
|
||||
{
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
this.priorityRange = priorityRange;
|
||||
}
|
||||
}
|
||||
|
||||
static class AmbientSoundManager
|
||||
{
|
||||
public static Sound[] flowSounds = new Sound[3];
|
||||
|
||||
private const float MusicLerpSpeed = 0.01f;
|
||||
|
||||
private static Sound waterAmbience;
|
||||
private static int waterAmbienceIndex;
|
||||
|
||||
private static DamageSound[] damageSounds;
|
||||
|
||||
private static BackgroundMusic currentMusic;
|
||||
private static BackgroundMusic targetMusic;
|
||||
private static BackgroundMusic[] musicClips;
|
||||
private static float musicVolume;
|
||||
|
||||
public static void Init(string filePath)
|
||||
{
|
||||
@@ -57,7 +80,7 @@ namespace Subsurface
|
||||
|
||||
var xDamageSounds = doc.Root.Elements("damagesound").ToList();
|
||||
|
||||
if (!xDamageSounds.Any())
|
||||
if (xDamageSounds.Any())
|
||||
{
|
||||
damageSounds = new DamageSound[xDamageSounds.Count()];
|
||||
int i = 0;
|
||||
@@ -85,6 +108,24 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
var xMusic = doc.Root.Elements("music").ToList();
|
||||
|
||||
if (xMusic.Any())
|
||||
{
|
||||
musicClips = new BackgroundMusic[xMusic.Count];
|
||||
int i = 0;
|
||||
foreach (XElement element in xMusic)
|
||||
{
|
||||
string file = ToolBox.GetAttributeString(element, "file", "").ToLower();
|
||||
string type = ToolBox.GetAttributeString(element, "type", "").ToLower();
|
||||
Vector2 priority = ToolBox.GetAttributeVector2(element, "priorityrange", new Vector2(0.0f,100.0f));
|
||||
|
||||
musicClips[i] = new BackgroundMusic(file, type, priority);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//Sound.StartStream("Content/Sounds/Music/Simplex.ogg", 0.3f);
|
||||
|
||||
}
|
||||
@@ -92,6 +133,8 @@ namespace Subsurface
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
UpdateMusic();
|
||||
|
||||
float ambienceVolume = 0.5f;
|
||||
float lowpassHFGain = 1.0f;
|
||||
if (Character.Controlled != null)
|
||||
@@ -110,6 +153,64 @@ namespace Subsurface
|
||||
waterAmbienceIndex = waterAmbience.Loop(waterAmbienceIndex, ambienceVolume);
|
||||
}
|
||||
|
||||
private static void UpdateMusic()
|
||||
{
|
||||
|
||||
Task criticalTask = null;
|
||||
if (Game1.GameSession!=null)
|
||||
{
|
||||
foreach (Task task in Game1.GameSession.taskManager.Tasks)
|
||||
{
|
||||
if (criticalTask == null || task.Priority > criticalTask.Priority)
|
||||
{
|
||||
criticalTask = task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<BackgroundMusic> suitableMusic = null;
|
||||
if (criticalTask == null)
|
||||
{
|
||||
suitableMusic = musicClips.Where(x => x.type == "default").ToList();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
suitableMusic = musicClips.Where(x =>
|
||||
x.type == criticalTask.MusicType &&
|
||||
x.priorityRange.X < criticalTask.Priority &&
|
||||
x.priorityRange.Y > criticalTask.Priority).ToList();
|
||||
}
|
||||
|
||||
if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic))
|
||||
{
|
||||
int index = Game1.localRandom.Next(suitableMusic.Count());
|
||||
|
||||
if (currentMusic == null || suitableMusic[index].file != currentMusic.file)
|
||||
{
|
||||
targetMusic = suitableMusic[index];
|
||||
}
|
||||
}
|
||||
|
||||
if (targetMusic == null || currentMusic == null || targetMusic.file != currentMusic.file)
|
||||
{
|
||||
musicVolume = MathHelper.Lerp(musicVolume, 0.0f, MusicLerpSpeed);
|
||||
if (currentMusic != null) Sound.StreamVolume(musicVolume);
|
||||
|
||||
if (musicVolume < 0.01f)
|
||||
{
|
||||
Sound.StopStream();
|
||||
if (targetMusic != null) Sound.StartStream(targetMusic.file, musicVolume);
|
||||
currentMusic = targetMusic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
musicVolume = MathHelper.Lerp(musicVolume, 0.3f, MusicLerpSpeed);
|
||||
Sound.StreamVolume(musicVolume);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayDamageSound(DamageSoundType damageType, float damage, Body body)
|
||||
{
|
||||
Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position);
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Subsurface
|
||||
|
||||
private static List<Sound> loadedSounds = new List<Sound>();
|
||||
|
||||
private static OggStream stream;
|
||||
|
||||
private OggSound oggSound;
|
||||
|
||||
string filePath;
|
||||
@@ -218,12 +220,17 @@ namespace Subsurface
|
||||
|
||||
public static void StartStream(string file, float volume = 1.0f)
|
||||
{
|
||||
SoundManager.StartStream(file, volume);
|
||||
stream = SoundManager.StartStream(file, volume);
|
||||
}
|
||||
|
||||
public static void Stoptream()
|
||||
public static void StreamVolume(float volume = 1.0f)
|
||||
{
|
||||
SoundManager.StopStream();
|
||||
stream.Volume = volume;
|
||||
}
|
||||
|
||||
public static void StopStream()
|
||||
{
|
||||
if (stream!=null) SoundManager.StopStream();
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<Compile Include="GUI\GUIImage.cs" />
|
||||
<Compile Include="GUI\GUIMessageBox.cs" />
|
||||
<Compile Include="GUI\GUITickBox.cs" />
|
||||
<Compile Include="Interface1.cs" />
|
||||
<Compile Include="IPropertyObject.cs" />
|
||||
<Compile Include="Items\CharacterInventory.cs" />
|
||||
<Compile Include="Items\Components\MiniMap.cs" />
|
||||
<Compile Include="Items\Components\Pump.cs" />
|
||||
@@ -586,6 +586,12 @@
|
||||
<None Include="Content\Sounds\Damage\LimbSlash2.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Music\Enter the Maze.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\Music\Unseen Horrors.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Sounds\stepMetal.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
Reference in New Issue
Block a user