예제 #1
0
        private void Player_CurrentStateChanged(MediaPlayer sender, object args)
        {
            PlayerStateChanged?.Invoke(this,
                                       new PlayerStateChangedEventArgs((PlayerState)(int)sender.PlaybackSession.PlaybackState));

            switch (sender.PlaybackSession.PlaybackState)
            {
            case MediaPlaybackState.None:
                _controls.PlaybackStatus = MediaPlaybackStatus.Closed;
                break;

            case MediaPlaybackState.Opening:
                _controls.PlaybackStatus = MediaPlaybackStatus.Changing;
                break;

            case MediaPlaybackState.Buffering:
                _controls.PlaybackStatus = MediaPlaybackStatus.Changing;
                break;

            case MediaPlaybackState.Playing:
                _controls.PlaybackStatus = MediaPlaybackStatus.Playing;
                break;

            case MediaPlaybackState.Paused:
                _controls.PlaybackStatus = MediaPlaybackStatus.Paused;
                break;
            }
        }
예제 #2
0
        internal void UpdateState(int indexSpell, PlayerState newState)
        {
            state         = newState;
            spellToAttack = indexSpell;

            PlayerStateChanged?.Invoke(this, new InfoEventArgs <NewStatePlayerDto>(new NewStatePlayerDto(spellToAttack, state)));
        }
예제 #3
0
 private void VlcMediaPlayer_OnPaused(object sender, VlcMediaPlayerPausedEventArgs e)
 {
     PlayerState = PlayerState.Paused;
     PlayerStateChanged?.Invoke(this, new PlayerStateChangedEventArgs
     {
         PlayerState = PlayerState
     });
 }
예제 #4
0
        private void WsReceived(ResponseMessage msg)
        {
            var srvMsg = JsonConvert.DeserializeObject <ServerMessage <JRaw> >(msg.Text);

            if (srvMsg.OpCode == OP_CLIENT_WELCOME)
            {
                var cw = JsonConvert.DeserializeObject <ClientWelcome>(srvMsg.Result.ToString());
                HandleClientWelcome(cw);
                PlayerStateChanged?.Invoke(this, cw);
            }

            ServerMessageReceived(srvMsg);
        }
    }       // set up les vector par rapport a ceux de la cam, utile pour le deplacement

    private void Update()
    {
        if (Input.GetButtonDown("Y"))
        {
            RaycastHit hitStele;
            Physics.Raycast(transform.position, Vector3.down, out hitStele, 10);
            Debug.DrawRay(transform.position, Vector3.down, Color.red, 10);
            if (hitStele.transform.TryGetComponent(out Stele stele))
            {
                onStele  = true;
                canInput = false;
                stele.Interact();
            }
        }
        if (onStele && Input.GetButtonDown("B"))
        {
            if (_canQuit)
            {
                PlayerStateChanged?.Invoke(CameraLockState.Idle);
                canInput = true;
            }
        }

        if (Input.GetButtonDown("Dash"))
        {
            /*_isDashing = true;
             * _arrowAngle = (Mathf.Atan2(Input.GetAxis("Horizontal"), (Input.GetAxis("Vertical")) * Mathf.Rad2Deg)*//* - 90f*//*);
             * transform.rotation = Quaternion.Euler(0, difAngle, 0);
             * StartCoroutine(Dash());*/

            //_arrowAngle = (Mathf.Atan2(Input.GetAxis("Vertical"), (Input.GetAxis("Horizontal")) * Mathf.Rad2Deg)/* - 90f*/);
            //transform.rotation = Quaternion.Euler(0, _arrowAngle, 0);


            Vector2 stickInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
            dashDirection = (cameraRight * stickInput.x) + (cameraForward * stickInput.y);
            difAngle      = SignedAngle(transform.forward, dashDirection, Vector3.up);
            transform.Rotate(new Vector3(0f, difAngle, 0f));

            _isDashing = true;
            StartCoroutine(Dash());
        }
    }
예제 #6
0
 protected virtual void OnPlayerStateChanged(object sender, PlayerStateEventArgs ea)
 {
     PlayerStateChanged?.Invoke(sender, ea);
 }
예제 #7
0
 /// <summary>
 /// Event triggered when our player changes state
 /// </summary>
 /// <param name="status"> new status of our player</param>
 /// <param name="videoId"> our videoId which is being used</param>
 private void PlayerStateTrigger(Player_VideoStatus status, string videoId)
 {
     PlayerStateChanged?.Invoke(null, new PlayerStateChangedArgs {
         PlayerVideoStatus = status, VideoId = videoId
     });
 }
예제 #8
0
 public void OnPlayerStateChanged(bool p0, int p1)
 {
     PlayerStateChanged?.Invoke(p0, (PlaybackState)p1);
 }
예제 #9
0
 private void Player_CurrentStateChanged(MediaPlayer sender, object args)
 {
     PlayerStateChanged?.Invoke(this,
                                new PlayerStateChangedEventArgs((PlayerState)(int)sender.CurrentState));
 }
예제 #10
0
 protected void RaisePlayerStateChanged()
 {
     PlayerStateChanged?.Invoke(this, EventArgs.Empty);
 }
 private void OnPlayerStateChanged(object sender, PlayerStateChangedEventArgs e)
 {
     PlayerStateChanged?.Invoke(this, new SubscriptionsEventArgs <ILibrary, PlayerStateChangedEventArgs>(sender, e));
 }
