示例#1
0
        public override void FireCommand(cWeapon owner)
        {
            cLevel lev = PrimalDevistation.Instance.Level;

            Vector2 where = Vector2.Zero;
            Vector2 vel = Vector2.Zero;

            if (_where == "this")
            {
                where.X = owner.Position.X; where.Y = owner.Position.Y;
            }
            if (_velocity == "this")
            {
                vel.X = owner.Velocity.X; vel.Y = owner.Velocity.Y;
            }
            if (_type == "explosion")
            {
                PrimalDevistation.Instance.Explode(_size, where, vel / 2f, owner.Owner, true);
            }
            else if (_type == "shrapnel")
            {
                List <Vector2> positions  = new List <Vector2>(_quantity);
                List <Vector2> velocities = new List <Vector2>(_quantity);
                List <Color>   colors     = new List <Color>(_quantity);
                Color          c          = new Color(200, 200, 200, 255);
                for (int i = 0; i < _quantity; i++)
                {
                    positions.Add(new Vector2(where.X + cMath.Rand(-4f, 4f), where.Y + cMath.Rand(-4f, 4f)));
                    velocities.Add(new Vector2(cMath.Rand(-1f, 1f) + vel.X / 10, cMath.Rand(-1f, 1f) + vel.Y / 10));
                    colors.Add(c);
                }
                PrimalDevistation.Instance.PhysicsParticles.SpawnParticles(positions, velocities, colors);
            }
        }
示例#2
0
        public cPlayer(GameScene scene, Vector2f pos) : base(scene, pos)
        {
            fireLight                 = new cLight();
            fireLight.Pos             = this.Bounds.center;
            fireLight.Bleed           = 10.0f;
            fireLight.Radius          = 120.0f;
            fireLight.LinearizeFactor = 0.96f;
            fireLight.OriginalColor   = new Color(136, 216, 176);
            fireLight.Color           = new Color(136, 216, 176);
            fireLight.TurnOff();
            this.Scene.LightMap.AddStaticLight(fireLight);


            p_followLight                 = new cLight();
            p_followLight.Pos             = this.Bounds.center;
            p_followLight.Radius          = 160.0f;
            p_followLight.LinearizeFactor = 0.9f;
            p_followLight.OriginalColor   = new Color(240, 219, 164);
            p_followLight.Color           = new Color(240, 219, 164);
            // p_followLight.TurnOff();
            this.Scene.LightMap.AddStaticLight(p_followLight);

            this.weapon =                                                                // new cMachineGun(this, Constants.DEFAULT_WEAPON_FIRING_FREQUENCY);
                          new cShotgun(this, Constants.DEFAULT_WEAPON_FIRING_FREQUENCY); // 9

            this.health              = 50;
            healthText               = new Text("", Scene.Assets.GetFont("pf_tempesta_seven"));
            healthText.Position      = new Vector2f(pscene.AppController.MainWindow.DefaultView.Size.X - 500, 30);
            healthText.CharacterSize = 28; // in pixels, not points!
            healthText.FillColor     = Color.White;
            healthText.Style         = Text.Styles.Bold;

            this.boundingRadius = 12.0f;
        }
 public void Collision(cWeapon owner)
 {
     owner.Position -= owner.Velocity;
     for (int i = 0; i < _commands.Count; i++)
     {
         _commands[i].FireCommand(owner);
     }
 }
示例#4
0
 public void Update(cWeapon owner, GameTime gameTime)
 {
     if (owner.Age >= _atAge)
     {
         for (int i = 0; i < _commands.Count; i++)
         {
             _commands[i].FireCommand(owner);
         }
     }
 }
示例#5
0
        public cPlayer(cGameScene scene, Vector2f pos) : base(scene, pos)
        {
            p_followLight                 = new cLight();
            p_followLight.Radius          = 80.0f;
            p_followLight.LinearizeFactor = 0.9f;
            p_followLight.Color           = new Color(240, 219, 164);
            this.Scene.LightMap.AddStaticLight(p_followLight);

            this.weapon = new cShotgun(this, Constants.DEFAULT_WEAPON_FIRING_FREQUENCY); // 9

            healthText               = new Text("", cAssetManager.GetFont("pf_tempesta_seven"));
            healthText.Position      = new Vector2f(pscene.AppController.MainWindow.DefaultView.Size.X - 500, 30);
            healthText.CharacterSize = 28; // in pixels, not points!
            healthText.Color         = Color.White;
            healthText.Style         = Text.Styles.Bold;
        }
示例#6
0
        public void Update(GameTime gameTime, Vector4[] forces)
        {
            if (_weaponSwitching)
            {
                _weaponSwitchTimer += gameTime.ElapsedGameTime.Milliseconds;
                if (_weaponSwitchTimer > 1000)
                {
                    _weaponSwitching = false;
                }
            }

            if (_currentAmmoLevels[_currentWeaponIndex, 4] <= _currentAmmoLevels[_currentWeaponIndex, 5])
            {
                _currentAmmoLevels[_currentWeaponIndex, 4] += gameTime.ElapsedGameTime.Milliseconds;
                if (_currentAmmoLevels[_currentWeaponIndex, 4] > _currentAmmoLevels[_currentWeaponIndex, 5])
                {
                    PrimalDevistation.Instance.Audio.play("RELOAD_GUN");
                }
            }

            if (_currentAmmoLevels[_currentWeaponIndex, 2] <= _currentAmmoLevels[_currentWeaponIndex, 3])
            {
                _currentAmmoLevels[_currentWeaponIndex, 2] += gameTime.ElapsedGameTime.Milliseconds;
                if (_currentAmmoLevels[_currentWeaponIndex, 2] > _currentAmmoLevels[_currentWeaponIndex, 3])
                {
                    cWeapon wep = PrimalDevistation.Instance.Weapons.WeaponBlueprints[_currentWeaponIndex];
                    if (wep.Name == "shotgun")
                    {
                        PrimalDevistation.Instance.Audio.play("RELOAD_SHOTGUN");
                    }
                }
            }

            //if (_reticuleAngle != _moveToReticuleAngle)
            //{
            //    float inc = _reticuleRotateRate;
            //    if (_reticuleAngle > _moveToReticuleAngle) { inc = -inc; }
            //    //if (_moveToReticuleAngle > Math.PI / 2 && _reticuleAngle< -Math.PI/2) { inc = -inc; }
            //    _reticuleAngle += inc;
            //    if (inc < 0 && _reticuleAngle < _moveToReticuleAngle) { _reticuleAngle = _moveToReticuleAngle; }
            //    else if (inc > 0 && _reticuleAngle > _moveToReticuleAngle) { _reticuleAngle = _moveToReticuleAngle; }
            //}



            //_sprite.Update(gameTime);
            UpdateInput(gameTime);
            this.UpdateForces(forces);
            this.UpdatePhysics(gameTime, null);
            _velocity  = _velocity * 0.99f;
            _rotation += (_velocity.X / 16);
            if (_walkDir != 0)
            {
                _rotation += _walkDir / 20;
            }

            if (_bubbles)
            {
                PrimalDevistation.Instance.AddForce(Position, -1, (_bubble.Width / 2) + 10);
            }
        }
示例#7
0
 public override void FireCommand(cWeapon owner)
 {
     owner.KillFlag = true;
 }
示例#8
0
 public void Attack(DynamicObj aggressor, cWeapon weapon) // TODO: fick denna ur koden men
 {
     weapon.OnUse(aggressor);
 }