void Start()
    {
        inputController = GetComponent <InputController>();
        helicopterInfo  = GetComponent <HelicopterInfo>();

        rigidbody = GetComponent <Rigidbody>();

        audioSource = new AudioSource[2];

        audioSource[(int)SFX_List.HELICOPTER_FLIGHT]        = gameObject.AddComponent <AudioSource>();
        audioSource[(int)SFX_List.HELICOPTER_FLIGHT].clip   = sfxHelicopterFlight;
        audioSource[(int)SFX_List.HELICOPTER_FLIGHT].loop   = true;
        audioSource[(int)SFX_List.HELICOPTER_FLIGHT].pitch  = 0.0f;
        audioSource[(int)SFX_List.HELICOPTER_FLIGHT].volume = 0.25f;
        audioSource[(int)SFX_List.HELICOPTER_FLIGHT].Play();

        audioSource[(int)SFX_List.TURBULENCE]        = gameObject.AddComponent <AudioSource>();
        audioSource[(int)SFX_List.TURBULENCE].clip   = sfxHelicopterTurbulence;
        audioSource[(int)SFX_List.TURBULENCE].loop   = true;
        audioSource[(int)SFX_List.TURBULENCE].volume = 0.0f;
        audioSource[(int)SFX_List.TURBULENCE].Play();

        motionInput = gameObject.AddComponent <MotionInput>();
        motionInput.UseAutoRotation = false;
        motionInput.UpdateMode      = MotionInput.UpdateModeList.WaitForFixedUpdate;
    }
示例#2
0
    void Start()
    {
        audioSourceBGM      = gameObject.AddComponent <AudioSource>();
        audioSourceBGM.clip = sfxBGM;
        audioSourceBGM.loop = true;
        audioSourceBGM.Play();

        audioSourceSFX = gameObject.AddComponent <AudioSource>();

        helicopterInfo = trsPlayer.GetComponent <HelicopterInfo>();
        trsPlayer.GetComponent <InputController>().bControllable = false;

        motionInput = trsPlayer.GetComponent <MotionInput>();

        for (int i = 0; i < rpbPassages.Length; i++)
        {
            rpbPassages[i].SetNumber(i);
        }

        btnExit.onClick.AddListener(OnButtonExitClicked);
        btnRestart.onClick.AddListener(OnButtonRestartClicked);

        nNumPassages = rpbPassages.Length;

        sceneFadingController.FadeIn();

        StartCoroutine("StartCountdown");
    }
示例#3
0
        public void UpdateUserConfiguration(InputConfig config)
        {
            if (config is StandardControllerInputConfig controllerConfig)
            {
                bool needsMotionInputUpdate = _config == null || (_config is StandardControllerInputConfig oldControllerConfig &&
                                                                  (oldControllerConfig.Motion.EnableMotion != controllerConfig.Motion.EnableMotion) &&
                                                                  (oldControllerConfig.Motion.MotionBackend != controllerConfig.Motion.MotionBackend));

                if (needsMotionInputUpdate)
                {
                    UpdateMotionInput(controllerConfig.Motion);
                }
            }
            else
            {
                // Non-controller doesn't have motions.
                _leftMotionInput = null;
            }

            _config = config;

            if (_isValid)
            {
                _gamepad.SetConfiguration(config);
            }
        }
