예제 #1
0
    public void SetCameraLocation(int type, LuaFunction callback)
    {
        _CtrlType = type;

        if (type == 1)
        {
            //进入近景模式
            if (LookAtTarget == null)
            {
                HobaDebuger.LogError("CPlayerNearCam SetCameraLocation to Near failed, Host Player got null.");
                return;
            }
            if (_ProfCfg == null)
            {
                HobaDebuger.LogError("CPlayerNearCam SetCameraLocation failed, Prof Config got null.");
                return;
            }

            _OriginLookAtPos = CCamCtrlMan.Instance.GetLookAtPosOfGameModel();
            _OriginFOV       = Main.Main3DCamera.fieldOfView;
            RollSensitivity  = 0.05f;
            _IsQuitNearCam   = false;

            try
            {
                _StageCfg = _ProfCfg.GetCurStageData(NearCamStage.Body);
                InitDefaultParams();
                float real_height_offset = GetRealHeightOffset();
                _CurLookAtPos   = GetRealLookAtPos(real_height_offset);
                _IsEnterNearCam = true;
                EnableCameraEffect(true);

                var cam_dest_pos = GetRealLookAtPos(real_height_offset) - _RealDir * _DistOffset;
                DoCamMove(true, cam_dest_pos, real_height_offset, _StageCfg._FOV, callback);
            }
            catch (System.Exception e)
            {
                HobaDebuger.LogErrorFormat("CPlayerNearCam SetCameraLocation to Near Exception:{0}", e.Message);
            }
        }
        else if (type == 2)
        {
            //退出近景模式
            if (LookAtTarget == null)
            {
                HobaDebuger.LogError("CPlayerNearCam SetCameraLocation to Far failed, Host Player got null.");
                return;
            }

            LuaScriptMgr.Instance.CallLuaFunction("OpenOrCloseUIPanel", "CPanelUINearCam", false);
            CCamCtrlMan.Instance.GetGameCamCtrl().SetToDefaultCamera(false, false, true, true);
            _IsQuitNearCam = true;
            EnableCameraEffect(false);
            EnableLookIK(false);

            float des_height_offset = CCamCtrlMan.Instance.GetGameCamCtrl().GetHeightOffset();
            var   dest_game_cam_pos = GetGameCamPosAfterCollionFix(des_height_offset);
            DoCamMove(false, dest_game_cam_pos, des_height_offset, _OriginFOV, null);
        }
    }
