コード例 #1
0
    /// <summary>
    /// 摇杆操作
    /// </summary>
    /// <param name="move"></param>
    void OnJoystickMove(MovingJoystick move)
    {
        if (_avatarObj == null)
        {
            return;
        }
        if (move.joystickName != "New joystick")
        {
            return;
        }

        _positionX = move.joystickAxis.x;      //   获取摇杆偏移摇杆中心的x坐标
        _positionY = move.joystickAxis.y;      //    获取摇杆偏移摇杆中心的y坐标
        if (_bBeforeDragging)
        {
            _bBeforeDragging = false;
            //   _avatarObj.ChangeAvatarForward(ComMoveControllerObj.GetFPTransform().forward);
            _fpChangeAvatarForward = ComMoveControllerObj.GetFPTransform().forward;
            _fpDragFlag            = true;
            Debug.Log("_bBeforeDragging_bBeforeDragging_bBeforeDragging::" + _fpChangeAvatarForward.ToVector());
        }

        FrameSyncInput.SetFP((byte)E_InputId.E_MOVE_X, _positionX);
        FrameSyncInput.SetFP((byte)E_InputId.E_MOVE_Y, _positionY);
    }
コード例 #2
0
    public void DidStep(FrameSyncEngine engine, FrameSyncGame game)
    {
        if (_watchStarted && game.gameState == FrameSyncGameState.Running)
        {
            _watchStarted = false;
            float ms = _watch.Stop();
            SWConsole.Verbose($"Debugger DidStep {game.frameNumber} ms={ms}");
            //_watcStarted might be in wrong state
            if (game.frameNumber == 0)
            {
                return;
            }

            _debugFrame.frameNumber           = game.frameNumber;
            _debugFrame.elapsedMS             = ms;
            _debugFrame.playerFrameOnServer   = engine.PlayerFrameCountOnServer;
            _debugFrame.localServerFrameCount = engine.LocalServerFrameCount;
            _debugFrame.inputSampleInterval   = FrameSyncTime.internalInputSampleInterval * 1000;
            _debugFrame.localStepInterval     = FrameSyncTime.internalFixedDeltaTime * 1000;

            SWSystemDataFrame systemDataFrame = engine.GetSystemDataFrame(game.frameNumber);
            _debugFrame.hash = systemDataFrame.bytes.Crc32();
            SWConsole.Verbose($"Debugger DidStep frame hash={_debugFrame.hash}");

            InputFrame           inputFrame  = engine.GetInputFrame(game.frameNumber);
            FrameSyncInput       input       = _agent.frameSyncInput;
            FrameSyncInputConfig inputConfig = input.inputConfig;

            _debugFrame.inputs.Clear();

            foreach (FrameSyncPlayer player in input._Players())
            {
                _debugFrame.inputs[player.PlayerID.ToString()] = player.ExportDictionary(inputConfig, inputFrame.bytes);
            }

            _debugFrame.staticBehaviours.Clear();
            List <StaticFrameSyncBehaviour> staticFrameSyncBehaviours = new List <StaticFrameSyncBehaviour>(StaticFrameSyncBehaviourManager._behaviours.Values);

            foreach (StaticFrameSyncBehaviour behaviour in staticFrameSyncBehaviours)
            {
                _debugFrame.staticBehaviours[behaviour.FrameSyncBehaviourID.ToString()] = behaviour.ExportDictionary();
            }

            string json = JSONWriter.ToJson(_debugFrame);
            SWConsole.Verbose(json);

            if (game.type == FrameSyncGameType.Offline)
            {
                SendData(json, 1);
            }
            else
            {
                SendData(json, game.localPlayer.PlayerID);
            }
        }
    }
コード例 #3
0
    public override void OnSyncedInput()
    {
        bool     MouseLeft     = Input.GetMouseButtonDown(0);
        bool     MouseRight    = Input.GetMouseButtonDown(1);
        FPVector MousePosition = Input.mousePosition.ToFPVector();

        FrameSyncInput.SetBool((byte)OPER_CMD.MOUSE_LEFT, MouseLeft);
        FrameSyncInput.SetBool((byte)OPER_CMD.MOUSE_RIGHT, MouseRight);
        FrameSyncInput.SetFPVector((byte)OPER_CMD.MOUSE_POSITION, MousePosition);
    }
コード例 #4
0
    void OnStepUpdate(List <InputDataBase> allInputData)
    {
        FrameSyncInput.SetAllInputs(allInputData);

        FrameSyncInput.CurrentSimulationData = null;


        for (int index = 0; index < mapManagedBehaviors.Count; index++)
        {
            FrameSyncManagedBehaviour bh = mapManagedBehaviors[index].Value;

            if (bh != null && !bh.disabled)
            {
                bh.OnSyncedUpdate();
            }
        }

        for (int index = 0, length = allInputData.Count; index < length; index++)
        {
            InputDataBase playerInputData = allInputData[index];

            if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
            {
                FrameSyncInput.CurrentSimulationData = (InputData)playerInputData;

                List <FrameSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                {
                    FrameSyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                    if (bh != null && !bh.disabled)
                    {
                        bh.OnSyncedUpdate();
                    }
                }
            }

            FrameSyncInput.CurrentSimulationData = null;
        }
    }
