Exemplo n.º 1
0
        /* Move the pack to an adjacent node. */
        public void move(Node u, Node playerlocation = null)
        {
            if (u == location)
            {
                return;
            }
            if (!location.neighbors.Contains(u) || u == null)
            {
                throw new ArgumentException();
            }
            uint capacity = dungeon.M * (dungeon.level(u) + 1);

            if (u.CountCreatures() + this.members.Count() >= capacity)
            {
                Logger.log("Pack " + id + " is trying to move to an already full node " + u.id + ". Rejected.");
                //throw new ArgumentException();
            }
            else if (u == dungeon.exitNode)
            {
                Logger.log("Pack " + id + " is trying to move to the exit node, rejected.");
                // throw new ArgumentException();
            }
            else
            {
                location.packs.Remove(this);
                location = u;
                if (location == playerlocation && members.Count > 0)
                {
                    location.contested = true;
                }
                foreach (Monster m in members.ToList())
                {
                    m.location = u;
                }
                u.packs.Add(this);
            }
        }