Example #1
0
 public Weapon(Bullet bulletType, float firerate, Player owner)
 {
     BulletType = bulletType;
     Firerate = firerate;
     Owner = owner;
     TimeSinceLastShot = firerate;
 }
Example #2
0
 public void BulletImpact(Bullet bullet, GameObject Object)
 {
     var enemy = Object as Enemy.Enemy;
     if (enemy != null && enemy.Dead)
     {
         Money += enemy.Bounty;
     }
 }
Example #3
0
 public Bullet(Bullet CopyBullet)
 {
     Listeners = new List<IBulletListener>();
     HealthChange = CopyBullet.HealthChange;
     Effect = CopyBullet.Effect.Clone();
     isVisible = true;
     Texture = CopyBullet.Texture;
     TravelSpeed = CopyBullet.TravelSpeed;
     Scale = 0.4f;
 }
Example #4
0
        public void Shoot(GameTime gameTime)
        {
            TimeSinceLastShot += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (!IsDisabled && TimeSinceLastShot >= Firerate)
            {
                Bullet newBullet = new Bullet(BulletType);
                newBullet.Scale = BulletType.Scale;
                newBullet.Velocity = new Vector2((float)Math.Cos(Owner.Rotation), (float)Math.Sin(Owner.Rotation)) * newBullet.TravelSpeed;
                newBullet.Position = Owner.Position + new Vector2((float)Math.Cos(Owner.Rotation), (float)Math.Sin(Owner.Rotation)) * 40f;
                newBullet.Listeners.Add(Owner);
                LevelController lcon = GameServices.GetService<LevelController>();
                lcon.CurrentLevel.AllDrawableGameObjects.Add(newBullet);
                TimeSinceLastShot = 0;

            }
        }
Example #5
0
        public Player(string name, Vector2 position, Texture2D texture)
        {
            Texture = texture;
            Name = name;
            Rotation = 0.0f;
            Position = position;
            AccelerationRate = 8.0f;
            RotationRate = 8.0f;
            Scale = 0.5f;

            MaxHealthPoints = 1000;
            HealthPoints = MaxHealthPoints;

            Money = 0;

            ContentManager cm = GameServices.GetService<ContentManager>();
            Bullet weaponBullet = new Bullet(-30f, 700f, new DisableEffect(2000f), cm.Load<Texture2D>("Textures/bullet"));
            Weapon = new Weapon(weaponBullet, 100f, this);

            HealthBar = new HealthBar(this);
            PlayerControls = ControlsController.GetControls(this);
        }
Example #6
0
        public void Reset()
        {
            AccelerationRate = 8.0f;
            RotationRate = 8.0f;
            MaxHealthPoints = 1000;
            HealthPoints = MaxHealthPoints;
            Dead = false;
            Disabled = false;

            Money = 0;

            ContentManager cm = GameServices.GetService<ContentManager>();
            Bullet weaponBullet = new Bullet(-30f, 700f, new DisableEffect(2000f), Weapon.BulletType.Texture);
            Weapon = new Weapon(weaponBullet, 100f, this);
        }