コード例 #5
0
    public override void OnSyncedUpdate()
    {
        bool     MouseLeft     = FrameSyncInput.GetBool((byte)OPER_CMD.MOUSE_LEFT);
        bool     MouseRight    = FrameSyncInput.GetBool((byte)OPER_CMD.MOUSE_RIGHT);
        FPVector MousePosition = FrameSyncInput.GetFPVector((byte)OPER_CMD.MOUSE_POSITION);

        if ((MouseLeft || MouseRight) && !GameUtils.IsCursorOverUI())//如果鼠标不是点击在UI上面
        {
            var        ray = Camera.main.ScreenPointToRay(MousePosition.ToVector());
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (MouseLeft)
                {
                    GameEntity targetEntity = hit.transform.GetComponent <GameEntity>();
                    if (targetEntity)
                    {
                        SetIndicatorViaParent(hit.transform);               //地图上标记目的地

                        if (CanCastSkill(SKILL_NMAE.SKILL_1, targetEntity)) //平A
                        {
                            CastSkill(SKILL_NMAE.SKILL_1, targetEntity);
                        }
                    }
                }
                else if (MouseRight)
                {
                    GameEntity targetEntity = hit.transform.GetComponent <GameEntity>();
                    if (targetEntity)
                    {
                        SetIndicatorViaParent(hit.transform);//地图上标记目的地
                    }
                }
                else
                {
                }
            }
        }
    }
コード例 #6
0
    public override void OnSyncedUpdate()
    {
        DealSycncedEndInfo();

        FPVector changeForwardVec3 = FrameSyncInput.GetFPVector((byte)E_InputId.E_DRAGGING_CAMERA);
        bool     IdelFlag          = FrameSyncInput.GetBool((byte)E_InputId.E_IDEL);
        FP       move_x            = FrameSyncInput.GetFP((byte)E_InputId.E_MOVE_X);
        FP       move_y            = FrameSyncInput.GetFP((byte)E_InputId.E_MOVE_Y);


        bool mouseDraggingFlag = FrameSyncInput.GetBool((byte)E_InputId.E_MOUSE_DRAGGING);
        bool mouseDragEndFlag  = FrameSyncInput.GetBool((byte)E_InputId.E_MOUSE_DRAGEND);

        if (mouseDraggingFlag || mouseDragEndFlag)
        {
            bool leftDirection  = FrameSyncInput.GetBool((byte)E_InputId.E_MOUSE_DRAG_LEFT);
            bool rightDirection = FrameSyncInput.GetBool((byte)E_InputId.E_MOUSE_DRAG_RIGHT);
            ComMoveFollowObj.SetMouseDragDirection(leftDirection, rightDirection);
            if (mouseDraggingFlag)
            {
                ComMoveFollowObj.SetMouseDragFlag(true);
            }
            else
            {
                ComMoveFollowObj.SetMouseDragFlag(false);
            }
        }

        if (changeForwardVec3 != FPVector.zero)
        {
            Debug.Log("changeForwardVec3:::::::::::" + changeForwardVec3.ToVector() + ",,,E_InputId.E_IDEL::" + IdelFlag);
            Debug.Log("FP_FP_FP_::move_x_xxxxxxxx::" + move_x.AsFloat() + ",move_y::" + move_y.AsFloat());
        }

        //移动处理
        if (IdelFlag)
        {
            Idle();
            ComMoveFollowObj.SetJoyStickMoveFlag(false);
            //Debug.Log("idelidelidelidelidelidelidelidelidelidelidelidelidelidelidel");
        }
        else
        {
            if (move_x != 0 || move_y != 0)
            {
                if (changeForwardVec3 != FPVector.zero)
                {
                    Debug.Log("changeForwardVec3::" + changeForwardVec3.ToVector() + "camera::" + ComMoveFollowObj.transform.forward + ",touch:::" + ComMoveFollowObj._bTouchMouse);
                    ChangeAvatarForward(changeForwardVec3);
                    // Debug.Log("changeForwardVec3:::::::::::" + changeForwardVec3.ToVector()  +"camera::"+ ComMoveFollowObj.transform.forward);
                }
                SycnMove(move_x, move_y);
            }
        }


        //射击处理
        bool shootDownFlag = FrameSyncInput.GetBool((byte)E_InputId.E_SHOOT_DOWN);

        if (shootDownFlag)
        {
            Shoot(changeForwardVec3);
        }
        bool shootUpFlag = FrameSyncInput.GetBool((byte)E_InputId.E_SHOOT_UP);

        if (shootUpFlag)
        {
            Shoot(FPVector.zero, false);
        }

        //跳跃处理
        bool jumpFlag = FrameSyncInput.GetBool((byte)E_InputId.E_JUMP);

        if (jumpFlag)
        {
            Jump();
        }

        //模型改变处理
        int modelRender = FrameSyncInput.GetInt((byte)E_InputId.E_CHANGE_MODEL);

        if (modelRender > 0)
        {
            if (modelRender == (int)KeyCode.P)      //人形
            {
                ChangeAvatarForm(Avatar.E_AvatarForm.PERSON_STATE);
            }
            else if (modelRender == (int)KeyCode.F)  //乌贼
            {
                ChangeAvatarForm(Avatar.E_AvatarForm.INKFISH_STATE);
            }
            else if (modelRender == (int)KeyCode.D)  //下潜模式
            {
                ChangeAvatarForm(Avatar.E_AvatarForm.INKFISHDIVE_STATE);
            }
        }

        //更换装备
        int replaceWeaponFlag = FrameSyncInput.GetInt((byte)E_InputId.E_REPLACE_WEAPON);

        if (replaceWeaponFlag > 0)
        {
            ChangeWeapon(replaceWeaponFlag);
        }

        //扔手雷
        bool throwGrenadeFlag = FrameSyncInput.GetBool((byte)E_InputId.E_THROW_GRENADE);

        if (throwGrenadeFlag)
        {
            ThrowGrenade();
        }
    }
