-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
55 lines (48 loc) · 1.32 KB
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SpaceAdventure
{
class Player
{
public int HP { get; set; }
public bool isActive { get; private set; }
public int score { get; set; }
public int enemiesEliminated { get; set; }
public String attackSoundEffect { get; set; }
public String missSoundEffect { get; set; }
public String hurtSoundEffect { get; private set; }
public String lowHealthSoundEffect { get; set; }
public Player()
{
HP = 0;
isActive = true;
score = 0;
}
public Player(int hp)
{
this.HP = hp;
isActive = true;
score = 0;
}
//Returns true if attack is succesful, false otherwise
public bool attack(Enemy monster, AttackType attack)
{
if (attack == monster.attackType)
{
monster.state = Enemy.State.destroyed;
score += 535;
enemiesEliminated += 1;
return true;
}
else return false;
}
public void takeDamage(int damage)
{
HP -= damage;
if (HP <= 0)
isActive = false;
}
}
}