示例#1
0
    public void ClearAllBanks()
    {
        foreach (var kv in _DicBankLoad)
        {
            string     bankName = kv.Key;
            CBankEntry entry    = kv.Value;
            if (entry.InMemoryBankPtr != IntPtr.Zero)
            {
                AKRESULT result = AkSoundEngine.UnloadBank(entry.BankID, entry.InMemoryBankPtr);
                if (result == AKRESULT.AK_Success)
                {
                    entry.PinnedArray.Free();
                }
                else
                {
                    HobaDebuger.LogWarningFormat("UnloadBank Failed: {0} {1}", bankName, result);
                }
                entry.InMemoryBankPtr = IntPtr.Zero;
            }
            else
            {
                AkSoundEngine.UnloadBank(entry.BankID, IntPtr.Zero, null, null);
            }

            GameObject.Destroy(entry.GameObject);
        }
        _DicBankLoad.Clear();
    }
示例#2
0
    private static void AsyncLoadResourceInternal(string assetName, string bundleName, Hoba.Action <UnityObject> onLoadFinish, bool needInstantiate)
    {
        if (string.IsNullOrEmpty(bundleName))
        {
            HobaDebuger.LogWarningFormat("Can not load bundle with empty name, {0} - {1}", assetName, bundleName);
            return;
        }

        if (assetName == null)
        {
            assetName = "";
        }

        var cb = onLoadFinish;

#if DEBUG_DELAY
        if (ResLoadDelay > 0)
        {
            cb = (asset) =>
            {
                Instance.StartCoroutine(DelayCallOnLoadFinish(ResLoadDelay, onLoadFinish, asset));
            };
        }
#endif
        //assetName = assetName.ToLower();
        bundleName = bundleName.ToLower();
        LoadResourceInternalImp(assetName, bundleName, cb, needInstantiate);
    }
示例#3
0
    private void FindKeyGameObject()
    {
        if (_KeyGameObjectL1 != null || _KeyGameObjectL2 != null || _KeyGameObjectL3 != null)
        {
            return;
        }

        for (var i = 0; i < transform.childCount; i++)
        {
            var child = transform.GetChild(i);
            if (child != null)
            {
                if (child.name.Contains("_L0"))
                {
                    _KeyGameObjectL1 = child.gameObject;
                    _AnimatorArrayL1 = _KeyGameObjectL1.GetComponentsInChildren <Animator>(true);
                }
                else if (child.name.Contains("_L1"))
                {
                    _KeyGameObjectL2 = child.gameObject;
                    _AnimatorArrayL2 = _KeyGameObjectL2.GetComponentsInChildren <Animator>(true);
                }
                else if (child.name.Contains("_L3"))
                {
                    _KeyGameObjectL3 = child.gameObject;
                    _AnimatorArrayL3 = _KeyGameObjectL3.GetComponentsInChildren <Animator>(true);
                }
            }
            else
            {
                HobaDebuger.LogWarningFormat("gfx {0}'s allKeyGameObjects has null child");
            }
        }
    }
示例#4
0
    public override void DoLoginCallBack(string param)
    {
        HobaDebuger.LogWarningFormat("{0}DoLoginCallBack param: {1}", _LongtuPrefix, param);
        var result = JsonUtility.FromJson <LTLoginResult>(param);

        if (result != null)
        {
            if (result.code == LTResultCode.LoginSucceed)
            {
                OnLoginSucceed(result.loginInfo);
            }
            else
            {
                LOGIN_STATE state = LOGIN_STATE.LT_LOGIN_UNKOWN_ERROR;

                if (result.code == LTResultCode.LoginTimeout)
                {
                    state = LOGIN_STATE.LT_LOGIN_TIME_OUT;
                }
                else if (result.code == LTResultCode.LoginCancel)
                {
                    state = LOGIN_STATE.LT_LOGIN_USER_CANCEL;
                }

                if (_LoginCallback != null)
                {
                    _LoginCallback(state, new USER_INFO());
                }
            }
        }
    }
示例#5
0
    //可以判断本navmesh以外的navmesh
    public bool IsValidPositionStrict(string strGameResPath, string strNavMeshPath, Vector3 pos, bool adjustHeight = true, float fDistanceLimit = 0.0f)
    {
        if (strNavMeshPath == _NavMeshName && !string.IsNullOrEmpty(_NavMeshName))
            return IsValidPositionStrict(_NavQuery, pos, adjustHeight, fDistanceLimit);

        string fullName = Path.Combine(strGameResPath, "Maps/") + strNavMeshPath;
        try
        {
            var navmesh_data = File.ReadAllBytes(fullName);
            Common.SCounters.Instance.Increase(EnumCountType.LoadNavMeshFromMemory);
            IntPtr navMesh = LuaDLL.NM_LoadNavMeshFromMemory(navmesh_data, navmesh_data.GetLength(0));
            if (navMesh == IntPtr.Zero)
                return false;

            Common.SCounters.Instance.Increase(EnumCountType.CreateNavQuery);
            IntPtr navQuery = LuaDLL.NM_CreateNavQuery(navMesh, MAX_NODES);
            if (navQuery == IntPtr.Zero)
                return false;

            bool ret = IsValidPositionStrict(navQuery, pos, adjustHeight, fDistanceLimit);
            Common.SCounters.Instance.Increase(EnumCountType.ClearNavMesh);
            Common.SCounters.Instance.Increase(EnumCountType.ClearNavQuery);
            LuaDLL.NM_ClearNavQuery(navQuery);
            LuaDLL.NM_ClearNavMesh(navMesh);

            return ret;
        }
        catch (Exception e)
        {
#if !SERVER_USE
                HobaDebuger.LogWarningFormat("raise Exception {1} when ReadAllBytes {0}", fullName, e);
#endif
            return false;
        }
    }