コード例 #7
0
    public override void OnSyncedInput()
    {
        if (_dragging)//拖拽中
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAGGING, _dragging);
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAG_LEFT, _directorToLeft);
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAG_RIGHT, _directorToRight);
        }
        if (_fpDragEndFlag) //拖拽结束
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAGEND, _fpDragEndFlag);
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAG_LEFT, false);
            FrameSyncInput.SetBool((byte)E_InputId.E_MOUSE_DRAG_RIGHT, false);
        }

        //如果之前有摄像头拖拽,传递数值
        if (_fpDragFlag)
        {
            FrameSyncInput.SetFPVector((byte)E_InputId.E_DRAGGING_CAMERA, _fpChangeAvatarForward);
            //   Debug.Log("Input_Input_Input:::DraggingDraggingDraggingDragging + " + _fpChangeAvatarForward.ToVector() + ", datax::" + _positionX + " , _datay::" + _positionY);
        }

        //移动
        if (_positionX != 0 || _positionY != 0)
        {
            FrameSyncInput.SetFP((byte)E_InputId.E_MOVE_X, _positionX);
            FrameSyncInput.SetFP((byte)E_InputId.E_MOVE_Y, _positionY);
            // Debug.Log("FP_FP_FP_::move_yyyyyyyyyy::" + _positionX.AsFloat() + ",move_y::" + _positionY.AsFloat());
        }
        //暂停
        if (_fpIdleFlag)
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_IDEL, _fpIdleFlag);
            // Debug.Log("Input_Input_Input:::IdelIdelIdelIdelIdelIdelIdelIdel");
        }

        //射击
        if (_fpShootDownFlag)
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_SHOOT_DOWN, _fpShootDownFlag);
        }
        if (_fpShootUpFlag)
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_SHOOT_UP, _fpShootUpFlag);
        }

        //跳跃
        if (_fpJumpFlag)
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_JUMP, _fpJumpFlag);
            //  Debug.Log("Input_Input_Input:::JUMPJUMPJUMPJUMPJUMPJUMPJUMP");
        }


        //改变模型格局
        if (_fpModelChangeState > 0)
        {
            FrameSyncInput.SetInt((byte)E_InputId.E_CHANGE_MODEL, _fpModelChangeState);
        }

        //更换装备
        if (_fpReplaceWeapon)
        {
            FrameSyncInput.SetInt((byte)E_InputId.E_REPLACE_WEAPON, GameManager.Instance.CurWeapon);
        }

        //扔手雷
        if (_fpThrowGrenadeFlag)
        {
            FrameSyncInput.SetBool((byte)E_InputId.E_THROW_GRENADE, _fpThrowGrenadeFlag);
        }



        //FrameSyncInput.SetFPVector((byte)E_InputId.E_SHOOT_FORWARD, _fpBeforeShootForward);
        //FrameSyncInput.SetFPVector((byte)E_InputId.E_CHANGE_AVATAR_FORWARD, _fpChangeAvatarForward);


        //重置数值
        _fpIdleFlag         = false;
        _fpModelChangeState = 0;
        _fpJumpFlag         = false;
        _fpReplaceWeapon    = false;
        _fpThrowGrenadeFlag = false;
        _fpShootUpFlag      = false;
        _fpDragFlag         = false;
        _fpDragEndFlag      = false;
    }