Beispiel #1
0
    void Update()
    {
        bool tempPickUp = false;

        if (pickedUp)
        {
            CheckForSpecialActionButtonPress();
        }

        //If the item is not already picked up and the pickup prompt is enabled, the check for the button press for item pickup
        if (!pickedUp && promptPickUp)
        {
            tempPickUp = PickUp();
        }

        //If the item is picked up, check for the drop
        if (pickedUp)
        {
            //Debug.Log("pickup");
            previousPickUpPosition = new Vector3(playerMechanics.gameObject.transform.position.x,
                                                 playerMechanics.gameObject.transform.position.y + playerMechanics.GetComponent <Collider2D>().bounds.size.y,
                                                 playerMechanics.gameObject.transform.position.z);
            OrientAndAbsorbItem(Quaternion.Euler(targetRotation), targetScale, localtargetPosition);

            SetAnimation();
            ModifyForces();
            if (!tempPickUp)
            {
                Drop();
            }
        }
        else
        {
            //Debug.Log("Not picked up");
            OrientAndAbsorbItem(defaultOrientation, defaultScale, previousPickUpPosition - localtargetPosition);
        }


        if (pickedUp)
        {
            //Give the center position value to the shader
            spriteRenderer.sharedMaterial.SetVector("_Center", new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, 0));
            spriteRenderer.sharedMaterial.SetFloat("_MaxDistance", maxMaskValue);
            spriteRenderer.sharedMaterial.SetFloat("_MinDistance", minMaskValue);
        }
    }
Beispiel #2
0
    void ModifyForces()
    {
        switch (item)
        {
        case Item.parachute:
            //If the parachute is equipped, then cut off the movement accordingly
            if (playerMechanics.GetComponent <MovementScript2D>().CurrentJumpSpeed < 0)
            {
                if (itemAnimator != null)
                {
                    if (itemAnimator.GetBool("Open"))
                    {
                        playerMechanics.GetComponent <MovementScript2D>().externalVerticalMovementDamp   = 0.1f;
                        playerMechanics.GetComponent <MovementScript2D>().externalHorizontalMovementDamp = 0.7f;
                    }
                }
            }
            break;

        default:
            break;
        }
    }