Пример #1
0
    //<summary>
    //Creates any objects needed on demand
    //</summary>
    private void CreateMirrorObjects(Camera currentCamera, out Camera reflectionCamera)
    {
        reflectionCamera = null;

        //Reflection render texture
        if (!m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize)
        {
            if (m_ReflectionTexture)
            {
                Destroy(m_ReflectionTexture);
            }
            m_ReflectionTexture              = new RenderTexture(m_TextureSize, m_TextureSize, 16);
            m_ReflectionTexture.name         = HobaText.Format("__MirrorReflection{0}", GetInstanceID());
            m_ReflectionTexture.isPowerOfTwo = true;
            m_ReflectionTexture.hideFlags    = HideFlags.DontSave;
            m_OldReflectionTextureSize       = m_TextureSize;
        }

        //Camera for reflection
        if (!m_ReflectionCameras.TryGetValue(currentCamera, out reflectionCamera)) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
        {
            GameObject go = new GameObject(
                HobaText.Format("Mirror Refl Camera id{0} for {1}", GetInstanceID(), currentCamera.GetInstanceID()),
                typeof(Camera), typeof(Skybox));
            reflectionCamera                    = go.GetComponent <Camera>();
            reflectionCamera.enabled            = false;
            reflectionCamera.transform.position = transform.position;
            reflectionCamera.transform.rotation = transform.rotation;
            reflectionCamera.gameObject.AddComponent <FlareLayer>();
            go.hideFlags = HideFlags.HideAndDontSave;
            m_ReflectionCameras.Add(currentCamera, reflectionCamera);

            UpdateCameraSkyboxs();
        }
    }
Пример #2
0
 public static void SetDownStatusString(float progress)
 {
     if (bShowProgress)
     {
         SetStatus(HobaText.Format("{0}: {1:P}", GetStateString(UPDATE_STATE.UpdateStatus_Downloading), progress));
     }
 }
Пример #3
0
    public Material Get(Material originMat)
    {
        if (originMat == null)
        {
            return(null);
        }

        Material mat = null;

        if (_PooledMaterials.Count >= 1)
        {
            mat = _PooledMaterials.Dequeue();
        }

        if (mat != null)
        {
            mat.shader = originMat.shader;
            mat.CopyPropertiesFromMaterial(originMat);
        }
        else
        {
            _TotalInstancesCreated++;
            mat = new Material(originMat);
        }

        mat.name = HobaText.Format("{0}{1}", RUN_TIME_SYMBOL, originMat.name);
#if UNITY_EDITOR
        mat.hideFlags = HideFlags.DontSave;
#else
        mat.hideFlags = HideFlags.HideAndDontSave;
#endif

        return(mat);
    }
Пример #4
0
    public void SetEnterGameProgress(float progress)
    {
        if (progress < 0.0f)
        {
            return;
        }

        float value = 0.0f;

        if (progress > 1.0f)
        {
            value = 1.0f;
        }
        else
        {
            value = progress;
        }

        pSlderProgress.value = value;
        pTextProgress.text   = HobaText.Format("{0:0} %", value * 100);
        if (!Frame_Progress.activeSelf)
        {
            Frame_Progress.SetActive(true);
        }
    }
Пример #5
0
        private string GetFullAssetPath(string animationName)
        {
            if (_AnimationNameMap == null)
            {
                _AnimationNameMap = new Dictionary <string, int>();
                BuildAnimationMap(_AnimationNameMap);
            }

            int index = 0;

            if (_AnimationNameMap.TryGetValue(animationName, out index))
            {
                return(HobaText.Format("{0}{1}", FRONT_NAME, _AnimationInfo.animationPaths[index]));
            }

//             var keyName = HobaText.Format("/{0}.anim", animationName);
//             for (int i = 0; i < _AnimationInfo.animationPaths.Length; i++)
//             {
//                 if (_AnimationInfo.animationPaths[i].EndsWith(keyName))
//                 {
//                     //return FRONT_NAME + _AnimationInfo.animationPaths[i];
//                     return HobaText.Format("{0}{1}", FRONT_NAME, _AnimationInfo.animationPaths[i]);
//                 }
//             }
            return(string.Empty);
        }
