Пример #1
0
        public static void RectCollisionDetectAttack(string attackName, ConfigEntityAttackPattern patternConfig, IAttacker attacker, LayerMask layerMask)
        {
            RectCollisionDetect    detect         = (RectCollisionDetect)patternConfig;
            Vector3                recCenterPoint = new Vector3(attacker.XZPosition.x, attacker.XZPosition.y + detect.CenterYOffset, attacker.XZPosition.z);
            List <CollisionResult> results        = CollisionDetectPattern.RectCollisionDetectByRay(recCenterPoint, detect.OffsetZ, attacker.FaceDirection, detect.Width, detect.Distance, layerMask);

            TestAndActHit(attackName, patternConfig, attacker, results);
        }
Пример #2
0
        private static List <CollisionResult> FilterRealAttackeesByBodyParts(string attackName, ConfigEntityAttackPattern patternConfig, IAttacker attacker, List <CollisionResult> results)
        {
            ConfigEntityAttackPattern pattern = patternConfig;
            Dictionary <BaseMonoEntity, List <CollisionResult> > dictionary = new Dictionary <BaseMonoEntity, List <CollisionResult> >();
            List <CollisionResult> list = new List <CollisionResult>();

            foreach (CollisionResult result in results)
            {
                BaseMonoEntity entity = result.entity;
                if (entity != null)
                {
                    if (entity is MonoBodyPartEntity)
                    {
                        BaseMonoEntity owner = ((MonoBodyPartEntity)entity).owner;
                        if (!dictionary.ContainsKey(owner))
                        {
                            dictionary[owner] = new List <CollisionResult>();
                        }
                        dictionary[owner].Add(result);
                    }
                    else
                    {
                        list.Add(result);
                    }
                }
            }
            List <CollisionResult> list3 = new List <CollisionResult>();

            foreach (CollisionResult result2 in list)
            {
                if (!dictionary.ContainsKey(result2.entity))
                {
                    list3.Add(result2);
                }
            }
            foreach (BaseMonoEntity entity3 in dictionary.Keys)
            {
                CollisionResult result3 = null;
                if (((pattern is FanCollisionDetect) || (pattern is CylinderCollisionDetect)) || ((pattern is CylinderCollisionDetectTargetLocked) || (pattern is RectCollisionDetect)))
                {
                    Vector3 b = new Vector3();
                    if (pattern is RectCollisionDetect)
                    {
                        RectCollisionDetect detect        = (RectCollisionDetect)pattern;
                        Vector3             vector2       = new Vector3(attacker.XZPosition.x, 0f, attacker.XZPosition.z);
                        Vector3             faceDirection = attacker.FaceDirection;
                        faceDirection.y = 0f;
                        b = vector2 + ((Vector3)(detect.OffsetZ * faceDirection.normalized));
                    }
                    else
                    {
                        b = attacker.XZPosition;
                    }
                    float maxValue = float.MaxValue;
                    foreach (CollisionResult result4 in dictionary[entity3])
                    {
                        float num2 = Vector3.Distance(result4.entity.XZPosition, b);
                        if (num2 < maxValue)
                        {
                            result3  = result4;
                            maxValue = num2;
                        }
                    }
                }
                else
                {
                    result3 = dictionary[entity3][0];
                }
                CollisionResult item = new CollisionResult(entity3, result3.hitPoint, result3.hitForward);
                list3.Add(item);
            }
            return(list3);
        }