-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76b0291
commit a9f1e3f
Showing
12 changed files
with
113 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
[*.cs] | ||
|
||
# CA1050: Declare types in namespaces | ||
dotnet_diagnostic.CA1050.severity = none | ||
|
||
# IDE0270: Use coalesce expression | ||
dotnet_style_coalesce_expression = false | ||
|
||
dotnet_diagnostic.IDE0044.severity = none | ||
|
||
# IDE0025: Use expression body for property | ||
dotnet_diagnostic.IDE0025.severity = none | ||
dotnet_diagnostic.CA1050.severity = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Godot; | ||
|
||
[GlobalClass] | ||
public abstract partial class GenProp : StaticBody3D | ||
{ | ||
[Export] | ||
public float MaxHealth = 35; | ||
|
||
private float _health = 35; | ||
[Export] | ||
public float Health | ||
{ | ||
get { return _health; } | ||
set | ||
{ | ||
if (value > MaxHealth) return; | ||
|
||
if (_health <= 0) OnDeath(); | ||
|
||
if (_health > value) OnHit(value); | ||
|
||
_health = value; | ||
} | ||
} | ||
|
||
protected abstract void OnHit(float newHealth); | ||
|
||
protected virtual void OnDeath() | ||
{ | ||
if (_health <= 0) | ||
QueueFree(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
using Godot; | ||
|
||
[GlobalClass] | ||
public partial class TreeProp : StaticBody3D | ||
public partial class TreeProp : GenProp | ||
{ | ||
[Export] | ||
public float MaxHealth = 35; | ||
|
||
private float _health = 35; | ||
[Export] | ||
public float Health | ||
public int WoodDropAmount { get; set; } = 5; | ||
protected override void OnHit(float newHealth) | ||
{ | ||
get { return _health; } | ||
set | ||
{ | ||
if (value > MaxHealth) return; | ||
|
||
if (_health > value) OnTreeHit(value); | ||
|
||
_health = value; | ||
} | ||
GD.Print(newHealth); | ||
} | ||
|
||
private void OnTreeHit(float health) | ||
protected override void OnDeath() | ||
{ | ||
if (health <= 0) | ||
{ | ||
QueueFree(); | ||
} | ||
Pickup.DropItem(GlobalPosition, Items.ItemCode.Wood, WoodDropAmount, GetTree()); | ||
|
||
base.OnDeath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters