public PlayerBrain(GameObject owner) : base(owner) { _movingBody = owner.Components.Get <MovingBody>(); _transform = owner.Components.Get <TransformComponent>(); _spriteRender = owner.Components.Get <SpriteRenderComponent>(); _halfSize = _spriteRender.Sprite.Bounds.Size / 2; _boundingBox = owner.Components.Get <BoundingBoxComponent>(); _boundingBox.OnCollision += (sender, collidedWith) => { this.Owner.Enabled = false; }; }
protected override ValueTask Init(GameContext game) { _inputService = game.GetService <InputService>(); _collisionService = game.GetService <CollisionService>(); _transform = this.Owner.Components.Get <TransformComponent>(); _renderer = this.Owner.Components.Get <SpriteRenderComponent>(); var map = game.SceneManager.Current.FindGameObjectByName(ObjectNames.Map); _mapRenderer = map.Components.Get <MapRenderComponent>(); return(base.Init(game)); }
protected override void Init() { _movingBody = Owner.Components.Get <MovingBody>(); _transform = Owner.Components.Get <TransformComponent>(); _spriteRender = Owner.Components.Get <SpriteRenderComponent>(); _halfSize = _spriteRender.Sprite.Bounds.Size / 2; _boundingBox = Owner.Components.Get <BoundingBoxComponent>(); _boundingBox.OnCollision += (sender, collidedWith) => { if (collidedWith.Owner.Components.TryGet <AsteroidBrain>(out var _)) { this.Stats.Health--; if (0 == this.Stats.Health) { this.Owner.Enabled = false; this.OnDeath?.Invoke(this.Owner); } } }; }
public LogoBrain(GameObject owner) : base(owner) { _transform = owner.Components.Get <Transform>() ?? throw new ArgumentOutOfRangeException(nameof(Transform)); _renderComponent = owner.Components.Get <SpriteRenderComponent>() ?? throw new ArgumentOutOfRangeException(nameof(SpriteRenderComponent)); }