Ejemplo n.º 1
0
    void Update()
    {
        if (vi.GetButtonDown(Button.ACTION))
        {
            if (possessing != null)
            {
                ActivatePossessing();
            }
            else
            {
                Possess();
            }
        }
        if (vi.GetButtonDown(Button.JUMP))
        {
            if (possessing != null)
            {
                Unpossess();
            }
        }

        if (possessing)
        {
            return;
        }

        ////////////////////////////////////////////////////////
        // Move the player

        float h = vi.GetAxisRaw(Axis.HORIZONTAL) * speed;
        float v = vi.GetAxisRaw(Axis.VERTICAL) * speed;

        Vector2 move = new Vector2(h, v) * Time.deltaTime;

        bool flipSprite = (spriteRenderer.flipX ? (move.x > 0.01f) : (move.x < -0.01f));

        if (flipSprite)
        {
            spriteRenderer.flipX = !spriteRenderer.flipX;
        }

        if ((rb.position.x + move.x) > boundX || (rb.position.x + move.x) < -boundX)
        {
            move.x = 0;
        }
        if ((rb.position.y + move.y) > boundY || (rb.position.y + move.y) < -boundY)
        {
            move.y = 0;
        }

        rb.position += move;
    }
Ejemplo n.º 2
0
    // Update is used to set features regardless the active behaviour.
    void Update()
    {
        // Activate/deactivate aim by input.
        if (VirtualInput.GetAxisRaw(aimButton) != 0 && !aim)
        {
            StartCoroutine(ToggleAimOn());
        }
        else if (aim && VirtualInput.GetAxisRaw(aimButton) == 0)
        {
            StartCoroutine(ToggleAimOff());
        }

        // No sprinting while aiming.
        canSprint = !aim;

        // Toggle camera aim position left or right.
        if (aim && VirtualInput.GetButtonDown(shoulderButton))
        {
            aimCamOffset.x   = aimCamOffset.x * (-1);
            aimPivotOffset.x = aimPivotOffset.x * (-1);
        }

        // Set aim boolean on the Animator Controller.
        behaviourManager.GetAnim.SetBool(aimBool, aim);
    }
Ejemplo n.º 3
0
 private void OnTriggerStay(Collider other)
 {
     if (message2 != "" && other.gameObject == player && VirtualInput.GetButtonDown(changeMessageButton))
     {
         manager.SetMessage(message2);
     }
 }
Ejemplo n.º 4
0
    protected override void ComputeVelocity()
    {
        applyPhysics = !wallLatched;

        if (wallLatchCooldownTimer > 0 && !wallLatched)
        {
            wallLatchCooldownTimer -= Time.deltaTime;
        }

        // Play latch sound if just latched
        if (wallLatched)
        {
            if (!wasWallLatched)
            {
                audioSource.PlayOneShot(latchSound);
            }
        }
        else if (wallLatchCooldownTimer > 0)
        {
            wallLatchCooldownTimer -= Time.deltaTime;
        }
        wasWallLatched = wallLatched;


        // Compute Velocity
        Vector2 move = Vector2.zero;

        move.x = vi.GetAxisRaw(Axis.HORIZONTAL) * speed;

        if (vi.GetButtonDown(Button.JUMP) && (grounded || wallLatched))
        {
            velocity.y = jumpVelocity;

            wallLatchCooldownTimer = wallLatchCooldown;
            wallLatched            = false;
            animator.SetBool("wallLatched", wallLatched);

            // Play jump sound
            audioSource.PlayOneShot(jumpSound);
        }
        else if (vi.GetButtonUp(Button.JUMP) && canCancelJump)
        {
            if (velocity.y > 0)
            {
                velocity.y = velocity.y * jumpCancelVelocityModifier;
            }
        }

        bool flipSprite = (spriteRenderer.flipX ? (move.x > 0.01f) : (move.x < -0.01f));

        if (flipSprite && !wallLatched)
        {
            spriteRenderer.flipX = !spriteRenderer.flipX;
        }

        animator.SetBool("grounded", grounded);
        animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / speed);

        targetVelocity = move;
    }
