public static HomingComponent CreateDefaultHomingCircle( GameObject owner, BodyComponent bodyComponentToMove, float sensorRadius, HomingType homingType, float homingSpeed) { var tsc = new TargetSensorComponent(owner) { TargetCollisionCategories = CollisionCategory.Owliver, SensorType = TargetSensorType.Circle, CircleSensorRadius = sensorRadius, }; tsc.AttachTo(bodyComponentToMove); var hoc = new HomingComponent(owner) { BodyComponentToMove = bodyComponentToMove, TargetSensor = tsc, Speed = homingSpeed, HomingType = homingType, DebugDrawingEnabled = true, }; hoc.AttachTo(bodyComponentToMove); return(hoc); }
public SpikeTrap() { FixedOrigin = new SpatialComponent(this); TargetSensor = new TargetSensorComponent(this) { SensorType = TargetSensorType.Rectangle, TargetCollisionCategories = CollisionCategory.Friendly, }; TargetSensor.AttachTo(FixedOrigin); MovingBodyComponent = new BodyComponent(this) { InitMode = BodyComponentInitMode.Manual, }; RootComponent = MovingBodyComponent; Animation = new SpriteAnimationComponent(this) { AnimationTypes = new List <SpriteAnimationType> { SpriteAnimationType.Shopkeeper_Idle_Front }, }; Animation.AttachTo(this); }
public Singer() { BodyComponent = new BodyComponent(this) { InitMode = BodyComponentInitMode.Manual, }; RootComponent = BodyComponent; TargetSensor = new TargetSensorComponent(this) { SensorType = TargetSensorType.Circle, CircleSensorRadius = SensorReach, TargetCollisionCategories = CollisionCategory.Friendly, }; TargetSensor.AttachTo(RootComponent); Animation = new SpriteAnimationComponent(this) { AnimationTypes = new List <SpriteAnimationType> { SpriteAnimationType.Singer_Idle_Left, SpriteAnimationType.Singer_Idle_Right, }, }; Animation.AttachTo(RootComponent); Health = GameObjectFactory.CreateDefaultHealth(this, maxHealth: 3, hitDuration: HitDuration, deathParticleTimeToLive: TimeSpan.FromSeconds(1)); HealthDisplay = new HealthDisplayComponent(this) { Health = Health, HealthIcon = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross), }; HealthDisplay.AttachTo(Animation); }