misc UI stuff, gamesession additions, limbs don't have individual health anymore, background music

This commit is contained in:
Regalis
2015-06-09 18:18:34 +03:00
parent d3896383fd
commit d7fde606e9
50 changed files with 595 additions and 282 deletions
+1 -1
View File
@@ -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);
+47 -22
View File
@@ -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();
+32 -32
View File
@@ -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);
+1 -1
View File
@@ -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);
}
}