예제 #2
0
    public static int ResetTimer(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("ResetTimer: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            ObjectBehaviour comp = obj.GetComponent <ObjectBehaviour>();
            if (comp == null)
            {
                HobaDebuger.LogError("ResetTimer: param 1 must have ObjectBehaviour");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            int id = (int)LuaScriptMgr.GetNumber(L, 2);
            comp.ResetTimer(id);
            return(GameUtilWrap.CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("ResetTimer", count);
            return(GameUtilWrap.CheckReturnNum(L, count, nRet));
        }
    }
예제 #3
0
    public static int BluntAttachedFxs(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(float), typeof(float)))
        {
            var go = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (go != null)
            {
                var lastTime   = (float)LuaScriptMgr.GetNumber(L, 2);
                var fixedSpeed = (float)LuaScriptMgr.GetNumber(L, 3);
                var fxs        = go.GetComponentsInChildren <CFxOne>();
                for (var i = 0; i < fxs.Length; i++)
                {
                    fxs[i].Blunt(lastTime, fixedSpeed);
                }
            }
        }
        else
        {
            HobaDebuger.LogError("invalid arguments to method: GameUtilWrap.BluntAttachedFxs");
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #4
0
    static int SetTextColor(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                LuaScriptMgr.Instance.CallOnTraceBack();
                HobaDebuger.LogError("SetTextColor: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }
            Color color = LuaScriptMgr.GetColor(L, 2);
            var   text  = obj.GetComponent <UnityEngine.UI.Text>();
            if (text != null)
            {
                text.color = color;
            }
            else
            {
                HobaDebuger.LogError("SetTextColor: param 2 must be color");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetTextColor", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
예제 #5
0
    private static int AsyncLoad(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count >= 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(LuaFunction)))
        {
            string assetname = LuaScriptMgr.GetString(L, 1);
            //Debug.Log("C#====assetname" + assetname);
            if (string.IsNullOrEmpty(assetname))
            {
                HobaDebuger.LogError("GameUtilWrap.AsyncLoad's argument #1 can not be empty");
                return(CheckReturnNum(L, count, nRet));
            }

            if (!LuaDLL.lua_isfunction(L, 2))
            {
                HobaDebuger.LogError("GameUtilWrap.AsyncLoad: second param must be function");
                return(CheckReturnNum(L, count, nRet));
            }
            // assetname, cb,
            LuaDLL.lua_pushvalue(L, 2);                                         // assetname, cb, cb
            int callbackRef = LuaDLL.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); // assetname, cb

            var needInstantiate = LuaScriptMgr.GetBoolean(L, 3);
            DoAsyncLoadResource(L, assetname, callbackRef, needInstantiate);
            return(CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("AsyncLoad", count);
            return(CheckReturnNum(L, count, nRet));
        }
    }
예제 #6
0
    private static int DoScaleFrom(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float), typeof(int), typeof(LuaFunction)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("GameUtil :: DoScaleFrom -> the GameObject is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>();
            if (doTween == null)
            {
                doTween = obj.AddComponent <DoTweenComponent>();
            }

            Vector3 fromScale = LuaScriptMgr.GetVector3(L, 2);
            float   interval  = (float)LuaScriptMgr.GetNumber(L, 3);
            Ease    easeType  = (Ease)LuaScriptMgr.GetNumber(L, 4);

            LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 5);
            doTween.DoScaleFrom(fromScale, interval, easeType, callbackRef);
        }
        else
        {
            LogParamError("DoScaleFrom", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #7
0
    private static int SetLayerRecursively(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                LuaScriptMgr.Instance.CallOnTraceBack();
                HobaDebuger.LogError("SetLayerRecursively: param 1 must be GameObject");
                return(CheckReturnNum(L, count, nRet));
            }

            int layer = (int)LuaScriptMgr.GetNumber(L, 2);
            Util.SetLayerRecursively(obj, layer);
        }
        else
        {
            LogParamError("SetLayerRecursively", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #8
0
    public static int GetScenePath(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if (count == 1 && (LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject))))
        {
            var go = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (go == null)
            {
                HobaDebuger.LogError("GetScenePath: GameObject got null");
                LuaDLL.lua_pushstring(L, string.Empty);
                return(CheckReturnNum(L, count, nRet));
            }

            Transform trans = go.transform;
            string    s     = "";
            while (trans != null)
            {
                s     = trans.name + "/" + s;
                trans = trans.parent;
            }

            LuaDLL.lua_pushstring(L, s);
        }
        else
        {
            LuaDLL.lua_pushstring(L, string.Empty);
            LogParamError("GetScenePath", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #9
0
    static int SetAlpha(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                LuaScriptMgr.Instance.CallOnTraceBack();
                HobaDebuger.LogError("SetAlpha: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }
            var a       = (int)LuaScriptMgr.GetNumber(L, 2);
            var graphic = obj.GetComponent <Graphic>();
            if (graphic != null)
            {
                var c = graphic.color;
                c.a           = a / 255f;
                graphic.color = c;
            }
            else
            {
                HobaDebuger.LogError("Failed to call SetAlpha");
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetAlpha", count);
        }

        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
예제 #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
    private static int DoLoopRotate(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("GameUtil :: DoRotation -> the GameObject is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>();
            if (doTween == null)
            {
                doTween = obj.AddComponent <DoTweenComponent>();
            }

            var   endValue = LuaScriptMgr.GetVector3(L, 2);
            float interval = (float)LuaScriptMgr.GetNumber(L, 3);
            doTween.DoLoopRotate(endValue, interval);
        }
        else
        {
            LogParamError("DoLoopRotate", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #12
0
    public static int SetMineObjectScale(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(float)))
        {
            var go = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (go != null)
            {
                var scale = (float)LuaScriptMgr.GetNumber(L, 2);
                go.transform.localScale = new Vector3(scale, scale, scale);

                var projectors = go.GetComponentsInChildren <Projector>();
                foreach (var v in projectors)
                {
                    v.orthographicSize = scale * v.orthographicSize;
                }

                var scaleCurves = go.GetComponentsInChildren <RFX4_ScaleCurves>();
                foreach (var v in scaleCurves)
                {
                    v.SetScaleFactor(scale);
                    v.SetActive(true);
                }
            }
        }
        else
        {
            HobaDebuger.LogError("invalid arguments to method: GameUtilWrap.SetMineFxScale");
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #13
0
    public static int CaptureScreen(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 0)
        {
            var main_cam = Main.Main3DCamera;
            if (main_cam == null)
            {
                HobaDebuger.LogError("CaptureScreen: Main3DCamera got null");
                return(CheckReturnNum(L, count, nRet));
            }
            var post = main_cam.GetComponent <PostProcessChain>();
            if (post == null)
            {
                HobaDebuger.LogError("CaptureScreen: Main3DCamera has no PostProcessChain");
                return(CheckReturnNum(L, count, nRet));
            }
            post.CaptureScreen();
        }
        else
        {
            LogParamError("CaptureScreen", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #14
0
    private static int DoKill(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("GameUtil :: DoKill -> the GameObject is null.");
                return(CheckReturnNum(L, count, nRet));
            }
            //Debug.Log("Kill " + obj.name);
            DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>();
            if (doTween != null)
            {
                doTween.KillAll();
            }

            DOTween.Kill(obj);
        }
        else
        {
            LogParamError("DoKill", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #15
0
    private static int DoAlpha(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(float), typeof(float), typeof(LuaFunction)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("GameUtil :: DoAlpha -> the GameObject is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>();
            if (doTween == null)
            {
                doTween = obj.AddComponent <DoTweenComponent>();
            }

            float endValue = (float)LuaScriptMgr.GetNumber(L, 2);
            float interval = (float)LuaScriptMgr.GetNumber(L, 3);

            LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 4);

            doTween.DoAlpha(endValue, interval, callbackRef);
        }
        else
        {
            LogParamError("DoAlpha", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #16
0
    public static int DebugKey(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        bool ret = false;

#if UNITY_EDITOR
        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string)))
        {
            try
            {
                string str = LuaScriptMgr.GetString(L, 1);
                ret = Input.GetKey(str);
            }
            catch (Exception e)
            {
                HobaDebuger.LogWarning("TestKey:" + e);
            }
        }
        else
        {
            HobaDebuger.LogError("TestKey: param 1 must be string");
        }
#endif
        LuaScriptMgr.Push(L, ret);

        return(CheckReturnNum(L, count, nRet));
    }
예제 #17
0
    private static int DoLocalMove(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float), typeof(int), typeof(LuaFunction)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                //LuaScriptMgr.Instance.CallOnTraceBack();
                HobaDebuger.LogError("GameUtil :: DoLocalMove -> the GameObject is null.");
                return(CheckReturnNum(L, count, nRet));
            }

            DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>();
            if (doTween == null)
            {
                doTween = obj.AddComponent <DoTweenComponent>();
            }

            var         toPos       = LuaScriptMgr.GetVector3(L, 2);
            float       interval    = (float)LuaScriptMgr.GetNumber(L, 3);
            Ease        easeType    = (Ease)LuaScriptMgr.GetNumber(L, 4);
            LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 5);

            //Debug.Log("DoLocalMove " + obj.name+" to "+ toPos);
            doTween.DoLocalMove(toPos, interval, easeType, callbackRef);
        }
        else
        {
            LogParamError("DoLocalMove", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #18
0
    private void BuildShaderList(GameObject shaderListObj)
    {
        //ShaderManager.Instance._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)
                        {
                            Debug.LogErrorFormat("ShaderManager.Init, Shader {0} is missing!", i);
                            AssetBundleCheck.Instance._ErrorString += string.Format("ShaderManager.Init, Shader {0} is missing!", i);
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    HobaDebuger.LogError(ae.Message);
                }
            }
        }
    }
예제 #19
0
    private static int IsGameObjectInCamera(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable)))
        {
            GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (obj == null)
            {
                HobaDebuger.LogError("IsGameObjectInCamera: param 1 must be GameObject");
                LuaScriptMgr.Push(L, false);
                return(CheckReturnNum(L, count, nRet));
            }

            Vector3 size = LuaScriptMgr.GetVector3(L, 2);

            bool isIn = CCamCtrlMan.Instance.IsGameObjectInCamera(obj.transform, size);
            LuaScriptMgr.Push(L, isIn);
            return(CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("IsGameObjectInCamera", count);
            LuaScriptMgr.Push(L, false);
            return(CheckReturnNum(L, count, nRet));
        }
    }
예제 #20
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);
    }
예제 #21
0
    private static int SetCameraParams(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(int)))
        {
            CAM_CTRL_MODE mode = (CAM_CTRL_MODE)LuaScriptMgr.GetNumber(L, 1);
            CCamCtrlMan.Instance.SetCurCamCtrl(mode, true);
        }
        else if (count == 6 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(bool), typeof(GameObject), typeof(int), typeof(LuaTable), typeof(LuaFunction)))
        {
            //CAM_CTRL_MODE mode = (CAM_CTRL_MODE)LuaScriptMgr.GetNumber(L, 1);
            //var adjust_immediatelly = LuaScriptMgr.GetBoolean(L, 2);
            GameObject npc_obj      = LuaScriptMgr.GetUnityObject <GameObject>(L, 3);
            int        look_at_type = (int)LuaScriptMgr.GetNumber(L, 4);
            Vector3    destDir      = LuaScriptMgr.GetVector3(L, 5);

            if (npc_obj == null)
            {
                HobaDebuger.LogError("the target object you wanna look at is null. => GameUtil.SetCameraParams");
                return(CheckReturnNum(L, count, nRet));
            }

            LuaFunction callback = LuaScriptMgr.GetLuaFunction(L, 6);
            CCamCtrlMan.Instance.SetNpcInfo(destDir);
            CCamCtrlMan.Instance.SetCurCamCtrl(CAM_CTRL_MODE.NPC, true, npc_obj, look_at_type, callback);
        }
        else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(GameObject), typeof(int), typeof(LuaFunction)))
        {
            CAM_CTRL_MODE mode           = (CAM_CTRL_MODE)LuaScriptMgr.GetNumber(L, 1);
            GameObject    look_at_target = LuaScriptMgr.GetUnityObject <GameObject>(L, 2);
            int           look_at_type   = (int)LuaScriptMgr.GetNumber(L, 3);

            if (look_at_target == null)
            {
                HobaDebuger.LogError("the target object you wanna look at is null. => GameUtil.SetCameraParams");
                return(CheckReturnNum(L, count, nRet));
            }

            LuaFunction callback = LuaScriptMgr.GetLuaFunction(L, 4);
            CCamCtrlMan.Instance.SetCurCamCtrl(mode, true, look_at_target, look_at_type, callback);
        }
        else if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(bool), typeof(GameObject), typeof(int), typeof(LuaFunction)))
        {
            CAM_CTRL_MODE mode = (CAM_CTRL_MODE)LuaScriptMgr.GetNumber(L, 1);
            bool          adjust_immediatelly = LuaScriptMgr.GetBoolean(L, 2);
            GameObject    target       = LuaScriptMgr.GetUnityObject <GameObject>(L, 3);
            int           look_at_type = (int)LuaScriptMgr.GetNumber(L, 4);
            LuaFunction   callback     = LuaScriptMgr.GetLuaFunction(L, 5);

            CCamCtrlMan.Instance.SetCurCamCtrl(mode, adjust_immediatelly, target, look_at_type, callback);
        }
        else
        {
            LogParamError("SetCameraParams", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #22
0
 public void Regist(GameObject template, int maxCount = 5)
 {
     _Template      = template;
     _MaxCacheCount = maxCount;
     if (template == null)
     {
         HobaDebuger.LogError("Can not Regist null to GameObjectPool");
     }
 }
예제 #23
0
    public static int RequestArcFx(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 2;

        if (LuaDLL.lua_isstring(L, 1) == false)
        {
            HobaDebuger.LogError("GetArcFx: param 1 must be string");
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }

        string name   = LuaScriptMgr.GetString(L, 1);
        var    owner  = LuaScriptMgr.GetUnityObject <GameObject>(L, 2);
        var    target = LuaScriptMgr.GetUnityObject <GameObject>(L, 3);

        if (owner == null || target == null)
        {
            HobaDebuger.LogError("GetArcFx: param 2 or 3 is null");
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }

        int priority = 0;

        if (count > 3)
        {
            priority = (int)LuaScriptMgr.GetNumber(L, 4);
        }

        int    fxId  = 0;
        CFxOne fxone = CFxCacheMan.Instance.RequestFxOne(name, priority, out fxId);

        if (fxone != null)
        {
            fxone.IsFixRot = false;
            if (fxone.ArcReactor == null)
            {
                fxone.ArcReactor = new ArcReactorInfo();
            }
            fxone.ArcReactor.Set(owner.transform, target.transform);

            LuaScriptMgr.Push(L, fxone.gameObject);
            LuaScriptMgr.Push(L, fxId);
        }
        else
        {
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, fxId);
        }

        return(CheckReturnNum(L, count, nRet));
    }
예제 #24
0
    public static int SetCameraGreyOrNot(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(bool)))
        {
            bool isSetGrey = LuaScriptMgr.GetBoolean(L, 1);
            DynamicEffectManager.Instance.EnablePlayerDeathEffect(isSetGrey);
        }
        else
        {
            HobaDebuger.LogError("SetCameraGreyOrNot's param is WRONG");
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
예제 #25
0
    public static int OpenUIWithEffect(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(int)))
        {
            int effectID = (int)LuaScriptMgr.GetNumber(L, 1);
            DynamicEffectManager.Instance.EnterUIDynamicEffect(effectID);
        }
        else
        {
            HobaDebuger.LogError("EnterUIdynamicEffect's param is WRONG");
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
예제 #26
0
    public static int EnableFpsPingDisplay(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(bool)))
        {
            var enable = LuaScriptMgr.GetBoolean(L, 1);
            CDebugUIMan.Instance.EnableDisplay(enable);
        }
        else
        {
            HobaDebuger.LogError("EnableFPSDisplay: must have 1 params");
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #27
0
    public static int UpdatePingDisplay(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(float)))
        {
            var ping = (float)LuaScriptMgr.GetNumber(L, 1);
            CDebugUIMan.Instance.UpdatePing(ping);
        }
        else
        {
            HobaDebuger.LogError("UpdatePing: must have 1 params");
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #28
0
        public static int print(IntPtr L)
        {
            if (HobaDebuger.GameLogLevel < LogLevel.Log)
            {
                return(0);
            }

            // For each argument we'll 'tostring' it
            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 print 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("print LUA: {0}", s));
            }
