Changeset 2361 for 2011/26


Ignore:
Timestamp:
2011-06-30 14:20:00 (12 years ago)
Author:
teeevasa
Message:

added preliminary rifle support

Location:
2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Enemies.cs

    r2355 r2361  
    88public class MeleeAlien : GenCharacter 
    99{ 
     10    const int speed = 100; 
     11    const int mass = 15; 
    1012    Image portrait = Game.LoadImage("Images/basealien"); 
     13    FollowerBrain brain; 
    1114 
    12         public MeleeAlien(double width, double height, Shape shape, int HP) 
    13         : base(width, height, shape, HP) 
     15        public MeleeAlien(double width, double height, Shape shape, int HP, PhysicsObject target) 
     16        : base(width, height, shape, HP, target) 
    1417        { 
    1518        this.Image = portrait; 
    1619        this.Tag = "MeleeAlien"; 
     20        this.Mass = mass; 
     21 
     22        brain = new FollowerBrain(); 
     23        this.Brain = brain; 
     24        brain.Target = target; 
     25        brain.Speed = speed; 
     26        brain.FollowAlways = true; 
     27        //brain.StopWhenTargetClose = true; 
     28        brain.TargetCloseDistance = 20; 
    1729        } 
     30 
     31    private void closeToTarget(FollowerBrain senderBrain, EventArgs e) 
     32    { 
     33        senderBrain.Speed += 500; 
     34    } 
     35 
     36    public override void deathOccurred() 
     37    { 
     38        /*Explosion explosion = new Explosion(1000); 
     39        explosion.Position = this.Position; 
     40        Add(explosion);*/ 
     41        this.Destroy(); 
     42    } 
    1843} 
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/GenCharacter.cs

    r2355 r2361  
    2121 
    2222    // The constructor that just relays the variables forward 
    23     public GenCharacter(double width, double height, Shape shape, int HP) 
     23    public GenCharacter(double width, double height, Shape shape, int HP, PhysicsObject target = null) 
    2424        : base(width, height, shape) 
    2525    { 
     
    4444 
    4545    // A method for handling death, i.e., removing the player, saving scores or whatever 
    46     private void deathOccurred() 
     46    public virtual void deathOccurred() 
    4747    { 
     48        /*Explosion explosion = new Explosion(100); 
     49        explosion.Position = this.Position; 
     50        Add(explosion);*/ 
    4851        this.Destroy(); 
    4952    } 
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Peli.cs

    r2360 r2361  
    1414    Player player; 
    1515    Image background1 = LoadImage("Images/reactorBG"); 
    16  
    1716 
    1817    public override void Begin() 
     
    106105    MeleeAlien addMeleeAlien() 
    107106    { 
    108         MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 50); 
     107        MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 50, player); 
    109108        return meleeAlien; 
    110109    } 
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Player.cs

    r2356 r2361  
    99{ 
    1010    const int speed = 200; 
    11     const int jumpSpeed = 500; 
     11    const int jumpSpeed = 200; 
    1212    const int mass = 10; 
    1313    Image portrait = Game.LoadImage("Images/character"); 
    1414    SoundEffect walking = Game.LoadSoundEffect("Sounds/walkingsound"); 
     15 
     16    Pistol pistol; 
     17    // Rifle rifle; 
    1518 
    1619    Timer walker; 
     
    2326        this.Image = portrait; 
    2427        this.CollisionIgnoreGroup = 1; 
     28        this.Mass = mass; 
    2529 
    2630        // Creating the timer system that is *supposed* to enable a nice walking sound effect 
     
    3034 
    3135        // Creating the weapon; for now only a pistol 
    32         Pistol pistol = new Pistol(20.0, 10.0); 
     36        pistol = new Pistol(20.0, 10.0); 
    3337        pistol.X = 18; 
    3438        pistol.Y = 11; 
    35         this.Weapon = pistol; 
     39        this.Weapon = pistol; // The default weapon 
    3640        pistol.ProjectileCollision += bulletReachedTarget; 
    3741 
     42        /* 
     43        rifle = new Rifle(20.0, 10.0); 
     44        rifle.X = 18; 
     45        rifle.Y = 11;         
     46        rifle.ProjectileCollision += bulletReachedTarget; 
     47        */ 
    3848        // Collision handlers for enemies 
    3949        //AddCollisionHandler(); 
     
    4858    } 
    4959 
     60    // Because all the weapons have infinite ammo, we don't have to check for null 
    5061    private void shoot() 
    5162    { 
    5263        PhysicsObject bullet = this.Weapon.Shoot(); 
    53  
    54         // As of now weapons are set to have infinite ammo, but that might change 
    55         if (bullet != null) 
    56         {  
    57              
    58         } 
    5964    } 
    6065 
     
    9499        this.Jump(jumpSpeed); 
    95100    } 
    96  
    97101} 
Note: See TracChangeset for help on using the changeset viewer.