Skip to content

Commit 4e9e3af

Browse files
committed
Added # ships on display
1 parent 6013e23 commit 4e9e3af

File tree

5 files changed

+6
-2
lines changed

5 files changed

+6
-2
lines changed

Assets/ECS_MLAgents_v0/Example/SpaceWars/Scripts/FPSDisplay.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void OnGUI()
2323
style.normal.textColor = new Color (1.0f, 1.0f, 0.5f, 1.0f);
2424
float msec = deltaTime * 1000.0f;
2525
float fps = 1.0f / deltaTime;
26-
string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
26+
string text = string.Format(" {0:0.0} ms ({1:0.} fps)\n" +
27+
" # Ships : {2}", msec, fps, Globals.NumberShips);
2728
GUI.Label(rect, text, style);
2829
}
2930
}

Assets/ECS_MLAgents_v0/Example/SpaceWars/Scripts/Globals.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace ECS_MLAgents_v0.Example.SpaceWars.Scripts
88
{
99
public class Globals : MonoBehaviour
1010
{
11+
public static int NumberShips;
12+
1113
public static float SHIP_SPEED = 2f;
1214
public static float SHIP_ROTATION_SPEED = 1f;
1315

Assets/ECS_MLAgents_v0/Example/SpaceWars/Scripts/Manager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ void Update()
8888

8989
var camPosition = manager.GetComponentData<Position>(_playerEntity).Value;
9090
var camRotation = manager.GetComponentData<Rotation>(_playerEntity).Value;
91-
camPosition += math.mul(camRotation, new float3(-2, 0, 5));
91+
camPosition += math.mul(camRotation, new float3(0, 0, 5));
9292
Camera.transform.position = Vector3.Lerp(Camera.transform.position,camPosition,0.1f);
9393
Camera.transform.rotation = Quaternion.Lerp(Camera.transform.rotation,camRotation,0.1f);
9494

9595
}
9696

9797
void Spawn(int amount)
9898
{
99+
Globals.NumberShips += amount;
99100
NativeArray<Entity> entities = new NativeArray<Entity>(amount, Allocator.Temp);
100101
manager.Instantiate(prefab, entities);
101102
for (int i = 0; i < amount; i++)

0 commit comments

Comments
 (0)