コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
 void AttackOver()
 {
     startAttack = false;
     AIUtility.OnDamage(attackingMonster, procedureOwner.Owner);
     attackingMonster = null;
 }
コード例 #4
0
 public bool CanAttackPlayer(Entity attacker)
 {
     return(AIUtility.GetDistance(player, attacker) < minAttackDistance);
 }
コード例 #5
0
ファイル: TargetableObject.cs プロジェクト: happylays/tbb2
        private void OnTriggerEnter(Collider other)
        {
            Entity entity = other.gameObject.GetComponent <Entity>();

            AIUtility.PerformCollision(this, entity);
        }