示例#4
0
        public void Update()
        {
            if (_isValid && GamepadDriver != null)
            {
                State = _gamepad.GetMappedStateSnapshot();

                if (_config is StandardControllerInputConfig controllerConfig && controllerConfig.Motion.EnableMotion)
                {
                    if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.GamepadDriver)
                    {
                        if (_gamepad.Features.HasFlag(GamepadFeaturesFlag.Motion))
                        {
                            Vector3 accelerometer = _gamepad.GetMotionData(MotionInputId.Accelerometer);
                            Vector3 gyroscope     = _gamepad.GetMotionData(MotionInputId.Gyroscope);

                            accelerometer = new Vector3(accelerometer.X, -accelerometer.Z, accelerometer.Y);
                            gyroscope     = new Vector3(gyroscope.X, gyroscope.Z, gyroscope.Y);

                            _leftMotionInput.Update(accelerometer, gyroscope, (ulong)PerformanceCounter.ElapsedNanoseconds / 1000, controllerConfig.Motion.Sensitivity, (float)controllerConfig.Motion.GyroDeadzone);

                            if (controllerConfig.ControllerType == ConfigControllerType.JoyconPair)
                            {
                                _rightMotionInput = _leftMotionInput;
                            }
                        }
                    }
                    else if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.CemuHook && controllerConfig.Motion is CemuHookMotionConfigController cemuControllerConfig)
                    {
                        int clientId = (int)controllerConfig.PlayerIndex;

                        // First of all ensure we are registered
                        _cemuHookClient.RegisterClient(clientId, cemuControllerConfig.DsuServerHost, cemuControllerConfig.DsuServerPort);

                        // Then request and retrieve the data
                        _cemuHookClient.RequestData(clientId, cemuControllerConfig.Slot);
                        _cemuHookClient.TryGetData(clientId, cemuControllerConfig.Slot, out _leftMotionInput);

                        if (controllerConfig.ControllerType == ConfigControllerType.JoyconPair)
                        {
                            if (!cemuControllerConfig.MirrorInput)
                            {
                                _cemuHookClient.RequestData(clientId, cemuControllerConfig.AltSlot);
                                _cemuHookClient.TryGetData(clientId, cemuControllerConfig.AltSlot, out _rightMotionInput);
                            }
                            else
                            {
                                _rightMotionInput = _leftMotionInput;
                            }
                        }
                    }
                }
            }
            else
            {
                // Reset states
                State            = default;
                _leftMotionInput = null;
            }
        }
 protected override void UpdateMotionInput(ref MotionInput mi)
 {
     if (_previousTargetPosition != Target.position)
     {
         UpdateTargetTracking();
     }
     mi.MovementDirection = NextDirection;
 }
 protected override void OnUpdate()
 {
     for (int i = 0; i < Group.Length; ++i)
     {
         MotionInput mot = Group.MotionInput[i];
         mot.Horizontal = Group.PlayerInput[i].Horizontal;
         mot.Vertical   = Group.PlayerInput[i].Vertical;
     }
 }
示例#7
0
 private void UpdateMotionInput(MotionConfigController motionConfig)
 {
     if (motionConfig.MotionBackend != MotionInputBackendType.CemuHook)
     {
         _leftMotionInput = new MotionInput();
     }
     else
     {
         _leftMotionInput = null;
     }
 }
示例#8
0
    void Start()
    {
        audioSource = transform.gameObject.AddComponent <AudioSource>();
        motionInput = transform.GetComponent <MotionInput>();

        btnExit.onClick.AddListener(delegate { sfc.FadeOutForLoad("Lobby"); });
        btnRestart.onClick.AddListener(delegate { sfc.FadeOutForLoad(SceneManager.GetActiveScene().name); });

        sfc.FadeIn();
        StartCoroutine("TutorialNarrStart");
    }
    void Start()
    {
        helicopterInfo  = trsPlayer.GetComponent <HelicopterInfo>();
        inputController = trsPlayer.GetComponent <InputController>();
        motionInput     = trsPlayer.GetComponent <MotionInput>();
        audioSource     = GetComponent <AudioSource>();

        btnExit.onClick.AddListener(OnButtonExitClicked);
        btnRestart.onClick.AddListener(OnButtonRestartClicked);

        sfc.FadeIn();

        StartCoroutine("MissionStart");
    }