예제 #12
0
 /// <summary>
 /// Event triggered when our player changes state
 /// </summary>
 /// <param name="status"> new status of our player</param>
 /// <param name="videoId"> our videoId which is being used</param>
 private void PlayerStateTrigger(MediaPlaybackState status, string videoId)
 {
     PlayerStateChanged?.Invoke(null, new PlayerStateChangedArgs {
         playbackState = status, videoId = videoId
     });
 }
    void FixedUpdate()
    {
        if (canInput)
        {
            if (!_isDashing)
            {
                if (moveDirection.y < 0)
                {
                    controller.Move(Vector3.up * Physics.gravity.y * (fallMultiplier - 1) * Time.deltaTime);
                    moveSpeed = speedStore * 0.5f;
                }
                else if (moveDirection.y > 0 && !Input.GetButton("Jump"))
                {
                    controller.Move(Vector3.up * Physics.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime);
                }

                Vector2 stickInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
                if (stickInput.magnitude < deadZone)                                                                                    //     SI LE JOUEUR NE TOUCHE PAS AU JOYSTICK
                {
                    stickInput = Vector2.zero;                                                                                          //      INPUT = ZERO
                }
                else                                                                                                                    //
                {                                                                                                                       //
                    difAngle = SignedAngle(transform.forward, new Vector3(moveDirection.x, 0f, moveDirection.z), Vector3.up);           //
                    if (difAngle > 4)                                                                                                   //
                    {                                                                                                                   //      SINON
                        transform.Rotate(new Vector3(0f, Mathf.Min(7f, difAngle), 0f));                                                 //      ROTATE LE PLAYER POUR
                    }                                                                                                                   //      L'ALIGNER AVEC LA CAMERA
                    else if (difAngle < -4)                                                                                             //
                    {                                                                                                                   //
                        transform.Rotate(new Vector3(0f, Mathf.Max(-7f, difAngle), 0f));                                                //
                    }
                }

                Vector2 stickInputR = new Vector2(Input.GetAxis("HorizontalCamera"), Input.GetAxis("VerticalCamera"));
                if (stickInputR.magnitude < deadZone)
                {
                    stickInputR = Vector2.zero;
                }

                GetCamSettings();                 // RECUPERE LES VECTEUR DE LA CAMERA

                if (controller.isGrounded)        // si le player est au sol
                {
                    //Duplayeralakamera
                    moveDirection   = (cameraRight * stickInput.x) + (cameraForward * stickInput.y);                                //                      DIRECTION DU PLAYER EN FONCTION DE LA CAMERA
                    moveDirection   = moveDirection.normalized * (moveSpeed * ((180 - Mathf.Abs(difAngle)) / 180));                 //     SPEED  * (180 - X) / 180    //  calcule la speed en fonction de l'orientation par rapport au deplacement
                    moveDirection.y = 0;                                                                                            //     reset y vector a 0 pour eviter de plaquer le player au sol

                    moveInputR = (cameraRight * stickInputR.x) + (cameraForward * stickInputR.y);                                   //     stick droit pour deplacer le player en meme temps que el monde si il est grounded
                    moveInputR = moveInputR.normalized * 5f;

                    if (Input.GetButtonDown("Jump"))
                    {
                        moveDirection.y = jumpForce;
                        jumpCount      += 1;
                        firstJump       = true;
                    }
                    else
                    {
                        jumpCount = 0;
                        firstJump = false;
                    }

                    moveSpeed = speedStore;
                    PlayerStateChanged?.Invoke(CameraLockState.Idle);
                }

                else
                {
                    float yStore = moveDirection.y;
                    moveDirection   = (cameraRight * stickInput.x) + (cameraForward * stickInput.y);
                    moveDirection   = moveDirection.normalized * (moveSpeed * ((180 - Mathf.Abs(difAngle)) / 180));                           // SPEED  * (180 - X) / 180
                    moveDirection.y = yStore;


                    if (Input.GetButtonDown("Jump") && jumpCount >= 1)
                    {
                        moveDirection.y = 0;
                        gravityScale    = 4f;
                        moveSpeed       = speedStore;
                        jumpCount      += 1;
                        firstJump       = false;
                        PlayerStateChanged?.Invoke(CameraLockState.Flight);
                    }
                    else if (Input.GetButton("Jump") && jumpForce >= 1 && moveDirection.y < 0 && !firstJump)
                    {
                        moveDirection.y = 0;
                        gravityScale    = 4f;
                        moveSpeed       = speedStore;

                        PlayerStateChanged?.Invoke(CameraLockState.Flight);
                    }
                    else
                    {
                        gravityScale = 5;
                    }
                }
                moveDirection.y += (Physics.gravity.y * gravityScale * Time.deltaTime);
                controller.Move(moveDirection * Time.deltaTime);
            }
            else
            {
                moveSpeed = speedStore * 2;
                controller.Move(dashDirection * moveSpeed * Time.deltaTime);
            }
        }
    }
예제 #14
0
 internal static void OnPlayerStateChanged(PlayerStateType currentState, PlayerStateType previousState)
 {
     PlayerStateChanged?.Invoke(currentState, previousState);
 }