public override void Initialize(Section owner) { base.Initialize(owner); graphics = (ComplexGraphicsObject)ContentPackageManager.GetGraphicsResource("SMBBuzzyBeetle"); HealthComponent health = new HealthComponent(1, 1, new string[] { SpriteDamageTypes.PlayerFireball, SpriteDamageTypes.PlayerStomp }); health.SpriteKilled += Health_SpriteKilled; SpriteDirection initialDirection = ResolveDirection(this, Direction, Owner); facingDirection = (initialDirection == SpriteDirection.Left) ? SMLimitless.Direction.Left : SMLimitless.Direction.Right; Components.Add(health); Components.Add(new WalkerComponent(this, initialDirection, WalkingSpeed.Value)); Components.Add(new DamageComponent()); Components.Add(new ChasePlayerComponent(this, 60)); ShelledEnemyComponent shelledEnemy = new ShelledEnemyComponent(this, WalkingSpeed.Value, ShellSpinningSpeed.Value, FramesUntilBeginEmerge.Value, FramesUntilEmerge.Value); shelledEnemy.StateChanged += ShelledEnemy_StateChanged; Components.Add(shelledEnemy); }
public override void Update() { base.Update(); if (Velocity.X < 0f && facingDirection == SMLimitless.Direction.Right) { facingDirection = SMLimitless.Direction.Left; var walker = GetComponent<WalkerComponent>(); if (walker != null) { walker.Direction = facingDirection; } } else if (Velocity.X > 0f && facingDirection == SMLimitless.Direction.Left) { facingDirection = SMLimitless.Direction.Right; var walker = GetComponent<WalkerComponent>(); if (walker != null) { walker.Direction = facingDirection; } } graphics.Update(); }