source: 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/GenCharacter.cs @ 2397

Revision 2397, 1.4 KB checked in by teeevasa, 10 years ago (diff)

revised the first level so that it works with the background, as well as some misc updates

Line 
1using System;
2using Jypeli;
3using Jypeli.Assets;
4using Jypeli.Controls;
5using Jypeli.Effects;
6using Jypeli.Widgets;
7
8public class GenCharacter : PlatformCharacter
9{
10    // The amount of hit points the player/enemy has. Will be defined in their respective classes later on.
11    protected int hitPoints { get; set; }
12
13    // The maximum amount of hit points a player can have, which is currently defined as 100.
14    // This is done so that when/if a player receives a health replenishment, it won't go over the limit.
15    /*protected int _maxHP;
16
17    protected int maxHP
18    {
19        get {return _maxHP;}
20    }*/
21
22    // The constructor that just relays the variables forward
23    public GenCharacter(double width, double height, Shape shape, int HP, PhysicsObject target = null)
24        : base(width, height, shape)
25    {
26        hitPoints = HP;
27    }
28
29    // Players and enemies have different ways of attacking
30    //public abstract void attack();
31
32    // A particlular method for reducing hit points. It also handles death, when it
33    public void reduceHitPointsBy(int reduction)
34    {
35        if (hitPoints > reduction)
36        {
37            hitPoints -= reduction;
38        }
39        else
40        {
41            deathOccurred();
42        }
43    }
44
45    // A method for handling death, i.e., removing the player, saving scores or whatever
46    public void deathOccurred()
47    {
48        this.Destroy();
49    }
50}
Note: See TracBrowser for help on using the repository browser.