示例#6
0
    public void UnloadBank(string inBankFilename)
    {
        CBankEntry entry;

        if (!_DicBankLoad.TryGetValue(inBankFilename.ToLower(), out entry))
        {
            return;
        }

        if (entry.InMemoryBankPtr != IntPtr.Zero)
        {
            AKRESULT result = AkSoundEngine.UnloadBank(entry.BankID, entry.InMemoryBankPtr);
            if (result == AKRESULT.AK_Success)
            {
                entry.PinnedArray.Free();
            }
            else
            {
                HobaDebuger.LogWarningFormat("UnloadBank Failed: {0} {1}", inBankFilename, result);
            }
            entry.InMemoryBankPtr = IntPtr.Zero;
        }
        else
        {
            AkSoundEngine.UnloadBank(entry.BankID, IntPtr.Zero, null, null);
        }

        if (entry.GameObject != null)
        {
            GameObject.Destroy(entry.GameObject);
        }
        _DicBankLoad.Remove(inBankFilename.ToLower());
    }
示例#7
0
    private static int GetUnicodeStrLength(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string)))
        {
            string str = LuaScriptMgr.GetString(L, 1);
            if (string.IsNullOrEmpty(str))
            {
                HobaDebuger.LogWarningFormat("GetUnicodeStrLength string is null or empty");
                LuaScriptMgr.Push(L, 0);
                return(CheckReturnNum(L, count, nRet));
            }
            int length = str.Length;
            LuaScriptMgr.Push(L, length);
            return(CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("GetUnicodeStrLength", count);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }
    }
示例#8
0
        private bool UpdateFashionInfo(SkinnedMeshRenderer smr, OutwardPart part, GameObject prefab, string assetPath)
        {
            var fashionOutInfo = prefab.GetComponent <FashionOutwardInfo>();

            if (fashionOutInfo == null)
            {
                return(false);
            }

            CleanupExtraInfo(part);

            string partName = PartNames[(int)part];
            var    info1    = GetFashionOutward(partName, fashionOutInfo.FashionOutwardArray);

            if (null == info1)
            {
                HobaDebuger.LogWarningFormat("fashion info is null");
                return(true);
            }
            SaveDefaultOutward(part, smr);
            SetSmrPropertyByFashionInfo(part, smr, info1);

            // body时装可能用到两套材质球
            if (part == OutwardPart.Body)
            {
                var bodyRoot  = smr.gameObject;
                var extraInfo = GetFashionOutward(ExtraBodyNames, fashionOutInfo.FashionOutwardArray);
                if (null != extraInfo)
                {
                    var extrabodyTrans = transform.Find(ExtraBodyNames);
                    if (extrabodyTrans == null)
                    {
                        var extrabody = GameObject.Instantiate(bodyRoot, transform);
                        extrabody.name = ExtraBodyNames;
                        extrabodyTrans = extrabody.transform;
                        _ExtraTransDic[(int)part].Add(extrabodyTrans);
                    }

                    var extraSmr = extrabodyTrans.GetComponent <SkinnedMeshRenderer>();

                    if (null != extraSmr)
                    {
                        extraSmr.rootBone = transform.Find(extraInfo.RootBonesPath);
                        SetSmrPropertyByFashionInfo(part, extraSmr, extraInfo);
                    }
                }
            }

            //加载特效信息
            var outwardSfx = prefab.GetComponent <OutwardSfx>();

            if (null != outwardSfx)
            {
                LoadOutwardGfx(part, outwardSfx, assetPath);
            }

            //UpdateDynamicBoneInfo(part, prefab);
            UpdateDynamicBoneInfo(part, fashionOutInfo.DynamicBoneInfoArray);
            return(true);
        }
