public void Init(IEntity entity, AssetStatus status)
        {
            var playerEntity = entity as PlayerEntity;
            var hitboxConfig = status.Object.AsGameObject;

            HitBoxComponentUtility.InitHitBoxComponent(playerEntity.entityKey.Value, playerEntity, hitboxConfig);
        }
Beispiel #2
0
            public void OnLoadSucc(object source, UnityObjectWrapper <GameObject> obj)
            {
                PlayerEntity playerEntity = (PlayerEntity)source;
                var          hitboxConfig = (GameObject)obj;

                HitBoxComponentUtility.InitHitBoxComponent(playerEntity.entityKey.Value, playerEntity, hitboxConfig);
            }
Beispiel #3
0
        public static void OnLoadSucc(object source, UnityObjectWrapper <GameObject> obj)
        {
            VehicleEntity vehicle        = (VehicleEntity)source;
            var           hitboxConfig   = (GameObject)obj;
            var           hitboxImposter = HitBoxComponentUtility.InitHitBoxComponent(vehicle.entityKey.Value, vehicle, hitboxConfig);

            vehicle.ConfigHitBoxImposter(hitboxImposter);
        }
Beispiel #4
0
        public static void OnLoadSucc(VehicleEntity vehicle, UnityObject unityObj)
        {
            var hitboxConfig = unityObj.AsGameObject;

            if (hitboxConfig == null)
            {
                _logger.ErrorFormat("Can not found hitbox for entity {0}", vehicle.entityKey);
                return;
            }

            var hitboxImposter = HitBoxComponentUtility.InitHitBoxComponent(vehicle.entityKey.Value, vehicle, hitboxConfig);

            vehicle.ConfigHitBoxImposter(hitboxImposter);
        }
Beispiel #5
0
        public void OnLoadSucc(PlayerEntity player, UnityObject unityObj)
        {
            if (null == unityObj || null == unityObj.AsGameObject)
            {
                Logger.ErrorFormat("CharacterLog-- playerEntity:  {0}  unityObj is Null", player.entityKey);
            }

            GameObject go = unityObj;

            if (player.hasThirdPersonModel)
            {
                _assetManager.Recycle(player.thirdPersonModel.UnityObjectValue);
                player.RemoveAsset(player.thirdPersonModel.UnityObjectValue);
            }

            player.ReplaceThirdPersonModel(go, unityObj);

            var provider = SingletonManager.Get <HitBoxTransformProviderCache>()
                           .GetProvider(player.thirdPersonModel.Value);

            HitBoxComponentUtility.InitHitBoxComponent(player.entityKey.Value, player, provider);

            RemoveRagdollOnServerSide(go, provider.GetHitBoxColliders().Values.ToList());

            HandleLoadedModel(player, go);

            InitCharacterControllerSetting(player);

            player.AddAsset(unityObj);

            go.name = go.name.Replace("(Clone)", "");

            go.transform.SetParent(GetThirdModelParent(player.RootGo().transform));
            go.transform.localPosition = new Vector3(0, 0, 0);
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            Logger.InfoFormat("CharacterLog-- P3 loaded: {0}", player.entityKey);

            BoneTool.CacheTransform(go);

            player.ReplaceBones(null, null, null);

            player.bones.Head  = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterHeadBoneName);
            player.bones.Spine = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterSpineName);

            player.ReplaceThirdPersonAnimator(go.GetComponent <Animator>());

            if (player.hasFsmInputRelateInterface)
            {
                player.fsmInputRelateInterface.Relate.InitLimit();
                player.fsmInputRelateInterface.Relate.CreateAllLimitFsmInput(player.thirdPersonAnimator.UnityAnimator);
            }

            var ik = go.AddComponent <PlayerIK>();

            ik.SetAnimator(AvatarIKGoal.LeftHand, player.thirdPersonAnimator.UnityAnimator);
            ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer);
            ik.SetAnimator(AvatarIKGoal.RightHand, player.thirdPersonAnimator.UnityAnimator);
            ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer);

            if (player.isFlagSelf)
            {
                var animationEvent = go.AddComponent <AnimationClipEvent>();
                animationEvent.Player = player;
                player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent
                                                                               .InterruptAnimationEventFunc);
            }
            else
            {
                go.AddComponent <ThirdPersonAnimationClipEvent>();
            }

            // 设置大厅传入的roleId和avatarId
            player.appearanceInterface.Appearance.SetRoleModelIdAndInitAvatar(player.playerInfo.RoleModelId,
                                                                              player.playerInfo.AvatarIds);

            player.characterControllerInterface.CharacterController.SetCharacterRoot(player.characterContoller.Value
                                                                                     .gameObject);
            player.appearanceInterface.Appearance.SetRootGo(player.RootGo());
            player.appearanceInterface.Appearance.SetThirdPersonCharacter(go);
            player.appearanceInterface.Appearance.SetRagDollComponent(player.ragDoll);
            player.characterControllerInterface.CharacterController.SetThirdModel(player.thirdPersonModel.Value);

            player.characterBoneInterface.CharacterBone.SetCharacterRoot(player.characterContoller.Value
                                                                         .gameObject);
            player.characterBoneInterface.CharacterBone.SetThirdPersonCharacter(go);
            ForceCrouch(player.thirdPersonAnimator.UnityAnimator);
            player.characterBoneInterface.CharacterBone.SetStableCrouchPelvisRotation();
            ForceStand(player.thirdPersonAnimator.UnityAnimator);
            player.characterBoneInterface.CharacterBone.SetStableStandPelvisRotation();

            player.appearanceInterface.Appearance.SetAnimatorP3(player.thirdPersonAnimator.UnityAnimator);

            player.appearanceInterface.Appearance.PlayerReborn();
            player.characterControllerInterface.CharacterController.PlayerReborn();
            if (player.hasStateInterface)
            {
                player.stateInterface.State.PlayerReborn();
            }
            if (player.hasPlayerInfo)
            {
                player.playerInfo.InitTransform();
            }

            player.ReplaceNetworkAnimator(
                NetworkAnimatorUtil.CreateAnimatorLayers(player.thirdPersonAnimator.UnityAnimator),
                NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator));

            player.networkAnimator.SetEntityName(player.entityKey.ToString());

            player.ReplaceOverrideNetworkAnimator();

            if (SharedConfig.IsServer)
            {
                player.ReplaceNetworkAnimatiorServerTime(0);
            }

            // 禁用非可见状态下的动画更新,在获取Stable状态之后
            if (SharedConfig.IsServer || !player.isFlagSelf)
            {
                player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
            }
            else
            {
                player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
            }

            //人物变身、换肤时,清空特效数据
            if (player.hasEffects)
            {
                player.effects.ResetEffects();
            }

            // 处理显隐
            if (player.hasGamePlay)
            {
                PlayerEntityUtility.SetVisibility(go, player.gamePlay.Visibility);
            }
        }
