Exemplo n.º 1
0
        public AvatarProperty(AvatarProperty other)
        {
            BodyId          = other.BodyId;
            WeaponId        = other.WeaponId;
            FashionWingId   = other.FashionWingId;
            FashionBodyId   = other.FashionBodyId;
            FashionWeaponId = other.FashionWeaponId;
            EquipBodyId     = other.EquipBodyId;
            EquipWeaponId   = other.EquipWeaponId;

            if (other.SuitEffectIds != null)
            {
                SuitEffectIds = new List <uint>(other.SuitEffectIds);
            }

            WingResPath = other.WingResPath;

            Vocation = other.Vocation;

            ElfinId      = other.ElfinId;
            ElfinResPath = other.ElfinResPath;

            FashionMagicalPetId = other.FashionMagicalPetId;
            MagicalPetResPath   = other.MagicalPetResPath;

            FashionFootprintId  = other.FashionFootprintId;
            FashionBubbleId     = other.FashionBubbleId;
            FashionPhotoFrameId = other.FashionPhotoFrameId;
            LightWeaponId       = other.LightWeaponId;
            BackAttachmentID    = other.BackAttachmentID;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 使用传入的actor的换装数据来创建新的预览角色
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="actionAfterLoad"></param>
        /// <returns></returns>
        public static UnitID CreateClientModelByCloneForLua(Actor actor, Action <Actor> actionAfterLoad, bool updateWithRawActor = true, bool isUIModel = true)
        {
            if (actor == null || actor.mAvatarCtrl == null)
            {
                return(null);
            }
            AvatarProperty ap           = actor.mAvatarCtrl.GetLatestAvatartProperty();
            List <uint>    modelList    = new List <uint>();
            List <uint>    fashionList  = new List <uint>();
            List <uint>    suit_effects = null;

            if (ap != null)
            {
                modelList    = ap.GetEquipModleIds();
                fashionList  = ap.GetFashionModleIds();
                suit_effects = ap.SuitEffectIds != null ? new List <uint>(ap.SuitEffectIds) : null;
            }
            ClientModel client_model = CreateClientModel(actor.TypeIdx, actor.UID.obj_idx, modelList, fashionList, suit_effects, actionAfterLoad, updateWithRawActor, isUIModel);

            if (client_model == null)
            {
                return(null);
            }

            ShadowBehavior shadow_behavior = client_model.GetBehavior <ShadowBehavior>();

            if (shadow_behavior != null)
            {
                shadow_behavior.HideFakeShadow = true;
            }

            return(client_model.UID);
        }
Exemplo n.º 3
0
        void OnSwitchScene(CEventBaseArgs kArgs)
        {
            Clear();

            foreach (SGameEngine.AssetResource ar in mPreloadedTimelineReses.Values)
            {
                if (ar != null)
                {
                    ar.destroy();
                }
            }
            mPreloadedTimelineReses.Clear();

            foreach (Coroutine coroutine in mLoadPrefabCoroutines)
            {
                SGameEngine.ResourceLoader.Instance.StopCoroutine(coroutine);
            }
            mLoadPrefabCoroutines.Clear();

            Actor localPlayer = Game.Instance.GetLocalPlayer();

            if (localPlayer != null && localPlayer.mAvatarCtrl != null && localPlayer.mAvatarCtrl.GetLatestAvatartProperty() != null)
            {
                mPlayerLastSceneAvatarProperty = localPlayer.mAvatarCtrl.GetLatestAvatartProperty();
            }
        }
Exemplo n.º 4
0
        //剧情换装
        public static IEnumerator ChangeModel(GameObject model, AvatarProperty ap, bool isLocalPlayer = true)
        {
            if (ap == null)
            {
                yield break;
            }

            yield return(ResourceLoader.Instance.StartCoroutine(ChangePart(model, ap.BodyId, isLocalPlayer)));

            yield return(ResourceLoader.Instance.StartCoroutine(ChangePart(model, ap.WeaponId, isLocalPlayer)));

            yield return(ResourceLoader.Instance.StartCoroutine(SetSuitEffect(model, ap, isLocalPlayer)));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 通过actor的avatar数据来创建角色(用于创建上坐骑的角色)
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="actionAfterLoad"></param>
        /// <returns></returns>
        public static ClientModel CreateClientModelByClone(Actor actor, Action <Actor> actionAfterLoad)
        {
            if (actor == null || actor.mAvatarCtrl == null)
            {
                return(null);
            }
            AvatarProperty ap = actor.mAvatarCtrl.GetLatestAvatartProperty();

            if (ap == null || actor == null)
            {
                return(null);
            }

            List <uint> suit_effects = ap.SuitEffectIds != null ? new List <uint>(ap.SuitEffectIds) : null;
            ClientModel cm           = CreateClientModel(actor.TypeIdx, actor.UID.obj_idx, ap.GetEquipModleIds(), ap.GetFashionModleIds(), suit_effects, actionAfterLoad);

            cm.mAvatarCtrl.CloneAvatar(actor);
            cm.IsRidePlayer = true;
            //ActorManager.Instance.StartCoroutine(RotineCreateClientModelByClone(actor ,cm,  actionAfterLoad));
            return(cm);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 设置套装特效
        /// </summary>
        /// <param name="effect_id_list"></param>
        /// <returns></returns>
        private static IEnumerator SetSuitEffect(GameObject model, AvatarProperty ap, bool isLocalPlayer = true)
        {
            List <uint> effect_id_list = ap.SuitEffectIds;

            if (effect_id_list == null || effect_id_list.Count == 0 || model == null)
            {
                yield break;
            }

            // 屏蔽特效显示

            /*if (!EnableEffect)
             * {
             *  if (mOwner == null || !mOwner.UID.Equals(Game.GetInstance().LocalPlayerID))
             *      yield return null;
             * }*/

            //var avartaPartData = DBManager.GetInstance().GetDB<DBAvatarPart>().mData;

            foreach (var id in effect_id_list)
            {
                var effect_id = id;
                if (id == 1 || id == 2)
                {
                    effect_id = id == 1 ? ap.BodyId : ap.WeaponId;
                }

                var effect_info = DBManager.Instance.GetDB <DBSuitEffect>().GetEffectInfo(effect_id);
                if (effect_info == null)
                {
                    GameDebug.Log("Cannot find suit effect info, id: " + effect_id);
                    continue;
                }

                // 检查特效id是否与当前的装备或武器匹配
                if (effect_info.effect_type == 1)
                {
                    if (effect_id != ap.BodyId)
                    {
                        continue;
                    }
                }
                else if (effect_info.effect_type == 2)
                {
                    if (effect_id != ap.WeaponId)
                    {
                        continue;
                    }
                }

                bool is_local_player_model = isLocalPlayer;
                foreach (var bind_info in effect_info.bind_infos)
                {
                    // 本地玩家才使用高配的特效
                    string res_path = "";

                    if (is_local_player_model)                // 本地玩家
                    {
                        if (QualitySetting.GraphicLevel == 2) // 低配也使用低配特效
                        {
                            res_path = ModelHelper.GetModelPrefab(bind_info.low_model_id);
                        }
                        else
                        {
                            res_path = ModelHelper.GetModelPrefab(bind_info.model_id);
                        }
                    }
                    else// 其他玩家
                    {
                        res_path = ModelHelper.GetModelPrefab(bind_info.low_model_id);
                    }

                    if (string.IsNullOrEmpty(res_path))
                    {
                        GameDebug.LogError("Cannot find suit res info, model_id: " + bind_info.model_id);
                        continue;
                    }

                    var mount_point = CommonTool.FindChildInHierarchy(model.transform, bind_info.bind_node);
                    if (mount_point == null)
                    {
                        GameDebug.LogError("Cannot find suit mount point, bind_node: " + bind_info.bind_node);
                        continue;
                    }

                    ObjectWrapper ow = new ObjectWrapper();
                    yield return(ResourceLoader.Instance.StartCoroutine(ObjCachePoolMgr.Instance.LoadPrefab(res_path, ObjCachePoolType.SFX, res_path, ow)));

                    GameObject effect_object = ow.obj as GameObject;

                    if (effect_object == null)
                    {
                        GameDebug.LogError("Cannot load suit effect point, res_path: " + res_path);
                        continue;
                    }

                    GameObject.DontDestroyOnLoad(effect_object);
                    if (model == null)
                    {
                        ObjCachePoolMgr.Instance.RecyclePrefab(effect_object, ObjCachePoolType.SFX, res_path);
                        break;
                    }

                    //int layer = 0;
                    //if (mModelParent != null)
                    //    layer = mModelParent.layer;
                    //SetRenderLayer(effect_object, layer, false, false);
                    //m_EffectObjs[res_path] = effect_object;

                    var trans = effect_object.transform;
                    trans.parent        = mount_point;
                    trans.localPosition = Vector3.zero;
                    trans.localRotation = Quaternion.identity;
                    trans.localScale    = Vector3.one;

                    ListTrailRenderer trail_render_list = effect_object.GetComponent <ListTrailRenderer>();
                    if (trail_render_list == null)
                    {
                        trail_render_list = effect_object.AddComponent <ListTrailRenderer>();
                    }
                    if (trail_render_list != null)
                    {
                        trail_render_list.ResetPos();
                    }

                    // 设置层级
                    xc.ui.ugui.UIHelper.SetLayer(effect_object.transform, model.layer);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 播放Timeline动画
        /// </summary>
        /// <param name="id">剧情配置表里面的id</param>
        /// <param name="finishCallback">播放结束回调</param>
        public void Play(uint id, System.Action finishCallback = null, AvatarProperty avatarProperty = null)
        {
            //GameDebug.LogError("TimelineManager.Play: " + id);
            //GameDebug.Log("TimelineManager.Play: " + id);

            TimelineConfig timelineConfig = null;

            if (GetTimelineConfig(id, out timelineConfig) == false)
            {
                if (finishCallback != null)
                {
                    finishCallback();
                }

                GameDebug.LogError("Play timeline error, can not find timeline id: " + id);
                return;
            }

            if (QualitySetting.SkipTimeline(timelineConfig.MinMemory) == true)
            {
                // 野外场景中记住正在寻路的任务
                uint navigatingTaskId = 0;
                if (SceneHelp.Instance.IsInWildInstance() == true)
                {
                    Task navigatingTask = TaskManager.Instance.NavigatingTask;
                    if (navigatingTask != null)
                    {
                        navigatingTaskId = navigatingTask.Define.Id;
                    }
                }
                bool isAutoFighting = InstanceManager.Instance.IsAutoFighting;

                if (finishCallback != null)
                {
                    finishCallback();
                }

                // 恢复自动战斗和任务寻路
                InstanceManager.Instance.IsAutoFighting = isAutoFighting;
                if (navigatingTaskId > 0)
                {
                    TaskHelper.TaskGuide(navigatingTaskId);
                }

                return;
            }

            mPlayedTimelineIds.Add(id);

            if (mLoadingTimelineIdList.Contains(id) == false)
            {
                mLoadingTimelineIdList.Add(id);
            }

            // 停止并禁止玩家操作
            if (timelineConfig.NoStopLocalPlayer == false)
            {
                Actor localPlayer = Game.Instance.GetLocalPlayer();
                if (localPlayer != null)
                {
                    localPlayer.Stop();
                    localPlayer.MoveCtrl.TryWalkAlongStop();
                }
            }
            GameInput.Instance.EnableInput(false, true);

            Coroutine coroutine = SGameEngine.ResourceLoader.Instance.StartCoroutine(LoadPrefabCoroutine(timelineConfig, finishCallback, avatarProperty));

            mLoadPrefabCoroutines.Add(coroutine);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 加载timeline prefab协程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="prefabPath"></param>
        /// <param name="finishCallback"></param>
        /// <param name="pos"></param>
        /// <param name="needCameraFollowInterpolationWhenFinished"></param>
        /// <param name="showLocalPlayer"></param>
        /// <returns></returns>
        IEnumerator LoadPrefabCoroutine(TimelineConfig config, System.Action finishCallback, AvatarProperty avatarProperty)
        {
            uint    id         = config.Id;
            string  prefabPath = config.PrefabPath;
            Vector3 pos        = config.Pos;
            Vector3 rotation   = config.Rotation;
            bool    needCameraFollowInterpolationWhenFinished = config.NeedCameraFollowInterpolationWhenFinished;
            bool    showLocalPlayer   = config.ShowLocalPlayer;
            bool    noStopLocalPlayer = config.NoStopLocalPlayer;
            bool    showUI            = config.ShowUI;
            bool    pauseMusic        = config.PauseMusic;
            bool    needGC            = config.NeedGC;

            SGameEngine.PrefabResource pr = new SGameEngine.PrefabResource();
            yield return(SGameEngine.ResourceLoader.Instance.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab(string.Format("Assets/Res{0}.prefab", prefabPath), pr)));

            // 延迟资源的加载,测试用
            //yield return new WaitForSeconds(5f);

            // 恢复玩家操作
            GameInput.Instance.EnableInput(true, true);

            GameObject obj = pr.obj_;

            if (obj == null)
            {
                if (finishCallback != null)
                {
                    finishCallback();
                }

                if (mLoadingTimelineIdList.Contains(id) == true)
                {
                    mLoadingTimelineIdList.Remove(id);
                }

                GameDebug.LogError("Play timeline " + prefabPath + " error, can not load prefab!");
                yield break;
            }

            PlayableDirector playableDirector = obj.GetComponent <PlayableDirector>();

            if (playableDirector == null)
            {
                GameObject.DestroyImmediate(obj);

                if (finishCallback != null)
                {
                    finishCallback();
                }

                if (mLoadingTimelineIdList.Contains(id) == true)
                {
                    mLoadingTimelineIdList.Remove(id);
                }

                GameDebug.LogError("Play timeline " + prefabPath + " error, can not find PlayableDirector component!");
                yield break;
            }

            string relatedPrefabPath = config.RelatedPrefabPath;

            SGameEngine.PrefabResource relatedPrefabPr = null;
            if (string.IsNullOrEmpty(relatedPrefabPath) == false)
            {
                relatedPrefabPr = new SGameEngine.PrefabResource();
                yield return(SGameEngine.ResourceLoader.Instance.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab(string.Format("Assets/Res{0}.prefab", relatedPrefabPath), relatedPrefabPr)));
            }

            obj.SetActive(false);
            obj.transform.position         = pos;
            obj.transform.localScale       = Vector3.one;
            obj.transform.localEulerAngles = rotation;

            TimelineInfo timelineInfo = new TimelineInfo();

            playableDirector.time         = 0;
            timelineInfo.Id               = id;
            timelineInfo.PlayableDirector = playableDirector;
            timelineInfo.FinishCallback   = finishCallback;
            timelineInfo.AvatarProperty   = avatarProperty;
            timelineInfo.NeedCameraFollowInterpolationWhenFinished = needCameraFollowInterpolationWhenFinished;
            timelineInfo.ShowLocalPlayer   = showLocalPlayer;
            timelineInfo.NoStopLocalPlayer = noStopLocalPlayer;
            timelineInfo.ShowUI            = showUI;
            timelineInfo.PauseMusic        = pauseMusic;
            timelineInfo.NeedGC            = needGC;

            // 关联GameObject
            timelineInfo.RelatedGameObject = null;
            if (relatedPrefabPr != null)
            {
                if (relatedPrefabPr.obj_ != null)
                {
                    timelineInfo.RelatedGameObject = relatedPrefabPr.obj_;
                    timelineInfo.RelatedGameObject.SetActive(false);
                    timelineInfo.RelatedGameObject.transform.position         = config.RelatedPrefabPos;
                    timelineInfo.RelatedGameObject.transform.localScale       = Vector3.one;
                    timelineInfo.RelatedGameObject.transform.localEulerAngles = Vector3.zero;
                }
                else
                {
                    GameDebug.LogError("Play timeline " + id + " error, can not load related prefab " + relatedPrefabPath);
                }
            }

            // lua脚本
            if (string.IsNullOrEmpty(config.BehaviorScript) == false)
            {
                if (LuaScriptMgr.Instance != null && LuaScriptMgr.Instance.IsLuaScriptExist(config.BehaviorScript))
                {
                    LuaMonoBehaviour com = obj.AddComponent <LuaMonoBehaviour>();
                    com.Init(config.BehaviorScript);
                }
                else
                {
                    System.Type t = System.Type.GetType(config.BehaviorScript);
                    if (t != null)
                    {
                        obj.AddComponent(t);
                    }
                }
            }

            // 延迟资源的加载,测试用
            //yield return new WaitForSeconds(10f);

            if (mPlayingTimeline != null)
            {
                mCacheTimelineList.Enqueue(timelineInfo);
            }
            else
            {
                PlayImpl(timelineInfo);
            }

            if (mLoadingTimelineIdList.Contains(id) == true)
            {
                mLoadingTimelineIdList.Remove(id);
            }

            //GameDebug.LogError("TimelineManager.LoadPrefabCoroutine: " + id);
        }