Example #1
0
        private static ShapeDef CreateBaseCircleDef(PhysicsSetups setups, SizeF size)
        {
            ShapeDef circleShape = new CircleDef();

            (circleShape as CircleDef).Radius = size.Width / 2;
            circleShape.Restitution           = setups.restetution;
            circleShape.Friction = setups.friction;
            circleShape.Density  = setups.density;

            return(circleShape);
        }
Example #2
0
        private static ShapeDef CreateBaseRectangleDef(PhysicsSetups setups, SizeF size)
        {
            ShapeDef RectangleDef = new PolygonDef();

            (RectangleDef as PolygonDef).SetAsBox(size.Width / 2, size.Height / 2);
            RectangleDef.Restitution = setups.restetution;
            RectangleDef.Friction    = setups.friction;
            RectangleDef.Density     = setups.density;

            return(RectangleDef);
        }
Example #3
0
        private static Weapon CreateShotWeapon(IModelForComponents model, PhysicsSetups physicsSetupsWeapon,
                                               WeaponSetups weaponSetups, SizeF sizeWeapon, TypesWeapon typeWeapon, PointF location)
        {
            var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, typeWeapon);

            CreateStandartComponentForWeapon(weapon, physicsSetupsWeapon, weaponSetups, sizeWeapon, typeWeapon, location);

            var shot = new Shot(weapon);

            weapon.Components.Add(shot);

            return(weapon);
        }
Example #4
0
        private static SolidBody CreateBodyWeapon(Weapon weapon, PointF location, PhysicsSetups physicsSetupsWeapon, SizeF sizeWeapon)
        {
            ShapeDef circleShape = CreateBaseCircleDef(physicsSetupsWeapon, sizeWeapon);

            circleShape.Filter.CategoryBits = (ushort)CollideCategory.Loot;
            circleShape.Filter.MaskBits     = (ushort)CollideCategory.Box | (ushort)CollideCategory.Stone;

            ShapeDef sensorDef = CreateBaseCircleDef(physicsSetupsWeapon, sizeWeapon);

            sensorDef.IsSensor            = true;
            sensorDef.Filter.CategoryBits = (ushort)CollideCategory.Loot;
            sensorDef.Filter.MaskBits     = (ushort)CollideCategory.Player;

            var body = new SolidBody(weapon, new RectangleF(location, sizeWeapon), new ShapeDef[] { circleShape, sensorDef },
                                     physicsSetupsWeapon.linearDamping, Vec2.Zero);

            weapon.Components.Add(body);

            return(body);
        }
Example #5
0
 private static void CreateStandartComponentForWeapon(Weapon weapon, PhysicsSetups physicsSetupsWeapon,
                                                      WeaponSetups weaponSetups, SizeF sizeWeapon, TypesWeapon typeWeapon, PointF location)
 {
     CreateBodyWeapon(weapon, location, physicsSetupsWeapon, sizeWeapon);
     CreateMagazin(weapon, weaponSetups, typeWeapon);
 }