// Co-routine to check if person is alive or not IEnumerator checkAlive() { while (true) { ArrayList ids = new ArrayList(); foreach (KeyValuePair <int, AugmentaPerson> p in AugmentaPoints) { ids.Add(p.Key); } foreach (int id in ids) { if (AugmentaPoints.ContainsKey(id)) { AugmentaPerson p = AugmentaPoints[id]; if (p.inactiveTime < PointTimeOut) { //Debug.Log("***: IS ALIVE"); // We add a frame to the inactiveTime count p.inactiveTime += Time.deltaTime; } else { //Debug.Log("***: DESTROY"); // The point hasn't been updated for a certain number of frames : remove SendAugmentaEvent(AugmentaEventType.PersonWillLeave, p); AugmentaPoints.Remove(id); } } } ids.Clear(); yield return(0); } }
private void updatePerson(AugmentaPerson p, ArrayList args) { p.pid = (int)args[0]; p.oid = (int)args[1]; p.age = (int)args[2]; var centroid = new Vector3((float)args[3], (float)args[4]); var velocity = new Vector3((float)args[5], (float)args[6]); var boudingRect = new Vector3((float)args[8], (float)args[9]); var highest = new Vector3((float)args[12], (float)args[13]); if (FlipX) { centroid.x = 1 - centroid.x; velocity.x = -velocity.x; boudingRect.x = 1 - boudingRect.x; highest.x = 1 - highest.x; } if (FlipY) { centroid.y = 1 - centroid.y; velocity.y = -velocity.y; boudingRect.y = 1 - boudingRect.y; highest.y = 1 - highest.y; } p.centroid = centroid; p.AddVelocity(velocity); p.depth = (float)args[7]; p.boundingRect.x = boudingRect.x; p.boundingRect.y = boudingRect.y; p.boundingRect.width = (float)args[10]; p.boundingRect.height = (float)args[11]; p.highest.x = highest.x; p.highest.y = highest.y; p.highest.z = (float)args[14]; NbAugmentaPoints = AugmentaPoints.Count; p.Position = transform.TransformPoint(new Vector3(p.centroid.x - 0.5f, -(p.centroid.y - 0.5f), p.centroid.z)); // Inactive time reset to zero : the point has just been updated p.inactiveTime = 0; _orderedPids.Sort(delegate(int x, int y) { if (x == y) { return(0); } else if (x < y) { return(-1); } else { return(1); } }); }
private AugmentaPerson addPerson(ArrayList args) { AugmentaPerson newPerson = new AugmentaPerson(); newPerson.Init(); updatePerson(newPerson, args); AugmentaPoints.Add(newPerson.pid, newPerson); _orderedPids.Add(newPerson.pid); return(newPerson); }
public virtual void PersonUpdated(AugmentaPerson p) { if (InstantiatedObjects.ContainsKey(p.pid)) { p.VelocitySmooth = VelocityAverageValueCount; } else { PersonEntered(p); } }
public override void PersonUpdated(AugmentaPerson p) { if (InstantiatedObjects.ContainsKey(p.pid)) { InstantiatedObjects[p.pid].GetComponent <AugmentaPersonDebugger>().MyAugmentaPerson = p; p.VelocitySmooth = VelocityAverageValueCount; } else { PersonEntered(p); } }
public void SendAugmentaEvent(AugmentaEventType type, AugmentaPerson person = null) { if (ActualPointType == AugmentaPointType.Oldest && type != AugmentaEventType.SceneUpdated) { var askedOldest = GetOldestPoints(AskedPoints); if (!askedOldest.Contains(person)) { type = AugmentaEventType.PersonWillLeave; } } if (ActualPointType == AugmentaPointType.Newest && type != AugmentaEventType.SceneUpdated) { var askedNewest = GetNewestPoints(AskedPoints); if (!askedNewest.Contains(person)) { type = AugmentaEventType.PersonWillLeave; } } switch (type) { case AugmentaEventType.PersonEntered: if (personEntered != null) { personEntered(person); } break; case AugmentaEventType.PersonUpdated: if (personUpdated != null) { personUpdated(person); } break; case AugmentaEventType.PersonWillLeave: if (personLeaving != null) { personLeaving(person); } break; case AugmentaEventType.SceneUpdated: if (sceneUpdated != null) { sceneUpdated(augmentaScene); } break; } }
public virtual void PersonLeft(AugmentaPerson p) { if (InstantiatedObjects.ContainsKey(p.pid)) { var augBehaviour = InstantiatedObjects[p.pid].GetComponent <AugmentaPersonBehaviour>(); if (augBehaviour != null) { augBehaviour.Disappear(); } else { HandleDisappearedObject(p.pid); } } }
public virtual void PersonEntered(AugmentaPerson p) { if (!InstantiatedObjects.ContainsKey(p.pid)) { var newObject = Instantiate(PrefabToInstantiate, p.Position, Quaternion.identity, this.transform); newObject.transform.localRotation = Quaternion.Euler(Vector3.zero); InstantiatedObjects.Add(p.pid, newObject); var augBehaviour = newObject.GetComponent <AugmentaPersonBehaviour>(); if (augBehaviour != null) { augBehaviour.pid = p.pid; augBehaviour.disappearAnimationCompleted += HandleDisappearedObject; augBehaviour.Appear(); } } }
public void OSCMessageReceived(OSCMessage message) { if (Mute) { return; } string address = message.Address; ArrayList args = new ArrayList(message.Data); //message.Data.ToArray(); //Debug.Log("OSC received with address : "+address); if (address == "/au/personEntered/" || address == "/au/personEntered") { int pid = (int)args[0]; AugmentaPerson currentPerson = null; if (!AugmentaPoints.ContainsKey(pid)) { currentPerson = addPerson(args); SendAugmentaEvent(AugmentaEventType.PersonEntered, currentPerson); } else { currentPerson = AugmentaPoints[pid]; updatePerson(currentPerson, args); SendAugmentaEvent(AugmentaEventType.PersonUpdated, currentPerson); } } else if (address == "/au/personUpdated/" || address == "/au/personUpdated") { int pid = (int)args[0]; AugmentaPerson currentPerson = null; if (!AugmentaPoints.ContainsKey(pid)) { currentPerson = addPerson(args); SendAugmentaEvent(AugmentaEventType.PersonEntered, currentPerson); } else { currentPerson = AugmentaPoints[pid]; updatePerson(currentPerson, args); SendAugmentaEvent(AugmentaEventType.PersonUpdated, currentPerson); } } else if (address == "/au/personWillLeave/" || address == "/au/personWillLeave") { int pid = (int)args[0]; if (AugmentaPoints.ContainsKey(pid)) { AugmentaPerson personToRemove = AugmentaPoints[pid]; SendAugmentaEvent(AugmentaEventType.PersonWillLeave, personToRemove); _orderedPids.Remove(personToRemove.pid); _orderedPids.Sort(delegate(int x, int y) { if (x == y) { return(0); } else if (x < y) { return(-1); } else { return(1); } }); AugmentaPoints.Remove(pid); } } else if (address == "/au/scene/" || address == "/au/scene") { augmentaScene.Width = (int)args[5]; augmentaScene.Height = (int)args[6]; AspectRatio = (augmentaScene.Width / augmentaScene.Height); transform.localScale = new Vector3(augmentaScene.Width * (MeterPerPixel) * Zoom, augmentaScene.Height * (MeterPerPixel) * Zoom, 1.0f); SendAugmentaEvent(AugmentaEventType.SceneUpdated); } else { print(address + " "); } }
public override void PersonEntered(AugmentaPerson p) { base.PersonEntered(p); InstantiatedObjects[p.pid].GetComponent <AugmentaPersonDebugger>().BorderColor = Color.HSVToRGB(UnityEngine.Random.value, 0.85f, 0.75f); }