예제 #1
0
        public override void Load()
        {
            string path = PathHelp.GetFullPaltformPath(mStrPath, false);

            if (System.IO.File.Exists(path))
            {
                System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
                if (stream != null)
                {
                    byte[] content = new byte[stream.Length];
                    stream.Read(content, 0, (int)stream.Length);

                    IsLoaded = true;

                    string strData = CommonTool.BytesToUtf8(content);
                    ParseData(strData);
                    stream.Close();
                }
            }
        }
예제 #2
0
        public static void SetActorScale(Actor actor, float modelScale, Vector2 modelOffset, bool isPlayer, UIPreviewTexture previewTexture)
        {
            if (actor != null && actor.MoveImplement != null)
            {
                actor.transform.rotation = new Quaternion(0f, 180f, 0f, 1f);
                actor.Play("idle");

                var actorRq = actor.gameObject.AddComponent <ActorRenderqueueComponent>();
                actorRq.ExplicitRenderQueue = 4000;

                int layer = LayerMask.NameToLayer("UI");
                actor.gameObject.layer = layer;
                CommonTool.SetChildLayer(actor.transform, layer);

                // 设置模型缩放和位置
                Vector3 scale = actor.transform.localScale * modelScale;
                if (isPlayer)
                {
                    if (actor.MoveImplement.CharacterRadius > 0f)
                    {
                        scale = scale * 0.375f / actor.MoveImplement.CharacterRadius;
                    }
                    previewTexture.CameraPosOffset = new Vector3(0f, 1.5f, -4.5f);
                }
                else
                {
                    if (actor.MoveImplement.CharacterRadius > 0f)
                    {
                        scale = scale * 1f / actor.MoveImplement.CharacterRadius;
                    }
                    previewTexture.CameraPosOffset = new Vector3(0f, 1.09f, -4.37f);

                    Vector3 oldOffset = previewTexture.CameraPosOffset;
                    previewTexture.CameraPosOffset = new Vector3(oldOffset.x + modelOffset.x, oldOffset.y + modelOffset.y, oldOffset.z);
                }
                actor.transform.localScale = scale;

                //actor.transform.position = new Vector3(mActorParentTransform.position.x + mDialogContentInfo.x, mActorParentTransform.position.y + mDialogContentInfo.y, mActorParentTransform.position.z);
            }
        }
예제 #3
0
        public IEnumerator LoadSceneEffect(Vector3 position, string fileName, float delayTime)
        {
            ObjectWrapper ow = new ObjectWrapper();

            yield return(ResourceLoader.Instance.StartCoroutine(ObjCachePoolMgr.Instance.LoadPrefab(fileName, ObjCachePoolType.SFX, fileName, ow)));

            GameObject effect_object = ow.obj as GameObject;

            if (effect_object == null)
            {
                yield break;
            }

            GameObject.DontDestroyOnLoad(effect_object);

            if (mIsDestroy)
            {
                BeforeRecycleEffect(effect_object);
                ObjCachePoolMgr.Instance.RecyclePrefab(effect_object, ObjCachePoolType.SFX, fileName);
                yield break;
            }
            effect_object.transform.position = position;
            CommonTool.SetActive(effect_object, false);
            CommonTool.SetActive(effect_object, true);

            var delay_timer = effect_object.GetComponent <DelayTimeComponent>();

            if (delay_timer == null)
            {
                delay_timer = effect_object.AddComponent <DelayTimeComponent>();
            }
            delay_timer.DelayTime = delayTime;
            delay_timer.Start();

            SceneEffectInfo info = new SceneEffectInfo(fileName, delayTime, effect_object);

            mEffectObjects[effect_object.GetHashCode()] = info;

            delay_timer.SetEndCallBack(new DelayTimeComponent.EndCallBackInfo(OnEffectPlayFinish, effect_object));
        }
