mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 18:43:07 +02:00
Merge branch 'kuchy-soldier-tick' into 'Development'
feat: add tick system soldier, add set tag See merge request gskowron/eopsy-lab-567-project!4
This commit is contained in:
commit
635597680b
@ -13,14 +13,29 @@ public class Soldier : MonoBehaviour
|
|||||||
[SerializeField] private float speedAttack = 1;
|
[SerializeField] private float speedAttack = 1;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start(){
|
void Start(){
|
||||||
|
setEnemyTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwnTag(string tag)
|
||||||
|
{
|
||||||
|
gameObject.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnemyTag()
|
||||||
|
{
|
||||||
if(gameObject.tag == "Ally") enemyTag = "Enemy";
|
if(gameObject.tag == "Ally") enemyTag = "Enemy";
|
||||||
else enemyTag = "Ally";
|
else enemyTag = "Ally";
|
||||||
InvokeRepeating("UpdateTarget", 0f, 0.5f);
|
|
||||||
// Call UpdateTarget method at the begining of the Start()
|
|
||||||
// and repeat every 0.5 second
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
TickSystem.OnTick += HandleTick;
|
||||||
|
}
|
||||||
|
private void HandleTick(TickSystem.OnTickEventArgs tickEventArgs)
|
||||||
|
{
|
||||||
|
UpdateTarget();
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateTarget ()
|
void UpdateTarget ()
|
||||||
{
|
{
|
||||||
// Enemies are the game objects tagged with the "Enemy"
|
// Enemies are the game objects tagged with the "Enemy"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user