-
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
a907530
commit 3f40e9a
Showing
13 changed files
with
168 additions
and
60 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
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
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,19 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Unigine; | ||
|
||
[Component(PropertyGuid = "51e877b3c29f323185bb02f9fb15bbc3f3022b4b")] | ||
public class Health : Component | ||
{ | ||
public int health = 5; // начальный уровень здоровья | ||
|
||
// флаг, проверяющий, не достиг ли текущий уровень здоровья 0 | ||
public bool IsDead => health <= 0; | ||
|
||
public void TakeDamage(int damage) | ||
{ | ||
// применяем ущерб | ||
health = MathLib.Max(health - damage, 0); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
data/csharp_template/FP_controller/components/Health.cs.meta
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<asset version="2.18.0.1"> | ||
<guid>6629c61dbcf5668c3f0966d3e2f41c71b0b5b1b5</guid> | ||
<type>component</type> | ||
<hash>a2f4f621</hash> | ||
<runtimes> | ||
<runtime id="6629c61dbcf5668c3f0966d3e2f41c71b0b5b1b5" name="Health.cs" link="0"/> | ||
<runtime id="51e877b3c29f323185bb02f9fb15bbc3f3022b4b" name="Health.prop" link="1" type="4"/> | ||
</runtimes> | ||
</asset> |
29 changes: 29 additions & 0 deletions
29
data/csharp_template/FP_controller/components/PlayerLogic.cs
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,29 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Unigine; | ||
|
||
[Component(PropertyGuid = "96c240040ff7888aa3804c36b43a466e1b430b9e")] | ||
public class PlayerLogic : Component | ||
{ | ||
private Health health = null; | ||
private void Init() | ||
{ | ||
// берем у ноды компонент Health | ||
health = node.GetComponentInChildren<Health>(); | ||
// обновляем информацию об исходном здоровье игрока | ||
ComponentSystem.FindComponentInWorld<HUD>().UpdateHealthInfo(health.health); | ||
} | ||
|
||
private void Update() | ||
{ | ||
// проверяем выставлен ли флаг IsDead | ||
if (health && health.IsDead) | ||
{ | ||
// обездвиживаем игрока, отключая компоненты | ||
node.GetComponent<FirstPersonController>().Enabled = false; | ||
node.GetComponent<WeaponController>().Enabled = false; | ||
node.GetComponent<ShootInput>().Enabled = false; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
data/csharp_template/FP_controller/components/PlayerLogic.cs.meta
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<asset version="2.18.0.1"> | ||
<guid>c70564d6d805b75f7c23b858d839b1091b4f9c80</guid> | ||
<type>component</type> | ||
<hash>8602d67f</hash> | ||
<runtimes> | ||
<runtime id="c70564d6d805b75f7c23b858d839b1091b4f9c80" name="PlayerLogic.cs" link="0"/> | ||
<runtime id="96c240040ff7888aa3804c36b43a466e1b430b9e" name="PlayerLogic.prop" link="1" type="4"/> | ||
</runtimes> | ||
</asset> |
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
Oops, something went wrong.