示例#1
0
        public void RemoveMember(AbstractBot bot)
        {
            if (Group == null)
            {
                Group = new Dictionary <string, AbstractBot>();
            }

            bot.Leader = null;
            Group.Remove(bot.BotId);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 public void Follow(AbstractBot leader)
 {
     MoveTo(leader.transform.position);
 }