Exemple #1
0
        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);
        }
Exemple #2
0
        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;
 }
Exemple #4
0
 public bool CanAttackPlayer(Entity attacker)
 {
     return(AIUtility.GetDistance(player, attacker) < minAttackDistance);
 }
Exemple #5
0
        private void OnTriggerEnter(Collider other)
        {
            Entity entity = other.gameObject.GetComponent <Entity>();

            AIUtility.PerformCollision(this, entity);
        }