补炮弹飞行轨迹可视化 + 到达后清理
This commit is contained in:
parent
12d2ff423a
commit
af8b0dac35
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using CounterDrone.Core;
|
||||
using CounterDrone.Core.Algorithms;
|
||||
@ -111,6 +112,32 @@ namespace CounterDrone.Unity
|
||||
}
|
||||
}
|
||||
|
||||
// 炮弹飞行轨迹
|
||||
foreach (var m in _engine.Munitions)
|
||||
{
|
||||
if (!_knownMunitions.Contains(m.Id))
|
||||
{
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
||||
go.name = m.Id;
|
||||
go.transform.localScale = new UVector3(2, 10, 2);
|
||||
_knownMunitions.Add(m.Id);
|
||||
_entityVisuals[m.Id] = go;
|
||||
}
|
||||
if (_entityVisuals.TryGetValue(m.Id, out var mgo))
|
||||
mgo.transform.position = new UVector3(m.PosX, m.PosY, m.PosZ);
|
||||
}
|
||||
|
||||
// 清理已到达的炮弹(已转为云团)
|
||||
foreach (var id in _knownMunitions.ToArray())
|
||||
{
|
||||
if (!_engine.Munitions.Any(m => m.Id == id) && _entityVisuals.TryGetValue(id, out var go))
|
||||
{
|
||||
Destroy(go);
|
||||
_knownMunitions.Remove(id);
|
||||
_entityVisuals.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.State == SimulationState.Completed)
|
||||
Debug.Log($"Simulation done. Drone: {_engine.Drones[0].Status}, HP: {_engine.Drones[0].Hp:F2}");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user