/// <summary> /// Constructor /// </summary> /// <param name="parent">GameObect that owns the component</param> public FlyingBugControllerComponent(AnimationSetRenderComponent animSetComponent, PhysicsComponent physicsComponent, float movementImpulse, GameObject parent) : base(parent) { MovementImpulse = movementImpulse; AnimationSetRenderComponent = animSetComponent; PhysicsComponent = physicsComponent; Debug.Assert(AnimationSetRenderComponent != null); Debug.Assert(PhysicsComponent != null); AnimationSetRenderComponent.SetAnimation("Flying"); }
/// <summary> /// Constructor /// </summary> /// <param name="parent">GameObect that owns the component</param> public CharacterControllerComponent(AnimationSetRenderComponent animSetComponent, PhysicsComponent physicsComponent, Camera camera, // for camera shake, needs to be moved if there are other "Characters" than the player. GameObject parent) : base(parent) { AnimationSetRenderComponent = animSetComponent; PhysicsComponent = physicsComponent; Camera = camera; FeetColliders = new List<GameObject>(); Debug.Assert(AnimationSetRenderComponent != null); Debug.Assert(PhysicsComponent != null); }
public JabControllerComponent(PhysicsComponent physicsComp, MeleeWeaponComponent meleeWeapon, Vector2f forwardPosition, Vector2f backwardPosition, double fullForwardTime, double fullBackwardTime, GameObject parent) : base(parent) { ForwardPosition = forwardPosition; BackwardPosition = backwardPosition; FullForwardTime = fullForwardTime; FullBackwardTime = fullBackwardTime; Time = 0; PhysicsComponent = physicsComp; MeleeWeapon = meleeWeapon; // Debug.Assert(FullBackwardTime > fullForwardTime); }
public PhysicsComponent MakeNewComponent(GameObject owner, float width, float height, bool dynamic) { //Fixed density of 1.0 var body = BodyFactory.CreateRectangle(_world, width, height, 1.0f); body.Position = new Vector2(owner.Position.X, owner.Position.Y); if (dynamic) { body.BodyType = BodyType.Dynamic; } else { body.BodyType = BodyType.Static; } //AABB, no rotation body.FixedRotation = true; PhysicsComponent comp = new PhysicsComponent(owner, body); Components.Add(comp); return(comp); }
public PhysicsComponent MakeNewComponent(GameObject owner, float width, float height, Category categories, Category collidesWith, BodyType bodyType) { //Fixed density of 1.0 var body = BodyFactory.CreateRectangle(_world, width, height, 1.0f); body.Position = new Vector2(owner.Position.X, owner.Position.Y); body.BodyType = bodyType; //AABB, no rotation body.FixedRotation = true; PhysicsComponent comp = new PhysicsComponent(body, this, owner); body.UserData = owner; body.OnCollision += OnFixtureCollision; body.OnSeparation += OnFixtureSeperation; body.CollidesWith = collidesWith; body.CollisionCategories = categories; body.LinearDamping = 1; Components.Add(comp); return comp; }