Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
 void AttackOver()
 {
     startAttack = false;
     AIUtility.OnDamage(attackingMonster, procedureOwner.Owner);
     attackingMonster = null;
 }
Beispiel #4
0
 public bool CanAttackPlayer(Entity attacker)
 {
     return(AIUtility.GetDistance(player, attacker) < minAttackDistance);
 }
Beispiel #5
0
        private void OnTriggerEnter(Collider other)
        {
            Entity entity = other.gameObject.GetComponent <Entity>();

            AIUtility.PerformCollision(this, entity);
        }