-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destruicao de objetos e cenario de testes
- Loading branch information
1 parent
bcfca7e
commit fc2d2c2
Showing
156 changed files
with
11,555 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class BreakableObject : MonoBehaviour, IDamagable | ||
{ | ||
[SerializeField] private int _required_energy; | ||
|
||
public void hit(float energy) | ||
{ | ||
//Test if enough Energy | ||
if (_required_energy > energy) return; | ||
|
||
gameObject.SetActive(false); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class Breaker : MonoBehaviour | ||
{ | ||
[SerializeField] private Transform _attack_point = null; | ||
[SerializeField] private LayerMask _attack_layer; | ||
|
||
public float attackRange = 1f; | ||
public float attackPower = 1f; | ||
|
||
public void OnHit() | ||
{ | ||
Debug.Log("attacking"); | ||
Collider2D[] collisions = Physics2D.OverlapCircleAll(_attack_point.position, attackRange, _attack_layer); | ||
foreach (Collider2D entity in collisions) | ||
{ | ||
entity.GetComponent<IDamagable>()?.hit(attackPower); | ||
} | ||
} | ||
|
||
//Draw Attack Range gizmo | ||
void OnDrawGizmosSelected() | ||
{ | ||
if (_attack_point == null) | ||
{ | ||
return; | ||
} | ||
Gizmos.DrawWireSphere(_attack_point.position, attackRange); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
interface IDamagable | ||
{ | ||
void hit(float energy); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.