コード例 #1
0
 public void PickUp()
 {
     if (Input.GetButton(playerData.actionButon))
     {
         pickUpTimer += Time.deltaTime;
         playerUI.loadingCircleImage.fillAmount += Time.deltaTime / grabber.objectToPickUp.timeToPickUp;
         playerUI.EnableLoadingCircle(true);
         if (pickUpTimer >= grabber.objectToPickUp.timeToPickUp)
         {
             pickUpTimer = 0;
             state       = PlayerStates.HOLDING_ITEM;
             animator.runtimeAnimatorController = controllerWithBox;
             pickUpedObjectWeight = grabber.objectToPickUp.weight;
             pickUpedObject       = grabber.objectToPickUp;
             playerUI.loadingCircleImage.fillAmount = 0;
             playerUI.EnableLoadingCircle(false);
             grabber.PickUpObject();
         }
     }
     else if (Input.GetButtonUp(playerData.actionButon))
     {
         state = PlayerStates.NOT_HOLDING_ITEM;
         playerUI.loadingCircleImage.fillAmount = 0;
         playerUI.EnableLoadingCircle(false);
         pickUpTimer = 0;
     }
 }
コード例 #2
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("PickUpableObject"))
        {
            if (objectToPickUp == null)
            {
                objectToPickUp = collision.gameObject.GetComponent <PickUpableObject>();
            }

            if (!objectToPickUp.BeingPickedUp)
            {
                canPickUp = true;
                objectToPickUp.BeingPickedUp = true;
                player.playerUI.EnableInfoPanel(true, objectToPickUp);
            }
        }

        if (collision.gameObject.CompareTag("Truck"))
        {
            if (collision.gameObject == player.truckToCharge.gameObject)
            {
                canDrop = true;
            }
        }
    }
コード例 #3
0
 public void PickUpObject()
 {
     if (objectToPickUp != null)
     {
         Destroy(objectToPickUp.gameObject);
     }
     objectToPickUp = null;
 }
コード例 #4
0
    void OnTriggerStay(Collider col)
    {
        tempPickUpObject = col.GetComponent <PickUpableObject>();

        if (tempPickUpObject)
        {
            tempPickUpObject.TargetObject(l_TargetTowers);
            tempPickUpObject.UpdateCurrentTarget();
        }
    }
コード例 #5
0
 public void EnableInfoPanel(bool enable, PickUpableObject obj)
 {
     objectInfo.SetActive(enable);
     if (enable)
     {
         objectName.text     = "Object: " + obj.nameToDisplay + "  ";
         happinessValue.text = "Happiness: " + obj.score.ToString() + "  ";
         weight.text         = "Weigh: " + obj.weight.ToString() + "  ";
         timeToPickUp.text   = "Time to pick up: " + obj.timeToPickUp.ToString() + "  ";
     }
 }
コード例 #6
0
    void PickUpObject()
    {
        Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);

        RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);

        if (hit.collider != null)
        {
            //Debug.Log("Object: " + hit.collider.name);

            currentObj = hit.collider.GetComponent <PickUpableObject>();
            currentObj.BeingPickedUp = true;
        }
    }
コード例 #7
0
    public void Drop()
    {
        if (grabber.canDrop)
        {
            if (Input.GetButtonDown(playerData.actionButon))
            {
                truckToCharge.AddObjeetToTruck(pickUpedObject);

                score += pickUpedObject.score;
                state  = PlayerStates.NOT_HOLDING_ITEM;
                animator.runtimeAnimatorController = controllerWithOutBox;

                pickUpedObject = null;
            }
        }
    }
コード例 #8
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Object"))
        {
            Debug.Log("CAN pick up");
            CanPickUpObj = true;

            objToPickUp = collision.gameObject.GetComponent <PickUpableObject>();

            //objToPickUp.SetObjectForPlayerUI(objToPickUp);

            playerUI.SetCurrentObj(collision.gameObject.GetComponent <PickUpableObject>());

            DisplayObjectInfo();
        }
    }
