Exemplo n.º 1
0
 public void CreateDialogue()
 {
     dialogueText.text = dialogueLines[dialogueIndex];
     nameText.text     = npcName;
     dialoguePanel.SetActive(true);
     thisCamera.DisableMouse();
     thisCamera.UnlockCursor();
     pController.DisableMove();
 }
    void Update()
    {
        if (moveEnable)
        {
            //CONTROLLING THE CHARACTER
            //input
            Vector2 input          = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            Vector2 inputDirection = input.normalized;

            bool running = Input.GetKey(KeyCode.LeftShift);

            Move(inputDirection, running);

            if (Input.GetKeyDown(KeyCode.Space))
            {
                Jump();
            }

            //animation
            float animationSpeedPercent = ((running) ? currentSpeed / runSpeed : currentSpeed / walkSpeed * .5f);
            animator.SetFloat("SpeedPercent", animationSpeedPercent, speedSmoothTime, Time.deltaTime);

            //FOR HEALTH
            if (Input.GetKeyDown(KeyCode.Q))
            {
                health.CurrentValue -= 10;
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                health.CurrentValue += 10;
            }

            //OPENING UP INVENTORY
            if (Input.GetKeyDown(KeyCode.I))
            {
                InventoryPanel.SetActive(true);
                thisCamera.DisableMouse();
                thisCamera.UnlockCursor();
                DisableMove();
            }
        }
    }