AI combat, misc AI improvements, characters can't get stuck inside doors
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -60,6 +60,7 @@
|
||||
<Compile Include="Source\Characters\AICharacter.cs" />
|
||||
<Compile Include="Source\Characters\AI\AIController.cs" />
|
||||
<Compile Include="Source\Characters\AI\AITarget.cs" />
|
||||
<Compile Include="Source\Characters\AI\Objectives\AIObjectiveCombat.cs" />
|
||||
<Compile Include="Source\Characters\AI\Objectives\AIObjectiveContainItem.cs" />
|
||||
<Compile Include="Source\Characters\AI\Order.cs" />
|
||||
<Compile Include="Source\Characters\AI\CrewCommander.cs" />
|
||||
@@ -1124,9 +1125,9 @@
|
||||
<Project>{49ba1c69-6104-41ac-a5d8-b54fa9f696e8}</Project>
|
||||
<Name>Lidgren.Network</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Subsurface_content\Subsurface_content\Subsurface_content.csproj">
|
||||
<ProjectReference Include="..\Subsurface_content\Subsurface_content\Barotrauma_content.csproj">
|
||||
<Project>{1e6bf44d-6e31-40cc-8321-3d5958c983e7}</Project>
|
||||
<Name>Subsurface_content</Name>
|
||||
<Name>Barotrauma_content</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
<Item
|
||||
name="Harpoon Gun"
|
||||
pickdistance="200"
|
||||
price="500">
|
||||
price="500"
|
||||
tags="weapon">
|
||||
|
||||
<Sprite texture="weapons.png" sourcerect="0,25,98,25" depth="0.5"/>
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
name="Stun Grenade"
|
||||
pickdistance="200"
|
||||
price="200"
|
||||
tags="smallitem">
|
||||
tags="smallitem,weapon">
|
||||
|
||||
<Sprite texture="weapons.png" sourcerect="98,0,11,24"/>
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
|
||||
<Item
|
||||
name="Stun Baton"
|
||||
Tags="smallitem"
|
||||
Tags="smallitem,weapon"
|
||||
pickdistance="150"
|
||||
price="100">
|
||||
|
||||
|
||||
@@ -48,36 +48,54 @@ namespace Barotrauma
|
||||
frame = new GUIFrame(Rectangle.Empty, Color.Black * 0.3f);
|
||||
frame.Padding = new Vector4(200.0f, 100.0f, 200.0f, 100.0f);
|
||||
|
||||
UpdateCharacters();
|
||||
//UpdateCharacters();
|
||||
|
||||
int x = 0, y = 150;
|
||||
foreach (Order order in Order.PrefabList)
|
||||
{
|
||||
if (order.ItemComponentType!=null)
|
||||
int buttonWidth = 130;
|
||||
int spacing = 10;
|
||||
|
||||
int y = 250;
|
||||
|
||||
for (int n = 0; n<2; n++)
|
||||
{
|
||||
|
||||
List<Order> orders = (n==0) ?
|
||||
Order.PrefabList.FindAll(o => o.ItemComponentType == null) :
|
||||
Order.PrefabList.FindAll(o=> o.ItemComponentType!=null);
|
||||
|
||||
int startX = (int)-(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
|
||||
|
||||
int i=0;
|
||||
foreach (Order order in orders)
|
||||
{
|
||||
var matchingItems = Item.ItemList.FindAll(i => i.components.Find(ic => ic.GetType() == order.ItemComponentType) != null);
|
||||
int y2 = y;
|
||||
foreach (Item it in matchingItems)
|
||||
int x = startX + (buttonWidth + spacing) * (i % orders.Count);
|
||||
|
||||
if (order.ItemComponentType!=null)
|
||||
{
|
||||
var newOrder = new Order(order, it.components.Find(ic => ic.GetType() == order.ItemComponentType));
|
||||
var matchingItems = Item.ItemList.FindAll(it => it.components.Find(ic => ic.GetType() == order.ItemComponentType) != null);
|
||||
int y2 = y;
|
||||
foreach (Item it in matchingItems)
|
||||
{
|
||||
var newOrder = new Order(order, it.components.Find(ic => ic.GetType() == order.ItemComponentType));
|
||||
|
||||
var button = new GUIButton(new Rectangle(x, y2, 150, 20), order.Name, GUI.Style, frame);
|
||||
button.UserData = newOrder;
|
||||
button.OnClicked = SetOrder;
|
||||
y2 += 25;
|
||||
var button = new GUIButton(new Rectangle(x+buttonWidth/2, y2, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
|
||||
button.UserData = newOrder;
|
||||
button.OnClicked = SetOrder;
|
||||
y2 += 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var button = new GUIButton(new Rectangle(x, y, 150, 20), order.Name, GUI.Style, frame);
|
||||
button.UserData = order;
|
||||
button.OnClicked = SetOrder;
|
||||
else
|
||||
{
|
||||
var button = new GUIButton(new Rectangle(x + buttonWidth / 2, y, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
|
||||
button.UserData = order;
|
||||
button.OnClicked = SetOrder;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
x += 160;
|
||||
y += 80;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateCharacters()
|
||||
@@ -97,12 +115,30 @@ namespace Barotrauma
|
||||
frame.RemoveChild(child);
|
||||
}
|
||||
|
||||
int x = 0, y = 0;
|
||||
foreach (Character character in crewManager.characters)
|
||||
{
|
||||
if (character.IsDead) continue;
|
||||
List<Character> aliveCharacters = crewManager.characters.FindAll(c => !c.IsDead);
|
||||
|
||||
GUIButton characterButton = new GUIButton(new Rectangle(x, y, 150, 40), "", Color.Transparent, null, frame);
|
||||
int charactersPerRow = 4;
|
||||
|
||||
int spacing = 5;
|
||||
|
||||
|
||||
int rows = (int)Math.Ceiling((double)aliveCharacters.Count / charactersPerRow);
|
||||
|
||||
int i = 0;
|
||||
foreach (Character character in aliveCharacters)
|
||||
{
|
||||
int rowCharacterCount = Math.Min(charactersPerRow, aliveCharacters.Count);
|
||||
if (aliveCharacters.Count - i < charactersPerRow-1) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
|
||||
|
||||
// rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i);
|
||||
int startX = (int)-(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;
|
||||
|
||||
|
||||
int x = startX + (150 + spacing) * (i % Math.Min(charactersPerRow, aliveCharacters.Count));
|
||||
int y = (105 + spacing)*((int)Math.Floor((double)i / charactersPerRow));
|
||||
|
||||
GUIButton characterButton = new GUIButton(new Rectangle(x+75, y, 150, 40), "", Color.Black, Alignment.TopCenter, null, frame);
|
||||
|
||||
characterButton.UserData = character;
|
||||
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
|
||||
@@ -113,8 +149,10 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
characterButton.Color = Color.Black * 0.5f;
|
||||
characterButton.HoverColor = Color.LightGray * 0.5f;
|
||||
characterButton.SelectedColor = Color.Gold * 0.5f;
|
||||
characterButton.OutlineColor = Color.LightGray * 0.8f;
|
||||
}
|
||||
|
||||
string name = character.Info.Name.Replace(' ', '\n');
|
||||
@@ -130,7 +168,7 @@ namespace Barotrauma
|
||||
|
||||
new GUIImage(new Rectangle(-10, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, characterButton);
|
||||
|
||||
x += 160;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace Barotrauma
|
||||
private float sight;
|
||||
//how far the NPC can hear targets from (0.0 = deaf, 1.0 = hears every target within soundRange)
|
||||
private float hearing;
|
||||
|
||||
public AITarget SelectedAiTarget
|
||||
{
|
||||
get { return selectedAiTarget; }
|
||||
}
|
||||
|
||||
public EnemyAIController(Character c, string file) : base(c)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Barotrauma
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
Character.ClearInputs();
|
||||
|
||||
steeringManager = Character.AnimController.CurrentHull == null ? outdoorsSteeringManager : indoorsSteeringManager;
|
||||
|
||||
if (updateObjectiveTimer>0.0f)
|
||||
@@ -45,15 +47,14 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
objectiveManager.DoCurrentObjective(deltaTime);
|
||||
|
||||
//if (Character.Controlled != null)
|
||||
//{
|
||||
// steeringManager.SteeringSeek(Character.Controlled.Position);
|
||||
//}
|
||||
|
||||
|
||||
Character.AnimController.IgnorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||
|
||||
if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
|
||||
if (Character.IsKeyDown(InputType.Aim))
|
||||
{
|
||||
Character.AnimController.TargetDir = Character.CursorPosition.X > Character.Position.X ? Direction.Right : Direction.Left;
|
||||
}
|
||||
else if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
|
||||
{
|
||||
Character.AnimController.TargetDir = Character.AnimController.TargetMovement.X > 0.0f ? Direction.Right : Direction.Left;
|
||||
}
|
||||
@@ -64,6 +65,14 @@ namespace Barotrauma
|
||||
steeringManager.Update(moveSpeed);
|
||||
}
|
||||
|
||||
public override void OnAttacked(IDamageable attacker, float amount)
|
||||
{
|
||||
var enemy = attacker as Character;
|
||||
if (enemy == null) return;
|
||||
|
||||
objectiveManager.AddObjective(new AIObjectiveCombat(Character, enemy));
|
||||
}
|
||||
|
||||
public void SetOrder(Order order, string option)
|
||||
{
|
||||
objectiveManager.SetOrder(order, option);
|
||||
|
||||
132
Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
Normal file
132
Subsurface/Source/Characters/AI/Objectives/AIObjectiveCombat.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class AIObjectiveCombat : AIObjective
|
||||
{
|
||||
const float CoolDown = 10.0f;
|
||||
|
||||
private Character enemy;
|
||||
|
||||
private AIObjectiveFindSafety escapeObjective;
|
||||
|
||||
float coolDownTimer;
|
||||
|
||||
private readonly float enemyStrength;
|
||||
|
||||
public AIObjectiveCombat (Character character, Character enemy)
|
||||
: base(character, "")
|
||||
{
|
||||
this.enemy = enemy;
|
||||
|
||||
foreach (Limb limb in enemy.AnimController.Limbs)
|
||||
{
|
||||
if (limb.attack == null) continue;
|
||||
enemyStrength += limb.attack.GetDamage(1.0f);
|
||||
}
|
||||
|
||||
coolDownTimer = CoolDown;
|
||||
|
||||
}
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
coolDownTimer -= deltaTime;
|
||||
|
||||
var weapon = character.Inventory.FindItem("weapon");
|
||||
|
||||
if (weapon==null)
|
||||
{
|
||||
Escape(deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!character.SelectedItems.Contains(weapon))
|
||||
{
|
||||
character.Inventory.TryPutItem(weapon, 3, false);
|
||||
weapon.Equip(character);
|
||||
}
|
||||
character.CursorPosition = enemy.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
|
||||
Vector2 enemyDiff = Vector2.Normalize(enemy.Position - character.Position);
|
||||
float weaponAngle = ((weapon.body.Dir == 1.0f) ? weapon.body.Rotation : weapon.body.Rotation - MathHelper.Pi);
|
||||
Vector2 weaponDir = new Vector2((float)Math.Cos(weaponAngle), (float)Math.Sin(weaponAngle));
|
||||
|
||||
if (Vector2.Dot(enemyDiff, weaponDir)<0.9f) return;
|
||||
|
||||
List<FarseerPhysics.Dynamics.Body> ignoredBodies = new List<FarseerPhysics.Dynamics.Body>();
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
ignoredBodies.Add(limb.body.FarseerBody);
|
||||
}
|
||||
|
||||
var pickedBody = Submarine.PickBody(character.SimPosition, enemy.SimPosition, ignoredBodies);
|
||||
if (pickedBody != null && pickedBody.UserData as Limb == null) return;
|
||||
|
||||
weapon.Use(deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
private void Escape(float deltaTime)
|
||||
{
|
||||
if (escapeObjective == null)
|
||||
{
|
||||
escapeObjective = new AIObjectiveFindSafety(character);
|
||||
}
|
||||
|
||||
if (enemy.AnimController.CurrentHull == character.AnimController.CurrentHull)
|
||||
{
|
||||
escapeObjective.OverrideCurrentHullSafety = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
escapeObjective.OverrideCurrentHullSafety = null;
|
||||
}
|
||||
|
||||
escapeObjective.TryComplete(deltaTime);
|
||||
|
||||
if (Vector2.Distance(character.SimPosition, enemy.SimPosition) < 3.0f)
|
||||
{
|
||||
character.AIController.SteeringManager.SteeringManual(deltaTime, character.SimPosition - enemy.SimPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
coolDownTimer = CoolDown;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsCompleted()
|
||||
{
|
||||
return enemy.IsDead || coolDownTimer <= 0.0f;
|
||||
}
|
||||
|
||||
public override float GetPriority(Character character)
|
||||
{
|
||||
//clamp the strength to the health of this character
|
||||
//(it doesn't make a difference whether the enemy does 200 or 600 damage, it's one hit kill anyway)
|
||||
|
||||
float enemyDanger = Math.Min(enemyStrength, character.Health) + enemy.Health / 10.0f;
|
||||
|
||||
EnemyAIController enemyAI = enemy.AIController as EnemyAIController;
|
||||
if (enemyAI != null)
|
||||
{
|
||||
if (enemyAI.SelectedAiTarget == character.AiTarget) enemyDanger *= 2.0f;
|
||||
}
|
||||
|
||||
return Math.Max(enemyDanger, 30.0f);
|
||||
}
|
||||
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
{
|
||||
AIObjectiveCombat objective = otherObjective as AIObjectiveCombat;
|
||||
if (objective == null) return false;
|
||||
|
||||
return objective.enemy == enemy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace Barotrauma
|
||||
|
||||
bool isCompleted;
|
||||
|
||||
public bool IgnoreAlreadyContainedItems;
|
||||
|
||||
public AIObjectiveContainItem(Character character, string itemName, ItemContainer container)
|
||||
: base (character, "")
|
||||
@@ -47,14 +48,16 @@ namespace Barotrauma
|
||||
var itemToContain = character.Inventory.FindItem(itemName);
|
||||
if (itemToContain == null)
|
||||
{
|
||||
AddSubObjective(new AIObjectiveGetItem(character, itemName));
|
||||
var getItem = new AIObjectiveGetItem(character, itemName);
|
||||
getItem.IgnoreContainedItems = IgnoreAlreadyContainedItems;
|
||||
AddSubObjective(getItem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Vector2.Distance(character.SimPosition, container.Item.SimPosition) > container.Item.PickDistance
|
||||
|| !container.Item.IsInsideTrigger(character.Position))
|
||||
&& !container.Item.IsInsideTrigger(character.Position))
|
||||
{
|
||||
AddSubObjective(new AIObjectiveGoTo(container.Item.SimPosition, character));
|
||||
AddSubObjective(new AIObjectiveGoTo(container.Item, character));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +68,9 @@ namespace Barotrauma
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
{
|
||||
AIObjectiveContainItem objective = otherObjective as AIObjectiveContainItem;
|
||||
return (objective != null);
|
||||
if (objective == null) return false;
|
||||
|
||||
return objective.itemName == itemName && objective.container == container;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,13 +11,15 @@ namespace Barotrauma
|
||||
const float SearchHullInterval = 3.0f;
|
||||
const float MinSafety = 50.0f;
|
||||
|
||||
AIObjectiveGoTo gotoObjective;
|
||||
private AIObjectiveGoTo goToObjective;
|
||||
|
||||
private List<Hull> unreachable;
|
||||
|
||||
float currenthullSafety;
|
||||
|
||||
float searchHullTimer;
|
||||
private float currenthullSafety;
|
||||
|
||||
private float searchHullTimer;
|
||||
|
||||
public float? OverrideCurrentHullSafety;
|
||||
|
||||
public AIObjectiveFindSafety(Character character)
|
||||
: base(character, "")
|
||||
@@ -27,20 +29,24 @@ namespace Barotrauma
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
if (character.AnimController.CurrentHull == null || GetHullSafety(character.AnimController.CurrentHull) > MinSafety)
|
||||
|
||||
currenthullSafety = OverrideCurrentHullSafety == null ?
|
||||
GetHullSafety(character.AnimController.CurrentHull) : (float)OverrideCurrentHullSafety;
|
||||
|
||||
if (character.AnimController.CurrentHull == null || currenthullSafety > MinSafety)
|
||||
{
|
||||
character.AIController.SteeringManager.SteeringSeek(character.AnimController.CurrentHull.SimPosition);
|
||||
|
||||
character.AIController.SelectTarget(null);
|
||||
|
||||
gotoObjective = null;
|
||||
goToObjective = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchHullTimer>0.0f)
|
||||
{
|
||||
searchHullTimer -= deltaTime;
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -67,37 +73,35 @@ namespace Barotrauma
|
||||
|
||||
if (bestHull != null)
|
||||
{
|
||||
var path = pathSteering.PathFinder.FindPath(character.SimPosition, bestHull.SimPosition);
|
||||
if (pathSteering.CurrentPath != null && pathSteering.CurrentPath.Cost < path.Cost && !pathSteering.CurrentPath.Unreachable && gotoObjective!=null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathSteering.SetPath(path);
|
||||
}
|
||||
//var path = pathSteering.PathFinder.FindPath(character.SimPosition, bestHull.SimPosition);
|
||||
//if (pathSteering.CurrentPath == null || (pathSteering.CurrentPath.NextNode==null && pathSteering.CurrentPath.Cost > path.Cost) ||
|
||||
// pathSteering.CurrentPath.Unreachable || goToObjective==null)
|
||||
//{
|
||||
|
||||
//pathSteering.SetPath(path);
|
||||
goToObjective = new AIObjectiveGoTo(bestHull, character);
|
||||
//}
|
||||
|
||||
gotoObjective = new AIObjectiveGoTo(bestHull, character);
|
||||
//character.AIController.SelectTarget(bestHull.AiTarget);
|
||||
|
||||
//haracter.AIController.SelectTarget(bestHull.AiTarget);
|
||||
}
|
||||
|
||||
|
||||
searchHullTimer = SearchHullInterval;
|
||||
}
|
||||
|
||||
if (gotoObjective != null)
|
||||
if (goToObjective != null)
|
||||
{
|
||||
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
||||
if (pathSteering!=null && pathSteering.CurrentPath!= null &&
|
||||
pathSteering.CurrentPath.Unreachable && !unreachable.Contains(gotoObjective.Target))
|
||||
pathSteering.CurrentPath.Unreachable && !unreachable.Contains(goToObjective.Target))
|
||||
{
|
||||
unreachable.Add(gotoObjective.Target as Hull);
|
||||
unreachable.Add(goToObjective.Target as Hull);
|
||||
}
|
||||
|
||||
|
||||
goToObjective.TryComplete(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
gotoObjective.TryComplete(deltaTime);
|
||||
}
|
||||
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
@@ -125,7 +129,7 @@ namespace Barotrauma
|
||||
|
||||
float safety = 100.0f - fireAmount;
|
||||
if (waterPercentage > 30.0f) safety -= waterPercentage;
|
||||
if (hull.OxygenPercentage < 30.0f) safety -= (30.0f-hull.OxygenPercentage)*3.0f;
|
||||
if (hull.OxygenPercentage < 30.0f) safety -= (30.0f-hull.OxygenPercentage)*5.0f;
|
||||
|
||||
return safety;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@ namespace Barotrauma
|
||||
|
||||
private bool canBeCompleted;
|
||||
|
||||
public bool IgnoreContainedItems;
|
||||
|
||||
public override bool CanBeCompleted
|
||||
{
|
||||
get { return canBeCompleted; }
|
||||
}
|
||||
|
||||
|
||||
public AIObjectiveGetItem(Character character, string itemName)
|
||||
: base (character, "")
|
||||
{
|
||||
@@ -39,7 +42,6 @@ namespace Barotrauma
|
||||
{
|
||||
targetItem.Pick(character, false, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (currSearchIndex >= Item.ItemList.Count)
|
||||
@@ -47,20 +49,23 @@ namespace Barotrauma
|
||||
canBeCompleted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Item.ItemList[currSearchIndex].HasTag(itemName) || Item.ItemList[currSearchIndex].Name == itemName)
|
||||
{
|
||||
targetItem = Item.ItemList[currSearchIndex];
|
||||
|
||||
while (targetItem.container != null)
|
||||
{
|
||||
targetItem = targetItem.container;
|
||||
}
|
||||
|
||||
subObjectives.Add(new AIObjectiveGoTo(targetItem.Position, character));
|
||||
}
|
||||
|
||||
currSearchIndex++;
|
||||
|
||||
if (!Item.ItemList[currSearchIndex].HasTag(itemName) && Item.ItemList[currSearchIndex].Name != itemName) return;
|
||||
if (IgnoreContainedItems && Item.ItemList[currSearchIndex].container != null) return;
|
||||
|
||||
targetItem = Item.ItemList[currSearchIndex];
|
||||
|
||||
Item moveToTarget = targetItem;
|
||||
while (moveToTarget.container != null)
|
||||
{
|
||||
moveToTarget = moveToTarget.container;
|
||||
}
|
||||
|
||||
subObjectives.Add(new AIObjectiveGoTo(moveToTarget, character));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
|
||||
@@ -35,14 +35,15 @@ namespace Barotrauma
|
||||
: base (character, "")
|
||||
{
|
||||
this.target = target;
|
||||
this.repeat = false;
|
||||
this.repeat = repeat;
|
||||
}
|
||||
|
||||
|
||||
public AIObjectiveGoTo(Vector2 targetPos, Character character)
|
||||
public AIObjectiveGoTo(Vector2 simPos, Character character, bool repeat = false)
|
||||
: base(character, "")
|
||||
{
|
||||
this.targetPos = targetPos;
|
||||
this.targetPos = simPos;
|
||||
this.repeat = repeat;
|
||||
}
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Barotrauma
|
||||
{
|
||||
class AIObjectiveIdle : AIObjective
|
||||
{
|
||||
const float WallAvoidDistance = 150.0f;
|
||||
|
||||
AITarget currentTarget;
|
||||
private float newTargetTimer;
|
||||
|
||||
@@ -33,40 +35,30 @@ namespace Barotrauma
|
||||
{
|
||||
currentTarget = FindRandomTarget();
|
||||
|
||||
if (currentTarget!=null)
|
||||
if (currentTarget != null)
|
||||
{
|
||||
var path = pathSteering.PathFinder.FindPath(character.SimPosition, currentTarget.SimPosition);
|
||||
if (path.Cost > 200.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathSteering.SetPath(path);
|
||||
}
|
||||
if (path.Cost > 200.0f) return;
|
||||
|
||||
pathSteering.SetPath(path);
|
||||
}
|
||||
|
||||
|
||||
newTargetTimer = currentTarget == null ? 5.0f : 10.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
newTargetTimer -= deltaTime;
|
||||
}
|
||||
|
||||
|
||||
if (currentTarget == null) return;
|
||||
|
||||
|
||||
|
||||
newTargetTimer -= deltaTime;
|
||||
|
||||
//wander randomly if reached the end of the path or the target is unreachable
|
||||
if (pathSteering!=null && pathSteering.CurrentPath != null &&
|
||||
(pathSteering.CurrentPath.NextNode == null || pathSteering.CurrentPath.Unreachable))
|
||||
if (pathSteering==null || (pathSteering.CurrentPath != null &&
|
||||
(pathSteering.CurrentPath.NextNode == null || pathSteering.CurrentPath.Unreachable)))
|
||||
{
|
||||
if (character.Position.X < character.AnimController.CurrentHull.Rect.X + 200.0f)
|
||||
//steer away from edges of the hull
|
||||
if (character.Position.X < character.AnimController.CurrentHull.Rect.X + WallAvoidDistance)
|
||||
{
|
||||
pathSteering.SteeringManual(deltaTime, Vector2.UnitX);
|
||||
}
|
||||
else if (character.Position.X > character.AnimController.CurrentHull.Rect.Right - 200.0f)
|
||||
else if (character.Position.X > character.AnimController.CurrentHull.Rect.Right - WallAvoidDistance)
|
||||
{
|
||||
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX);
|
||||
}
|
||||
@@ -75,8 +67,8 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentTarget == null) return;
|
||||
character.AIController.SteeringManager.SteeringSeek(currentTarget.SimPosition);
|
||||
|
||||
}
|
||||
|
||||
private AITarget FindRandomTarget()
|
||||
@@ -111,7 +103,7 @@ namespace Barotrauma
|
||||
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
{
|
||||
return true;
|
||||
return (otherObjective as AIObjectiveIdle != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@ namespace Barotrauma
|
||||
case "follow":
|
||||
currentOrder = new AIObjectiveGoTo(Character.Controlled, character, true);
|
||||
break;
|
||||
case "wait":
|
||||
currentOrder = new AIObjectiveGoTo(character.SimPosition, character, true);
|
||||
break;
|
||||
default:
|
||||
if (order.TargetItem == null) return;
|
||||
|
||||
|
||||
@@ -27,11 +27,14 @@ namespace Barotrauma
|
||||
|
||||
PrefabList.Add(new Order("Follow", "Following"));
|
||||
|
||||
PrefabList.Add(new Order("Dismiss", "Dismissed"));
|
||||
|
||||
PrefabList.Add(new Order("Wait", "Wait"));
|
||||
|
||||
PrefabList.Add(new Order("Operate Reactor", "Operating reactor", typeof(Reactor), new string[] {"Power up", "Shutdown"}));
|
||||
PrefabList.Add(new Order("Operate Railgun", "Operating railgun", typeof(Turret), new string[] { "Fire at will", "Hold fire" }));
|
||||
|
||||
|
||||
PrefabList.Add(new Order("Dismiss", "Dismissed"));
|
||||
}
|
||||
|
||||
private Order(string name, string doingText, Type itemComponentType, string[] parameters = null)
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Barotrauma
|
||||
|
||||
public void SteeringManual(float deltaTime, Vector2 velocity)
|
||||
{
|
||||
steering += velocity * deltaTime;
|
||||
steering += velocity;
|
||||
}
|
||||
|
||||
public virtual void Update(float speed = 1.0f)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Barotrauma
|
||||
public bool Unreachable
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
set;
|
||||
}
|
||||
|
||||
public SteeringPath(bool unreachable = false)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Barotrauma
|
||||
|
||||
return DiffToCurrentNode();
|
||||
}
|
||||
|
||||
|
||||
Vector2 diff = DiffToCurrentNode();
|
||||
|
||||
if (diff == Vector2.Zero) return -host.Steering;
|
||||
@@ -85,10 +85,18 @@ namespace Barotrauma
|
||||
|
||||
if (canOpenDoors) CheckDoorsInPath();
|
||||
|
||||
currentPath.CheckProgress(host.SimPosition, character.AnimController.InWater ? 1.0f : 0.6f);
|
||||
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
|
||||
if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f;
|
||||
|
||||
currentPath.CheckProgress(host.SimPosition, allowedDistance);
|
||||
|
||||
if (currentPath.CurrentNode == null) return Vector2.Zero;
|
||||
|
||||
//if (currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f && character.AnimController.Stairs == null)
|
||||
//{
|
||||
// return currentPath.PrevNode.SimPosition - host.SimPosition;
|
||||
//}
|
||||
|
||||
return currentPath.CurrentNode.SimPosition - host.SimPosition;
|
||||
}
|
||||
|
||||
@@ -109,6 +117,7 @@ namespace Barotrauma
|
||||
if (door.IsOpen != open)
|
||||
{
|
||||
var buttons = door.Item.GetConnectedComponents<Controller>();
|
||||
|
||||
foreach (Controller controller in buttons)
|
||||
{
|
||||
if (Vector2.Distance(controller.Item.SimPosition, character.SimPosition) > controller.Item.PickDistance * 2.0f) continue;
|
||||
@@ -131,6 +140,8 @@ namespace Barotrauma
|
||||
if (!canOpenDoors) return null;
|
||||
|
||||
var doorButtons = nextNode.Waypoint.ConnectedGap.ConnectedDoor.Item.GetConnectedComponents<Controller>();
|
||||
if (!doorButtons.Any()) return null;
|
||||
|
||||
foreach (Controller button in doorButtons)
|
||||
{
|
||||
if (Math.Sign(button.Item.Position.X - nextNode.Waypoint.Position.X) !=
|
||||
@@ -250,10 +250,13 @@ namespace Barotrauma
|
||||
|
||||
float shortestAngle = leg.Rotation - torso.Rotation;
|
||||
|
||||
if (Math.Abs(shortestAngle)<2.5f) continue;
|
||||
//leg = GetLimb((i == 0) ? LimbType.LeftLeg : LimbType.RightLeg);
|
||||
if (Math.Abs(shortestAngle)<2.4f) continue;
|
||||
|
||||
leg.body.ApplyTorque(-shortestAngle*10.0f);
|
||||
|
||||
leg = GetLimb((i == 0) ? LimbType.LeftThigh : LimbType.RightThigh);
|
||||
leg.body.ApplyTorque(-shortestAngle * 5.0f);
|
||||
|
||||
// float torsoRot = MathHelper.WrapAngle(torso.Rotation);
|
||||
// torsoRot = MathHelper.ToDegrees(torsoRot);
|
||||
|
||||
|
||||
@@ -480,6 +480,13 @@ namespace Barotrauma
|
||||
return keys[(int)inputType].Held;
|
||||
}
|
||||
|
||||
public void SetInput(InputType inputType, bool hit, bool held)
|
||||
{
|
||||
keys[(int)inputType].Hit = hit;
|
||||
keys[(int)inputType].Held = held;
|
||||
|
||||
}
|
||||
|
||||
public void ClearInput(InputType inputType)
|
||||
{
|
||||
keys[(int)inputType].Hit = false;
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Barotrauma
|
||||
|
||||
|
||||
Hull.renderer = new WaterRenderer(GraphicsDevice);
|
||||
TitleScreen.LoadState = 1.0f;
|
||||
TitleScreen.LoadState = 1.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
GUI.LoadContent(GraphicsDevice);
|
||||
@@ -203,19 +203,25 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs));
|
||||
TitleScreen.LoadState = 15.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure));
|
||||
TitleScreen.LoadState = 25.0f;
|
||||
TitleScreen.LoadState = 20.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
ItemPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Item));
|
||||
TitleScreen.LoadState = 40.0f;
|
||||
TitleScreen.LoadState = 30.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
Debug.WriteLine("sounds");
|
||||
CoroutineManager.StartCoroutine(SoundPlayer.Init());
|
||||
|
||||
int i = 0;
|
||||
while (!SoundPlayer.Initialized)
|
||||
{
|
||||
i++;
|
||||
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f/41, 70.0f);
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
TitleScreen.LoadState = 70.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
@@ -244,10 +250,9 @@ namespace Barotrauma
|
||||
|
||||
LocationType.Init("Content/Map/locationTypes.xml");
|
||||
MainMenuScreen.Select();
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
TitleScreen.LoadState = 100.0f;
|
||||
hasLoaded = true;
|
||||
TitleScreen.LoadState = 100.0f;
|
||||
hasLoaded = true;
|
||||
yield return CoroutineStatus.Success;
|
||||
|
||||
}
|
||||
|
||||
@@ -244,6 +244,43 @@ namespace Barotrauma.Items.Components
|
||||
OpenState += deltaTime * ((isOpen) ? 2.0f : -2.0f);
|
||||
LinkedGap.Open = openState;
|
||||
}
|
||||
|
||||
if (openState > 0.0f && openState < 1.0f)
|
||||
{
|
||||
//push characters out of the doorway when the door is closing/opening
|
||||
Vector2 simPos = ConvertUnits.ToSimUnits(new Vector2(item.Rect.X, item.Rect.Y));
|
||||
Vector2 simSize = ConvertUnits.ToSimUnits(new Vector2(doorSprite.size.X,
|
||||
item.Rect.Height * (1.0f - openState)));
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
int dir = Math.Sign(c.SimPosition.X - item.SimPosition.X);
|
||||
foreach (Limb l in c.AnimController.Limbs)
|
||||
{
|
||||
if (l.SimPosition.Y > simPos.Y || l.SimPosition.Y < simPos.Y - simSize.Y) continue;
|
||||
|
||||
if (Math.Sign(l.SimPosition.X - item.SimPosition.X) != dir)
|
||||
{
|
||||
l.body.SetTransform(new Vector2(item.SimPosition.X + dir * simSize.X*1.2f, item.SimPosition.Y), l.body.Rotation);
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, 1.0f, l.body.FarseerBody);
|
||||
//c.AddDamage(item.SimPosition, DamageType.Blunt, 1.0f, 0.0f, 0.0f, true);
|
||||
|
||||
l.body.ApplyLinearImpulse(new Vector2(dir * 0.5f, isOpen ? 0.0f : -1.0f));
|
||||
}
|
||||
|
||||
if (Math.Abs(l.SimPosition.X - item.SimPosition.X) > simSize.X*0.5f) continue;
|
||||
|
||||
|
||||
l.body.ApplyLinearImpulse(new Vector2(dir * 0.5f, isOpen ? 0.0f : -0.5f));
|
||||
c.StartStun(0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
body.Enabled = openState < 1.0f;
|
||||
}
|
||||
|
||||
|
||||
item.SendSignal((isOpen) ? "1" : "0", "state_out");
|
||||
@@ -278,32 +315,7 @@ namespace Barotrauma.Items.Components
|
||||
spriteBatch.Draw(doorSprite.Texture, new Vector2(item.Rect.Center.X, -item.Rect.Y),
|
||||
new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.size.Y * openState),
|
||||
(int)doorSprite.size.X, (int)(doorSprite.size.Y * (1.0f - openState))),
|
||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||
|
||||
if (openState == 0.0f)
|
||||
{
|
||||
body.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//push characters out of the doorway when the door is closing/opening
|
||||
Vector2 simPos = ConvertUnits.ToSimUnits(new Vector2(item.Rect.X, item.Rect.Y));
|
||||
Vector2 simSize = ConvertUnits.ToSimUnits(new Vector2(item.Rect.Width,
|
||||
item.Rect.Height * (1.0f - openState)));
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
int dir = Math.Sign(c.AnimController.Limbs[0].SimPosition.X - simPos.X);
|
||||
foreach (Limb l in c.AnimController.Limbs)
|
||||
{
|
||||
if (l.SimPosition.Y < simPos.Y || l.SimPosition.Y > simPos.Y - simSize.Y) continue;
|
||||
if (Math.Abs(l.SimPosition.X - simPos.X) > simSize.X * 2.0f) continue;
|
||||
|
||||
l.body.ApplyForce(new Vector2(dir * 10.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
|
||||
@@ -90,26 +90,18 @@ namespace Barotrauma.Items.Components
|
||||
+ Rand.Range(-degreeOfFailure, degreeOfFailure));
|
||||
|
||||
projectile.Use(deltaTime);
|
||||
projectileComponent.User = character;
|
||||
|
||||
projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
|
||||
|
||||
//recoil
|
||||
//recoil
|
||||
item.body.ApplyLinearImpulse(
|
||||
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f);
|
||||
|
||||
//else
|
||||
//{
|
||||
projectileComponent.ignoredBodies = limbBodies;
|
||||
|
||||
//recoil
|
||||
//item.body.ApplyLinearImpulse(
|
||||
// new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * -item.body.Mass);
|
||||
//}
|
||||
projectileComponent.ignoredBodies = limbBodies;
|
||||
|
||||
item.RemoveContained(projectile);
|
||||
|
||||
|
||||
|
||||
Rope rope = item.GetComponent<Rope>();
|
||||
if (rope != null) rope.Attach(projectile);
|
||||
|
||||
@@ -117,9 +109,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public List<Body> ignoredBodies;
|
||||
|
||||
public Character User;
|
||||
|
||||
[HasDefaultValue(10.0f, false)]
|
||||
public float LaunchImpulse
|
||||
{
|
||||
@@ -127,17 +129,15 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (stickJoint != null && stickJoint.JointTranslation < 0.01f)
|
||||
{
|
||||
if (stickTarget!=null)
|
||||
if (stickTarget != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
|
||||
#endif
|
||||
//the body that the projectile was stuck to has been removed
|
||||
}
|
||||
|
||||
stickTarget = null;
|
||||
@@ -147,11 +147,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to remove stickJoint", e);
|
||||
#endif
|
||||
//the body that the projectile was stuck to has been removed
|
||||
}
|
||||
|
||||
stickJoint = null;
|
||||
@@ -165,17 +163,17 @@ namespace Barotrauma.Items.Components
|
||||
if (ignoredBodies.Contains(f2.Body)) return false;
|
||||
|
||||
AttackResult attackResult = new AttackResult(0.0f, 0.0f);
|
||||
if (attack!=null)
|
||||
if (attack != null)
|
||||
{
|
||||
Limb limb;
|
||||
Structure structure;
|
||||
if ((limb = (f2.Body.UserData as Limb)) != null)
|
||||
{
|
||||
attackResult = attack.DoDamage(null, limb.character, item.SimPosition, 1.0f);
|
||||
{
|
||||
attackResult = attack.DoDamage(User, limb.character, item.SimPosition, 1.0f);
|
||||
}
|
||||
else if ((structure = (f2.Body.UserData as Structure)) != null)
|
||||
{
|
||||
attackResult = attack.DoDamage(null, structure, item.SimPosition, 1.0f);
|
||||
attackResult = attack.DoDamage(User, structure, item.SimPosition, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
var projectiles = GetLoadedProjectiles();
|
||||
|
||||
if (projectiles.Count==0 || (projectiles.Count==1 && objective.Option.ToLower()=="hold fire"))
|
||||
if (projectiles.Count==0 || (projectiles.Count==1 && objective.Option.ToLower()!="fire at will"))
|
||||
{
|
||||
ItemContainer container = null;
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
@@ -174,8 +174,10 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
if (container == null || container.ContainableItems.Count==0) return true;
|
||||
|
||||
objective.AddSubObjective(new AIObjectiveContainItem(character, container.ContainableItems[0].Names[0], container));
|
||||
|
||||
var containShellObjective = new AIObjectiveContainItem(character, container.ContainableItems[0].Names[0], container);
|
||||
containShellObjective.IgnoreAlreadyContainedItems = true;
|
||||
objective.AddSubObjective(containShellObjective);
|
||||
return false;
|
||||
}
|
||||
else if (GetAvailablePower() < powerConsumption)
|
||||
@@ -186,7 +188,7 @@ namespace Barotrauma.Items.Components
|
||||
PowerContainer batteryToLoad = null;
|
||||
foreach (PowerContainer battery in batteries)
|
||||
{
|
||||
if (batteryToLoad==null || battery.Charge < lowestCharge)
|
||||
if (batteryToLoad == null || battery.Charge < lowestCharge)
|
||||
{
|
||||
batteryToLoad = battery;
|
||||
lowestCharge = battery.Charge;
|
||||
@@ -205,7 +207,6 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
//enough shells and power
|
||||
|
||||
Character closestEnemy = null;
|
||||
float closestDist = 3000.0f;
|
||||
foreach (Character enemy in Character.CharacterList)
|
||||
@@ -256,6 +257,13 @@ namespace Barotrauma.Items.Components
|
||||
return availablePower;
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
barrelSprite.Remove();
|
||||
}
|
||||
|
||||
private List<Projectile> GetLoadedProjectiles(bool returnFirst = false)
|
||||
{
|
||||
List<Projectile> projectiles = new List<Projectile>();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -19,8 +20,7 @@ namespace Barotrauma
|
||||
|
||||
private int selectedRightPanel;
|
||||
|
||||
private GUIListBox characterList;
|
||||
private GUIListBox hireList;
|
||||
private GUIListBox characterList, hireList;
|
||||
|
||||
private GUIListBox selectedItemList, itemList;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Barotrauma
|
||||
|
||||
private string CostTextGetter()
|
||||
{
|
||||
return "Cost: "+selectedItemCost.ToString();
|
||||
return "Cost: "+selectedItemCost.ToString()+" credits";
|
||||
}
|
||||
|
||||
private int selectedItemCost
|
||||
@@ -183,32 +183,6 @@ namespace Barotrauma
|
||||
|
||||
bottomPanel[(int)PanelTab.CurrentLocation].ClearChildren();
|
||||
bottomPanel[(int)PanelTab.CurrentLocation].UserData = location;
|
||||
//rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
|
||||
|
||||
//for (int i = 0; i < Enum.GetNames(typeof(PanelTab)).Length; i++ )
|
||||
//{
|
||||
|
||||
// float size = Math.Max(
|
||||
// (float)GameMain.GraphicsWidth / (float)location.Type.Background.SourceRect.Width,
|
||||
// (float)GameMain.GraphicsHeight / (float)location.Type.Background.SourceRect.Height);
|
||||
// location.Type.Background.size = new Vector2(
|
||||
// location.Type.Background.SourceRect.Width*size,
|
||||
// location.Type.Background.SourceRect.Height*size);
|
||||
|
||||
|
||||
// topPanel.sprites.Clear();
|
||||
// topPanel.TileSprites = false;
|
||||
// topPanel.sprites.Add(location.Type.Background);
|
||||
|
||||
// bottomPanel[i].sprites.Clear();
|
||||
// bottomPanel[i].TileSprites = false;
|
||||
// bottomPanel[i].sprites.Add(location.Type.Background);
|
||||
//}
|
||||
|
||||
//new GUITextBlock(new Rectangle(0, 0, 200, 25),
|
||||
// "Location: "+location.Name, GUI.Style, bottomPanel[(int)PanelTab.CurrentLocation]);
|
||||
//new GUITextBlock(new Rectangle(0, 20, 200, 25),
|
||||
// "("+location.Type.Name+")", GUI.Style, bottomPanel[(int)PanelTab.CurrentLocation]);
|
||||
|
||||
if (location.HireManager != null)
|
||||
{
|
||||
@@ -257,17 +231,17 @@ namespace Barotrauma
|
||||
|
||||
if (location == null) return;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 0), location.Name, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel).Font = GUI.LargeFont;
|
||||
new GUITextBlock(new Rectangle(0, 0, 250, 0), location.Name, GUI.Style, Alignment.TopLeft, Alignment.TopCenter, locationPanel, true, GUI.LargeFont);
|
||||
|
||||
if (GameMain.GameSession.Map.SelectedConnection != null && GameMain.GameSession.Map.SelectedConnection.Quest != null)
|
||||
{
|
||||
var quest = GameMain.GameSession.Map.SelectedConnection.Quest;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 40, 0, 20), "Quest: "+quest.Name, Color.Black*0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, 80, 0, 20), "Quest: "+quest.Name, Color.Black*0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 60, 0, 20), "Reward: " + quest.Reward, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 20), "Reward: " + quest.Reward+" credits", Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 80, 0, 0), quest.Description, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel, true);
|
||||
new GUITextBlock(new Rectangle(0, 120, 0, 0), quest.Description, Color.Black * 0.8f, Color.White, Alignment.TopLeft, null, locationPanel, true);
|
||||
|
||||
}
|
||||
|
||||
@@ -282,15 +256,6 @@ namespace Barotrauma
|
||||
foreach (CharacterInfo c in CrewManager.characterInfos)
|
||||
{
|
||||
c.CreateCharacterFrame(characterList, c.Name + " ("+c.Job.Name+") ", c);
|
||||
|
||||
//GUITextBlock textBlock = new GUITextBlock(
|
||||
// new Rectangle(0, 0, 0, 25),
|
||||
// c.Name + " (" + c.Job.Name + ")", GUI.Style,
|
||||
// Alignment.Left,
|
||||
// Alignment.Left,
|
||||
// characterList, false, GameMain.GraphicsWidth<1000 ? GUI.SmallFont : GUI.Font);
|
||||
//textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||
//textBlock.UserData = c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +423,7 @@ namespace Barotrauma
|
||||
|
||||
private string GetMoney()
|
||||
{
|
||||
return "Money: " + ((GameMain.GameSession == null) ? "" : CrewManager.Money.ToString());
|
||||
return "Money: " + ((GameMain.GameSession == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", CrewManager.Money)) + " credits";
|
||||
}
|
||||
|
||||
private bool SelectCharacter(GUIComponent component, object selection)
|
||||
|
||||
@@ -68,11 +68,11 @@ namespace Barotrauma
|
||||
private static float currMusicVolume;
|
||||
|
||||
private static Sound startDrone;
|
||||
|
||||
public static bool Initialized;
|
||||
|
||||
public static IEnumerable<object> Init()
|
||||
{
|
||||
|
||||
|
||||
startDrone = Sound.Load("Content/Sounds/startDrone.ogg", false);
|
||||
startDrone.Play();
|
||||
|
||||
@@ -148,6 +148,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Initialized = true;
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
|
||||
}
|
||||
|
||||
@@ -182,21 +182,30 @@ namespace Barotrauma
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Vector2 pos, float rotate=0.0f, float scale=1.0f, SpriteEffects spriteEffect = SpriteEffects.None)
|
||||
{
|
||||
spriteBatch.Draw(texture, pos + offset, sourceRect, Color.White, rotation + rotate, origin, scale, spriteEffect, depth);
|
||||
this.Draw(spriteBatch, pos, Color.White, rotate, scale, spriteEffect);
|
||||
}
|
||||
|
||||
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);
|
||||
this.Draw(spriteBatch, pos, color, this.origin, rotate, new Vector2(scale,scale), spriteEffect, 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);
|
||||
this.Draw(spriteBatch, pos, color, origin, rotate, new Vector2(scale, scale), spriteEffect, depth);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate, Vector2 scale, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null)
|
||||
{
|
||||
//for (int x = -1; x < 3; x+=2 )
|
||||
//{
|
||||
// for (int y = -1; y < 3; y+=2 )
|
||||
// {
|
||||
|
||||
// spriteBatch.Draw(texture, pos + offset + new Vector2(x, y)*1.0f, sourceRect, Color.Black, rotation + rotate, origin, scale, spriteEffect, (depth == null ? this.depth : (float)depth)+0.0001f);
|
||||
// }
|
||||
//}
|
||||
|
||||
spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth);
|
||||
}
|
||||
|
||||
@@ -214,14 +223,14 @@ namespace Barotrauma
|
||||
int xTiles = (int)Math.Ceiling((targetSize.X+startOffset.X) / sourceRect.Width);
|
||||
//how many times the texture needs to be drawn on the y-axis
|
||||
int yTiles = (int)Math.Ceiling((targetSize.Y+startOffset.Y) / sourceRect.Height);
|
||||
|
||||
Vector2 position = pos-startOffset;
|
||||
|
||||
Vector2 position = pos - startOffset;
|
||||
Rectangle drawRect = sourceRect;
|
||||
|
||||
position.X = pos.X;
|
||||
|
||||
for (int x = 0 ; x<xTiles ; x++)
|
||||
{
|
||||
for (int x = 0; x < xTiles; x++)
|
||||
{
|
||||
drawRect.X = sourceRect.X;
|
||||
drawRect.Height = sourceRect.Height;
|
||||
|
||||
@@ -243,11 +252,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
position.Y = pos.Y;
|
||||
|
||||
for (int y = 0 ; y<yTiles ; y++)
|
||||
|
||||
for (int y = 0; y < yTiles; y++)
|
||||
{
|
||||
drawRect.Y = sourceRect.Y;
|
||||
|
||||
|
||||
if (y == yTiles - 1)
|
||||
{
|
||||
drawRect.Height -= (int)((position.Y + sourceRect.Height) - (pos.Y + targetSize.Y));
|
||||
@@ -264,10 +273,10 @@ namespace Barotrauma
|
||||
drawRect.Height -= diff;
|
||||
drawRect.Y += diff;
|
||||
}
|
||||
|
||||
|
||||
spriteBatch.Draw(texture, position,
|
||||
drawRect, color, rotation, Vector2.Zero, 1.0f, effects, depth);
|
||||
|
||||
|
||||
position.Y += sourceRect.Height;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,12 @@ VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma", "Subsurface\Barotrauma.csproj", "{008C0F83-E914-4966-9135-EA885059EDD8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface_contentContent", "Subsurface_content\Subsurface_contentContent\Subsurface_contentContent.contentproj", "{8C1D2051-F0F3-457B-AAAE-4E155FC7C75C}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma_contentContent", "Subsurface_content\Subsurface_contentContent\Barotrauma_contentContent.contentproj", "{8C1D2051-F0F3-457B-AAAE-4E155FC7C75C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface_content", "Subsurface_content\Subsurface_content\Subsurface_content.csproj", "{1E6BF44D-6E31-40CC-8321-3D5958C983E7}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma_content", "Subsurface_content\Subsurface_content\Barotrauma_content.csproj", "{1E6BF44D-6E31-40CC-8321-3D5958C983E7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Farseer Physics MonoGame", "Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj", "{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldLauncher", "Launcher\OldLauncher.csproj", "{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher2\Launcher.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
||||
@@ -214,51 +212,6 @@ Global
|
||||
{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||
{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}.Windows8|x86.ActiveCfg = Release|x86
|
||||
{0AAD36E3-51A5-4A07-AB60-5C8A66BD38B7}.Windows8|x86.Build.0 = Release|x86
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Android|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Android|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Android|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.iOS|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.iOS|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.iOS|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.iOS|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.iOS|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Linux|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Linux|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Linux|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Linux|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Linux|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.OSX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.OSX|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.OSX|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.OSX|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.OSX|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.PSM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.PSM|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.PSM|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.PSM|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.PSM|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows|x86.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows8|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows8|Any CPU.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows8|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows8|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{24420B91-6CD9-4DE3-9ADD-2F2C7E1FB6BB}.Windows8|x86.ActiveCfg = Release|Any CPU
|
||||
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Android|Any CPU.Build.0 = Release|Any CPU
|
||||
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
|
||||
Binary file not shown.
@@ -46,8 +46,8 @@
|
||||
<Reference Include="mscorlib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Subsurface_contentContent\Subsurface_contentContent.contentproj">
|
||||
<Name>Subsurface_contentContent</Name>
|
||||
<ProjectReference Include="..\Subsurface_contentContent\Barotrauma_contentContent.contentproj">
|
||||
<Name>Barotrauma_contentContent</Name>
|
||||
<XnaReferenceType>Content</XnaReferenceType>
|
||||
<Project>{8C1D2051-F0F3-457B-AAAE-4E155FC7C75C}</Project>
|
||||
</ProjectReference>
|
||||
@@ -0,0 +1,6 @@
|
||||
Content\SpriteFont1.xnb
|
||||
Content\SmallFont.xnb
|
||||
Content\LargeFont.xnb
|
||||
Content\SpriteFont1.spritefont
|
||||
Content\SmallFont.spritefont
|
||||
Content\LargeFont.spritefont
|
||||
BIN
UpgradeLog.htm
BIN
UpgradeLog.htm
Binary file not shown.
BIN
UpgradeLog2.htm
BIN
UpgradeLog2.htm
Binary file not shown.
Reference in New Issue
Block a user