コード例 #1
0
        public static GameObject InitHitBoxComponent(EntityKey entityKey, IHitBox playerEntity, GameObject hitboxGo)
        {
            hitboxGo.name = "hitbox_" + entityKey;
            GameObject bsGo = HitBoxConstants.FindBoundingSphereModel(hitboxGo);

            SphereCollider sc = bsGo.GetComponent <SphereCollider>();

            sc.enabled = false;

            hitboxGo.transform.Recursively(t =>
            {
                var go = t.gameObject;
                HitBoxOwnerComponent pc = go.GetComponent <HitBoxOwnerComponent>();
                if (pc == null)
                {
                    pc = go.AddComponent <HitBoxOwnerComponent>();
                }
                pc.OwnerEntityKey   = entityKey;
                pc.gameObject.layer = UnityLayers.HitBoxLayer;
            });
            playerEntity.AddHitBox(new BoundingSphere(sc.center, sc.radius), hitboxGo);
            hitboxGo.SetActive(false);

            return(hitboxGo);
        }
コード例 #2
0
        public static HitBoxInfo ParseFromTransform(Transform root)
        {
            var info = new HitBoxInfo();

            Read(info, root, RootName);

            var sp = HitBoxConstants.FindBoundingSphereModel(root.gameObject).GetComponent <SphereCollider>();

            info.HitPreliminaryGeo = new BoundingSphere {
                position = sp.center, radius = sp.radius
            };
            info.Root = root.name;
            return(info);
        }