Inheritance: MonoBehaviour
コード例 #1
0
    public void Start()
    {
        collider = GetComponent <CircleCollider2D>();

        dragTransform = GetComponent <DragTransform>();
        dragTransform.stoppedDragAction = CheckSlot;
    }
コード例 #2
0
    // 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;
        }
    }
コード例 #3
0
 void OnTriggerExit(Collider other)
 {
     if (other.gameObject.layer == 10)
     {
         otherObject = null;
         height      = 0;
         isColliding = false;
     }
 }
コード例 #4
0
    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;
        }
    }
コード例 #5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        DragTransform dtrans = other.GetComponentInParent <DragTransform> ();

        if (dtrans != null && !dtrans.dragging)
        {
            other.gameObject.GetComponent <SpawnObject> ().RemoveTag();
            Destroy(other.gameObject);
        }
    }
コード例 #6
0
 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;
         }
     }
 }
コード例 #7
0
    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();
        }
    }