示例#9
0
        public void ChangeArmorEmbroidery(string path)
        {
            if (!_EmbroiderySetting.IsValid)
            {
                HobaDebuger.LogWarning("Current Armor does not support ChangeEmbroidery");
                return;
            }

            var bodyRender = GetSkinnedMeshRenderer(OutwardPart.Body);

            if (bodyRender == null)
            {
                HobaDebuger.LogWarningFormat("Current Armor named {0} has no Body Render", gameObject.name);
                return;
            }

            Material mat = new Material(bodyRender.sharedMaterial);

            if (string.IsNullOrEmpty(path))
            {
                ChangeArmorEmbroidery(mat, false, null, null, null, Vector4.zero);
                bodyRender.sharedMaterial = mat;

                var man = transform.GetComponent <EntityEffectComponent>();
                if (null != man)
                {
                    man.OnMaterialChanged(bodyRender);
                }
            }
            else
            {
                Vector4 rect = new Vector4(_EmbroiderySetting.XMin, _EmbroiderySetting.YMin, _EmbroiderySetting.XMax, _EmbroiderySetting.YMax);

                Action <UnityEngine.Object> callback = (asset) =>
                {
                    GameObject go = asset as GameObject;
                    if (go != null)
                    {
                        var imgset = go.GetComponent <EmbroideryImg>();
                        if (imgset != null)
                        {
                            ChangeArmorEmbroidery(mat, true, imgset.DiffuseTex as Texture2D,
                                                  imgset.NormalTex as Texture2D, imgset.SpecularTex as Texture2D, rect);
                            bodyRender.sharedMaterial = mat;

                            var man = transform.GetComponent <EntityEffectComponent>();
                            if (null != man)
                            {
                                man.OnMaterialChanged(bodyRender);
                            }
                        }
                    }
                    else
                    {
                        HobaDebuger.LogWarningFormat("Resource named {0} is null", path);
                    }
                };
                CAssetBundleManager.AsyncLoadResource(path, callback, false, "outward");
            }
        }
示例#10
0
    public override void Exit()
    {
        HobaDebuger.LogWarningFormat("{0}Exit Start", _LongtuPrefix);
        AndroidJavaClass LongtuSDK = new AndroidJavaClass(_ClassName);

        LongtuSDK.CallStatic("PlatformExitGame");
    }
示例#11
0
    public override bool IsPlatformExitGame()
    {
        AndroidJavaClass LongtuSDK = new AndroidJavaClass(_ClassName);
        bool             isExit    = LongtuSDK.CallStatic <bool>("IsPlatformExitGame");

        HobaDebuger.LogWarningFormat("{0}IsPlatformExitGame isExit: {1}", _LongtuPrefix, isExit.ToString());
        return(isExit);
    }
示例#12
0
    public static T SyncLoadAssetFromBundle <T>(string assetName, string bundleName = null, bool addToCache = false) where T : UnityObject
    {
        if (string.IsNullOrEmpty(assetName))
        {
            return(null);
        }

        if (addToCache)
        {
            LoadedAsset cache;
            if (_LoadedAssetsCache.TryGetValue(assetName, out cache))
            {
                cache.BornTime = Time.time;
                T result = cache.Asset as T;
                return(result);
            }
        }

        if (string.IsNullOrEmpty(bundleName))
        {
            bundleName = Instance.GetBundleName(assetName);
        }

        if (string.IsNullOrEmpty(bundleName))
        {
            HobaDebuger.LogWarningFormat("{0} cant be load,because it cant find bundle name", assetName);
            return(null);
        }

        var error  = String.Empty;
        var bundle = GetLoadedAssetBundle(bundleName, out error);

        if (null == bundle)
        {
            var url = IsUpdateFileExist(bundleName) ? Path.Combine(_UpdateAssetBundleURL, bundleName) : Path.Combine(_BaseAssetBundleURL, bundleName);
            var ab  = AssetBundle.LoadFromFile(url);
            if (ab == null)
            {
                HobaDebuger.LogWarningFormat("AssetBundle {0} has not been loaded first", bundleName);
                return(null);
            }

            bundle = new LoadedAssetBundle(ab, bundleName);
            _LoadedAssetBundles.Add(bundleName, bundle);
        }

        var asset = bundle.Bundle.LoadAsset <T>(assetName);

        if (addToCache && asset != null)
        {
            if (!_LoadedAssetsCache.ContainsKey(assetName))
            {
                _LoadedAssetsCache.Add(assetName, new LoadedAsset(asset));
            }
        }

        return(asset);
    }
示例#13
0
 public override void Logout(bool bCleanAutoLogin = false)
 {
     if (_IsLogined)
     {
         HobaDebuger.LogWarningFormat("{0}Logout Start", _LongtuPrefix);
         AndroidJavaClass LongtuSDK = new AndroidJavaClass(_ClassName);
         LongtuSDK.CallStatic("PlatformLogout");
     }
 }
示例#14
0
 public override void LogoutDirectly()
 {
     if (_IsLogined)
     {
         HobaDebuger.LogWarningFormat("{0}LogoutDirectly Start", _LongtuPrefix);
         AndroidJavaClass LongtuSDK = new AndroidJavaClass(_ClassName);
         LongtuSDK.CallStatic("PlatformLogout");
     }
 }