Пример #6
0
        private void InitRealTextValue()
        {
            var dialogue = CGManager.Instance.GetDialogueById(textValue);

            if (dialogue == null)
            {
                return;
            }

            switch (dialogueType)
            {
            case DialogueType.Name:
                realTextValue = dialogue.Name;
                break;

            case DialogueType.Content:
                realTextValue = dialogue.Content;
                break;

            case DialogueType.All:
                realTextValue = HobaText.Format("{0}{1}", dialogue.Name, dialogue.Content);
                break;

            default:
                realTextValue = string.Empty;
                Debug.LogError("Error dialogueType!!!");
                break;
            }
        }
Пример #7
0
    public override void InitSDK(LT_INITED_NOTIFICATION_DELEGATE fnInit)
    {
        if (!_IsInited)
        {
            Reset();
            //EntryPoint.Instance.gameObject.AddComponent<Test.TestKakao>();
            //³õʼ»¯´òµãSDK
            var singularSDK = new GameObject("SingularSDK");
            singularSDK.AddComponent <SingularSDK>();

            KakaoUtil.Start((isAuthorized, resultCode) =>
            {
                if (resultCode == KGResultCode.Success)
                {
                    _IsInited  = true;
                    _IsLogined = isAuthorized;
                    DeviceLogger.Instance.WriteLog(HobaText.Format("Start succeeded, isAthorized: {0}, ", isAuthorized.ToString()));

                    if (fnInit != null)
                    {
                        fnInit(INITED_STATE.LT_INITED_SUCCEED, resultCode);
                    }
                }
                else
                {
                    DeviceLogger.Instance.WriteLog(HobaText.Format("Start failed, result code: {0}, ", resultCode.ToString()));
                    if (fnInit != null)
                    {
                        fnInit(INITED_STATE.LT_INITED_FAIL, resultCode);
                    }
                }
            });
        }
    }
Пример #8
0
    public byte[] CustomLoader(string name)
    {
        string path = HobaText.Format(@"{0}/{1}", _LuaPath, name);

        byte[] bytes = Util.ReadFile(path);
        return(bytes);
    }