#endif
            HobaDebuger.LogFormat("LUA: {0}", s);

            return(0);
        }
예제 #29
0
    public static int PreloadFxAsset(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (LuaDLL.lua_isstring(L, 1) == false)
        {
            HobaDebuger.LogError("PreLoadHostFx: param 1 must be string");
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }
        string name = LuaScriptMgr.GetString(L, 1);

        CFxCacheMan.Instance.PreloadFxAsset(name);
        return(CheckReturnNum(L, count, nRet));
    }
예제 #30
0
    public static int RequestFx(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 2;

        if (LuaDLL.lua_isstring(L, 1) == false)
        {
            HobaDebuger.LogError("RequestFx: param 1 must be string");
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }
        if (LuaDLL.lua_isboolean(L, 2) == false)
        {
            HobaDebuger.LogError("RequestFx: param 2 must be boolean");
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, 0);
            return(CheckReturnNum(L, count, nRet));
        }
        string name     = LuaScriptMgr.GetString(L, 1);
        bool   fixRot   = (bool)LuaScriptMgr.GetBoolean(L, 2);
        int    priority = 50;

        if (count > 2)
        {
            priority = (int)LuaScriptMgr.GetNumber(L, 3);
        }

        int    fxId  = 0;
        CFxOne fxone = CFxCacheMan.Instance.RequestFxOne(name, priority, out fxId);

        if (fxone != null)
        {
            fxone.IsFixRot = fixRot;
            LuaScriptMgr.Push(L, fxone.gameObject);
            LuaScriptMgr.Push(L, fxId);
        }
        else
        {
            LuaDLL.lua_pushnil(L);
            LuaScriptMgr.Push(L, fxId);
        }

        return(CheckReturnNum(L, count, nRet));
    }