Example #1
0
    IEnumerator Iconset()
    {
        for (int i = 0; i < bds.Count; i++)
        {
            ChunkFromVector3(SpawnPosition).EditVoxel(SpawnPosition, (byte)i);

            if ((bool)blockdata[i].GetDataTag("Item", "bx"))
            {
                snap.snapCam = snapCam2;
            }
            else
            {
                snap.snapCam = snapCam1;
            }

            snap.snap();
            yield return(new WaitForSeconds(0.1f));
        }
    }
Example #2
0
    private void Update()
    {
        if (dragScript.playermanagerScript.stanInPlay == false)
        {
            if (dragging)
            {
                Vector3 currentPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);

                Vector3 worldPosition = UnityEngine.Camera.main.ScreenToWorldPoint(currentPosition);

                //Snap to int grid
                // worldPosition = new Vector3((int)worldPosition.x, (int)worldPosition.y);

                //Clamp our position
                //releative to our x position from our fan
                float relativeX = fan.transform.position.x - worldPosition.x;
                relativeX = Mathf.Abs(relativeX);

                worldPosition.y = Mathf.Clamp(worldPosition.y, fan.transform.position.y + relativeX, 100000);
                worldPosition.z = 0;

                transform.position = Snap.snap(worldPosition, .5f);

                if (Input.GetMouseButtonUp(0))
                {
                    dragging = false;
                    //reset our position to x dist from fan
                    Vector3 offset = transform.position - fan.transform.position;
                    offset             = offset.normalized * snapDist;
                    transform.position = fan.transform.position + offset;
                    Vector3 pos = transform.position;
                    pos.z = 0;
                    transform.position = pos;
                }
                Drag.globalDragging = dragging;
            }
        }
    }
Example #3
0
    private void Update()
    {
        if (privateDragging)
        {
            Vector3 currentPosition = new Vector3(Input.mousePosition.x - posX, Input.mousePosition.y - posY, 0);

            Vector3 worldPosition = UnityEngine.Camera.main.ScreenToWorldPoint(currentPosition);

            //Vector3 floatSnap = new Vector3(5f, 5f , 0);

            //Snap to int grid
            // worldPosition = new Vector3(Mathf.Round(worldPosition.x)/100f * 100, Mathf.Round(worldPosition.y)/100f*100);
            // worldPosition = new Vector3(Mathf.Round(worldPosition.x / floatSnap.x),Mathf.Round(worldPosition.y / floatSnap.y));

            //int intSnap;

            //floatSnap = Mathf.Round(intSnap)/2;

            transform.position = Snap.snap(worldPosition, .5f);

            if (Input.GetMouseButtonUp(0))
            {
                privateDragging = false;

                if (RubbishBin.instance.hovering == true)
                {
                    //do stuff
                    itemScript = GetComponent <ItemCost>();

                    itemScript.Refund();

                    Destroy(gameObject);
                }
            }
            globalDragging = privateDragging;
        }
    }