public void addSighting(LabelHandle target, Vector3 position, Vector3?direction) { if (targetSightings.ContainsKey(target)) { SensoryInfo info = targetSightings[target]; if (info.getSightings() == 0) { // We have to increment the sighting count before we notify listeners info.addSighting(); notifyListenersTargetFound(target); } else { // Keep this. See above comment info.addSighting(); } info.updatePosition(position); info.updateDirection(direction); } else { targetSightings[target] = new SensoryInfo(position, direction, 1); notifyListenersTargetFound(target); } }
//Compiles all available info into one struct SensoryInfo CompileSensoryInfo() { SensoryInfo info = new SensoryInfo(); info._alertnessState = CurrentAlertnessState; info.currentHealth = _hc.GetHealth(); info.playerHealth = _player.GetComponent <HealthController>().GetHealth(); info.isSeeingPlayer = isSeeingPlayer; info.hasSeenPlayer = hasSeenPlayer; info.hasHeardPlayer = hasHeardPlayer; info.hearsGlobalAlert = hearsGlobalAlert; return(info); }
public void removeSighting(LabelHandle target, Vector3 position, Vector3? direction) { if (targetSightings.ContainsKey (target)) { SensoryInfo info = targetSightings[target]; info.removeSighting(); if (info.getSightings() < 1) { notifyListenersTargetLost (target); } info.updatePosition(position); } else { //Realistically we should never get here. This case is stupid. targetSightings[target] = new SensoryInfo(position, direction, 0); notifyListenersTargetLost (target); Debug.LogWarning("Target '" + target.getName() + "' that was never found has been lost. Shenanigans?"); } }
public void addSighting(LabelHandle target, Vector3 position, Vector3? direction) { if (targetSightings.ContainsKey (target)) { SensoryInfo info = targetSightings[target]; info.addSighting(); info.updateInfo(target); } else { if (staleTargetSightings.ContainsKey(target)) { SensoryInfo info = staleTargetSightings[target]; targetSightings.Add(target, info); staleTargetSightings.Remove(target); info.addSighting(); } else { targetSightings[target] = new SensoryInfo(position, direction, System.DateTime.Now, target.getTags(), 1); } registerTags(target); notifyListenersTargetFound(target); } }
public void addSighting(LabelHandle target, Vector3 position, Vector3? direction) { if (targetSightings.ContainsKey (target)) { SensoryInfo info = targetSightings[target]; if (info.getSightings() == 0) { // We have to increment the sighting count before we notify listeners info.addSighting(); notifyListenersTargetFound(target); } else { // Keep this. See above comment info.addSighting(); } info.updatePosition(position); info.updateDirection(direction); } else { targetSightings[target] = new SensoryInfo(position, direction, System.DateTime.Now, 1); notifyListenersTargetFound(target); } }
private void lookAround() { clearLines(); bool hasPower = (powerSource != null) && powerSource.hasPower(Time.deltaTime); foreach (Label label in Label.visibleLabels) { bool targetInView = hasPower && canSee(label.transform); if (targetInView) { if (!targetMap.ContainsKey(label)) { Rigidbody labelRB = label.GetComponent <Rigidbody>(); if (labelRB != null) { targetMap[label] = new SensoryInfo(label.transform.position, labelRB.velocity, System.DateTime.Now, 0); } else { targetMap[label] = new SensoryInfo(label.transform.position, null, System.DateTime.Now, 0); } } if (targetMap[label].getSightings() == 0) { //print("target sighted: " + label.name); roboController.enqueueMessage(new RobotMessage(RobotMessage.MessageType.TARGET_SIGHTED, "target sighted", label.labelHandle, label.transform.position, targetMap[label].getDirection())); targetMap[label].addSighting(); } targetMap[label].updatePosition(label.transform.position); } else { if (targetMap.ContainsKey(label) && targetMap [label].getSightings() == 1) { //print("target lost: " + label.name); roboController.enqueueMessage(new RobotMessage(RobotMessage.MessageType.TARGET_LOST, "target lost", label.labelHandle, targetMap[label].getPosition(), targetMap[label].getDirection())); targetMap[label].removeSighting(); } } } }
public void removeSighting(LabelHandle target, Vector3 position, Vector3?direction) { if (targetSightings.ContainsKey(target)) { SensoryInfo info = targetSightings[target]; info.removeSighting(); if (info.getSightings() < 1) { notifyListenersTargetLost(target); } info.updatePosition(position); } else { //Realistically we should never get here. This case is stupid. targetSightings[target] = new SensoryInfo(position, direction, 0); notifyListenersTargetLost(target); Debug.LogWarning("Target '" + target.getName() + "' that was never found has been lost. Shenanigans?"); } }
private void lookAround() { #if UNITY_EDITOR clearLines(); #endif bool hasPower = (powerSource != null) && powerSource.hasPower(Time.deltaTime); foreach (Label label in Label.visibleLabels) { if (label == null) { //TODO find a way to clean up this list //Label.visibleLabels.Remove(label); continue; } bool targetInView = hasPower && canSee(label.transform); if (targetInView) { if (!targetMap.ContainsKey(label)) { Rigidbody labelRB = label.GetComponent<Rigidbody>(); if (labelRB != null) { targetMap[label] = new SensoryInfo(label.transform.position, labelRB.velocity, System.DateTime.Now, label.getTags(), 0); } else { targetMap[label] = new SensoryInfo(label.transform.position, null, System.DateTime.Now, label.getTags(), 0); } } if (targetMap[label].getSightings() == 0) { registerSightingFound(label); } targetMap[label].updateInfo(label.labelHandle); } else { clearSighting(label); } } }
private void lookAround() { clearLines(); bool hasPower = (powerSource != null) && powerSource.hasPower(Time.deltaTime); foreach (Label label in Label.visibleLabels) { bool targetInView = hasPower && canSee (label.transform); if(targetInView) { if(!targetMap.ContainsKey(label)) { Rigidbody labelRB = label.GetComponent<Rigidbody>(); if (labelRB != null) { targetMap[label] = new SensoryInfo(label.transform.position, labelRB.velocity, System.DateTime.Now, 0); } else { targetMap[label] = new SensoryInfo(label.transform.position, null, System.DateTime.Now, 0); } } if(targetMap[label].getSightings() == 0) { //print("target sighted: " + label.name); roboController.enqueueMessage(new RobotMessage(RobotMessage.MessageType.TARGET_SIGHTED, "target sighted", label.labelHandle, label.transform.position, targetMap[label].getDirection())); targetMap[label].addSighting(); } targetMap[label].updatePosition(label.transform.position); } else { if (targetMap.ContainsKey(label) && targetMap [label].getSightings() == 1) { //print("target lost: " + label.name); roboController.enqueueMessage(new RobotMessage(RobotMessage.MessageType.TARGET_LOST, "target lost", label.labelHandle, targetMap[label].getPosition(), targetMap[label].getDirection())); targetMap[label].removeSighting(); } } } }