private void LoadAvatar(SceneObjectEntity sceneObjectEntity, PlayerEntity playerEntity,
                                RoleAvatarConfigItem avatarCfg)
        {
            var role = SingletonManager.Get <RoleConfigManager>().GetRoleItemById(playerEntity.playerInfo.RoleModelId);

            if (null != role)
            {
                switch ((Sex)role.Sex)
                {
                case Sex.Female:
                    var fAvatarAsset = new AssetInfo(avatarCfg.Bundle, avatarCfg.FPrefab);
                    _assetManager.LoadAssetAsync(sceneObjectEntity, fAvatarAsset,
                                                 simpleLoadHandler.OnLoadUnityObjectSucess);
                    break;

                case Sex.Male:
                    var mAvatarAsset = new AssetInfo(avatarCfg.Bundle, avatarCfg.MPrefab);
                    _assetManager.LoadAssetAsync(sceneObjectEntity, mAvatarAsset,
                                                 simpleLoadHandler.OnLoadUnityObjectSucess);
                    break;
                }

                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
            }
        }
 private void LoadEffectAssetAsync(SceneObjectEntity sceneObjectEntity, AssetInfo assetInfo)
 {
     if (sceneObjectEntity.multiUnityObject.AddLoadingAssets(assetInfo))
     {
         _assetManager.LoadAssetAsync(sceneObjectEntity, assetInfo, weaponLoadHandler.OnLoadEffectObjetSucess);
     }
     else
     {
         weaponLoadHandler.OnLoadEffectObjetSucess(sceneObjectEntity,
                                                   sceneObjectEntity.multiUnityObject.LoadedAssets[assetInfo]);
     }
 }
Exemplo n.º 3
0
        void LoadAsset(int effectId)
        {
            var effectConfig = SingletonManager.Get <ClientEffectConfigManager>().GetConfigItemById(effectId);

            if (effectConfig != null && null != effectConfig.Asset)
            {
                Asset = new AssetInfo(effectConfig.Asset.BundleName, effectConfig.Asset.AssetName);
            }
            else
            {
                Asset = AssetInfo.EmptyInstance;
            }
            StageType = EEffectStageType.WaitCreate;
        }
 private void LoadPartAssetAsync(SceneObjectEntity sceneObjectEntity, AssetInfo assetInfo,
                                 PartAssetData partAssetData)
 {
     sceneObjectEntity.weaponAttachment.PartAssetDict[assetInfo] = partAssetData;
     if (sceneObjectEntity.multiUnityObject.AddLoadingAssets(assetInfo))
     {
         _assetManager.LoadAssetAsync(sceneObjectEntity, assetInfo, weaponLoadHandler.OnLoadPartObjectSucess);
     }
     else
     {
         weaponLoadHandler.OnLoadPartObjectSucess(sceneObjectEntity,
                                                  sceneObjectEntity.multiUnityObject.LoadedAssets[assetInfo]);
     }
 }
        private void LoadWeaponObject(SceneObjectEntity sceneObjectEntity, WeaponResConfigItem weaponCfg)
        {
            var avatarId = weaponCfg.AvatorId;

            if (sceneObjectEntity.weaponObject.WeaponAvatarId > 0)
            {
                avatarId = sceneObjectEntity.weaponObject.WeaponAvatarId;
            }
            AssetInfo thdPersonAsset = SingletonManager.Get <WeaponAvatarConfigManager>().GetThirdPersonWeaponModel(avatarId);

            if (!sceneObjectEntity.hasMultiUnityObject)
            {
                sceneObjectEntity.AddMultiUnityObject();
            }
            else
            {
                sceneObjectEntity.multiUnityObject.Prepare();
            }
            if (!sceneObjectEntity.hasWeaponAttachment)
            {
                sceneObjectEntity.AddWeaponAttachment();
            }
            else
            {
                sceneObjectEntity.weaponAttachment.Reset();
            }
            LoadNecessaryAssetAsync(sceneObjectEntity, thdPersonAsset);
            List <int> weaponParts = sceneObjectEntity.weaponObject.CollectParts();

            for (int i = 0; i < weaponParts.Count; i++)
            {
                AssetInfo partAssetInfo = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(weaponParts[i]);
                var       partAssetData = new PartAssetData();
                partAssetData.PartId       = weaponParts[i];
                partAssetData.PartSlotType = (int)SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(weaponParts[i]);
                LoadPartAssetAsync(sceneObjectEntity, partAssetInfo, partAssetData);
            }

            //加载特效
            List <AssetInfo> effectAssetInfo =
                SingletonManager.Get <WeaponAvatarConfigManager>().GetEffectAsset(avatarId);

            foreach (var effect in effectAssetInfo)
            {
                LoadEffectAssetAsync(sceneObjectEntity, effect);
            }

            sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
        }
