Beispiel #1
0
        protected override void UpdateBehaviour(float elapsedSeconds, float totalSeconds)
        {
            // Switch to next state after some time
            if (timerForChange.Tick(elapsedSeconds))
            {
                SwitchToOutputState();
            }

            Body body     = this.Entity.Body;
            var  position = body.Position;
            var  rotation = body.Rotation;

            Vector2 desiredPosition = position + VectorExtensions.AngleToUnitVector(rotation) * CircleCenterOffset;

            desiredPosition += VectorExtensions.AngleToUnitVector(RandomExt.GetRandomAngle()) * CircleRadius;

            Vector2 direction = (desiredPosition - position);

            movement.Speed        = RandomExt.GetRandomFloat(WanderingSpeedMin, WanderingSpeedMax);
            movement.TurningSpeed = MaxTurningSpeed;
            movement.Steer(direction, Weight);
        }