Пример #9
0
        private bool _IsParamsArray(IntPtr luaState, int currentLuaParam, ParameterInfo currentNetParam, out ExtractValue extractValue)
        {
            extractValue = null;

            if (currentNetParam.GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
            {
                LuaTypes luaType;

                try
                {
                    luaType = LuaDLL.lua_type(luaState, currentLuaParam);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Could not retrieve lua type while attempting to determine params Array Status." + ex.ToString());
                    Debug.WriteLine(ex.Message);
                    extractValue = null;
                    return(false);
                }

                if (luaType == LuaTypes.LUA_TTABLE)
                {
                    try
                    {
                        extractValue = translator.typeChecker.getExtractor(typeof(LuaTable));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("An error occurred during an attempt to retrieve a LuaTable extractor while checking for params array status." + ex.ToString());
                    }

                    if (extractValue != null)
                    {
                        return(true);
                    }
                }
                else
                {
                    Type paramElementType = currentNetParam.ParameterType.GetElementType();

                    try
                    {
                        extractValue = translator.typeChecker.checkType(luaState, currentLuaParam, paramElementType);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(HobaText.Format("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status:{1}", paramElementType.FullName, ex.ToString()));
                    }

                    if (extractValue != null)
                    {
                        return(true);
                    }
                }
            }

            Debug.WriteLine("Type wasn't Params object.");

            return(false);
        }
Пример #10
0
    private void BuildShaderList(GameObject shaderListObj)
    {
        _ShaderMap.Clear();

        if (shaderListObj != null)
        {
            ShaderList compShaderList = shaderListObj.GetComponent <ShaderList>();
            if (compShaderList != null && compShaderList.Shaders != null)
            {
                try
                {
                    int nCount = compShaderList.Shaders.Length;
                    HobaDebuger.LogFormat("ShaderManager.Init, Shaders Count: {0}", nCount);
                    for (int i = 0; i < nCount; ++i)
                    {
                        Shader shader = compShaderList.Shaders[i];
                        if (shader != null && !_ShaderMap.ContainsKey(shader.name))
                        {
                            _ShaderMap.Add(shader.name, shader);
                            //HobaDebuger.LogFormat("ShaderManager.Init, Load Shader: {0}", shader.name);
                        }
                        else
                        {
                            HobaDebuger.LogWarning(HobaText.Format("ShaderManager.Init, Shader {0} is missing!", i));
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    HobaDebuger.LogError(ae.Message);
                }
            }
        }
    }
Пример #11
0
    // Extra data handler to packet data and report them with exception.
    // Please do not do hard work in this handler
    private static Dictionary <string, string> MyLogCallbackExtrasHandler()
    {
        // TODO Test log, please do not copy it
        BuglyAgent.PrintLog(LogSeverity.Log, "extra handler");

        // TODO Sample code, please do not copy it
        Dictionary <string, string> extras = new Dictionary <string, string> ();

        extras.Add("ScreenSolution", HobaText.Format("{0}x{1}", Screen.width, Screen.height));
        extras.Add("deviceModel", SystemInfo.deviceModel);
        extras.Add("deviceName", SystemInfo.deviceName);
        extras.Add("deviceType", SystemInfo.deviceType.ToString());

        extras.Add("deviceUId", SystemInfo.deviceUniqueIdentifier);
        extras.Add("gDId", HobaText.Format("{0}", SystemInfo.graphicsDeviceID));
        extras.Add("gDName", SystemInfo.graphicsDeviceName);
        extras.Add("gDVdr", SystemInfo.graphicsDeviceVendor);
        extras.Add("gDVer", SystemInfo.graphicsDeviceVersion);
        extras.Add("gDVdrID", HobaText.Format("{0}", SystemInfo.graphicsDeviceVendorID));

        extras.Add("graphicsMemorySize", HobaText.Format("{0}", SystemInfo.graphicsMemorySize));
        extras.Add("systemMemorySize", HobaText.Format("{0}", SystemInfo.systemMemorySize));
        extras.Add("UnityVersion", Application.unityVersion);

        BuglyAgent.PrintLog(LogSeverity.LogInfo, "Package extra data");
        return(extras);
    }
Пример #12
0
    public bool Init()
    {
        int ret = 0;

        string AppID  = EntryPoint.Instance.GameCustomConfigParams.GCloud_AppID;
        string AppKey = EntryPoint.Instance.GameCustomConfigParams.GCloud_AppKey;

        if (m_voiceengine == null)
        {
            m_voiceengine = gcloud_voice.GCloudVoice.GetEngine();
            System.TimeSpan ts      = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
            string          strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString();

            ret = m_voiceengine.SetAppInfo(AppID, AppKey, strTime);
            if (ret != 0)
            {
                m_voiceengine = null;
                HobaDebuger.LogError(HobaText.Format("IGCloudVoice SetAppInfo Failed! ret: {0}", ret));
            }
            else
            {
                ret = m_voiceengine.Init();
                if (ret != 0)
                {
                    m_voiceengine = null;
                    HobaDebuger.LogError(HobaText.Format("IGCloudVoice Init Failed! ret: {0}", ret));
                }
            }
        }

        return(ret == 0);
    }
Пример #13
0
    public static UnityEngine.TrackedReference GetTrackedObject(IntPtr L, int stackPos, Type type)
    {
        if (LuaDLL.lua_isnil(L, stackPos))
        {
            return(null);
        }

        object obj = GetLuaObject(L, stackPos);

        if (obj == null)
        {
            LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got nil", type.Name));
            return(null);
        }

        UnityEngine.TrackedReference uObj = obj as UnityEngine.TrackedReference;

        if (uObj == null)
        {
            LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got nil", type.Name));
            return(null);
        }

        Type objType = obj.GetType();

        if (type == objType || objType.IsSubclassOf(type))
        {
            return(uObj);
        }

        LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got {1}", type.Name, objType.Name));
        return(null);
    }
Пример #14
0
    public static T[] GetParamsObject <T>(IntPtr L, int stackPos, int count)
    {
        List <T> list = new List <T>();
        T        obj  = default(T);

        while (count > 0)
        {
            object tmp = GetLuaObject(L, stackPos);

            ++stackPos;
            --count;

            if (tmp != null && tmp.GetType() == typeof(T))
            {
                obj = (T)tmp;
                list.Add(obj);
            }
            else
            {
                LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got nil", typeof(T).Name));
                break;
            }
        }

        return(list.ToArray());
    }
Пример #15
0
    public void Init(string lightRegionName)
    {
        _StaticLightMapRegionFile = new FileMapRegion();
        _HasStaticLightMapRegion  = false;

        _BlockLoadingRegionFile    = new FileMapRegion();
        _HasBlockLoadingRegionFile = false;
        string fileName = HobaText.Format("{0}/Maps/{1}.lightregion", EntryPoint.Instance.ResPath, lightRegionName);

        try
        {
            byte[] region_data = Util.ReadFile(fileName);
            _HasStaticLightMapRegion = _StaticLightMapRegionFile.ReadFromMemory(region_data, true);
        }
        catch (Exception)
        {
            _HasStaticLightMapRegion = false;
        }

        fileName = HobaText.Format("{0}/Maps/{1}.blockregion", EntryPoint.Instance.ResPath, lightRegionName);
        try
        {
            byte[] regionData = Util.ReadFile(fileName);
            _HasBlockLoadingRegionFile = _BlockLoadingRegionFile.ReadFromMemory(regionData, true);
        }
        catch (Exception)
        {
            _HasBlockLoadingRegionFile = false;
        }
    }
Пример #16
0
    public static object GetNetObject(IntPtr L, int stackPos, Type type)
    {
        if (LuaDLL.lua_isnil(L, stackPos))
        {
            return(null);
        }

        object obj = GetLuaObject(L, stackPos);


        if (obj == null)
        {
            LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got nil", type.Name));
            return(null);
        }

        Type objType = obj.GetType();

        if (type == objType || type.IsAssignableFrom(objType))
        {
            return(obj);
        }

        LuaDLL.luaL_argerror(L, stackPos, HobaText.Format("{0} expected, got {1}", type.Name, objType.Name));
        return(null);
    }
Пример #17
0
    public static void ShowGameLogs4Debug(int logType, GameObject textGo, GameObject contentViewGo)
    {
        if (_LogCacheQueue == null && _LogCacheQueue.Count == 0)
        {
            return;
        }
        var logs = string.Empty;

        foreach (var v in _LogCacheQueue)
        {
            if ((logType == 1) || // 全部显示
                (logType == 2 && v.Type == (int)LogType.Log) ||  // 显示Log
                (logType == 3 && v.Type == (int)LogType.Warning) ||  // 显示Warning
                (logType == 4 && ((v.Type == (int)LogType.Error) || (v.Type == (int)LogType.Exception)))      // 显示Error & Exception
                )
            {
                logs = HobaText.Format("{0}{1}", logs, v.Content);
            }
        }

        var textComp = textGo.GetComponent <Text>();

        textComp.text = logs;

        var viewTrans = contentViewGo.GetComponent <RectTransform>();
        var sizeDelta = viewTrans.sizeDelta;

        sizeDelta.y         = textComp.preferredHeight + 5;
        viewTrans.sizeDelta = sizeDelta;
    }
Пример #18
0
    public ResourceTracker(bool enableTracking)
    {
        if (enableTracking)
        {
            try
            {
                DateTime dt = DateTime.Now;

                string logFile = HobaText.Format("{0}_{1}_alloc.txt", SysUtil.FormatDateAsFileNameString(dt), SysUtil.FormatTimeAsFileNameString(dt));
                string logPath = Path.Combine(Application.persistentDataPath, logFile);

                _logWriter           = new FileInfo(logPath).CreateText();
                _logWriter.AutoFlush = true;
                _logPath             = logPath;
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogErrorFormat("[ResourceTracker.ctor] error: {0} ", ex.Message);

                if (_logWriter != null)
                {
                    _logWriter.Close();
                    _logWriter = null;
                }

                _logPath = "";
            }
        }

        _enableTracking = enableTracking;
    }
Пример #19
0
    public static void SynchronizeShape(this Transform destination, Transform source)
    {
        if (null == source || null == destination)
        {
            string s = HobaText.Format("source={0}, destination={1}", source, destination);
            UnityEngine.Debug.LogError(s);
            return;
        }

        using (var srcEnumerator = source.WalkTree().GetEnumerator())
            using (var dstEnumerator = destination.WalkTree().GetEnumerator())
            {
                srcEnumerator.MoveNext();
                dstEnumerator.MoveNext();

                while (srcEnumerator.MoveNext() && dstEnumerator.MoveNext())
                {
                    var srcTransform = srcEnumerator.Current;
                    var dstTransform = dstEnumerator.Current;
                    dstTransform.localPosition = srcTransform.localPosition;
                    dstTransform.localRotation = srcTransform.localRotation;
                    dstTransform.localScale    = srcTransform.localScale;
                }
            }
    }
Пример #20
0
    private static void WriteUnityLog2File(string condition, string stackTrace, LogType type)
    {
        string log = null;

        switch (type)
        {
        case LogType.Log:
            log = HobaText.Format("{0}", condition);
            break;

        case LogType.Warning:
            log = HobaText.Format("[warning] {0}", condition);
            break;

        case LogType.Exception:
            log = HobaText.Format("[exception] {0}:\n{1}", condition, stackTrace);
            break;

        case LogType.Error:
            log = HobaText.Format("[error] {0}:\n{1}", condition, stackTrace);
            break;

        default:
            log = HobaText.Format("[unknownerror] {0}", condition);
            break;
        }

        WriteLogImp(log);
    }
Пример #21
0
    private static void ReportException(int type, string name, string reason, string stackTrace, bool quitProgram)
    {
        ConfigCrashReporterType();

        string extraInfo = "";
        Dictionary <string, string> extras = null;

        if (_LogCallbackExtrasHandler != null)
        {
            extras = _LogCallbackExtrasHandler();
        }
        if (extras == null || extras.Count == 0)
        {
            extras = new Dictionary <string, string> ();
            extras.Add("UnityVersion", Application.unityVersion);
        }

        if (extras != null && extras.Count > 0)
        {
            if (!extras.ContainsKey("UnityVersion"))
            {
                extras.Add("UnityVersion", Application.unityVersion);
            }

            StringBuilder builder = HobaText.GetStringBuilder();
            foreach (KeyValuePair <string, string> kvp in extras)
            {
                builder.Append(HobaText.Format("\"{0}\" : \"{1}\"", kvp.Key, kvp.Value)).Append(" , ");
            }
            extraInfo = HobaText.Format("{{ {0} }}", builder.ToString().TrimEnd(" , ".ToCharArray()));
        }

        // 4 is C# exception
        _BuglyReportException(4, name, reason, stackTrace, extraInfo, quitProgram);
    }
Пример #22
0
    public static DownloadTaskErrorCode FetchByUrl(string url, string destFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(destFile))
        {
            Common.HobaDebuger.LogWarning(HobaText.Format("[FetchByUrl] MakeDir {0} Failed!", destFile));
        }

        if (FileOperate.IsFileExist(destFile))
        {
            FileOperate.DeleteFile(destFile);
        }

        string hostName = UpdateUtility.GetHostName(url);

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            destFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
Пример #23
0
    //从服务器下载 version.txt 到 strGameNewVerFile
    public DownloadTaskErrorCode FetchServerVersionFile(string url, string hostName, string savedFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(savedFile))
        {
            LogString(HobaText.Format("[FetchServerVersionFile] MakeDir {0} Failed!", savedFile));
        }

        if (FileOperate.IsFileExist(savedFile))
        {
            FileOperate.DeleteFile(savedFile);
        }

        //测试
        //         int filesize2 = (int)SeasideResearch.LibCurlNet.External.CURL_GetUrlFileSize(url, timeout);
        //         LogString(HobaString.Format("c++ url FileSize: {0}, fileSize: {1}", url, filesize2));
        //
        //         int filesize = (int)UpdateUtility.GetUrlFileSizeEx(url, hostName, timeout);
        //         LogString(HobaString.Format("url FileSize: {0}, fileSize: {1}", url, filesize));

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            savedFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
Пример #24
0
        private static void LoadPathIDData()
        {
            byte[] pathidContent = null;
            if (IsUpdateFileExist("PATHID.dat"))         //使用更新目录下的pathid.dat
            {
                var filePath = HobaText.Format("{0}{1}", _UpdateAssetBundleURL, "PATHID.dat");
                pathidContent = Util.ReadFile(filePath);
            }
            else
            {
                var filePath = HobaText.Format("{0}{1}", _GameResBasePath, "PATHID.dat");
                pathidContent = Util.ReadFile(filePath);
            }

            if (pathidContent != null && pathidContent.Length > 0)
            {
                StreamReader sr = new StreamReader(new MemoryStream(pathidContent));

                var strLine = sr.ReadLine();
                while (strLine != null)
                {
                    string[] asset_temp = strLine.Split(',');
                    if (asset_temp.Length >= 2)
                    {
                        _AssetSet.Add(asset_temp[1]);
                    }

                    strLine = sr.ReadLine();
                }
                ;

                sr.Close();
            }
        }
Пример #25
0
    public static void StaticBatching(UnityEngine.GameObject go)
    {
        MeshRenderer[] mrs = go.GetComponentsInChildren <MeshRenderer>();
        _BatchInfos.Clear();

        foreach (MeshRenderer mr in mrs)
        {
            var mat = mr.material;
            if (mat != null)
            {
                BatchItem o;
                if (!_BatchInfos.TryGetValue(mat.name, out o))
                {
                    o = new BatchItem()
                    {
                        MeshList = new List <MeshRenderer>()
                    };
                    _BatchInfos.Add(mat.name, o);
                }

                o.MeshList.Add(mr);
            }
        }

        int index = 0;
        var e     = _BatchInfos.GetEnumerator();

        while (e.MoveNext())
        {
            BatchItem pb = e.Current.Value;

            if (pb.MeshList.Count <= 1)
            {
                continue;
            }

            var root = new GameObject(HobaText.Format("Batch{0}", index++));
            var mt   = pb.MeshList[0].sharedMaterial;

            var goArray   = new GameObject[pb.MeshList.Count];
            var rootTrans = root.transform;
            for (int i = 0; i < pb.MeshList.Count; i++)
            {
                var cc = pb.MeshList[i];
                var g  = cc.gameObject;
                g.transform.parent = rootTrans;

                if (i != 0)
                {
                    cc.sharedMaterial = mt;
                }
                goArray[i] = g;
            }

            StaticBatchingUtility.Combine(goArray, root);
            rootTrans.parent = go.transform;
        }
        e.Dispose();
    }
Пример #26
0
    /// <summary>
    /// Prints the log.
    /// </summary>
    /// <param name="level">Level.</param>
    /// <param name="format">Format.</param>
    /// <param name="args">Arguments.</param>
    public static void PrintLog(LogSeverity level, string format, params object[] args)
    {
        if (string.IsNullOrEmpty(format))
        {
            return;
        }

        LogRecord(level, HobaText.Format(format, args));
    }
Пример #27
0
        public static void DebugAssert(bool condition, string message, params object[] args)
        {
#if DEBUG
            if (!condition)
            {
                DebugAssert(false, HobaText.Format(message, args));
            }
#endif
        }
Пример #28
0
    public static void CheckArgsCount(IntPtr L, int count)
    {
        int c = LuaDLL.lua_gettop(L);

        if (c != count)
        {
            string str = HobaText.Format("no overload for method '{0}' takes '{1}' arguments", GetErrorFunc(1), c);
            LuaDLL.luaL_error(L, str);
        }
    }
Пример #29
0
        public void OnConnectFailed(ConnectionEventArgs e)
        {
#if UNITY_EDITOR || UNITY_STANDALONE
            HobaDebuger.LogFormat(HobaText.Format("{0} ConnectFailed.", _IP));
#endif
            if (OnGatewayEvent != null)
            {
                OnGatewayEvent(EVENT.CONNECT_FAILED);
            }
        }
Пример #30
0
    public static T[] GetArrayObject <T>(IntPtr L, int stackPos)
    {
        //ObjectTranslator translator = GetTranslator(L);
        LuaTypes luatype = LuaDLL.lua_type(L, stackPos);

        if (luatype == LuaTypes.LUA_TTABLE)
        {
            int      index = 1;
            T        val   = default(T);
            List <T> list  = new List <T>();
            LuaDLL.lua_pushvalue(L, stackPos);
            Type t = typeof(T);

            do
            {
                LuaDLL.lua_rawgeti(L, -1, index);
                luatype = LuaDLL.lua_type(L, -1);

                if (luatype == LuaTypes.LUA_TNIL)
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }
                else if (!CheckType(L, t, -1))
                {
                    LuaDLL.lua_pop(L, 1);
                    break;
                }

                val = (T)GetVarObject(L, -1);
                list.Add(val);
                LuaDLL.lua_pop(L, 1);
                ++index;
            } while (true);

            return(list.ToArray());
        }
        else if (luatype == LuaTypes.LUA_TUSERDATA)
        {
            T[] ret = GetNetObject <T[]>(L, stackPos);

            if (ret != null)
            {
                return((T[])ret);
            }
        }
        else if (luatype == LuaTypes.LUA_TNIL)
        {
            return(null);
        }

        LuaDLL.luaL_error(L, HobaText.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
        return(null);
    }