// find all origami close to the given origami // and send the message to the origami public void SendSignal(DTGameObject gameObject, string signal) { if (!gameObject.Equals(null)) { List <Origami> origamis = GameManagerObj.GetComponent <GameManager>().origamis; foreach (DTGameObject o in origamis) { if (o.Name.Contains("ORI")) { Origami origami = (Origami)o; if (gameObject is Origami otherOrigami) { if (IsInRange(otherOrigami.GameObject, origami.GameObject, GameManager.OrigamiDZRADIUS) && (!gameObject.Name.Equals(origami.Name))) { origami.AddSignal(signal); } } else if (gameObject is Obstacle obstacle) { if (IsInRange(origami.GameObject, obstacle.GameObject, GameManager.ObstacleDZRADIUS)) { o.AddSignal(signal); GetComponent <Swarm_behaviour>().newObstacle = true; GetComponent <Swarm_behaviour>().ObstaclePattern = obstacle.Pattern; print("Sent Pattern: " + obstacle.Pattern); } } } } } }
public void AddSignal(string signal) { if (signal.Equals("Awake")) { Awake = true; sentasignal = false; } else if (Awake) { receivedSignals.Add(signal); Awake = false; if (!sentasignal) { sentasignal = true; List <Origami> origamis = GetComponent <GameManager>().origamis; foreach (DTGameObject o in origamis) { if (o.Name.Contains("ORI") && this is Origami) { Origami otherOrigami = (Origami)o; Origami origami = (Origami)this; if (IsInRange(origami.GameObject, otherOrigami.GameObject, GameManager.OrigamiDZRADIUS) && (!origami.Equals(otherOrigami))) { otherOrigami.AddSignal(signal); } } } } } }
public void AwakeOrigami() { List <Origami> origamis = GameManagerObj.GetComponent <GameManager>().origamis; foreach (DTGameObject o in origamis) { if (o.Name.Contains("ORI")) { Origami origami = (Origami)o; origami.AddSignal("Awake"); } } }