Beispiel #1
0
 void IncreaseStamina()
 {
     if (!PlayerStates.Singleton.IsSprinting && !GameInputManager.GetKey("Sprint") && !GameInputManager.GetKey("Jump") && !PlayerStates.Singleton.IsDead)
     {
         PlayerStates.Singleton.Stamina += PlayerStates.Singleton.StaminaStep;
     }
 }
Beispiel #2
0
 void CheckTools()
 {
     if (GameInputManager.GetKey("SoftRepairTool"))
     {
         List <Collider2D> targets = attackBox.Collisions();
         foreach (Collider2D coll in targets)
         {
             if (coll.GetComponent <Interactable>() != null)
             {
                 coll.GetComponent <Interactable>().OnSoftRepair();
             }
         }
     }
     if (GameInputManager.GetKey("HardRepairTool"))
     {
         List <Collider2D> targets = attackBox.Collisions();
         foreach (Collider2D coll in targets)
         {
             if (coll.GetComponent <Interactable>() != null)
             {
                 coll.GetComponent <Interactable>().OnHardRepair();
             }
         }
     }
 }
 public void InputKey()
 {
     SoundManager.Instance.Click();
     changingBinding  = true;
     description.text = "Choose a key to bind the action : " + actionKey;
     keyBind.text     = GameInputManager.GetKey(actionKey).ToString();
     panelBinding.SetActive(true);
     saveKeyBind.onClick.AddListener(delegate { ChangeMappingKey(actionKey); panelBinding.SetActive(false); });
 }
Beispiel #4
0
    public void SendMovementValues()
    {
        directionMove = Vector3.zero;

        if (GameInputManager.GetKey("Right"))
        {
            directionMove += Vector3.right;
        }

        if (GameInputManager.GetKey("Left"))
        {
            directionMove -= Vector3.right;
        }

        if (GameInputManager.GetKey("Forward"))
        {
            directionMove += Vector3.forward;
        }

        if (GameInputManager.GetKey("Backward"))
        {
            directionMove -= Vector3.forward;
        }

        if (GameInputManager.GetKey("Shift"))
        {
            if (!isRunning && runningTimer < halfRunningDuration)
            {
                isRunning    = false;
                runningTimer = Mathf.Clamp(runningTimer + Time.fixedDeltaTime * 0.5f, 0f, runningDuration);
            }
            else if (runningTimer <= 0f)
            {
                isRunning = false;
            }
            else
            {
                isRunning    = true;
                runningTimer = Mathf.Clamp(runningTimer - Time.fixedDeltaTime, 0f, runningDuration);
            }
        }
        else
        {
            isRunning    = false;
            runningTimer = Mathf.Clamp(runningTimer + Time.fixedDeltaTime * 0.5f, 0f, runningDuration);
        }

        if (Input.mouseScrollDelta.y != 0f)
        {
            InventoryUI.instance.SelectOrb((int)Math.Abs(Input.mouseScrollDelta.y));
        }

        directionMove = directionMove.normalized;
        playerMove.SetDirection(directionMove * (isRunning? multiplyRunningValue : 1f));
    }
Beispiel #5
0
 void Update()
 {
     if (GameInputManager.GetKey("MoveForward"))
     {
         print("Touche Enfoncée");
     }
     else
     {
         print("Touche Pas Enfoncée");
     }
 }
    void FixedUpdate()
    {
        if (GameInputManager.GetKey("Cancel") && currentSceneIndex == gameSceneIndex)
        {
            LoadMainMenuScene();
        }

        if (PlayerStates.Singleton.IsDead && !isLoadMainMenuSceneInvoked)
        {
            Invoke("LoadMainMenuScene", 10 * Time.timeScale);
            isLoadMainMenuSceneInvoked = true;
        }
    }
        protected override void VerticalMovement()
        {
            if (GameInputManager.GetKey(DefaultGameInput.JUMP_KEY_CODE))
            {
                JumpInputHandle();
            }
            else
            {
                m_JumpHold = false;
            }

            GravityAttract();
        }
