public GameObject(Vector2 position, Texture2D sprite, bool isVisible, MechanicsBaseComponent component) { initGameObject(position, sprite, isVisible, PhysicsType.MechanicsObject); this.physComp = component; PhysicsSystem.Instance.addMechanicObject(component); this.physComp.UpdateHitBoxPosition(position); }
private void initGameObject(Vector2 position, Texture2D sprite, bool isVisible, PhysicsType type) { //this.position = position; this.position = position; this.drawSpace = new Rectangle(position.ToPoint().X, position.ToPoint().Y, sprite.Width, sprite.Height); this.isVisible = isVisible; this.rendComp = new RenderComponent(sprite); if(type != PhysicsType.MechanicsObject) { this.physComp = new PhysicsComponent(sprite.Width, sprite.Height, type); if (type == PhysicsType.StaticObject) PhysicsSystem.Instance.addStaticObject(this.physComp); else if (type == PhysicsType.Door) PhysicsSystem.Instance.addDoorObject(this.physComp); else if (type == PhysicsType.Player) { } else throw new NotSupportedException("The type [" + type.ToString() + "] is not supported by the Physics System yet"); this.physComp.UpdateHitBoxPosition(position); } }