Beispiel #6
0
            public void OnLoadSucc(PlayerEntity playerEntity, UnityObject unityObject)
            {
                var hitboxConfig = unityObject;

                HitBoxComponentUtility.InitHitBoxComponent(playerEntity.entityKey.Value, playerEntity, hitboxConfig);
            }
Beispiel #7
0
            public void OnLoadSucc(PlayerEntity player, UnityObject unityObj)
            {
                GameObject go = unityObj;

                player.AddThirdPersonModel(go);

                var provider = SingletonManager.Get <HitBoxTransformProviderCache>()
                               .GetProvider(player.thirdPersonModel.Value);

                HitBoxComponentUtility.InitHitBoxComponent(player.entityKey.Value, player, provider);

                RemoveRagdollOnServerSide(go, provider.GetHitBoxColliders().Values.ToList());

                HandleLoadedModel(player, go);

                player.AddAsset(unityObj);

                go.name = go.name.Replace("(Clone)", "");
                go.transform.SetParent(player.RootGo().transform);
                go.transform.localPosition = new Vector3(0, -PlayerEntityUtility.CcSkinWidth, 0);
                go.transform.localRotation = Quaternion.identity;
                go.transform.localScale    = Vector3.one;
                _logger.InfoFormat("P3 loaded: {0}", player.entityKey);

                BoneTool.CacheTransform(go);

                if (!player.hasBones)
                {
                    player.AddBones(null, null, null);
                }

                player.bones.Head  = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterHeadBoneName);
                player.bones.Spine = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterSpineName);

                player.AddThirdPersonAnimator(go.GetComponent <Animator>());

                var ik = go.AddComponent <PlayerIK>();

                ik.SetAnimator(AvatarIKGoal.LeftHand, player.thirdPersonAnimator.UnityAnimator);
                ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer);
                ik.SetAnimator(AvatarIKGoal.RightHand, player.thirdPersonAnimator.UnityAnimator);
                ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer);

                if (player.isFlagSelf)
                {
                    var animationEvent = go.AddComponent <AnimationClipEvent>();
                    animationEvent.Player = player;
                    player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent.InterruptAnimationEventFunc);
                }
                else
                {
                    go.AddComponent <ThirdPersonAnimationClipEvent>();
                }

                // 设置大厅传入的roleId和avatarId
                player.appearanceInterface.Appearance.SetRoleModelIdAndInitAvatar(player.playerInfo.RoleModelId, player.playerInfo.AvatarIds);

                player.characterControllerInterface.CharacterController.SetCharacterRoot(player.characterContoller.Value.gameObject);
                player.appearanceInterface.Appearance.SetThirdPersonCharacter(go);
                player.thirdPersonAnimator.UnityAnimator.Update(0);
                player.characterControllerInterface.CharacterController.SetThirdModel(player.thirdPersonModel.Value);

                player.characterBoneInterface.CharacterBone.SetCharacterRoot(player.characterContoller.Value.gameObject);
                player.characterBoneInterface.CharacterBone.SetThirdPersonCharacter(go);
                player.characterBoneInterface.CharacterBone.SetStablePelvisRotation();

                player.appearanceInterface.Appearance.SetAnimatorP3(player.thirdPersonAnimator.UnityAnimator);

                player.appearanceInterface.Appearance.PlayerReborn();
                player.characterControllerInterface.CharacterController.PlayerReborn();

                // 实际应该使用SharedConfig.IsServer,但离线模式中其值为false
                if (!player.hasNetworkAnimator)
                {
                    player.AddNetworkAnimator(NetworkAnimatorUtil.CreateAnimatorLayers(player.thirdPersonAnimator.UnityAnimator),
                                              NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator));

                    player.networkAnimator.SetEntityName(player.entityKey.ToString());
                }

                if (!player.hasOverrideNetworkAnimator)
                {
                    player.AddOverrideNetworkAnimator();
                }

                if (SharedConfig.IsServer)
                {
                    player.AddNetworkAnimatiorServerTime(0);
                }

                // 禁用非可见状态下的动画更新,在获取Stable状态之后
                if (SharedConfig.IsServer || !player.isFlagSelf)
                {
                    player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
                }
                else
                {
                    player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                }

//                _assetManager.LoadAssetAsync(player, AssetConfig.GetCharacterHitboxAssetInfo(player.playerInfo.ModelName), new HitboxLoadResponseHandler().OnLoadSucc);
            }