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;
|
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{
|
abstract class BaseStateAI : BaseState{
|
||||||
protected AIEntity entity;
|
protected AIEntity entity;
|
||||||
public BaseStateAI(AIEntity entity){
|
public BaseStateAI(AIEntity entity){
|
||||||
@ -163,7 +172,7 @@ public class AIEntity : Entity
|
|||||||
private BaseState? Attack(){
|
private BaseState? Attack(){
|
||||||
Entity targetEntity = entity.GetTarget().GetComponent<Entity>();
|
Entity targetEntity = entity.GetTarget().GetComponent<Entity>();
|
||||||
if(targetEntity != null){
|
if(targetEntity != null){
|
||||||
targetEntity.TakeDamage(entity.attackDmg);
|
targetEntity.TakeDamage(entity.attackDmg, entity);
|
||||||
bool isTargetAlive = targetEntity.IsAlive();
|
bool isTargetAlive = targetEntity.IsAlive();
|
||||||
if(!isTargetAlive){
|
if(!isTargetAlive){
|
||||||
return new FindTargetState(entity);
|
return new FindTargetState(entity);
|
||||||
|
|||||||
@ -80,7 +80,7 @@ public class Entity : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Apply damage to the entity, returns true if it is still alive
|
//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;
|
Health -= amount;
|
||||||
healthBar.SetHealthFraction(Health / initialHealth);
|
healthBar.SetHealthFraction(Health / initialHealth);
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class MinionThrower : MonoBehaviour {
|
|||||||
if(minionHealthCost >= vampireEntity.Health) {
|
if(minionHealthCost >= vampireEntity.Health) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vampireEntity.TakeDamage(minionHealthCost);
|
vampireEntity.TakeDamage(minionHealthCost, vampireEntity);
|
||||||
|
|
||||||
currentInitialCooldown = 2f; // TODO
|
currentInitialCooldown = 2f; // TODO
|
||||||
currentCooldownTimer = currentInitialCooldown;
|
currentCooldownTimer = currentInitialCooldown;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class VampireEntity : Entity {
|
|||||||
if (gameFlowManager.Paused)
|
if (gameFlowManager.Paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TakeDamage(playerStats.bloodLossRate * Time.deltaTime);
|
TakeDamage(playerStats.bloodLossRate * Time.deltaTime, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public override void TakeDamage(float amount) {
|
// public override void TakeDamage(float amount) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user