예제 #1
0
    void UpdateToHandleInput()
    {
        CAM_CTRL_MODE mode = CCamCtrlMan.Instance.GetCurCamCtrlMode();

        if (mode == CAM_CTRL_MODE.LOGIN)
        {
            UpdateToHandleInput_LoginMode();
        }
        else if (mode == CAM_CTRL_MODE.GAME)
        {
            UpdateToHandleInput_Game();
        }
        else if (mode == CAM_CTRL_MODE.EXTERIOR || mode == CAM_CTRL_MODE.NEAR)
        {
            // 停止移动
            if (IsJoystickDraging())
            {
                Joystick.Instance.OnSimulateDrag(0, 0);
            }
            UpdateToHandleInput_Game();
        }
        else if (mode == CAM_CTRL_MODE.BOSS)
        {
            // 停止移动
            if (IsJoystickDraging())
            {
                Joystick.Instance.OnSimulateDrag(0, 0);
            }
        }
    }
예제 #2
0
    private static int SetCameraParamsEX(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count > 1 && LuaScriptMgr.CheckType(L, typeof(int), 1))
        {
            CAM_CTRL_MODE mode = (CAM_CTRL_MODE)LuaScriptMgr.GetNumber(L, 1);
            switch (mode)
            {
            case CAM_CTRL_MODE.DUNGEON:
                if (count == 4 && LuaScriptMgr.CheckTypes(L, 2, typeof(Vector3), typeof(Vector3), typeof(float)))
                {
                    Vector3 dest_pos = LuaScriptMgr.GetVector3(L, 2);
                    Vector3 dest_rot = LuaScriptMgr.GetVector3(L, 3);
                    float   fov      = (float)LuaScriptMgr.GetNumber(L, 4);
                    CCamCtrlMan.Instance.SetDungeonCamParam(dest_pos, dest_rot, fov);
                }
                else
                {
                    LogParamError("SetCameraParamsEX DUNGEON should be with params of : pos, rot, fov. ", count);
                }
                break;
            }
        }
        return(CheckReturnNum(L, count, nRet));
    }
예제 #3
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));
    }
예제 #4
0
    private void DealWithOneFinger(TouchState touch_state)
    {
        //HobaDebuger.LogWarningFormat("DealWithOneFinger fingerId: {0}", touch_state._ThisTouch.fingerId);
        _CurrentTouchPosition = touch_state._ThisTouch.position;

        if (touch_state._ThisTouch.phase == TouchPhase.Began)                    //点击或者触摸
        {
            _IsPointerBeginOnUI = IsPointerOverUIObject(touch_state._ThisTouch); // IsPointerOverUIObject(touch_state._ThisTouch);
            _OneFingerId        = touch_state._ThisTouch.fingerId;
            _IsAllowUIDrag      = IsThisUIAllowedDrag(touch_state._ThisTouch.fingerId);
        }
        else if (touch_state._ThisTouch.phase == TouchPhase.Moved)//点击 -> 按住
        {
            if ((_IsPointerBeginOnUI && !_IsAllowUIDrag) || _OneFingerId != touch_state._ThisTouch.fingerId)
            {
                //Common.HobaDebuger.LogWarningFormat("_IsPointerBeginOnUI {0}, {1}", touch_state._ThisTouch.position.x, touch_state._ThisTouch.position.y);
                return;
                // if (EventSystem.current.IsPointerOverGameObject(touch_state._ThisTouch.fingerId)) return;
            }

            float distx = touch_state._ThisTouch.position.x - touch_state._LastTouch.position.x;
            float disty = touch_state._ThisTouch.position.y - touch_state._LastTouch.position.y;

            // #if UNITY_STANDALONE_WIN
            //             float mag = (touch_state._ThisTouch.position - touch_state._LastTouch.position).sqrMagnitude;
            //             if (mag < 2.0f)
            //                 return;
            // #endif

            if (Mathf.Abs(distx) > 0.5f)
            {
                CCamCtrlMan.Instance.DragScreenStart();
                CCamCtrlMan.Instance.ManualAdjustCamera(CCamCtrlMan.ADJUST_STYLE.YAW, distx / 5);
            }

            if (Mathf.Abs(disty) > 0.6f)
            {
                CCamCtrlMan.Instance.DragScreenStart();
                CCamCtrlMan.Instance.ManualAdjustCamera(CCamCtrlMan.ADJUST_STYLE.PITCH, -disty / 6);
            }
        }
        else if (touch_state._ThisTouch.phase == TouchPhase.Ended)//抬起 -> 检测是否属于点击操作
        {
            CCamCtrlMan.Instance.DragScreenEnd();

            //Click Ground
            bool is_pointerOverUI = IsPointerOverUIObject(touch_state._ThisTouch);
            if (is_pointerOverUI || touch_state._HasMoved || _OneFingerId != touch_state._ThisTouch.fingerId)
            {
                return;
            }

            CAM_CTRL_MODE mode = CCamCtrlMan.Instance.GetCurCamCtrlMode();
            HandleClick(touch_state._ThisTouch.position, mode != CAM_CTRL_MODE.EXTERIOR && mode != CAM_CTRL_MODE.NEAR);
        }
    }