Beispiel #8
0
    // Update is called once per frame
    void SpaceshipMovement()
    {
        if (isInSpaceshipControlMode == true)
        {
            //DEPLACEMENTS
            if (GameInputManager.GetKey("MoveForward"))
            {
                spaceshipController.AddForce(transform.forward * speed * Time.deltaTime);
                print("MoveForward");
            }

            if (GameInputManager.GetKey("MoveBackward"))
            {
                spaceshipController.AddForce(-transform.forward * speed * Time.deltaTime);
            }

            if (GameInputManager.GetKey("MoveRight"))
            {
                spaceshipController.AddForce(transform.right * speed * Time.deltaTime);
            }

            if (GameInputManager.GetKey("MoveLeft"))
            {
                spaceshipController.AddForce(-transform.right * speed * Time.deltaTime);
            }

            if (GameInputManager.GetKey("MoveUp"))
            {
                spaceshipController.AddForce(transform.up * speed * Time.deltaTime);
            }

            if (GameInputManager.GetKey("MoveDown"))
            {
                spaceshipController.AddForce(-transform.up * speed * Time.deltaTime);
            }

            //ROTATIONS
            if (GameInputManager.GetKey("YawL"))
            {
            }
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        if (PlayerStates.Singleton.IsDead)
        {
            die.Execute(animator);
            return;
        }

        // Pause Game
        if (GameInputManager.GetKeyUp("Pause"))
        {
            PlayerStates.Singleton.TooglePause();
        }

        if (PlayerStates.Singleton.IsPaused)
        {
            return;
        }

        PlayerStates.Singleton.Position = transform.position;

        PlayerStates.Singleton.IsWalking  = GameInputManager.GetKey("Walk");
        PlayerStates.Singleton.IsGrounded = characterController.isGrounded;

        if (PlayerStates.Singleton.IsGrounded)
        {
            // Move
            float verticalAxis = 0f;
            if (GameInputManager.GetKey("Forward"))
            {
                verticalAxis = 1f;
            }
            else if (GameInputManager.GetKey("Backward"))
            {
                verticalAxis = -1f;
            }

            if (GameInputManager.GetKey("Sprint") && PlayerStates.Singleton.Stamina > 0f)
            {
                PlayerStates.Singleton.IsSprinting = true;
            }
            else
            {
                PlayerStates.Singleton.IsSprinting = false;
            }

            moveDirection = new Vector3(0, 0, verticalAxis);
            moveDirection = transform.TransformDirection(moveDirection);

            if (verticalAxis > 0 && PlayerStates.Singleton.IsWalking)
            {
                moveDirection *= PlayerStates.Singleton.WalkingSpeed;
                walk.Execute(animator);
            }
            else if (verticalAxis < 0)
            {
                PlayerStates.Singleton.IsWalkingBackward = true;
                moveDirection *= PlayerStates.Singleton.WalkingBackSpeed;
                walkBack.Execute(animator);
            }
            else if (verticalAxis > 0)
            {
                PlayerStates.Singleton.IsRunning         = true;
                PlayerStates.Singleton.IsWalkingBackward = false;
                moveDirection *= PlayerStates.Singleton.RunningSpeed + (PlayerStates.Singleton.IsSprinting ? PlayerStates.Singleton.SprintSpeedBoost : 0);
                run.Execute(animator);
            }
            else
            {
                PlayerStates.Singleton.IsWalkingBackward = false;
                PlayerStates.Singleton.IsRunning         = false;
                idle.Execute(animator);
            }

            // Jumps
            if (GameInputManager.GetKey("Jump") &&
                !PlayerStates.Singleton.IsJumping &&
                PlayerStates.Singleton.IsWalking &&
                PlayerStates.Singleton.Stamina >= PlayerStates.Singleton.StaminaNeededForJump &&
                !PlayerStates.Singleton.IsWalkingBackward)
            {
                PlayerStates.Singleton.IsJumping = true;
                Invoke("SetIsJumpingToFalse", 2.8f * Time.timeScale);
                PlayerStates.Singleton.Stamina -= PlayerStates.Singleton.StaminaNeededForJump;
                moveDirection.y = PlayerStates.Singleton.JumpHeight;
                moveDirection.z = PlayerStates.Singleton.JumpDistance;
                moveDirection   = transform.TransformDirection(moveDirection);
                jump.Execute(animator);
            }
            else if (GameInputManager.GetKey("Jump") && PlayerStates.Singleton.IsWalkingBackward)
            {
                moveDirection.y = PlayerStates.Singleton.BackJumpSpeed;
                moveDirection.z = -PlayerStates.Singleton.BackJumpDistance;
                moveDirection   = transform.TransformDirection(moveDirection);
                jumpBack.Execute(animator);
            }
        }

        // Gravity
        moveDirection.y -= PlayerStates.Singleton.Gravity * Time.deltaTime;
        characterController.Move(moveDirection * Time.deltaTime);


        // Rotation
        float horizontalAxis = 0;

        if (GameInputManager.GetKey("Left"))
        {
            horizontalAxis = -1f;
        }
        else if (GameInputManager.GetKey("Right"))
        {
            horizontalAxis = 1f;
        }

        transform.Rotate(0, horizontalAxis * PlayerStates.Singleton.RotationSpeed, 0);
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.FromToRotation(transform.up, GetHitNormal()) * transform.rotation, 5 * Time.deltaTime);
    }
