Esempio n. 1
0
        private void setNextWalk(IObject target, IFollowSettings settings, IWalkComponent walk)
        {
            if (isInAllowedDistance(target, settings) && MathUtils.Random().Next(100) <= settings.StayPutPercentage)
            {
                return;
            }

            PointF targetPoint = PointF.Empty;
            int    retries     = 3;

            while (retries > 0)
            {
                targetPoint = getFollowTargetPoint(target, settings);
                if (isWalkingDistanceValid(targetPoint, settings))
                {
                    break;
                }
                retries--;
            }

            if (retries <= 0)
            {
                Debug.WriteLine($"FollowComponent: Failed to get a target point which is not too close");
                return;
            }

            _currentWalk = walk.WalkAsync(new Position(targetPoint.X, targetPoint.Y));
        }
Esempio n. 2
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IWalkComponent>(c => _walk       = c, _ => _walk = null);
     Entity.Bind <IHasRoomComponent>(c => _hasRoom = c, _ => _hasRoom = null);
     Entity.Bind <ITranslateComponent>(c => _obj   = c, _ => _obj = null);
 }
Esempio n. 3
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     _follower = entity;
     entity.Bind <IWalkComponent>(c => _walk       = c, _ => _walk = null);
     entity.Bind <IHasRoomComponent>(c => _hasRoom = c, _ => _hasRoom = null);
     entity.Bind <ITranslateComponent>(c => _obj   = c, _ => _obj = null);
 }
Esempio n. 4
0
 public override void Init()
 {
     base.Init();
     _characterName = Entity.ID;
     Entity.Bind <IWorldPositionComponent>(c => _emitter.WorldPosition = c, _ => _emitter.WorldPosition = null);
     Entity.Bind <IHasRoomComponent>(c => _emitter.HasRoom             = c, _ => _emitter.HasRoom = null);
     Entity.Bind <IFaceDirectionComponent>(c => _faceDirection         = c, _ => _faceDirection = null);
     Entity.Bind <IOutfitComponent>(c => _outfit      = c, _ => _outfit = null);
     Entity.Bind <IWalkComponent>(c => _walkComponent = c, _ => _walkComponent = null);
 }
Esempio n. 5
0
        private void setNextWalk(IObject target, IFollowSettings settings, IWalkComponent walk)
        {
            PointF targetPoint;

            if (MathUtils.Random().Next(100) <= settings.WanderOffPercentage)
            {
                targetPoint = wanderOff();
            }
            else
            {
                targetPoint = follow(target, settings);
            }

            _currentWalk = walk.WalkAsync(new Position(targetPoint.X, targetPoint.Y));
        }
Esempio n. 6
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IFaceDirectionComponent>(c => _faceDirection = c, _ => _faceDirection = null);
     Entity.Bind <IWalkComponent>(c => _walk = c, _ => _walk = null);
 }
Esempio n. 7
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IWalkComponent>(c => _walk           = c, _ => _walk = null);
     Entity.Bind <ITranslateComponent>(c => _translate = c, _ => _translate = null);
 }