public void SpawnWeapon(cWeapon blueprint, Vector2 where, Vector2 vel, cPlayer owner) { if (blueprint.Name == "shotgun") { Vector2 normVel = new Vector2(vel.X, vel.Y); normVel.Normalize(); float angle = (float)Math.Atan2(normVel.Y, normVel.X); float ang; float len = vel.Length(); for (int i = 0; i < blueprint.NumToFire; i++) { ang = cMath.Rand(angle - blueprint.FireRangeAngle / 2f, angle + blueprint.FireRangeAngle / 2f); normVel.Y = (float)Math.Sin(ang); normVel.X = (float)Math.Cos(ang); normVel *= cMath.Rand(len * 0.8f, len); cWeapon instance = blueprint.Instantiate(); instance.Position = where; instance.Velocity = normVel; instance.Owner = owner; _activeWeapons.Add(instance); } } else { cWeapon instance = blueprint.Instantiate(); instance.Position = where; instance.Velocity = vel * instance.LaunchPower; instance.Owner = owner; _activeWeapons.Add(instance); } if (blueprint.Name == "machinegun") { PrimalDevistation.Instance.Audio.play("GUN_SINGLE1"); } if (blueprint.Name == "grenade") { PrimalDevistation.Instance.Audio.play("GRENADE_LAUNCH"); } if (blueprint.Name == "rocket") { PrimalDevistation.Instance.Audio.play("rocketLaunch"); } if (blueprint.Name == "shotgun") { PrimalDevistation.Instance.Audio.play("SHOTGUN_SINGLE"); } }
public virtual cWeapon SetProps(cWeapon w) { w.Name = _name; w.Texture = _texture; w.TrailTexture = _trailTexture; w.Type = _type; w.OnCollisionEvents = _onCollisionEvents; w.Friction = _friction; w.OnAgeEvents = _onAgeEvents; w.RateOfFire = _rateOfFire; w.MaxAmmo = _maxAmmo; w.ReloadTime = _reloadTime; w.LaunchPower = _launchPower; w.NumToFire = _numToFire; w.FireRangeAngle = _fireRangeAngle; return(w); }
public abstract void FireCommand(cWeapon owner);
public void SpawnWeapon(string name, Vector2 where, Vector2 vel, cPlayer owner) { cWeapon bp = GetWepByName(name); SpawnWeapon(bp, where, vel, owner); }