Beispiel #10
0
    // Update is called once per frame
    void Update()
    {
        iFramesLeft--;
        if (explosionMomentum != Vector2.zero)
        {
            rb.velocity        = explosionMomentum;
            cam.targetPosition = transform.position + camOffset;

            explosionMomentum = Vector2.MoveTowards(explosionMomentum, Vector2.zero, deceleration);
            return;
        }
        if (GameInputManager.isConfiguringControls || isUsingPreview)
        {
            return;
        }

        if (GameInputManager.GetKey("Block"))
        {
            blocking = true;
            return;
        }
        else
        {
            blocking = false;
        }
        cam.targetPosition = transform.position + camOffset;
        movementUp         = 0;
        movementDown       = 0;
        movementRight      = 0;
        movementLeft       = 0;
        if (GameInputManager.GetKey("Up"))
        {
            movementUp = speed;
        }
        if (GameInputManager.GetKey("Down"))
        {
            movementDown = speed;
        }
        if (GameInputManager.GetKey("Left"))
        {
            movementLeft = speed;
        }
        if (GameInputManager.GetKey("Right"))
        {
            movementRight = speed;
        }
        rb.velocity = new Vector3(movementRight - movementLeft, movementUp - movementDown, 0);
        if (movementRight - movementLeft != 0 || movementUp - movementDown != 0)
        {
            playerFacing = new Vector2(movementRight - movementLeft, movementUp - movementDown);
            animator.SetBool("Moving", true);
            animator.SetInteger("Direction", GetFacingDirection());
        }
        else
        {
            animator.SetBool("Moving", false);
        }
        switch (GetFacingDirection())
        {
        case 0:
            attackBox.Move(new Vector3(0, 0.8f, 0) + transform.position + new Vector3(0, -0.5f, 0));
            attackBox.transform.eulerAngles = new Vector3(0, 0, 0);
            break;

        case 1:
            attackBox.Move(new Vector3(0.8f, 0, 0) + transform.position + new Vector3(0, -0.5f, 0));
            attackBox.transform.eulerAngles = new Vector3(0, 0, 90);
            break;

        case 2:
            attackBox.Move(new Vector3(0, -0.8f, 0) + transform.position + new Vector3(0, -0.5f, 0));
            attackBox.transform.eulerAngles = new Vector3(0, 0, 180);
            break;

        case 3:
            attackBox.Move(new Vector3(-0.8f, 0, 0) + transform.position + new Vector3(0, -0.5f, 0));
            attackBox.transform.eulerAngles = new Vector3(0, 0, 270);
            break;
        }
        CheckAttack();
        CheckBow();
        CheckBomb();
        CheckTools();
        bombCooldown--;
        bowCounter--;
        attackCooldown--;
        attackCounter--;
    }