Exemplo n.º 1
0
        /// <summary>
        /// Safely shuts this virtualBot down and tidies up all resources.
        /// </summary>
        internal void Kill()
        {
            try { aiHandler.Abort(); }
            catch { }

            aiHandler       = null;
            Room            = null;
            Statuses        = null;
            Coords          = null;
            Sayings         = null;
            Shouts          = null;
            chatTriggers    = null;
            Customer        = null;
            customerTrigger = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invoked by a virtualRoomUser. There is checked if this bot reacts on a certain chat message, if so, then replies/orders etc are processed.
        /// </summary>
        /// <param name="roomUser">The virtualRoomUser object that interacts with this bot by saying a message.</param>
        /// <param name="Message">The message that the virtualRoomUser said to this bot.</param>
        internal void Interact(virtualRoomUser roomUser, string Message)
        {
            Message = Message.ToLower();
            string[] messageWords = Message.Split(' ');
            if (chatTriggers != null)
            {
                foreach (chatTrigger Trigger in chatTriggers)
                {
                    for (int i = 0; i < messageWords.Length; i++)
                    {
                        if (Trigger.containsWord(messageWords[i]))
                        {
                            if (Trigger.serveItem != "") // Serve an item, walk up to the customer and hand over the beverage
                            {
                                if (Customer != null)    // The bot is currently serving a different room user, ignore this trigger
                                {
                                    return;
                                }

                                Coord Closest = getClosestWalkCoordTo(roomUser.X, roomUser.Y);
                                if (Closest.X == -1) // Can't serve this user (no square close enough)
                                {
                                    return;
                                }

                                Room.sendSaying(this, Trigger.Reply);
                                removeStatus("dance");
                                addStatus("carryd", Trigger.serveItem); // Make the bot starting to carry the order to deliver it
                                goalX                = Closest.X;
                                goalY                = Closest.Y;
                                this.Customer        = roomUser;
                                this.customerTrigger = Trigger;
                            }
                            else
                            {
                                this.Z1 = Rotation.Calculate(X, Y, roomUser.X, roomUser.Y);
                                this.Z2 = this.Z1;
                                Room.sendSaying(this, Trigger.Reply);
                            }
                            return; // One trigger per time
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// If the bot currently is processing an order, then it'll hand over the order and prepare for a new one.
        /// </summary>
        internal void checkOrders()
        {
            if (Customer != null)
            {
                {
                    goalX = -1;
                    Rotate(Customer.X, Customer.Y);
                    removeStatus("carryd");
                    Room.sendSaying(this, customerTrigger.serveReply);

                    if (Customer.statusManager.containsStatus("sit") == false)
                    {
                        Customer.Z1 = Rotation.Calculate(Customer.X, Customer.Y, X, Y);
                        Customer.Z2 = Customer.Z1;
                    }
                    Customer.statusManager.carryItem(customerTrigger.serveItem);
                }

                {
                    Customer        = null;
                    customerTrigger = null;
                }
            }
        }
        /// <summary>
        /// Safely shuts this virtualBot down and tidies up all resources.
        /// </summary>
        internal void Kill()
        {
            try { aiHandler.Abort(); }
            catch { }

            aiHandler = null;
            Room = null;
            Statuses = null;
            Coords = null;
            Sayings = null;
            Shouts = null;
            chatTriggers = null;
            Customer = null;
            customerTrigger = null;
        }
        /// <summary>
        /// Invoked by a virtualRoomUser. There is checked if this bot reacts on a certain chat message, if so, then replies/orders etc are processed.
        /// </summary>
        /// <param name="roomUser">The virtualRoomUser object that interacts with this bot by saying a message.</param>
        /// <param name="Message">The message that the virtualRoomUser said to this bot.</param>
        internal void Interact(virtualRoomUser roomUser, string Message)
        {
            Message = Message.ToLower();
            string[] messageWords = Message.Split(' ');
            if (chatTriggers != null)
            {
                foreach (chatTrigger Trigger in chatTriggers)
                {
                    for (int i = 0; i < messageWords.Length; i++)
                    {
                        if (Trigger.containsWord(messageWords[i]))
                        {
                            if (Trigger.serveItem != "") // Serve an item, walk up to the customer and hand over the beverage
                            {
                                if (Customer != null) // The bot is currently serving a different room user, ignore this trigger
                                    return;

                                Coord Closest = getClosestWalkCoordTo(roomUser.X, roomUser.Y);
                                if (Closest.X == -1) // Can't serve this user (no square close enough)
                                    return;

                                Room.sendSaying(this, Trigger.Reply);
                                removeStatus("dance");
                                addStatus("carryd", Trigger.serveItem); // Make the bot starting to carry the order to deliver it
                                goalX = Closest.X;
                                goalY = Closest.Y;
                                this.Customer = roomUser;
                                this.customerTrigger = Trigger;
                            }
                            else
                            {
                                this.Z1 = Rotation.Calculate(X,Y,roomUser.X,roomUser.Y);
                                this.Z2 = this.Z1;
                                Room.sendSaying(this, Trigger.Reply);
                            }
                            return; // One trigger per time
                        }
                    }
                }
            }
        }
        /// <summary>
        /// If the bot currently is processing an order, then it'll hand over the order and prepare for a new one.
        /// </summary>
        internal void checkOrders()
        {
            if (Customer != null)
            {
                {
                    goalX = -1;
                    Rotate(Customer.X, Customer.Y);
                    removeStatus("carryd");
                    Room.sendSaying(this, customerTrigger.serveReply);

                    if (Customer.statusManager.containsStatus("sit") == false)
                    {
                        Customer.Z1 = Rotation.Calculate(Customer.X, Customer.Y, X, Y);
                        Customer.Z2 = Customer.Z1;
                    }
                    Customer.statusManager.carryItem(customerTrigger.serveItem);
                }

                {
                    Customer = null;
                    customerTrigger = null;
                }
            }
        }