public bool Act(IContext context)
    {
        IFollower follower = (IFollower)context.GetVariable("IFollower");

        follower.SetNextWaypoint(follower.GetNextWaypoint());
        return(true);
    }
Example #2
0
    public bool Act(IContext context)
    {
        IWalker         walker          = (IWalker)context.GetVariable("IWalker");
        IFollower       follower        = (IFollower)context.GetVariable("IFollower");
        FacingDirection facingDirection = walker.GetFacingDirection();

        float maxWalkingSpeed = walker.GetWalkerSpeed();
        //= (float)context.GetVariable("maxWalkingSpeed");

        Vector2 myPosition = walker.GetWalkerTransform().position;
        Vector2 direction  = follower.GetCurrentWaypoint().GetWaypointPosition() - myPosition;

        direction.Normalize();

        if (direction.x > 0)
        {
            if (facingDirection == FacingDirection.LEFT)
            {
                walker.ChangeDirection(FacingDirection.RIGHT);
            }
            walker.MoveRight(maxWalkingSpeed);
        }
        else if (direction.x < 0)
        {
            if (facingDirection == FacingDirection.RIGHT)
            {
                walker.ChangeDirection(FacingDirection.LEFT);
            }
            walker.MoveLeft(maxWalkingSpeed);
        }
        return(true);
    }
Example #3
0
 public void Unfollow(IFollower follower)
 {
     followerList.Remove(follower);
     Console.WriteLine("Unfollow");
 }
Example #4
0
 public void Follow(IFollower follower)
 {
     followerList.Add(follower);
     Console.WriteLine("New follower");
 }
Example #5
0
 public RemoteSensoredGearbox(float unitsPerRevolution, IMotorController mc0, IFollower mc1, IFollower mc2, RemoteFeedbackDevice remoteFeedbackDevice) : this(unitsPerRevolution, mc0, new IFollower[] { mc1, mc2 }, remoteFeedbackDevice)
 {
 }
 public Gearbox(IMotorController mc0, IFollower mc1, IFollower mc2, IFollower mc3) : base(mc0, mc1, mc2, mc3)
 {
 }
 public Gearbox(IMotorController mc0, IFollower mc1) : base(mc0, mc1)
 {
 }
Example #8
0
        public void send(string message, UserAccount sender)
        {
            lock (chatLog)
            {
                int row = chatLog.Rows.Add();
                chatLog.Rows[row].Cells["chatNameColumn"].Value    = sender.Username;
                chatLog.Rows[row].Cells["chatMessageColumn"].Value = message;

                //Autoscroll down
                int displayed = chatLog.DisplayedRowCount(true);
                if (chatLog.FirstDisplayedScrollingRowIndex >= 0 && displayed < chatLog.RowCount)
                {
                    chatLog.FirstDisplayedScrollingRowIndex = chatLog.RowCount - displayed;
                }
            }

            //Determine who the message should be directed to
            UserAccount target       = null;
            string      selectedName = userStatusGridView.SelectedRows[0].Cells[1].Value.ToString();

            //Split message into words
            string[] messagePieces = message.Split(new char [] { ',', ' ' });

            //Check if the message is directed to a chatbot
            foreach (UserAccount account in Accounts)
            {
                if (account.Owner != null && account.Owner is IChatBot)
                {
                    IChatBot bot = (IChatBot)account.Owner;

                    ///Check if the message contains a follower name
                    if (messagePieces.Length > 1)
                    {
                        //Check if the name is in the beginning of the message
                        if (messagePieces[0].ToUpper().IndexOf(bot.Profile.Name.ToUpper()) > -1)
                        {
                            target  = account;
                            message = message.Substring(messagePieces[0].Length);
                            break;
                        }
                        //Check if the username is in the beginning of the message
                        else if (messagePieces[0].ToUpper().IndexOf(account.Username.ToUpper()) > -1)
                        {
                            target  = account;
                            message = message.Substring(messagePieces[0].Length);
                            break;
                        }
                        //Check if the name is in the end of the message
                        else if (messagePieces[messagePieces.Length - 1].ToUpper().IndexOf(bot.Profile.Name.ToUpper()) > -1)
                        {
                            target  = account;
                            message = message.Substring(0, message.Length - messagePieces[messagePieces.Length - 1].Length);
                            break;
                        }
                        //Check if the username is in the end of the message
                        else if (messagePieces[messagePieces.Length - 1].ToUpper().IndexOf(account.Username.ToUpper()) > -1)
                        {
                            target  = account;
                            message = message.Substring(0, message.Length - messagePieces[messagePieces.Length - 1].Length);
                            break;
                        }
                    }

                    //Direct the message to follower selected given that the message might not contain a follower name
                    if (target == null && account.Username.Equals(selectedName) && account.Status == ChatStatus.Available)
                    {
                        target = account;
                    }
                }
            }

            if (target != null && target.Owner != null)
            {
                //Target must be a chat bot
                ((IChatBot)target.Owner).receive(new ChatMessage(this, sender, target, new TextMessage(message)));
            }

            UserAccount lastListener = null;

            //Direct all followers who is available to listen to the message
            foreach (UserAccount account in Accounts)
            {
                if (account.Owner != null && account.Owner is IFollower && target != account && account.Status == ChatStatus.Available)
                {
                    lastListener = account;
                    IFollower follower = (IFollower)account.Owner;
                    follower.listen(new ChatMessage(this, sender, account, new TextMessage(message)));
                }
            }

            //Select the (last) follower in current conversation
            if (target != null && target.Owner != null)
            {
                userStatusGridView.Rows[statusTableBS.Find("Name", target.Username)].Selected = true;
            }
            else if (lastListener != null)
            {
                userStatusGridView.Rows[statusTableBS.Find("Name", lastListener.Username)].Selected = true;
            }
        }
    public bool ConditionPassed(IContext context)
    {
        IFollower follower = (IFollower)context.GetVariable("IFollower");

        return(follower.GetCurrentWaypoint().Reached((IWalker)follower));
    }
Example #10
0
 public void Initalize(IEntity pEntity, int pID)
 {
     _mFollower = (IFollower)pEntity;
     _bevID     = pID;
     _removeBev = false;
 }
Example #11
0
 public void Follow(IFollower follower)
 {
     followerList.Add(follower);
     Console.WriteLine("Новый подписчик");
 }
Example #12
0
 public void AddDirectReport(IFollower directReport)
 {
     _followers.Add(directReport);
 }
Example #13
0
 public Linkage(IMotorController mc0, IFollower mc1, IFollower mc2, IFollower mc3) : this(mc0, new IFollower[] { mc1, mc2, mc3 })
 {
 }
Example #14
0
 public Linkage(IMotorController mc0, IFollower mc1) : this(mc0, new IFollower[] { mc1 })
 {
 }
 public SensoredGearbox(float unitsPerRevolution, IMotorControllerEnhanced mc0, IFollower mc1, IFollower mc2, FeedbackDevice feedbackDevice)
     : this(unitsPerRevolution, mc0, new IFollower[] { mc1, mc2 }, feedbackDevice)
 {
 }