Esempio n. 1
0
        private BulletData mBulletData;                                          // The bullet data of this bullet. Needed for path, onHit, and damage.

        public Bullet(Vector2 position, GunData gunData, bool up, bool mirrored) :
            base(
                new List <Sprite> {
            new ManualSprite(ResourceManager.LoadSpriteData("Actor/Ally/Player/Guns/Projectiles/Projectiles", 5, 2),
                             (int)gunData.GunType,
                             up ? 1 : 0)
        },
                new List <Rectangle> {
            new Rectangle(0, 1, 6, 3)
        },
                position + CalculateOffset(gunData, up, mirrored),
                0)
        {
            CollisionListener += _OnCollision;
            Body.CollisionType = CollisionType.SOFT;

            mBulletData = gunData.BulletData;

            if (up)
            {
                Body.Velocity = new Vector2((mirrored ? -1 : 1) * mBulletData.AngledSpeed, -mBulletData.AngledSpeed);
            }
            else
            {
                Body.Velocity = new Vector2((mirrored ? -1 : 1) * mBulletData.Speed, 0);
            }

            Mirrored = mirrored;
        }
Esempio n. 2
0
 public GunData(string gunType, int fireRate, int[] barrelPos, int[] barrelAngledPos, BulletData bulletData)
 {
     // Enums and Vector2s cannot be stored in a JSON file, so some black magic fuckery is used.
     GunType         = (Guns)Enum.Parse(typeof(Guns), gunType);
     FireRate        = fireRate;
     BarrelPos       = new Vector2(barrelPos[0], barrelPos[1]);
     BarrelAngledPos = new Vector2(barrelAngledPos[0], barrelAngledPos[1]);
     BulletData      = bulletData;
 }