Ejemplo n.º 5
0
        protected virtual void Update()
        {
            if (currentPage != null)
            {
                foreach (string key in currentPage.cancelButtons)
                {
                    if (VirtualInput.GetButtonDown(key))
                    {
                        currentPage.Finish();
                        break;
                    }
                }
            }

            if (currentPage == null && Pages.Count > 0)
            {
                currentPage = Pages[Pages.Count - 1] as Page;
                currentPage.OnPageFocus();
            }
            else if (currentPage != null && Pages.Count > 0 && Pages[Pages.Count - 1] != currentPage)
            {
                currentPage.OnPageBlur();
                currentPage = Pages[Pages.Count - 1] as Page;
                currentPage.OnPageFocus();
            }
            if (currentPage != null)
            {
                currentPage.OnPageUpdate();
            }
        }
Ejemplo n.º 6
0
 // Update is used to set features regardless the active behaviour.
 void Update()
 {
     // Get jump input.
     if (!jump && VirtualInput.GetButtonDown(jumpButton) && behaviourManager.IsCurrentBehaviour(this.behaviourCode) && !behaviourManager.IsOverriding())
     {
         jump = true;
     }
 }
Ejemplo n.º 7
0
 protected virtual void Update()
 {
     if (VirtualInput.GetButtonDown(pickUpButton) && container != null)
     {
         Ray ray = Camera.main.ScreenPointToRay(VirtualInput.GetMousePosition());
         RaycastHit hit;
         if(Physics.Raycast(ray,out hit))
         {
             Item item = hit.transform.GetComponent<Item>();
             if (item != null)
             {
                 item.Pick(container);
             }
         }
     }
 }
Ejemplo n.º 8
0
    private void EEgg()
    {
        if (VirtualInput.GetButtonDown("Fly"))
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");
            if (player.GetComponent <BasicBehaviourMobile>().IsGrounded())
            {
                pressCount = 0;
            }
            else
            {
                pressCount++;
            }

            if (pressCount >= 7 && !player.GetComponent <BasicBehaviourMobile>().IsGrounded())
            {
                player.transform.Find("skeleton/Hips/Spine/Spine1/Spine2/Neck/Head/Head_end/mark").gameObject.SetActive(true);
            }
        }
    }
Ejemplo n.º 9
0
        public static bool GetValue(ButtonType state, string buttonKey)
        {
            if (buttonKey == null || buttonKey.Trim().Length == 0)
            {
                return(false);
            }
            switch (state)
            {
            case ButtonType.Normal:
                return(VirtualInput.GetButton(buttonKey));

            case ButtonType.Down:
                return(VirtualInput.GetButtonDown(buttonKey));

            case ButtonType.Up:
                return(VirtualInput.GetButtonUp(buttonKey));

            default:
                return(false);
            }
        }
Ejemplo n.º 10
0
    // Update is used to set features regardless the active behaviour.
    void Update()
    {
        // Toggle fly by input, only if there is no overriding state or temporary transitions.
        if (VirtualInput.GetButtonDown(flyButton) && !behaviourManager.IsOverriding() &&
            !behaviourManager.GetTempLockStatus(behaviourManager.GetDefaultBehaviour))
        {
            fly = !fly;

            // Force end jump transition.
            behaviourManager.UnlockTempBehaviour(behaviourManager.GetDefaultBehaviour);

            // Obey gravity. It's the law!
            behaviourManager.GetRigidBody.useGravity = !fly;

            // Player is flying.
            if (fly)
            {
                // Register this behaviour.
                behaviourManager.RegisterBehaviour(this.behaviourCode);
            }
            else
            {
                // Set collider direction to vertical.
                col.direction = 1;
                // Set camera default offset.
                behaviourManager.GetCamScript.ResetTargetOffsets();

                // Unregister this behaviour and set current behaviour to the default one.
                behaviourManager.UnregisterBehaviour(this.behaviourCode);
            }
        }

        // Assert this is the active behaviour
        fly = fly && behaviourManager.IsCurrentBehaviour(this.behaviourCode);

        // Set fly related variables on the Animator Controller.
        behaviourManager.GetAnim.SetBool(flyBool, fly);
    }