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; } }
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; } } }
public void PickUpObject() { if (objectToPickUp != null) { Destroy(objectToPickUp.gameObject); } objectToPickUp = null; }
void OnTriggerStay(Collider col) { tempPickUpObject = col.GetComponent <PickUpableObject>(); if (tempPickUpObject) { tempPickUpObject.TargetObject(l_TargetTowers); tempPickUpObject.UpdateCurrentTarget(); } }
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() + " "; } }
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; } }
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; } } }
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(); } }
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; } }
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; } } }
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; }
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(); } } }
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; } } }
public void AddObjeetToTruck(PickUpableObject obj) { objectsList.Add(obj); }
public void AddItem(PickUpableObject obj) { pickedUpObjects.Add(obj); score += obj.happiness; scoreText.text = "Happiness: " + score.ToString("0"); }
public void SetCurrentObj(PickUpableObject obj) { currentObj = obj; }