Beispiel #1
0
        private async Task onRepeatedlyExecute(object sender, AGSEventArgs args)
        {
            var target         = TargetBeingFollowed;
            var currentWalk    = _currentWalk;
            var followSettings = _followSettings;

            if (target == null || followSettings == null)
            {
                if (currentWalk != null)
                {
                    _walk.StopWalking();
                }
                return;
            }
            if (target == _lastTarget)
            {
                if (currentWalk != null && !currentWalk.IsCompleted)
                {
                    return;
                }
            }
            _lastTarget = target;
            if (_counter > 0)
            {
                if (_hasRoom.Room != target.Room && _newRoomX == null)
                {
                    _newRoomX = target.X;
                    _newRoomY = target.Y;
                }
                _counter--;
                return;
            }
            _counter = MathUtils.Random().Next(_followSettings.MinWaitBetweenWalks, _followSettings.MaxWaitBetweenWalks);
            if (_hasRoom.Room != target.Room)
            {
                if (_followSettings.FollowBetweenRooms)
                {
                    await _hasRoom.ChangeRoomAsync(target.Room, _newRoomX, _newRoomY);

                    _walk.PlaceOnWalkableArea();
                    _newRoomX = null;
                    _newRoomY = null;
                }
                return;
            }
            setNextWalk(target, followSettings);
        }
 public void PlaceOnWalkableArea()
 {
     _walkBehavior.PlaceOnWalkableArea();
 }