private void HandleFireInput() { if (_fireInput.isReleased) { float xImp = 5; xImp *= (_mDirection == EntityConstants.MovementDirection.RIGHT) ? 1 : -1; Vector2 force = new Vector2( xImp, -1 * EntityConstants.JumpVelocity / EntityConstants.PixelPerMeter); ProjectileComponent arrow = new ProjectileComponent(dust, force); var pos = this.transform.localPosition; pos.X += (_mDirection == EntityConstants.MovementDirection.RIGHT) ? 10 : -10; var ent = Core.scene.createEntity("arrow", pos); ent.addComponent(arrow); var arrowmove = new MovementComponent(); ent.addComponent(arrowmove); } }
public override void onAddedToEntity() { _mState = EntityConstants.MovementStates.JUMP; _mDirection = EntityConstants.MovementDirection.RIGHT; _velocity = new Vector2(0, 0); _sprite = this.getComponent <Sprite>(); _jumpInput = new VirtualButton(); _jumpInput.nodes.Add(new Nez.VirtualButton.KeyboardKey(Keys.W)); _fireInput = new VirtualButton(); _fireInput.nodes.Add(new Nez.VirtualButton.KeyboardKey(Keys.S)); _movementInput = new VirtualIntegerAxis(); _movementInput.nodes.Add(new Nez.VirtualAxis.KeyboardKeys(VirtualInput.OverlapBehavior.TakeNewer, Keys.A, Keys.D)); //_moveComp = new MovementComponent(); //this.entity.addComponent(_moveComp); _moveComp = this.entity.getComponent <MovementComponent>(); }
public override void onAddedToEntity() { _mover = this.entity.getComponent <MovementComponent>(); this.entity.addComponent(_sprite); }