示例#15
0
    public CFxOne RequestUncachedFx(string fxName, bool isSingleton = true)
    {
        CFxOne fxone = null;

        if (!isSingleton || !_UncachedFxs.TryGetValue(fxName, out fxone) || fxone == null || fxone.gameObject == null)           //被清理
        {
            fxone          = new GameObject("UncachedFx").AddComponent <CFxOne>();
            fxone.Priority = -1;
            fxone.IsCached = false;
            Action <UnityEngine.Object> callback = (asset) =>
            {
                if (asset != null && fxone != null && fxone.gameObject != null)
                {
                    GameObject fx = GameObject.Instantiate(asset) as GameObject;
                    if (fx != null)
                    {
                        Transform fxTrans = fx.transform;
                        fxTrans.parent        = fxone.transform;
                        fxTrans.localPosition = Vector3.zero;
                        fxTrans.localRotation = Quaternion.identity;
                        fxTrans.localScale    = Vector3.one;
                        Util.SetLayerRecursively(fx, fxone.gameObject.layer);
                        fxone.SetFxGameObject(fx);
                        fxone.Active(true);
                        fxone.SetScale(fxone.RealScale);
                    }
                    else
                    {
                        HobaDebuger.LogWarningFormat("RequestUncachedFx asset is not GameObject!: {0}", fxName);
                    }
                }
            };

            CAssetBundleManager.AsyncLoadResource(fxName, callback, false, "sfx");
            if (isSingleton)
            {
                fxone.transform.parent = _UncachedFxsRootTrans;

                if (!_UncachedFxs.ContainsKey(fxName))
                {
                    _UncachedFxs.Add(fxName, fxone);
                }
                else
                {
                    _UncachedFxs[fxName] = fxone;
                }
            }
        }
        else
        {
            fxone.Active(true);
            fxone.SetScale(fxone.RealScale);
        }

        return(fxone);
    }
示例#16
0
 public override void UploadRoleInfo(ROLE_INFO roleInfo)
 {
     if (_IsLogined && roleInfo != null)
     {
         string roleInfoJson = JsonUtility.ToJson(roleInfo);
         HobaDebuger.LogWarningFormat("{0}UploadRoleInfo Start, RoleInfo Json:{1}", _LongtuPrefix, roleInfoJson);
         AndroidJavaClass LongtuSDK = new AndroidJavaClass(_ClassName);
         LongtuSDK.CallStatic("UploadRoleInfo", roleInfoJson);
     }
 }
示例#17
0
    private void TestLoadResource(string assetname)
    {
        Action <UnityEngine.Object> callback = (asset) =>
        {
            var obj = GameObject.Instantiate(asset) as GameObject;
            HobaDebuger.LogWarningFormat("GameObject Loaded! name: {0}", obj.name);
            GameObject.DestroyImmediate(obj);
        };

        CAssetBundleManager.AsyncLoadResource(assetname, callback, false);
    }
示例#18
0
    // ´òµã²¿·ÖÔÝʱдËÀ
    public override void UploadRoleInfo(ROLE_INFO roleInfo)
    {
        if (roleInfo == null)
        {
            return;
        }

        if (roleInfo.roleLevel == 1 || roleInfo.roleLevel == 5 || roleInfo.roleLevel == 10)
        {
            HobaDebuger.LogWarningFormat("{0}UploadRoleInfo level:{1}", _KakaoPrefix, roleInfo.roleLevel.ToString());
            SingularSDK.Event("Level", "level", roleInfo.roleLevel.ToString());
        }
    }
示例#19
0
 private void ReadWwiseBankConfigParams()
 {
     _WwiseBankConfigParams.DefaultValue();
     try
     {
         string path  = Path.Combine(_ConfigPath, "WwiseBankConfig.xml");
         byte[] bytes = Util.ReadFile(path);
         if (bytes != null)
         {
             _WwiseBankConfigParams.ParseFromXmlString(Encoding.UTF8.GetString(bytes));
         }
     }
     catch (Exception e)
     {
         HobaDebuger.LogWarningFormat("ReadWwiseBankConfigParams raise an Exception, {0}", e);
     }
 }
示例#20
0
        public static int warn(IntPtr L)
        {
            if (HobaDebuger.GameLogLevel < LogLevel.Warning)
            {
                return(0);
            }

            int    n = LuaDLL.lua_gettop(L);
            string s = String.Empty;

            LuaDLL.lua_getglobal(L, "tostring");

            for (int i = 1; i <= n; i++)
            {
                LuaDLL.lua_pushvalue(L, -1);  /* function to be called */
                LuaDLL.lua_pushvalue(L, i);   /* value to print */
                LuaDLL.lua_call(L, 1, 1);
                string ret = LuaDLL.lua_tostring(L, -1);
                if (ret == null)
                {
                    HobaDebuger.LogError("!!!! lua warn return null*");
                }
                else
                {
                    s += ret;
                }

                if (i < n)
                {
                    s += "\t";
                }

                LuaDLL.lua_pop(L, 1);  /* pop result */
            }

#if !SERVER_USE
            if (!EntryPoint.Instance.IsInited)
            {
                LuaDLL.HOBA_LogString(HobaText.Format("warn LUA: {0}", s));
            }
#endif

            HobaDebuger.LogWarningFormat("LUA: {0}", s);

            return(0);
        }
