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

Revision 2348, 1.4 KB checked in by teeevasa, 9 years ago (diff)

messed w/ weapons

RevLine 
[2205]1using System;
2using Jypeli;
3using Jypeli.Assets;
4using Jypeli.Controls;
5using Jypeli.Effects;
6using Jypeli.Widgets;
7
8public class GenCharacter : PlatformCharacter
9{
[2217]10    // The amount of hit points the player/enemy has. Will be defined in their respective classes later on.
[2234]11    protected int hitPoints { get; set; }
[2206]12
[2217]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.
[2300]15    /*protected int _maxHP;
16
[2206]17    protected int maxHP
18    {
[2300]19        get {return _maxHP;}
20    }*/
[2206]21
[2217]22    // The constructor that just relays the variables forward
[2205]23    public GenCharacter(double width, double height, Shape shape)
24        : base(width, height, shape)
25    {
26
27    }
[2206]28
[2219]29    // Players and enemies have different ways of attacking
[2231]30    //public abstract void attack();
[2219]31
[2217]32    // A particlular method for reducing hit points. It also handles death, when it
[2348]33    public void reduceHitPointsBy(int reduction)
[2206]34    {
[2217]35        if (hitPoints > reduction)
36        {
37            hitPoints -= reduction;
38        }
39        else
40        {
41            deathOccurred();
42        }
[2206]43    }
[2217]44
45    // A method for handling death, i.e., removing the player, saving scores or whatever
46    private void deathOccurred()
47    {
[2261]48        this.Destroy();
[2217]49    }
[2205]50}
Note: See TracBrowser for help on using the repository browser.