예제 #4
0
        public override void LateUpdate()
        {
            if (mOwner.Trans == null)
            {
                return;
            }

            Vector3 actPos = mOwner.Trans.position;

            // 更新阴影
            if (mShadowType == ShadowType.FAKE_SHADOW)
            {
                if (mFakeShadow != null)
                {
                    //mFakeShadow.SetActive(true);
                    CommonTool.SetActive(mFakeShadow, true);
                }
                else
                {
                    EnableFakeShadow();
                }
            }
            else if (mShadowType == ShadowType.REAL_SHADOW)
            {
                if (mFakeShadow != null)
                {
                    //mFakeShadow.SetActive(!mRealShadow);
                    CommonTool.SetActive(mFakeShadow, !mRealShadow);
                }
            }
            else if (mShadowType == ShadowType.NONE)
            {
                if (mFakeShadow != null)
                {
                    //mFakeShadow.SetActive(false);
                    CommonTool.SetActive(mFakeShadow, false);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 初始化子弹和对应特效的位置和方向
        /// </summary>
        /// <param name="effectObject">特效跟节点物体</param>
        /// <param name="effectObject">特效物体</param>
        /// <param name="kPos">特效位置</param>
        /// <param name="kRotation">特效初始方向</param>
        /// <param name="sDir">子弹飞行的方向</param>
        void InitEffectObject(GameObject bullet_object, GameObject effect_object)
        {
            if (bullet_object == null)
            {
                if (effect_object != null)
                {
                    CommonTool.DestroyObjectImmediate(effect_object);
                }
                return;
            }

            if (effect_object == null)
            {
                return;
            }

            Transform bullet_trans = bullet_object.transform;

            // 设置特效位置和方向
            effect_object.SetActive(false);
            Transform effect_trans = effect_object.transform;

            effect_trans.parent        = bullet_trans;
            effect_trans.localPosition = Vector3.zero;
            effect_trans.localRotation = Quaternion.identity;
            effect_trans.localScale    = Vector3.one;

            DelayEnableComponent delayEnable = bullet_object.GetComponent <DelayEnableComponent>();

            if (delayEnable == null)
            {
                delayEnable = bullet_object.AddComponent <DelayEnableComponent>();
            }
            delayEnable.DelayTime = m_DelayTime;
            delayEnable.SetEnable = true;
            delayEnable.SetEnableTarget(effect_object);
        }
예제 #6
0
        public static string FillTemplateByContentList(string template, string[] param_list)
        {
            if (param_list.Length <= 0)
            {
                return(template);
            }
            if (string.IsNullOrEmpty(template))
            {
                return(string.Empty);
            }

            int index = 0;

            return(mNoticeRegex.Replace(template, new MatchEvaluator(
                                            delegate(Match match)
            {
                string ret = string.Empty;
                if (index >= param_list.Length)
                {
                    return ret;
                }

                string content = param_list [index];
                string target = match.ToString();
                if (target.Length >= 3)
                {
                    target = target.Substring(1, target.Length - 2);
                    EFillType contentType = (EFillType)(int.Parse(target));
                    uint contentNum = 0xffffffff;
                    try
                    {
                        contentNum = Convert.ToUInt32(content);
                    } catch
                    {
                        // Do nothing.
                    }

                    switch (contentType)
                    {
                    // 怪物名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.MONSTER_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    // 玩法场景名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.ACTIVITY_SCENE_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    case EFillType.COLOR_TYPE:
                        ret = GoodsHelper.GetGoodsColor(contentNum);
                        break;

                    case EFillType.CHAT_GOODS_TYPELINK:         // 物品超链接
                        {
                            if (param_list.Length >= 3)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 2]);
                                uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                                ulong goods_oid = Convert.ToUInt64(content);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                                uint goodsType = GoodsHelper.GetGoodsType(goods_gid);
                                if (goodsType == GameConst.GIVE_TYPE_EQUIP ||        // 装备
                                    goodsType == GameConst.GIVE_TYPE_RIDE_EQUIP ||   // 坐骑装备
                                    goodsType == GameConst.GIVE_TYPE_MAGIC_EQUIP ||  // 法宝装备
                                    goodsType == GameConst.GIVE_TYPE_DECORATE ||     // 饰品
                                    goodsType == GameConst.GIVE_TYPE_ELEMENT_EP ||   // 元素装备
                                    goodsType == GameConst.GIVE_TYPE_GOD_EQUIP ||    // 神兵
                                    goodsType == GameConst.GIVE_TYPE_ARTIFACT_EP ||  // 神器装备
                                    goodsType == GameConst.GIVE_TYPE_FIVE_ELEM)      // 五行战印
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_20"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_oid + "," + goods_gid + "})";
                                }
                                else
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_gid + "})";
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.CLIENT_GOODS_TYPELINK:       // 客户端物品超链接
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                            ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_22"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.GOODS_GID:
                        ret = string.Empty;
                        break;

                    case EFillType.HIDE_PLAYER_ID:
                        ret = string.Empty;
                        break;

                    case EFillType.GOODS_GID_NEW:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 1]);
                                uint goods_gid = Convert.ToUInt32(param_list[index]);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                                ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                ret = ret + "{" + playerId + "," + goods_gid + "})";
                            }
                            else
                            {
                                ret = content;
                            }

                            break;
                        }

                    case EFillType.PET_ID:     // 守护ID(显示带守护品质颜色的守护名字)
                        {
                            uint pet_id = Convert.ToUInt32(content);
                            var pet_info = DBManager.Instance.GetDB <DBPet>().GetOnePetInfo(pet_id);
                            if (pet_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(pet_info.Quality + 1);    //守护品质颜色和物品相差1
                                string actor_name = ActorHelper.GetActorName(pet_info.Actor_id);
                                ret = string.Format("{0}{1}</color>", color_str, actor_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TITLE_ID:
                        {
                            uint title_id = Convert.ToUInt32(content);
                            var title_info = DBManager.Instance.GetDB <DBHonor>().GetData(title_id);
                            if (title_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(title_info.Quality);
                                string title_name = title_info.Name;
                                ret = string.Format("{0}{1}</color>", color_str, title_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.QUAL_WORD:
                        {
                            uint qual = Convert.ToUInt32(content);
                            string color_str_name = GoodsHelper.GetGoodsColorName(qual);
                            string color_str = GoodsHelper.GetGoodsColor(qual);
                            ret = string.Format("{0}{1}</color>", color_str, color_str_name);
                        }
                        break;

                    case EFillType.TRANSFER_LV:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint init_vocation = Convert.ToUInt32(param_list[index]);
                                uint transfer_lv = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { transfer_lv, init_vocation };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "TransferMgr_GetVocationName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.InitVocation:
                        ret = string.Empty;
                        break;

                    case EFillType.SHOW_TYPE_TO_NAME:     //外显系统ID =>外显系统名字
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetShowName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_PARAM:    //外显系统ID => 与25一起使用,组成外显系统的外观名字
                        {
                            ret = string.Empty;
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_FACADE_ID:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint facade_id = Convert.ToUInt32(param_list[index]);
                                uint show_type = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { show_type, facade_id };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetFacadeName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_SYS_ID:       //外显系统ID =>外显系统ID
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetSysIdStr", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.FASHION_NAME:       //时装
                        {
                            uint fashionId = Convert.ToUInt32(param_list[index]);
                            object[] param = { fashionId };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "FashionManager_GetFashionNameWithColor", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.MALL_NAME:     //商城名字
                        {
                            uint mall_id = Convert.ToUInt32(param_list[index]);
                            var mall_tmpl = xc.DBManager.Instance.GetDB <DBMallType>().GetOneItem(mall_id);
                            if (mall_tmpl != null)
                            {
                                //string color_str = GoodsHelper.GetGoodsColor(mall_tmpl);
                                string tmall_name = mall_tmpl.Name;
                                //ret = string.Format("{0}{1}</color>", color_str, tmall_name);
                                ret = tmall_name;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.ESCORT_TASK_ID:     //护送任务的id
                        {
                            uint taskId = Convert.ToUInt32(param_list[index]);
                            TaskDefine taskDefine = TaskDefine.MakeDefine(taskId);
                            if (taskDefine != null)
                            {
                                ret = taskDefine.GetFollowNpcName(0);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.INSTANCE_ID:     //副本id
                        {
                            uint instanceId = Convert.ToUInt32(param_list[index]);
                            DBInstance.InstanceInfo instanceInfo = DBInstance.Instance.GetInstanceInfo(instanceId);
                            if (instanceInfo != null)
                            {
                                ret = instanceInfo.mName;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.GODWARE_ID:    //神器id
                        {
                            uint god_ware_id = Convert.ToUInt32(param_list[index]);
                            object[] param = { god_ware_id };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "GodWareManager_GetGodWareName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TIMEFORMAT:
                        int time = Convert.ToInt32(param_list[index]);
                        string strShowTime = CommonTool.SecondsToStr_2(time);
                        ret = strShowTime;
                        break;

                    case EFillType.BIG_PACKET:
                        uint bigNum = Convert.ToUInt32(param_list[index]);
                        if (bigNum != 0)
                        {
                            //ret = string.Format("{0}个大红包,", bigNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_BIG"), bigNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.SMALL_PACKET:
                        uint smallNum = Convert.ToUInt32(param_list[index]);
                        if (smallNum != 0)
                        {
                            //ret = string.Format("{0}个小红包,", smallNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_SMALL"), smallNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.MARKET_ID:
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                            // 【click={0}[{1}]</color>】(marketGoodsTips=
                            ret = string.Format(xc.TextHelper.GetConstText("GAME_CHAT_CLICK_MARKET_GOODS"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.CONTROL_ID:
                        var id = Convert.ToInt32(param_list[index]);
                        ret = SpanServerManager.Instance.GetServerNameByControlServerId((uint)id);
                        break;

                    case EFillType.CHANNEL_ID:
                        ret = ChannelHelper.GetChannelName(param_list[index]);
                        break;

                    default:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;
                    }
                }

                index++;
                return ret;
            }
                                            )));
        }
예제 #7
0
        private static IEnumerator ChangePart(GameObject model, uint partId, bool isLocalPlayer = true)
        {
            if (model == null)
            {
                yield break;
            }

            DBAvatarPart.Data data      = DBManager.Instance.GetDB <DBAvatarPart>().mData[partId];
            string            part_name = data.part == DBAvatarPart.BODY_PART.BODY ? xc.AvatarCtrl.BODY_NAME : xc.AvatarCtrl.WEAPON_NAME;

            // 查找旧资源中的换装节点
            Transform old_part = CommonTool.FindChildInHierarchy(model.transform, part_name);

            if (old_part == null)
            {
                Debug.LogError(string.Format("the model {0} does not have a part named {1}", model.name, part_name));
                yield break;
            }
            string path = data.SuitablePath(isLocalPlayer);
            // 加载换装部件的模型
            AssetResource ar = new AssetResource();

            yield return(ResourceLoader.Instance.StartCoroutine(ResourceLoader.Instance.load_asset(string.Format("{0}/{1}.prefab", xc.AvatarCtrl.AVATAR_PATH_PREFIX, path), typeof(GameObject), ar)));

            GameObject gameObjectAsset = ar.asset_ as GameObject;

            if (gameObjectAsset == null)
            {
                Debug.LogError(string.Format("the res {0} does not exist", path));
                yield break;
            }

            if (model == null)
            {
                ar.destroy();
                yield break;
            }

            old_part = CommonTool.FindChildInHierarchy(model.transform, part_name);
            if (old_part == null)
            {
                Debug.LogError(string.Format("the model {0} does not have a part named {1}", model.name, part_name));
                ar.destroy();
                yield break;
            }

            // 将asset资源的生命周期与角色GameObject关联起来
            ResourceUtilEx.Instance.host_res_to_gameobj(model, ar);

            // 查找新资源的换装节点
            Transform new_part = CommonTool.FindChildInHierarchy(gameObjectAsset.transform, part_name);

            if (new_part == null)
            {
                Debug.LogError(string.Format("the model {0} does not have a part named {1}", gameObjectAsset.name, part_name));
                yield break;
            }

            SkinnedMeshRenderer new_mesh_renderer = new_part.GetComponent <SkinnedMeshRenderer>();
            SkinnedMeshRenderer old_mesh_renderer = old_part.GetComponent <SkinnedMeshRenderer>();

            Transform[] old_bones = (Transform[])old_part.GetComponent <SkinnedMeshRenderer>().bones.Clone();
            ReplaceSkinnedMesh(old_bones, model, old_mesh_renderer, new_mesh_renderer);
        }
예제 #8
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);
                }
            }
        }
예제 #9
0
        public override void Load()
        {
#if UNITY_EDITOR
            string resName = DBManager.AssetsResPath + "/" + mStrPath;

            TextAsset textObj = EditorResourceLoader.LoadAssetAtPath(resName, typeof(TextAsset)) as TextAsset;
            if (textObj != null)
            {
                string strData = CommonTool.BytesToUtf8(textObj.bytes);
                if (strData != "")
                {
                    ParseData(strData);
                }

                IsLoaded = true;
            }
            else
            {
                GameDebug.LogError("DB file load failed: " + mStrPath);
            }
#else
            AssetBundle db_bundle = DBManager.GetInstance().DBBundle;
            if (db_bundle != null)
            {
                string fileName = Path.GetFileNameWithoutExtension(mStrPath);
                Object resObj   = db_bundle.LoadAsset(fileName);

                TextAsset text = resObj as TextAsset;
                if (text != null)
                {
                    string strData = CommonTool.BytesToUtf8(text.bytes);
                    if (strData != "")
                    {
                        ParseData(strData);
                    }

                    IsLoaded = true;
                    Resources.UnloadAsset(text);
                }
                else
                {
                    GameDebug.LogError("DB file load failed: " + mStrPath);
                }
            }
            else
            {
                GameDebug.LogError("DB asset is null!!!");
            }
#endif

            /*AssetManager manager = Game.GetInstance().MainInterface.GetAssetManager();
             * if (manager== null)
             * {
             *      GameDebug.LogError("No AssetManager!");
             *      return;
             * }*/

            /*if (xc.Game.GetInstance().IsUsePackage() || Application.platform != RuntimePlatform.WindowsPlayer)
             * {
             *      string path = mStrPath;
             *      //string ext = Path.GetExtension(mStrPath).ToLower();
             *      manager.LoadAsset(path, LoadData);
             * }
             * else
             * {
             *      string path = "";
             *      string nameNoExtend = PathHelp.GetPathWithNoExtend(mStrPath);
             *
             *      path = "Resources/" + mStrPath;
             *      path = PathHelp.GetFullPaltformPath(path, false);
             *
             *      System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
             *      byte[] content = new byte[stream.Length];
             *      stream.Read(content, 0, (int)stream.Length);
             *
             *      IsLoaded = true;
             *
             *      string strData = AssetManager.BinToUtf8(content);
             *      ParseData(strData);
             *      stream.Close();
             * }*/
        }
예제 #10
0
        /// <summary>
        /// 开始播放剧情
        /// </summary>
        /// <param name="timelineInfo"></param>
        void PlayImpl(TimelineInfo timelineInfo)
        {
            //GameDebug.LogError("TimelineManager.PlayImpl: " + timelineInfo.Id);

            mPlayingTimeline = timelineInfo;

            PlayableDirector playableDirector = timelineInfo.PlayableDirector;

            if (playableDirector == null)
            {
                if (timelineInfo.FinishCallback != null)
                {
                    timelineInfo.FinishCallback();
                }

                if (timelineInfo.RelatedGameObject != null)
                {
                    GameObject.DestroyImmediate(timelineInfo.RelatedGameObject);
                }

                return;
            }

            if (playableDirector.playableAsset == null)
            {
                if (timelineInfo.FinishCallback != null)
                {
                    timelineInfo.FinishCallback();
                }

                GameDebug.LogError("Play timeline " + playableDirector.gameObject.name + " error, playable asset is null!");

                mPlayingTimeline = null;
                GameObject.DestroyImmediate(playableDirector.gameObject);
                if (timelineInfo.RelatedGameObject != null)
                {
                    GameObject.DestroyImmediate(timelineInfo.RelatedGameObject);
                }
                return;
            }

            if (Game.Instance.MainCamera == null)
            {
                if (timelineInfo.FinishCallback != null)
                {
                    timelineInfo.FinishCallback();
                }

                GameDebug.LogError("Play timeline " + playableDirector.gameObject.name + " error, main camera is null!");

                mPlayingTimeline = null;
                GameObject.DestroyImmediate(playableDirector.gameObject);
                if (timelineInfo.RelatedGameObject != null)
                {
                    GameObject.DestroyImmediate(timelineInfo.RelatedGameObject);
                }
                return;
            }

            Cinemachine.CinemachineBrain cinemachineBrain = Game.Instance.MainCamera.GetComponent <Cinemachine.CinemachineBrain>();
            if (cinemachineBrain == null)
            {
                cinemachineBrain = Game.Instance.MainCamera.gameObject.AddComponent <Cinemachine.CinemachineBrain>();
            }
            if (cinemachineBrain != null)
            {
                cinemachineBrain.enabled = true;
            }
            else
            {
                GameDebug.LogError("Play timeline " + playableDirector.gameObject.name + " error, can not find CinemachineBrain component in main camera!");

                mPlayingTimeline = null;
                GameObject.DestroyImmediate(playableDirector.gameObject);
                if (timelineInfo.RelatedGameObject != null)
                {
                    GameObject.DestroyImmediate(timelineInfo.RelatedGameObject);
                }

                if (timelineInfo.FinishCallback != null)
                {
                    timelineInfo.FinishCallback();
                }

                return;
            }

            // 隐藏所有角色
            SetAllActorsVisible(false, timelineInfo.ShowLocalPlayer);

            // 野外场景中记住正在寻路的任务
            if (SceneHelp.Instance.IsInWildInstance() == true)
            {
                Task navigatingTask = TaskManager.Instance.NavigatingTask;
                if (navigatingTask != null)
                {
                    mNavigatingTaskIdBeforePlay = navigatingTask.Define.Id;
                }
            }

            Actor localPlayer = Game.Instance.GetLocalPlayer();

            TimelineAsset asset = playableDirector.playableAsset as TimelineAsset;

            foreach (TrackAsset track in asset.GetOutputTracks())
            {
                GroupTrack group = track.GetGroup();
                if (group != null)
                {
                    // 绑定主摄像机
                    if (group.name.StartsWith("Camera") == true)
                    {
                        Camera mainCamera = Game.Instance.MainCamera;
                        if (mainCamera != null)
                        {
                            foreach (PlayableBinding output in track.outputs)
                            {
                                if (output.sourceObject != null)
                                {
                                    playableDirector.SetGenericBinding(output.sourceObject, mainCamera.gameObject);
                                }
                            }
                        }
                    }

                    if (group.name.StartsWith("Hero") == true)
                    {
                        if (localPlayer != null)
                        {
                            foreach (PlayableBinding output in track.outputs)
                            {
                                GameObject actorModel = null;
                                if (output.sourceObject != null)
                                {
                                    Object binding = playableDirector.GetGenericBinding(output.sourceObject);
                                    if (binding == null)
                                    {
                                        GameDebug.LogError("Player timeline " + timelineInfo.PlayableDirector.name + " error!!! " + output.sourceObject.name + " 's binding object is null!!!");
                                        continue;
                                    }
                                    GameObject bindingObj = binding as GameObject;
                                    if (bindingObj != null)
                                    {
                                        bindingObj.SetActive(false);
                                    }

                                    // 根据职业显示主角的模型
                                    if (bindingObj != null && bindingObj.name.StartsWith("Hero_") == true)
                                    {
                                        uint vocation = uint.Parse(bindingObj.name.Substring(5));
                                        if (vocation == LocalPlayerManager.Instance.LocalActorAttribute.Vocation)
                                        {
                                            //playableDirector.SetGenericBinding(output.sourceObject, localPlayer.gameObject);
                                            CommonTool.SetActive(bindingObj, true);
                                            actorModel = bindingObj;
                                        }
                                        else
                                        {
                                            CommonTool.SetActive(bindingObj, false);
                                        }
                                    }
                                }
                                if (actorModel != null && changeSkin)
                                {
                                    //changeSkin = false;
                                    if (timelineInfo.AvatarProperty != null)
                                    {
                                        ResourceLoader.Instance.StartCoroutine(AvatarUtils.ChangeModel(actorModel, timelineInfo.AvatarProperty));
                                    }
                                    else
                                    {
                                        AvatarProperty avatarProperty;
                                        if (localPlayer.mAvatarCtrl != null && localPlayer.mAvatarCtrl.GetLatestAvatartProperty() != null)
                                        {
                                            avatarProperty = localPlayer.mAvatarCtrl.GetLatestAvatartProperty();
                                        }
                                        else
                                        {
                                            avatarProperty = mPlayerLastSceneAvatarProperty;
                                        }
                                        ResourceLoader.Instance.StartCoroutine(AvatarUtils.ChangeModel(actorModel, avatarProperty));
                                    }
                                }
                            }
                        }
                    }
                }

                // 音效是否静音
                AudioTrack audioTrack = track as AudioTrack;
                if (audioTrack != null)
                {
                    audioTrack.muted = GlobalSettings.Instance.SFXMute;
                }
            }

            if (Game.Instance.CameraControl != null)
            {
                Game.Instance.CameraControl.Target = null;
            }

            // 记住当前状态并暂停主角的自动战斗
            mIsAutoFightingWhenPlaying = InstanceManager.Instance.IsAutoFighting;
            InstanceManager.Instance.IsAutoFighting = false;

            // 停止主角的寻路
            if (timelineInfo.NoStopLocalPlayer == false)
            {
                TargetPathManager.Instance.StopPlayerAndReset();
            }

            mCameraRotationBeforePlay = Game.Instance.MainCamera.transform.rotation;
            mCameraFOVBeforePlay      = Game.Instance.MainCamera.fieldOfView;

            bool setUI = true;

            if (timelineInfo.ShowUI == true)
            {
                setUI = false;
            }
            GameInput.Instance.EnableInput(false, setUI);

            // 暂停CullManager的Update
            CullManager.Instance.IsEnabled = false;

            // 隐藏UI
            if (timelineInfo.ShowUI == false)
            {
                xc.ui.ugui.UIManager.Instance.CloseAllWindow();
            }

            if (!GlobalSettings.Instance.MusicMute && timelineInfo.PauseMusic)
            {
                AudioManager.Instance.PauseMusic(true);
            }

            playableDirector.gameObject.SetActive(true);

            if (timelineInfo.RelatedGameObject != null)
            {
                timelineInfo.RelatedGameObject.SetActive(true);
            }

            playableDirector.Play();

            ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TIMELINE_START, new CEventBaseArgs(timelineInfo.Id));
        }
예제 #11
0
        private void ProcessMoney(S2CMoney s2cMoney)
        {
            string text                  = string.Empty;
            bool   is_change             = false;
            bool   show_cost_or_add_tips = false;
            int    change_money          = 0;

            foreach (PkgMoneyInfo money in s2cMoney.info)
            {
                show_cost_or_add_tips = false;
                text = string.Empty;
                switch (money.money_type)
                {
                case GameConst.MONEY_COIN:
                {
                    if (Coin != money.num)
                    {
                        show_cost_or_add_tips = true;
                        change_money          = (int)(money.num) - (int)(Coin);
                        Coin      = money.num;
                        is_change = true;
                    }
                    break;
                }

                case GameConst.MONEY_TRIGRAM_SP:
                {
                    if (TrigramSp != money.num)
                    {
                        if (TrigramSp < money.num)
                        {
                            uint add_sp      = money.num - TrigramSp;
                            var  localplayer = Game.Instance.GetLocalPlayer();
                            if (localplayer != null)
                            {
                                localplayer.ShowDamageEffect(FightEffectHelp.FightEffectType.AddSp, 0, (int)(add_sp));
                            }
                        }
                        TrigramSp = money.num;
                        is_change = true;
                    }
                    break;
                }

                case GameConst.MONEY_DIAMOND:
                {
                    if (Diamond != money.num)
                    {
                        show_cost_or_add_tips = true;
                        change_money          = (int)(money.num) - (int)(Diamond);
                        Diamond   = money.num;
                        is_change = true;
                    }
                    break;
                }

                case GameConst.MONEY_SOUL_CREAM:
                {
                    if (SoulCream != money.num)
                    {
                        show_cost_or_add_tips = true;
                        change_money          = (int)(money.num) - (int)(SoulCream);
                        SoulCream             = money.num;
                        is_change             = true;
                    }
                    break;
                }

                case GameConst.MONEY_SOUL_HOLY_WATER:
                {
                    if (SoulHolyWater != money.num)
                    {
                        show_cost_or_add_tips = true;
                        change_money          = (int)(money.num) - (int)(SoulHolyWater);
                        SoulHolyWater         = money.num;
                        is_change             = true;
                    }
                    break;
                }

                case GameConst.MONEY_COIN_BIND:
                {
                    if (BindCoin != money.num)
                    {
                        BindCoin  = money.num;
                        is_change = true;
                    }
                    break;
                }

                case GameConst.MONEY_DIAMOND_BIND:
                {
                    if (BindDiamond != money.num)
                    {
                        show_cost_or_add_tips = true;
                        change_money          = (int)(money.num) - (int)(BindDiamond);
                        BindDiamond           = money.num;
                        is_change             = true;
                    }
                    break;
                }

                case GameConst.MONEY_HANG_TIME:
                {
                    if (HangTime != money.num)
                    {
                        show_cost_or_add_tips = true;
                        int    value = Mathf.Abs((int)HangTime - (int)money.num);
                        string str   = CommonTool.SecondsToStr_2(value);

                        if (HangTime > money.num)
                        {
                            text = string.Format(DBConstText.GetText("BAG_LOST_HANG_TIME"), str);
                        }
                        else
                        {
                            text = string.Format(DBConstText.GetText("BAG_GET_HANG_TIME"), str);
                        }

                        HangTime  = money.num;
                        is_change = true;

                        ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_OFFLINE_HANGE_TIME_UPDATE, null);
                    }
                    break;
                }

                default:
                {
                    uint old_num = 0;
                    if (MoneyData.ContainsKey((ushort)money.money_type))
                    {
                        old_num = MoneyData[(ushort)money.money_type];
                    }

                    MoneyData[(ushort)money.money_type] = money.num;
                    if (old_num != money.num)
                    {
                        if (old_num < money.num)         //获得货币
                        {
                            var info = DBMoney.Instance.GetMoneyInfo(money.money_type);
                            if (info != null)
                            {
                                show_cost_or_add_tips = info.show_get;
                            }

                            change_money = (int)(money.num - old_num);
                        }
                        is_change = true;
                    }
                    break;
                }
                }

                if (Game.Instance.AllSystemInited)
                {
                    if (s2cMoney.op == GameConst.MONEY_OPERATE_NO_TIP)
                    {
                        show_cost_or_add_tips = false;  //一定不飘字
                    }
                    if (show_cost_or_add_tips && string.IsNullOrEmpty(text))
                    {
                        string goods_name = GoodsHelper.GetGoodsNameByTypeId_blackBkg(money.money_type);
                        if (change_money > 0)
                        {
                            text = string.Format(DBConstText.GetText("COMMON_ADD_ONE_MONEY_NUM"), goods_name, change_money);
                        }
                    }

                    if (string.IsNullOrEmpty(text) == false)
                    {
                        UINotice.Instance.ShowMessage(text);
                    }
                }
            }

            if (is_change == false)
            {
                return;
            }

            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MONEY_UPDATE, null);
        }
예제 #12
0
        IEnumerator LoadStandEffect(string fileName)
        {
            GameObject model = mOwner.mAvatarCtrl.GetModel();

            if (model == null)
            {
                yield break;
            }

            RemoveStandEffect();
            Transform pos = CommonTool.FindChildInHierarchy(model.transform, AvatarCtrl.ROOT_NODE);

            if (pos == null)
            {
                Debug.LogError(string.Format("not found footprint point on {0}", model.name));
                yield break;
            }
            ObjectWrapper ow = new ObjectWrapper();

            yield return(ResourceLoader.Instance.StartCoroutine(ObjCachePoolMgr.Instance.LoadPrefab(fileName, ObjCachePoolType.SFX, fileName, ow)));

            GameObject effect_object = ow.obj as GameObject;

            if (effect_object == null)
            {
                yield break;
            }

            GameObject.DontDestroyOnLoad(effect_object);

            if (mIsDestroy || fileName != mStandEffectFile)
            {
                ObjCachePoolMgr.Instance.RecyclePrefab(effect_object, ObjCachePoolType.SFX, fileName);
                yield break;
            }
            RemoveStandEffect();

            if (mStandEffectContainer == null)
            {
                mStandEffectContainer = new GameObject("FootprintContainer");
            }
            mStandEffectContainer.transform.parent           = pos;
            mStandEffectContainer.transform.localPosition    = Vector3.zero;
            mStandEffectContainer.transform.localEulerAngles = new Vector3(0, 0, 0);
            mStandEffectContainer.transform.localScale       = Vector3.one;

            effect_object.transform.parent           = mStandEffectContainer.transform;
            effect_object.transform.localPosition    = Vector3.zero;
            effect_object.transform.localEulerAngles = new Vector3(0, 0, 0);
            effect_object.transform.localScale       = Vector3.one;

            int layer = 0;

            if (mOwner.mAvatarCtrl.GetModelParent() != null)
            {
                layer = mOwner.mAvatarCtrl.GetModelParent().layer;
            }
            mOwner.mAvatarCtrl.SetRenderLayer(effect_object, layer, false, false);

            mStandEffectInfo = new SceneEffectInfo(fileName, 0, effect_object);
        }
예제 #13
0
 public string GenFileNameByFileId(string file_id)
 {
     return(CommonTool.GetMD5(file_id));
 }