public SoulMonster GetPlayerAttackTarget() { if (monsters.Count <= 0) { return(null); } float minDis = float.MaxValue; int minIndex = 0; for (int i = 0; i < monsters.Count; i++) { float dis = AIUtility.GetDistance(player, monsters[i]); if (dis < minDis) { minDis = dis; minIndex = i; } } if (minDis < minAttackDistance) { return(monsters[minIndex]); } return(null); }
private void OnTriggerEnter(Collider other) { Entity entity = other.gameObject.GetComponent <Entity>(); if (entity == null) { return; } if (entity is TargetableObject && entity.Id >= Id) { // 碰撞事件由 Id 小的一方处理,避免重复处理 return; } AIUtility.PerformCollision(this, entity); }
void AttackOver() { startAttack = false; AIUtility.OnDamage(attackingMonster, procedureOwner.Owner); attackingMonster = null; }
public bool CanAttackPlayer(Entity attacker) { return(AIUtility.GetDistance(player, attacker) < minAttackDistance); }
private void OnTriggerEnter(Collider other) { Entity entity = other.gameObject.GetComponent <Entity>(); AIUtility.PerformCollision(this, entity); }