Exemple #1
0
    void checkNeighbors()
    {
        SC.DestroyDebug();
        foreach (GameObject obj in otherShapeObjects)
        {
            if (obj != gameObject)
            {
                float dist = Vector3.Distance(rectTrans.localPosition, obj.GetComponent <RectTransform> ().localPosition);
                if (dist < 2 * rectTrans.rect.width)
                {
                    float t = (2 * rectTrans.rect.width) / (dist + 0.01f) * 5;
//					Vector3 pos = obj.GetComponent<RectTransform> ().localPosition;
                    Shape     shape     = obj.GetComponent <Shape> ();
                    Vector3[] overLapVs = gameObject.GetComponent <Shape> ().OverlapVertices(shape);

                    foreach (Vector3 v in overLapVs)
                    {
                        SC.DrawDebugCircle(v, t);
                    }

//					Vector2[] veees = overLapVs;
//					DrawPolygon (overLapVs);
//					drawLine (newPos, obj.GetComponent<RectTransform>().localPosition, t);
//					drawCircle (newPos, t*2);
//					drawCircle (pos, t*2);

//					Vector3[] vees = obj.GetComponent<Shape> ().getVertices();
//					foreach (Vector3 v in vees) {
////						drawCircle (v+pos, t);
//						counter++;
//						bool inside = gameObject.GetComponent<Shape> ().IsInShape(v+pos);
//						if (inside) {
//							drawCircle (v+pos, t);
//						}
////						Debug.Log (gameObject.GetComponent<Shape> ().IsInShape(v+pos));
//					}


//					CO.ColorizeShape (gameObject.name);
//					CO.ColorizeShape (obj.name);
                }
            }
        }
    }
Exemple #2
0
    void makeGridVisible()
    {
        SC.DestroyDebug();
        int xCells = (int)Mathf.Floor(screenview.width / gridCellSize);
        int yCells = (int)Mathf.Floor(screenview.height / gridCellSize);

        if (xCells * yCells > 300)
        {
            Debug.LogError("To many cells to draw, will result in unstable Unity behaviour with current implementation");
        }
        else
        {
            for (int x = 1; x <= xCells; x++)
            {
                for (int y = 1; y <= yCells; y++)
                {
                    Vector3 pos = new Vector3(x * gridCellSize, y * gridCellSize, 0);
                    SC.DrawDebugCircle(pos + shiftPos, 3);
                }
            }
        }
    }