Felix Boucher 8dc77e1772 enlevé besoin d'un placeholder statique par unit
problème : créer un placeholder par unit allait être un sale hassle

solution : maintenant, le placeholder est créé dynamiquement

note : also, j'ai ajouté un système pour ajouter des tiles
2023-06-08 23:14:07 -04:00

47 lines
919 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Opponent : Entity
{
private Vector2 _movementVector = Vector2.zero;
private Rigidbody2D _rigidbody;
void Start()
{
_rigidbody = GetComponent<Rigidbody2D>();
}
void Update() {
_movementVector.x = -Time.deltaTime * Speed;
transform.position += (Vector3)_movementVector;
if(IsEnemyDetected) {
AttackEnemy();
}
}
void AttackEnemy() {
//Attack Cooldown
if(AttackSpeed < AttackSpeedWait)
{
Enemy.Hp-=AttackDamage;
Debug.Log("Ally Hp = " + Enemy.Hp);
//Kill if no hp
if(Enemy.Hp <= 0) {
Destroy(Enemy);
}
AttackSpeedWait = 0f;
}
AttackSpeedWait += Time.deltaTime;
}
}