示例#21
0
    public void Release(GameObject element)
    {
        if (_Stack.Count >= _MaxCacheCount)
        {
            Destroy(element);
            return;
        }

        if (_Stack.Contains(element))
        {
            HobaDebuger.LogWarningFormat("Can not release one element two times: {0}", element.name);
            //LuaScriptMgr.Instance.CallOnTraceBack();
            return;
        }
        element.transform.SetParent(_Parent);
        _Stack.Push(element);
    }
示例#22
0
    private static int PrintCurrentTime(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string))))
        {
            var msg = LuaDLL.lua_tostring(L, 1);
            HobaDebuger.LogWarningFormat(msg, System.DateTime.Now.Ticks);
        }
        else
        {
            LogParamError("PrintCurrentTime", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
示例#23
0
    public bool LoadBank(string inBankFileName, bool localized = false)
    {
        if (_DicBankLoad.ContainsKey(inBankFileName.ToLower()))
        {
            return(true);
        }

        /*
         * string bankPath;
         *
         * if (!localized)
         *  bankPath = HobaText.Format("{0}/{1}/{2}/{3}", EntryPoint.Instance.ResPath, AkInitializer.GetBasePath(), AkBasePathGetter.GetPlatformName(), in_bankFileName);
         * else
         *  bankPath = HobaText.Format("{0}/{1}/{2}/{3}/{4}", EntryPoint.Instance.ResPath, AkInitializer.GetBasePath(), AkBasePathGetter.GetPlatformName(), AkInitializer.GetCurrentLanguage(), in_bankFileName);
         *
         * SBankEntry entry = new SBankEntry();
         * if (DoLoadBankFromImage(bankPath, entry))
         * {
         *  string name = localized ? HobaText.Format("{0}/{1}", AkInitializer.GetCurrentLanguage(), in_bankFileName.ToLower()) : in_bankFileName.ToLower();
         *  entry.gameObject = new GameObject(name);
         *  entry.gameObject.transform.parent = WwiseSoundMan.Instance.BanksLoaded.transform;
         *  _DicBankLoad.Add(in_bankFileName.ToLower(), entry);
         *  return true;
         * }
         *
         * HobaDebuger.LogWarningFormat("LoadBank Failed: {0}", bankPath);
         * return false;
         */


        CBankEntry entry = new CBankEntry();
        string     name  = localized ? HobaText.Format("{0}/{1}", AkInitializer.GetCurrentLanguage(), inBankFileName) : inBankFileName;
        AKRESULT   ret   = AkSoundEngine.LoadBank(name, AkSoundEngine.AK_DEFAULT_POOL_ID, out entry.BankID);

        if (ret == AKRESULT.AK_Success)
        {
            entry.GameObject = new GameObject(name);
            entry.GameObject.transform.parent = WwiseSoundMan.Instance.BanksLoaded.transform;
            _DicBankLoad.Add(inBankFileName.ToLower(), entry);
            return(true);
        }

        HobaDebuger.LogWarningFormat("LoadBank Failed: {0}", name);
        return(false);
    }
示例#24
0
 public bool ReadPlayerNearCameraConfig(int prof)
 {
     _PlayerNearCameraConfig.DefaultValue(prof);
     try
     {
         string path  = Path.Combine(_ConfigPath, "PlayerNearCameraConfig.xml");
         byte[] bytes = Util.ReadFile(path);
         if (bytes != null)
         {
             _PlayerNearCameraConfig.ParseFromXmlString(Encoding.UTF8.GetString(bytes), prof);
             return(true);
         }
     }
     catch (Exception e)
     {
         HobaDebuger.LogWarningFormat("ReadPlayerNearCameraConfig raise an Exception, {0}", e);
     }
     return(false);
 }
示例#25
0
    public bool Load(string strFileRegionPath)
    {
        Clear();
        if (string.IsNullOrEmpty(Path.GetFileNameWithoutExtension(strFileRegionPath)))
        {
            return(true);
        }

        _IsInited = false;
        string fullName = HobaText.Format("{0}/Maps/{1}", EntryPoint.Instance.ResPath, strFileRegionPath);

        byte[] file_data = Util.ReadFile(fullName);
        if (file_data == null)
        {
            HobaDebuger.LogWarningFormat("{0} not exist", fullName);
            return(false);
        }

        return(LoadFromMemory(file_data));
    }
示例#26
0
    public void Apply(bool show, GameObject target, float distance, float targetId)
    {
        if (show)
        {
            if (target == null)
            {
                return;
            }

            FollowTarget = target;
            Distance     = distance;
            _TargetId    = targetId;
            var capsuleCollider = target.GetComponentInChildren <CapsuleCollider>();
            if (capsuleCollider != null)
            {
                var height = capsuleCollider.height / 2;
                _Radius   = capsuleCollider.radius;
                _Offset.y = height;
            }
            else
            {
                HobaDebuger.LogWarningFormat("EffectiveModel does not have CapsuleCollider: {0}", target.gameObject.name);
                var height = 1;
                _Offset.y = height;
            }
            if (_FxOneComp != null)
            {
                _FxOneComp.Play(-1);
            }
        }
        else
        {
            if (_FxOneComp != null)
            {
                _FxOneComp.Stop();
            }
            FollowTarget = null;
            Distance     = 0;
        }
    }
示例#27
0
 public void EnableOutwardPart(OutwardPart part, bool enable)
 {
     if (part == OutwardPart.Face)
     {
         var trans = transform.Find(PartNames[1]);
         if (trans != null && trans.gameObject.activeSelf != enable)
         {
             trans.gameObject.SetActive(enable);
         }
     }
     else if (part == OutwardPart.Hair)
     {
         var trans = transform.Find(PartNames[2]);
         if (trans != null && trans.gameObject.activeSelf != enable)
         {
             trans.gameObject.SetActive(enable);
         }
     }
     else
     {
         HobaDebuger.LogWarningFormat("EnableOutwarPart only work on part face or hair");
     }
 }
示例#28
0
    public override void DoLogoutCallBack(string param)
    {
        HobaDebuger.LogWarningFormat("{0}DoLogoutCallBack param: {1}", _LongtuPrefix, param);
        var result = JsonUtility.FromJson <LTCallbackResult>(param);

        if (result != null)
        {
            if (result.code == LTResultCode.LogoutSucceed)
            {
                _IsLogined = false;
                if (_LogoutCallback != null)
                {
                    _LogoutCallback(LOGOUT_STATE.LT_LOGOUT_SUCCEED);
                }
            }
            else if (result.code == LTResultCode.LogoutFailed)
            {
                if (_LogoutCallback != null)
                {
                    _LogoutCallback(LOGOUT_STATE.LT_LOGOUT_FAIL);
                }
            }
        }
    }
示例#29
0
    public static int ShowGameInfo(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string)))
        {
            var infotype = LuaScriptMgr.GetString(L, 1);
            if (infotype == "fog")
            {
                string formate = @"RenderSettings.fog = {0}
                RenderSettings.fogColor = {1}
                RenderSettings.fogMode = {2}
                RenderSettings.fogStartDistance = {3}
                RenderSettings.fogEndDistance = {4}
                RenderSettings.ambientSkyColor = {5}
                RenderSettings.ambientEquatorColor = {6}
                RenderSettings.ambientGroundColor = {7}
                RenderSettings.ambientIntensity = {8} ";
                string content = HobaText.Format(formate, RenderSettings.fog, RenderSettings.fogColor,
                                                 RenderSettings.fogMode, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance,
                                                 RenderSettings.ambientSkyColor, RenderSettings.ambientEquatorColor,
                                                 RenderSettings.ambientGroundColor, RenderSettings.ambientIntensity);
                HobaDebuger.LogWarning(content);
            }
            else
            {
                HobaDebuger.LogWarningFormat("Undefined Info type - {0}", infotype);
            }
        }
        else
        {
            LogParamError("ShowGameInfo", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
示例#30
0
    IEnumerable InitGameCoroutine()
    {
        DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine Start...");

        foreach (var item in PreInitGameCoroutine())
        {
            yield return(item);
        }

        SetupPath();

        HobaDebuger.GameLogLevel = WriteLogLevel;

        //IOS Application.persistentDataPath  /var/mobile/Containers/Data/Application/app sandbox/Documents
        //Android /storage/emulated/0/Android/data/package name/files
#if UNITY_IOS
        _DocPath = Application.persistentDataPath;
        _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes");
        _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp");
#elif UNITY_ANDROID
        _DocPath = Application.persistentDataPath;
        _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes");
        _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp");
#else
        _DocPath = Environment.CurrentDirectory;
        _LibPath = Path.Combine(Environment.CurrentDirectory, "UpdateRes");
        _TmpPath = Path.Combine(Environment.CurrentDirectory, "Tmp");
#endif
        yield return(null);

#if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS
        //初始化异常上报SDK
        CLogReport.Init();
        yield return(null);
#endif

        //初始化基础目录
        {
            string path = EntryPoint.Instance.ResPath;
            path = path.Replace("file://", "");
            LuaDLL.HOBA_Init(path, _DocPath, _LibPath, _TmpPath);
        }

        _VoiceDir         = Path.Combine(_TmpPath, "Voice");
        _CustomPicDir     = Path.Combine(_TmpPath, "CustomPic");
        _UserLanguageFile = Path.Combine(_DocPath, "userlanguage.txt");
        _UserBillingFile  = Path.Combine(_DocPath, "userbilling.bin");
        _UserDataDir      = Path.Combine(_DocPath, "UserData");

        string strOSLanguage   = OSUtility.GetSystemLanguageCode();
        string strUserLanguage = GetUserLanguageCode();

        if (!Directory.Exists(_LibPath))
        {
            Directory.CreateDirectory(_LibPath);
        }
        if (!Directory.Exists(_VoiceDir))
        {
            Directory.CreateDirectory(_VoiceDir);
        }
        if (!Directory.Exists(_CustomPicDir))
        {
            Directory.CreateDirectory(_CustomPicDir);
        }
        if (!Directory.Exists(_UserDataDir))
        {
            Directory.CreateDirectory(_UserDataDir);
        }
        LuaDLL.HOBA_DeleteFilesInDirectory(_VoiceDir);               //清空Tmp目录
        LuaDLL.HOBA_DeleteFilesInDirectory(_CustomPicDir);           //清空Tmp目录
        yield return(null);

        if (!File.Exists(_UserLanguageFile))                //创建语言配置文件
        {
            WriteUserLanguageCode(strOSLanguage);
        }
        yield return(null);

        //目录信息
//#if (UNITY_EDITOR || UNITY_STANDALONE_WIN)
//         var pType = LTPlatformBase.ShareInstance().GetPlatformType();
//         HobaDebuger.LogWarningFormat("LTPlatformType: {0}", pType.ToString());
//         HobaDebuger.LogWarningFormat("AssetBundlePath: {0}", _AssetBundlePath);
//         HobaDebuger.LogWarningFormat("ResPath: {0}", ResPath);
//         HobaDebuger.LogWarningFormat("DocPath: {0}", _DocPath);
//         HobaDebuger.LogWarningFormat("LibPath: {0}", _LibPath);
//         HobaDebuger.LogWarningFormat("TmpPath: {0}", _TmpPath);
//         HobaDebuger.LogWarningFormat("ConfigPath: {0}", _ConfigPath);
//         HobaDebuger.LogWarningFormat("LuaPath: {0}", _LuaPath);
//         HobaDebuger.LogWarningFormat("VoiceDir: {0}", _VoiceDir);
//         HobaDebuger.LogWarningFormat("CustomPickDir: {0}", _CustomPicDir);
//         HobaDebuger.LogWarningFormat("OSLanguage: {0}, UserLanguage: {1}", strOSLanguage, strUserLanguage);
//         yield return null;
//#endif

        //根据语言设置更新语言
        ReadUpdateStringXmlFromResources(strUserLanguage);
        yield return(null);

#if (UNITY_EDITOR || UNITY_STANDALONE_WIN)               //只在windows下起作用
        bool bDebugSetting = ReadDebugSettingXml();
//         HobaDebuger.LogWarningFormat("DebugSetting: {0}", bDebugSetting);
//         HobaDebuger.LogWarningFormat("DebugSetting SkipUpdate: {0}, Shortcut: {1}, LocalData: {2}, LocalLua: {3}, Is1080P: {4}, FullScreen: {5}",
//             _DebugSetting.SkipUpdate,
//             _DebugSetting.ShortCut,
//             _DebugSetting.LocalData,
//             _DebugSetting.LocalLua,
//             _DebugSetting.Is1080P,
//             _DebugSetting.FullScreen);

        _SkipUpdate = _DebugSetting.SkipUpdate || File.Exists(Path.Combine(_DocPath, "skip.txt"));
        //HobaDebuger.LogWarningFormat("SkipUpdate: {0}", _SkipUpdate);
#endif

#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
        if (_DebugSetting.Is1080P)
        {
            Screen.SetResolution(1920, 1080, _DebugSetting.FullScreen);
        }

        if (_DebugSetting.FPSLimit > 0)
        {
            Application.targetFrameRate = _DebugSetting.FPSLimit;
        }
#endif

        //初始化平台SDK
        {
            GameUpdateMan.Instance.InitUpdateUI(); //显示更新界面

            bool isFinish = false;
            int  code     = -1;
            LTPlatformBase.ShareInstance().InitSDK((_, resultCode) =>
            {
                code     = resultCode;
                isFinish = true;
            });
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start); //平台SDK打点:开始游戏

            while (!isFinish)
            {
                yield return(null);
            }

            bool isInited = LTPlatformBase.ShareInstance().IsInited;
            var  pType    = LTPlatformBase.ShareInstance().GetPlatformType();
            DeviceLogger.Instance.WriteLogFormat("LTPlatform InitSDK result:{0}, return code:{1}, platform type:{2}", isInited.ToString(), code.ToString(), pType.ToString());
            if (!isInited)
            {
                // 初始化失败,弹窗提示,退出游戏
                GameUpdateMan.Instance.HotUpdateViewer.SetCircle(false);
                string errStr = LTPlatformBase.ShareInstance().GetErrStr(code);
                yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, errStr, _UpdateStringConfigParams.PlatformSDKString_InitFailedTitle));

                ExitGame();
                yield break;
            }
        }

        {
            // copy base res
#if UNITY_ANDROID
            string srcDir  = "res_base";
            string destDir = Path.Combine(Application.persistentDataPath, "res_base");

            if (!Directory.Exists(destDir))
            {
                Directory.CreateDirectory(destDir);
            }

            IsInstallFinished = File.Exists(destDir + "/.lock");
            if (!IsInstallFinished)
            {
                DeviceLogger.Instance.WriteLog(string.Format("Begin RunInstallStage... from {0} to {1}", srcDir, destDir));
                foreach (var item in GameUpdateMan.Instance.RunInstallStage(srcDir, destDir))
                {
                    yield return(item);
                }
                DeviceLogger.Instance.WriteLog("End RunInstallStage...");
            }

            if (IsInstallFinished)
            {
                string       lockFile = Path.Combine(destDir, ".lock");
                StreamWriter writer   = File.CreateText(lockFile);
                writer.Write(TotalSizeToCopy);
                writer.Close();
                DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Success...");
            }
            else
            {
                DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Failed!");
            }
            yield return(null);
#endif
            //在更新开始前,获取ServerConfig.xml
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            {
                string configsDir = Path.Combine(_ResPath, "Configs");
                string path       = Path.Combine(configsDir, "ServerConfig.xml");
                if (!ReadServerConfigXml(path))
                {
                    HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", path);
                }
            }
#else
            {
                string url     = EntryPoint.Instance.GetClientServerUrl().NormalizeDir() + "ServerConfig.xml";
                string tmpPath = Path.Combine(EntryPoint.Instance.TmpPath, "ServerConfig.xml");
                string errMsg;
                var    code = Patcher.FetchByUrl(url, tmpPath, Downloader.DownloadMan.reqTimeOut, out errMsg);
                if (code == Downloader.DownloadTaskErrorCode.Success)
                {
                    if (!ReadServerConfigXml(tmpPath))
                    {
                        HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", url);
                    }
                }
                else
                {
                    HobaDebuger.LogWarningFormat("Download ServerConfig Failed: {0}, {1}", url, code);
                }
            }
#endif
            yield return(null);

            DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine Start...");
            //IAP Verify url init and check receipt cache.
            LTPlatformBase.ShareInstance().InitPurchaseVerifyUrl(_ServerConfigParams.GetPurchaseVerifyUrl());
            LTPlatformBase.ShareInstance().ProcessPurchaseCache();
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start_Update); //平台SDK打点:开始更新

            // App & 资源更新
            foreach (var item in GameUpdateMan.Instance.UpdateRoutine())
            {
                yield return(item);
            }
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_End_Update); //平台SDK打点:结束更新

            DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine End...");
        }

        //初始化pck包, 编辑器模式下不使用pck,策划编辑器模式下使用
