public void Start() { collider = GetComponent <CircleCollider2D>(); dragTransform = GetComponent <DragTransform>(); dragTransform.stoppedDragAction = CheckSlot; }
// Update is called once per frame void Update() { if (currentObject != null) { Cursor.visible = false; if (Input.GetKeyDown(KeyCode.Delete)) { Cursor.visible = true; Destroy(currentObject); } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); dragObject = currentObject.gameObject.GetComponent <DragTransform>(); Plane groundPlane = new Plane(Vector3.up, Vector3.up * dragObject.getHeight()); float rayDistance; if (groundPlane.Raycast(ray, out rayDistance)) { Vector3 point = ray.GetPoint(rayDistance); Debug.DrawLine(ray.origin, point, Color.red); position = point; } currentObject.transform.position = new Vector3(position.x, dragObject.getHeight(), position.z); } else { Cursor.visible = true; } }
void OnTriggerExit(Collider other) { if (other.gameObject.layer == 10) { otherObject = null; height = 0; isColliding = false; } }
void OnTriggerEnter2D(Collider2D other) { DragTransform dtrans = other.GetComponentInParent <DragTransform>(); if (dtrans != null && !dtrans.dragging) { other.gameObject.transform.position = dtrans.positionStart; other.gameObject.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static; } }
void OnTriggerEnter2D(Collider2D other) { DragTransform dtrans = other.GetComponentInParent <DragTransform> (); if (dtrans != null && !dtrans.dragging) { other.gameObject.GetComponent <SpawnObject> ().RemoveTag(); Destroy(other.gameObject); } }
void OnTriggerStay(Collider other) { if (other.gameObject.layer == 10) { if (other.bounds.size.y + other.GetComponent <Transform>().position.y > height) { otherObject = other.gameObject.GetComponent <DragTransform>(); height = (other.bounds.size.y); isColliding = true; } } }
void OnTriggerEnter2D(Collider2D other) { DragTransform dtrans = other.GetComponentInParent <DragTransform>(); if (dtrans != null && !dtrans.dragging) { // other.GetComponent<ResourceAttributes>().GetSpawnController().GetComponent<SpawnResource>().SubtractResources(1); ui.GetComponent <BuildRezeptAnzeige>().receiveGift(other.gameObject.tag); count += other.gameObject.GetComponent <ResourceAttributes>().ScoreValue; other.gameObject.GetComponent <SpawnObject>().RemoveTag(); Destroy(other.gameObject); AudioManager.instance.Play("Plop"); SetCountText(); } }