예제 #5
0
    public void SetCurCamCtrl(CAM_CTRL_MODE ctrlType, bool isReset, GameObject target = null, int type = 1, LuaFunction callback = null)
    {
        //if (_CurCamType == ctrlType) return;

        if (_CurCamCtrl != null)
        {
            _CurCamCtrl.OnDisable();
        }

        switch (ctrlType)
        {
        case CAM_CTRL_MODE.INVALID:
            _CurCamCtrl = null;
            break;

        case CAM_CTRL_MODE.LOGIN:
            _CurCamCtrl = _LoginCamCtrl;
            break;

        case CAM_CTRL_MODE.GAME:
            _CurCamCtrl = _GameCamCtrl;
            _GameCamCtrl.ResetCameraMode();
            break;

        case CAM_CTRL_MODE.CG:
            _CurCamCtrl = _CGCamCtrl;
            break;

        case CAM_CTRL_MODE.NPC:
            _CurCamCtrl = _NpcCamCtrl;
            _NpcCamCtrl.Reset();
            _NpcCamCtrl.SetCameraLocation(target, type, callback);
            break;

        case CAM_CTRL_MODE.DUNGEON:
            _CurCamCtrl = _DungeonCamCtrl;
            _DungeonCamCtrl.Reset();
            _DungeonCamCtrl.SetCameraLocation(target, type, callback);
            break;

        case CAM_CTRL_MODE.EXTERIOR:
            _CurCamCtrl = _UIExteriorCamCtrl;
            _UIExteriorCamCtrl.Reset();
            _UIExteriorCamCtrl.SetCameraLocation(type, callback);
            break;

        case CAM_CTRL_MODE.NEAR:
            _CurCamCtrl = _NearCamCtrl;
            _NearCamCtrl.Reset();
            _NearCamCtrl.SetCameraLocation(type, callback);
            break;

        case CAM_CTRL_MODE.BOSS:
            _CurCamCtrl = _BossCamCtrl;
            _BossCamCtrl.Reset();
            _BossCamCtrl.Start(target);
            break;

        case CAM_CTRL_MODE.SKILLACT:
            _CurCamCtrl = _SkillActCamCtrl;
            _SkillActCamCtrl.Reset();
            _SkillActCamCtrl.Start(target);
            break;

        case CAM_CTRL_MODE.SCENEDIALOG:
            _CurCamCtrl = _NpcDlgCamCtrl;
            _NpcDlgCamCtrl.Reset();
            _NpcDlgCamCtrl.Start();
            break;

        default:
            return;
        }

        _CurCamType = ctrlType;
        if (_CurCamCtrl != null && isReset)
        {
            _CurCamCtrl.Reset();
        }
    }