This repository was archived by the owner on Jan 29, 2024. It is now read-only.
File tree 2 files changed +18
-7
lines changed
2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public override void _Ready()
27
27
/// </summary>
28
28
/// <param name="body"> The node, wich collides </param>
29
29
/// <returns> If the bullet collides with a player, the name of that player else an empty string</returns>
30
- private string onCollision ( Node body )
30
+ private Player onCollision ( Node body )
31
31
{
32
32
//creates the collision animation;
33
33
collisionAnimation ( ) ;
@@ -36,12 +36,14 @@ private string onCollision(Node body)
36
36
GetParent ( ) . RemoveChild ( this ) ;
37
37
38
38
//Return the players name, if the bullet collide with a player.
39
- if ( false )
39
+ if ( body is Player )
40
40
{
41
-
41
+ Player player = ( Player ) body ;
42
+ player . Health -= Damage ;
43
+ return player ;
42
44
}
43
45
44
- return "" ;
46
+ return null ;
45
47
}
46
48
47
49
Original file line number Diff line number Diff line change @@ -42,12 +42,21 @@ public double Health
42
42
get => health ;
43
43
set
44
44
{
45
- if ( ( value >= 0 && value <= 100 ) || value == double . PositiveInfinity )
45
+ if ( value < 0 )
46
+ {
47
+ health = 0 ;
48
+ }
49
+ else if ( value > 100 )
50
+ {
51
+ health = 100 ;
52
+ }
53
+ else
46
54
{
47
55
health = value ;
48
- //sends an signal about
49
- EmitSignal ( nameof ( HealthChangeSignal ) , Health ) ;
50
56
}
57
+
58
+ //sends an signal about
59
+ EmitSignal ( nameof ( HealthChangeSignal ) , Health ) ;
51
60
}
52
61
}
53
62
You can’t perform that action at this time.
0 commit comments