public void Update(float deltaTime) { if (running) { if (!AllCarsDead()) { var bestBrain = FindBestBrain(); if (bestBrain.Id != currentBrainController.Id) { currentBrainController = bestBrain; debug.Log("found a better car: " + currentBrainController.Id); } } else { debug.Log("All cars are dead!"); debug.Log("Making a new generation!"); var newBrains = MakeNewGenerationOfBrains(brainControllerList); SetupGenerationOfBrains(newBrains); } var sensorData = currentBrainController.GetSensorData(); uiObject.SetSensorData(sensorData, "F2"); uiObject.SetScoreText(currentBrainController.Score.ToString()); uiObject.SetTurnText(currentBrainController.TurnOutput.ToString()); uiObject.SetCarIdText(currentBrainController.Id); mainGameObject.CameraFollowCar(currentBrainController.CarObjectId, deltaTime); } }
private void ReplayEvent(EventModelBase modelBase, float currentTimeSinceStartSeconds) { var eventType = modelBase.EventType; var instruction = _replayInstructions.Find(instr => instr.Name == eventType); if (instruction != null) { if (!instruction.EnableReplay) { if (modelBase is ComponentEventModel comp) { _debugger.Log($"Replay disabled time:{currentTimeSinceStartSeconds:0.00}, type:{comp.EventType}, gameObject:{comp.GameObjectName}, comp:{comp.ComponentType}"); } else { _debugger.Log($"Replay disabled time:{currentTimeSinceStartSeconds:0.00}, type:{modelBase.EventType}"); } return; } if (modelBase is ComponentEventModel compo) { _debugger.Log($"Replaying Event: time:{currentTimeSinceStartSeconds:0.00}, type:{compo.EventType}, gameObject:{compo.GameObjectName}, comp:{compo.ComponentType}"); } else { _debugger.Log($"Replaying Event: time:{currentTimeSinceStartSeconds:0.00}, type:{modelBase.EventType}"); } instruction.Replay(modelBase); return; } _debugger.LogWarning($"No event type found named:{eventType}"); }
public string OnHandUpdate(IHand hand) { // move up and out to text writer var side = hand.Side(); var gesture = gestures.GestureFor(side); // debug.Log("hand side: " + hand.Side()); // yes this is a bit odd, around construction-time access to vrtk // instances - have a look sometime when on vive setup gesture.hand = hand; gesture.OnHandUpdate(hand); debug.Log("text: " + text + ", words: " + String.Join(", ", words.ToArray())); return(text); }
public string OnHandUpdate(IHand hand) { if (!hand.IsPresent()) { ReleaseAllKnobs(); return(text); } debug.Log("hand position: " + hand.Centre()); debug.Log("text: " + text); var closest = knobs.FindClosestTo(hand); // debug.Log("Closest: " + closest); if (closest == null) { HandleAwayFromKnobs(); // debug.Log("Nearly grabbed things: " + string.Join(", ", close_things.ToList().Select(t => t.name).ToArray())); return(text); } HandleCloseToKnob(hand, closest); return(text); }