source: 2013/27/ArttuY/trunk/RampageRebellion/RampageRebellion/RampageRebellion/RRWeapon.cs @ 4451

Revision 4451, 2.5 KB checked in by eearyla, 7 years ago (diff)

Backup

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Jypeli;
6using Jypeli.Assets;
7using Jypeli.Controls;
8using Jypeli.Effects;
9using Jypeli.Widgets;
10
11/// <summary>
12/// RRWeapon class. Deviates from Weapon class by NOT resetting Power on each shot
13/// </summary>
14public class RRWeapon : Weapon
15{
16
17    public RRProjectileGenerator projectileGenerator;
18    public double weaponPower;
19    public bool countInWeaponArsenal = true;
20    public double randomizedAngleSlate = 0;
21    private Angle baseAngle;
22    private Boolean angleSet = false;
23
24    public RRWeapon(double width, double height, RRProjectileGenerator generator) : base(width, height)
25    {
26        projectileGenerator = generator;
27        this.IsVisible = false;
28        this.AmmoIgnoresExplosions = true;
29        this.AmmoIgnoresGravity = true;
30    }
31
32    public RRWeapon(double width, double height)
33        : this(width, height, new RRProjectileGenerator())
34    {
35    }
36
37
38    public void setPower (DoubleMeter power) 
39    {
40        this.Power = power;
41    }
42
43    public void setAmmo(IntMeter ammo)
44    {
45        this.Ammo = ammo;
46    }
47
48    /// <summary>
49    /// Create a new RRWeapon class
50    /// </summary>
51    /// <param name="width">Width</param>
52    /// <param name="height">Height</param>
53    /// <param name="infiniteAmmo">Has infinite ammo?</param>
54    /// <param name="power">How much force this weapon uses?</param>
55    /// <param name="fireRate">Fire rate?</param>
56
57    public RRWeapon(double width, double height, bool infiniteAmmo, double power, double fireRate) : this(width, height)
58    {
59        this.InfiniteAmmo = infiniteAmmo;
60        this.weaponPower = power;
61        this.Power.Value = power;
62        this.FireRate = fireRate;
63    }
64
65    public RRWeapon(double width, double height, bool infiniteAmmo, double power, double fireRate, RRProjectileGenerator generator)
66        : this(width, height, infiniteAmmo, power, fireRate)
67    {
68        this.projectileGenerator = generator;
69    }
70
71    public void setBaseAngle(Angle a)
72    {
73        baseAngle = a;
74        angleSet = true;
75    }
76
77    protected override PhysicsObject CreateProjectile()
78    {
79        if (projectileGenerator == null) return null;
80
81        if ((randomizedAngleSlate > 0) && angleSet) this.Angle = baseAngle + RandomGen.NextAngle(Angle.FromDegrees(-randomizedAngleSlate), Angle.FromDegrees(randomizedAngleSlate));
82
83        Power.Value = weaponPower;
84
85        return projectileGenerator.projectile();
86    }
87}
Note: See TracBrowser for help on using the repository browser.