コード例 #9
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Object"))
        {
            Debug.Log("CANT pick up");
            CanPickUpObj = false;

            HideObjectInfo();
            objToPickUp = null;
        }

        if (collision.gameObject.CompareTag("Truck"))
        {
            Debug.Log("CANT drop on truck");
            CanDropOnTruck = false;
        }
    }
コード例 #10
0
ファイル: Player.cs プロジェクト: LeanRodriguez98/GGJ-2019
    private void DropItem()
    {
        if (pickUpTrigger.CanDropOnTruck)
        {
            if (Input.GetButtonDown("Action"))
            {
                Debug.Log("Item dropped on truck");

                GameManager.GetInstance().PlayEffectSound(leaveBox);

                // push item into truck
                truck.AddItem(objectToPickUp);
                objectToPickUp = null;

                state = PlayerState.NOT_HOLDING_ITEM;
                animator.runtimeAnimatorController = controller;
            }
        }
    }
コード例 #11
0
ファイル: Player.cs プロジェクト: LeanRodriguez98/GGJ-2019
    void Start()
    {
        truck = FindObjectOfType <PickUpTruck>();

        grabberPos.transform.localPosition = new Vector2(0, grabberOffsetY * -1);

        animator = GetComponent <Animator>();
        animator.runtimeAnimatorController = controller;

        objectToPickUp = null;

        pickUpTrigger = GetComponentInChildren <PlayerPickUpTrigger>();
        movement      = transform.position;

        canPickUp = pickUpTrigger.CanPickUpObj;
        rb        = GetComponent <Rigidbody2D>();

        // Set default state
        state = PlayerState.NOT_HOLDING_ITEM;
    }
コード例 #12
0
ファイル: Player.cs プロジェクト: LeanRodriguez98/GGJ-2019
    private void PickUp()
    {
        canPickUp = pickUpTrigger.CanPickUpObj;

        if (Input.GetButton("Action") && pickUpTrigger.CanPickUpObj)
        {
            Debug.Log("Pick up button");

            // ------ New pick up mechanic------ //
            objectToPickUp = pickUpTrigger.objToPickUp;

            if (!objectToPickUp.BeingPickedUp)
            {
                playerUI.EnableLoadingCircle();

                //objectToPickUp.BeingPickedUp = true;

                // disable item
                if (objectToPickUp.GetPickedUp())
                {
                    GameManager.GetInstance().PlayEffectSound(pickUpBox);
                    playerUI.ResetTimer();
                    objectToPickUp.gameObject.SetActive(false);
                    canPickUp = false;
                    state     = PlayerState.HOLDING_ITEM;
                    pickUpTrigger.HideObjectInfo();
                    Debug.Log("Culo2");
                    animator.runtimeAnimatorController = controllerBox;
                }
            }
        }
        else if (Input.GetButtonUp("Action"))
        {
            if (objectToPickUp != null)
            {
                state = PlayerState.NOT_HOLDING_ITEM;
                objectToPickUp.BeingPickedUp = false;
                playerUI.ResetTimer();
            }
        }
    }
コード例 #13
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("PickUpableObject"))
        {
            if (objectToPickUp != null)
            {
                objectToPickUp.BeingPickedUp = false;
                objectToPickUp = null;
                player.playerUI.EnableInfoPanel(false, null);
            }
            canPickUp = false;
        }

        if (collision.gameObject.CompareTag("Truck"))
        {
            if (collision.gameObject == player.truckToCharge.gameObject)
            {
                canDrop = false;
            }
        }
    }
コード例 #14
0
 public void AddObjeetToTruck(PickUpableObject obj)
 {
     objectsList.Add(obj);
 }
コード例 #15
0
 public void AddItem(PickUpableObject obj)
 {
     pickedUpObjects.Add(obj);
     score         += obj.happiness;
     scoreText.text = "Happiness: " + score.ToString("0");
 }
コード例 #16
0
ファイル: PlayerUI.cs プロジェクト: LeanRodriguez98/GGJ-2019
 public void SetCurrentObj(PickUpableObject obj)
 {
     currentObj = obj;
 }