#if !UNITY_EDITOR
        {
            string path = _ResPath;
            path = path.Replace("file://", "");
            LuaDLL.HOBA_InitPackages(path);
        }
#endif
        //FIX ME:: 加载不等待2帧 Windows崩溃 待查
        yield return(null);  //等待一帧,否则部分 Android 设置闪烁

        yield return(null);  //等待一帧,否则部分 Android 设置闪烁

        ReadGameCustomConfigParams();
        yield return(null);

        ReadWwiseBankConfigParams();
        yield return(null);

        ReadWwiseSoundConfigParams();
        yield return(null);

        ReadPlayerFollowCameraConfig();
        yield return(null);

        CLogFile.Init();
        yield return(null);

        CGameSession.Instance().PingInterval              = GameCustomConfigParams.PingInterval;
        CGameSession.Instance().MaxProcessProtocol        = GameCustomConfigParams.MaxProcessProtocol;
        CGameSession.Instance().MaxProcessSpecialProtocol = GameCustomConfigParams.MaxProcessSpecialProtocol;

        foreach (var item in InitGameInternal())
        {
            yield return(item);
        }

        CleanupUpdateResources();

        if (PanelLogo != null)
        {
            PanelLogo.SetActive(true);
            yield return(null);
        }

        string videoPath = System.IO.Path.Combine(Application.streamingAssetsPath, "TERA_BackgroundStory.mp4");
        VideoManager.PlayVideo(videoPath, null, null, null, true);
        yield return(null);

        GFXConfig.Instance.Init();

        foreach (var item in DoStartGame())
        {
            yield return(item);
        }

        //DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine DoStartGame End...");

        DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine End...");

        //TestLoadResource("Assets/Outputs/Sfx/Scene/scene_chuansong_chuanzou01.prefab");
    }