Exemplo n.º 6
0
        private void LoadWeaponResources(SceneObjectEntity sceneObjectEntity,
                                         WeaponConfigNs.WeaponResConfigItem weaponCfg)
        {
            var avatarId = weaponCfg.AvatorId;

            if (sceneObjectEntity.hasWeaponObject && sceneObjectEntity.weaponObject.WeaponAvatarId > 0)
            {
                avatarId = sceneObjectEntity.weaponObject.WeaponAvatarId;
            }

            AssetInfo asset =
                SingletonManager.Get <WeaponAvatarConfigManager>().GetThirdPersonWeaponModel(avatarId);
            bool alreadyInitializedBefore = true;

            if (!sceneObjectEntity.hasMultiUnityObject || !sceneObjectEntity.hasWeaponAttachment)
            {
                alreadyInitializedBefore = false;

                sceneObjectEntity.AddMultiUnityObject();
                sceneObjectEntity.AddWeaponAttachment(
                    new Dictionary <AssetInfo, int>(AssetInfo.AssetInfoComparer.Instance), new List <AssetInfo>());
            }

            var dic = sceneObjectEntity.multiUnityObject.LoadedAssets;

            if (!alreadyInitializedBefore)
            {
                AssetInfo assetInfo = new AssetInfo(asset.BundleName, asset.AssetName);
                dic[assetInfo] = null;
                _assetManager.LoadAssetAsync(sceneObjectEntity, assetInfo, _weaponLoadHandler.OnLoadSucc);
            }

            var weaponParts = sceneObjectEntity.weaponObject.CollectParts();

            for (int i = 0; i < weaponParts.Count; i++)
            {
                var       attachId  = weaponParts[i];
                var       attach    = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(attachId);
                AssetInfo partsInfo = new AssetInfo(attach.BundleName, attach.AssetName);
                if (!sceneObjectEntity.weaponAttachment.AttachmentDic.ContainsKey(partsInfo))
                {
                    dic[partsInfo] = null;
                    sceneObjectEntity.weaponAttachment.AttachmentDic[partsInfo] =
                        (int)SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(attachId);
                    _assetManager.LoadAssetAsync(sceneObjectEntity, partsInfo, _weaponLoadHandler.OnLoadSucc);
                }
            }

            List <AssetInfo> effectAssetInfo =
                SingletonManager.Get <WeaponAvatarConfigManager>().GetEffectAsset(avatarId);

            if (effectAssetInfo.Count > 0)
            {
                foreach (var effect in effectAssetInfo)
                {
                    dic[effect] = null;
                    _assetManager.LoadAssetAsync(sceneObjectEntity, effect, _weaponLoadHandler.OnLoadSucc);
                    sceneObjectEntity.weaponAttachment.EffectDic.Add(effect);
                }
            }

            sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
        }
