Пример #1
0
    public bool possibleRotateZAxis(int direction)
    {
        bool currentBool     = true;
        var  anchorTransform = actualObjects.First.Value.transform;

        var newSet = new LinkedList <Vector3>();

        newSet.AddLast(anchorTransform.position);


        var tempObject   = FieldScript.getStupidSphere();
        var newTransform = tempObject.transform;

        foreach (var element in actualObjects)
        {
            tempObject.transform.position = element.transform.position;
            if (newTransform.position != anchorTransform.position)
            {
                newTransform.RotateAround(anchorTransform.position, Vector3.forward, direction * -90f);
                newSet.AddLast(newTransform.position);
            }
        }
        //setting current position to false
        foreach (var element in actualObjects)
        {
            FieldScript.boolField[(int)element.transform.position.x, (int)element.transform.position.y, (int)element.transform.position.z] = false;
        }
        //checking if overlaps
        foreach (var element in newSet)
        {
            if ((element.x < 0 || element.x >= FieldScript.sizeDim) || (element.y <= 0 || element.y >= FieldScript.sizeDim + FieldScript.yOffset) || (element.z < 0 || element.z >= FieldScript.sizeDim))
            {
                currentBool = false;
            }
            else if (FieldScript.boolField[(int)element.x, (int)element.y, (int)element.z])
            {
                currentBool = false;
            }
        }
        //setting back to normal
        foreach (var element in actualObjects)
        {
            FieldScript.boolField[(int)element.transform.position.x, (int)element.transform.position.y, (int)element.transform.position.z] = true;
        }
        //Debug.Log("finshed checker" + currentBool);
        FieldScript.destroyStupidSphere(tempObject);
        return(currentBool);
    }