Gladiators stop targeting vampire if monster hit
This commit is contained in:
parent
c74dbe3aef
commit
bac85ff90f
@ -48,6 +48,15 @@ public class AIEntity : Entity
|
||||
return false;
|
||||
}
|
||||
|
||||
override public bool TakeDamage(float amount, Entity other){
|
||||
Entity currTargetEntity = GetTarget().GetComponent<Entity>();
|
||||
if(!(currTargetEntity is null)){
|
||||
if(currTargetEntity.entityName == "Vampire")
|
||||
SetTarget(other.transform);
|
||||
}
|
||||
return base.TakeDamage(amount, other);
|
||||
}
|
||||
|
||||
abstract class BaseStateAI : BaseState{
|
||||
protected AIEntity entity;
|
||||
public BaseStateAI(AIEntity entity){
|
||||
@ -163,7 +172,7 @@ public class AIEntity : Entity
|
||||
private BaseState? Attack(){
|
||||
Entity targetEntity = entity.GetTarget().GetComponent<Entity>();
|
||||
if(targetEntity != null){
|
||||
targetEntity.TakeDamage(entity.attackDmg);
|
||||
targetEntity.TakeDamage(entity.attackDmg, entity);
|
||||
bool isTargetAlive = targetEntity.IsAlive();
|
||||
if(!isTargetAlive){
|
||||
return new FindTargetState(entity);
|
||||
|
||||
@ -80,7 +80,7 @@ public class Entity : MonoBehaviour {
|
||||
}
|
||||
|
||||
//Apply damage to the entity, returns true if it is still alive
|
||||
public virtual bool TakeDamage(float amount) {
|
||||
public virtual bool TakeDamage(float amount, Entity other) {
|
||||
Health -= amount;
|
||||
healthBar.SetHealthFraction(Health / initialHealth);
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ public class MinionThrower : MonoBehaviour {
|
||||
if(minionHealthCost >= vampireEntity.Health) {
|
||||
return;
|
||||
}
|
||||
vampireEntity.TakeDamage(minionHealthCost);
|
||||
vampireEntity.TakeDamage(minionHealthCost, vampireEntity);
|
||||
|
||||
currentInitialCooldown = 2f; // TODO
|
||||
currentCooldownTimer = currentInitialCooldown;
|
||||
|
||||
@ -21,7 +21,7 @@ public class VampireEntity : Entity {
|
||||
if (gameFlowManager.Paused)
|
||||
return;
|
||||
|
||||
TakeDamage(playerStats.bloodLossRate * Time.deltaTime);
|
||||
TakeDamage(playerStats.bloodLossRate * Time.deltaTime, this);
|
||||
}
|
||||
|
||||
// public override void TakeDamage(float amount) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user