Exemplo n.º 7
0
        private void LoadSimpleEquip(SceneObjectEntity sceneObjectEntity)
        {
            var category = sceneObjectEntity.simpleEquipment.Category;
            var id       = sceneObjectEntity.simpleEquipment.Id;

            if (id < 1)
            {
                Logger.ErrorFormat("itemid is illegal for weapon {0}", sceneObjectEntity.entityKey);
                return;
            }

            switch ((ECategory)category)
            {
            case ECategory.Weapon:
                var allConfigs = SingletonManager
                                 .Get <WeaponConfigManagement>()
                                 .FindConfigById(sceneObjectEntity.weaponObject.ConfigId);
                var weaponAvatarCfg = SingletonManager
                                      .Get <WeaponAvatarConfigManager>()
                                      .GetConfigById(allConfigs.NewWeaponCfg.AvatorId);
                if (null == weaponAvatarCfg || allConfigs == null)
                {
                    return;
                }

                if (weaponAvatarCfg.Size != 1)
                {
                    sceneObjectEntity.AddSize(weaponAvatarCfg.Size);
                }

                sceneObjectEntity.weaponObject.ApplyParts(allConfigs.DefaultParts);
                LoadWeaponResources(sceneObjectEntity, allConfigs.NewWeaponCfg);
                break;

            case ECategory.Avatar:
                var avatarCfg = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(id);
                if (null != avatarCfg)
                {
                    var player = _playerContext.flagSelfEntity;
                    if (null != player && player.hasPlayerInfo)
                    {
                        LoadAvatar(sceneObjectEntity, player, avatarCfg);
                    }
                }

                break;

            case ECategory.WeaponPart:
                var partId    = SingletonManager.Get <WeaponPartSurvivalConfigManager>().GetDefaultPartBySetId(id);
                var partCfg   = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(partId);
                var partAsset = new AssetInfo(partCfg.Bundle, partCfg.Res);
                if (string.IsNullOrEmpty(partAsset.AssetName) || string.IsNullOrEmpty(partAsset.BundleName))
                {
                    break;
                    ;
                }

                var partSize = SingletonManager.Get <WeaponPartSurvivalConfigManager>().GetSizeById(id);
                if (partSize != 1)
                {
                    sceneObjectEntity.AddSize(partSize);
                }

                _assetManager.LoadAssetAsync(sceneObjectEntity, partAsset, _simpleLoadHandler.OnLoadSucc);

                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);

                break;

            case ECategory.GameItem:
                var itemSsset = SingletonManager.Get <GameItemConfigManager>().GetAssetById(id);
                if (string.IsNullOrEmpty(itemSsset.AssetName) || string.IsNullOrEmpty(itemSsset.BundleName))
                {
                    return;
                }

                var itemSize = SingletonManager.Get <GameItemConfigManager>().GetSizeById(id);
                if (itemSize != 1)
                {
                    sceneObjectEntity.AddSize(itemSize);
                }

                _assetManager.LoadAssetAsync(sceneObjectEntity, itemSsset, _simpleLoadHandler.OnLoadSucc);
                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
                break;
            }
        }
        private void LoadSimpleItem(SceneObjectEntity sceneObjectEntity)
        {
            var category = sceneObjectEntity.simpleItem.Category;
            var id       = sceneObjectEntity.simpleItem.Id;

            if (id < 1)
            {
                Logger.ErrorFormat("itemid is illegal for item {0}", sceneObjectEntity.entityKey);
                return;
            }

            switch ((ECategory)category)
            {
            case ECategory.Avatar:
                var avatarCfg = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(id);
                if (null != avatarCfg)
                {
                    if (null != _playerContext.flagSelfEntity && _playerContext.flagSelfEntity.hasPlayerInfo)
                    {
                        LoadAvatar(sceneObjectEntity, _playerContext.flagSelfEntity, avatarCfg);
                    }
                }
                break;

            case ECategory.WeaponPart:
                var partId    = SingletonManager.Get <WeaponPartSurvivalConfigManager>().GetDefaultPartBySetId(id);
                var partCfg   = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(partId);
                var partAsset = new AssetInfo(partCfg.Bundle, partCfg.Res);
                if (string.IsNullOrEmpty(partAsset.AssetName) || string.IsNullOrEmpty(partAsset.BundleName))
                {
                    break;
                }

                var partSize = SingletonManager.Get <WeaponPartSurvivalConfigManager>().GetSizeById(id);
                if (partSize != 1)
                {
                    sceneObjectEntity.AddSize(partSize);
                }

                _assetManager.LoadAssetAsync(sceneObjectEntity, partAsset,
                                             simpleLoadHandler.OnLoadUnityObjectSucess);

                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);

                break;

            case ECategory.GameItem:
                var itemSsset = SingletonManager.Get <GameItemConfigManager>().GetAssetById(id);
                if (string.IsNullOrEmpty(itemSsset.AssetName) || string.IsNullOrEmpty(itemSsset.BundleName))
                {
#if UNITY_EDITOR
                    UnityEngine.Debug.LogError(string.Format("item is not config for id {0}", id));
#else
                    Logger.ErrorFormat("item is not config for id {0}", id);
#endif
                    return;
                }

                var itemSize = SingletonManager.Get <GameItemConfigManager>().GetSizeById(id);
                if (itemSize != 1)
                {
                    sceneObjectEntity.AddSize(itemSize);
                }

                _assetManager.LoadAssetAsync(sceneObjectEntity, itemSsset,
                                             simpleLoadHandler.OnLoadUnityObjectSucess);
                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
                break;
            }
        }