protected override void OnStopSimulation() { for (int i = 0; i < populationAgents.Count; i++) { TurretTankAgent turretTankAgent = populationAgents[i] as TurretTankAgent; turretTankAgent.DestroyProjectiles(); } }
protected override void OnStartSimulation() { for (int i = 0; i < populationAgents.Count; i++) { TurretTankAgent turretTankAgent = populationAgents[i] as TurretTankAgent; float maxSceneExtentsDistance = Mathf.Max(sceneHalfExtents.x, sceneHalfExtents.z) * 2f; turretTankAgent.MaxSqrDistanceToEnemy = maxSceneExtentsDistance * maxSceneExtentsDistance; } }
protected override void OnSimulationAgentUpdate(NeuralNetworkAgent agent) { TurretTankAgent turretTankAgent = agent as TurretTankAgent; if (!turretTankAgent.HasFired) { Collider enemy = GetNearestEnemy(turretTankAgent.transform); turretTankAgent.NearestEnemy = enemy; } else { turretTankAgent.UpdateCurrentProjectiles(); turretTankAgent.UpdateFiringCooldown(); } turretTankAgent.Think(); }