Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            hit      = Physics2D.Raycast(touchPos, Vector2.zero, 10, 1 << 9);

            if (hit.collider != null && objectHit == null)
            {
                objectHit        = hit.transform.parent;
                oldPostObjectHit = objectHit.position;
                objectHit.transform.localScale = Vector3.one;
            }
            if (objectHit != null)
            {
                objectHit.transform.position = new Vector3(touchPos.x, touchPos.y + 5f, objectHit.transform.position.z);
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (objectHit != null)
            {
                objectHit.transform.localScale = Vector3.one * 0.8f;
                objectHit.position             = oldPostObjectHit;
                InsertShapeMatrix newInsert = objectHit.GetComponentInChildren <BitController>().InsertValueToMatrix100();
                Debug.Log(objectHit.GetComponentInChildren <BitController>().name);
                if (newInsert != null)
                {
                    MatrixManager.Instance().InsertShapeMatrix(newInsert);
                }
                objectHit = null;
            }
        }
    }
Пример #2
0
    public void InsertShapeMatrix(InsertShapeMatrix insert)
    {
        Vector2Int        firstBitShape  = insert.FirstBitShape;
        Vector2Int        firstBitIn1010 = insert.FirstBitIn1010;
        List <Vector2Int> ValueableList  = insert.ValueableList;

        ValueMatrix1010[firstBitIn1010.x, firstBitIn1010.y] = 1;
        for (int i = 1; i < ValueableList.Count; i++)
        {
            diffFromFirstBit.x  = ValueableList[i].x - ValueableList[0].x;
            diffFromFirstBit.y  = ValueableList[i].y - ValueableList[0].y;
            diffFromFirstBit.x += firstBitIn1010.x;
            diffFromFirstBit.y += firstBitIn1010.y;
            ValueMatrix1010[diffFromFirstBit.x, diffFromFirstBit.y] = 1;
            diffFromFirstBit.x = 0;
            diffFromFirstBit.y = 0;
        }

        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                matrix += ValueMatrix1010[i, j];
            }
            matrix += "\n";
        }
        Debug.Log(matrix);
        matrix = "";
    }