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

            AIUtility.PerformCollision(this, entity);
        }