示例#10
0
        public SixAxisInput GetHLEMotionState(bool isJoyconRightPair = false)
        {
            float[] orientationForHLE = new float[9];
            Vector3 gyroscope;
            Vector3 accelerometer;
            Vector3 rotation;

            MotionInput motionInput = _leftMotionInput;

            if (isJoyconRightPair)
            {
                if (_rightMotionInput == null)
                {
                    return(default);
示例#11
0
    void Start()
    {
        audioSource     = GetComponent <AudioSource>();
        motionInput     = trsPlayer.GetComponent <MotionInput>();
        inputController = trsPlayer.GetComponent <InputController>();

        inputController.bControllable = false;

        btnExit.onClick.AddListener(delegate { sfc.FadeOutForLoad("Lobby"); });
        btnRestart.onClick.AddListener(delegate { sfc.FadeOutForLoad(SceneManager.GetActiveScene().name); });

        sfc.FadeIn();

        StartCoroutine(MissionStartBrief());

        trsPlayer.GetComponentInChildren <CompetitiveAdvantageDirectionalArrowBehaviour>().trsTarget = GameObject.Find("Narr Block - Entering Mission Area").transform;
    }
示例#12
0
文件: Client.cs 项目: zh010zh/Ryujinx
        public bool TryGetData(int player, int slot, out MotionInput input)
        {
            lock (_motionData)
            {
                if (_motionData.ContainsKey(player))
                {
                    if (_motionData[player].TryGetValue(slot, out input))
                    {
                        return(true);
                    }
                }
            }

            input = null;

            return(false);
        }
        /////////////////////////////
        ////////// Service //////////

        private void UpdateAxis(ref MotionInput mi)
        {
            if (_useRawAxisInput)
            {
                mi.MovementDirection.x = Input.GetAxisRaw(_horizontalAxisName);
                if (_useVerticalAxis)
                {
                    mi.MovementDirection.z = Input.GetAxisRaw(_verticalAxisName);
                }
            }
            else
            {
                mi.MovementDirection.x = Input.GetAxis(_horizontalAxisName);
                if (_useVerticalAxis)
                {
                    mi.MovementDirection.z = Input.GetAxis(_verticalAxisName);
                }
            }
        }
 /// <summary>
 /// Callback to update the motion input value in order to control the character system
 /// </summary>
 protected abstract void UpdateMotionInput(ref MotionInput mi);
 protected override void UpdateMotionInput(ref MotionInput mi)
 {
     UpdateAxis(ref mi);
     UpdateKeyCode(ref mi);
 }
 private void UpdateKeyCode(ref MotionInput mi)
 {
     mi.Crouch = Input.GetKey(_crouchKeyCode);
     mi.Run    = Input.GetKey(_runKeyCode);
 }
 private void Awake()
 {
     gameObjectEntity = GetComponent <GameObjectEntity>();
     motionInput      = GetComponent <MotionInput>();
 }
示例#18
0
#pragma warning disable CS1998
        public unsafe async Task HandleResponse(byte[] data, int clientId)
#pragma warning restore CS1998
        {
            MessageType type = (MessageType)BitConverter.ToUInt32(data.AsSpan().Slice(16, 4));

            data = data.AsSpan().Slice(16).ToArray();

            using (MemoryStream mem = new MemoryStream(data))
            {
                using (BinaryReader reader = new BinaryReader(mem))
                {
                    switch (type)
                    {
                    case MessageType.Protocol:
                        break;

                    case MessageType.Info:
                        ControllerInfoResponse contollerInfo = reader.ReadStruct <ControllerInfoResponse>();
                        break;

                    case MessageType.Data:
                        ControllerDataResponse inputData = reader.ReadStruct <ControllerDataResponse>();
                        var motionData = new MotionInput()
                        {
                            Accelerometer = new Vector3()
                            {
                                X = inputData.AccelerometerX,
                                Y = -inputData.AccelerometerZ,
                                Z = inputData.AccelerometerY
                            },
                            Gyroscrope = new Vector3()
                            {
                                X = inputData.GyroscopePitch,
                                Y = inputData.GyroscopeRoll,
                                Z = inputData.GyroscopeYaw * -1
                            }
                        };

                        lock (_motionData)
                        {
                            int slot = inputData.Shared.Slot;

                            if (_motionData.ContainsKey(clientId))
                            {
                                if (_motionData[clientId].ContainsKey(slot))
                                {
                                    _motionData[clientId][slot] = motionData;
                                }
                                else
                                {
                                    _motionData[clientId].Add(slot, motionData);
                                }
                            }
                            else
                            {
                                _motionData.Add(clientId, new Dictionary <int, MotionInput>()
                                {
                                    { slot, motionData }
                                });
                            }
                        }
                        break;
                    }
                }
            }
        }