public void RemoveMember(AbstractBot bot) { if (Group == null) { Group = new Dictionary <string, AbstractBot>(); } bot.Leader = null; Group.Remove(bot.BotId); }
public bool AddMember(AbstractBot bot) { if (bot.BotId == null) { return(false); } if (Group == null) { Group = new Dictionary <string, AbstractBot>(); } // bot.MAngent.destination = this.transform.position; bot.Leader = this; Group.Add(bot.BotId, bot); return(true); }
void OnCollisionEnter(Collision collision) { if (!this.IsLeader) { return; } GameObject o = collision.gameObject; if (!PotatoTags.BOT.Equals(o.tag)) { return; } MonoBehaviour b = o.GetComponent <MonoBehaviour>(); AbstractBot bot = (AbstractBot)b; if (bot.Leader == this) { return; } bot.UpdateColor(this.GetMainColor()); if (bot.Leader != null) { bot.Leader.RemoveMember(bot); } bool ok = this.AddMember(bot); if (ok) { bot.ChangeRunStatus(true); } // print("collision==>" + o + ":" + b.GetType().Name); }
public void Follow(AbstractBot leader) { MoveTo(leader.transform.position); }