GetTotalPointCount() private method

private GetTotalPointCount ( ) : int
return int
 static public int GetTotalPointCount(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l);
         var ret = self.GetTotalPointCount();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
	internal CasterCollider(PolygonCollider2D coll){
		collider = coll;
		transform = coll.transform;
		TotalPointsCount = coll.GetTotalPointCount();
		points = new Vector2[TotalPointsCount];
		points = coll.points;
		type = CasterType.PolygonCollider2d;
	}
Beispiel #3
0
 static public int GetTotalPointCount(IntPtr l)
 {
     try {
         UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l);
         var ret = self.GetTotalPointCount();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #4
0
 static public int GetTotalPointCount(IntPtr l)
 {
     try{
         UnityEngine.PolygonCollider2D self = (UnityEngine.PolygonCollider2D)checkSelf(l);
         System.Int32 ret = self.GetTotalPointCount();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #5
0
    void Start()
    {
        switch (gameObject.GetComponent<PlayerController> ().playerType) {

        case 0:
            pc2 = squareCollider;
            break;

        case 1:
            //pc2 = circleCollider;
            gameObject.GetComponent<MeshRenderer>().enabled = false;
            break;

        case 2:
            pc2 = triangleCollider;
            break;

        case 3:
            pc2 = trapezoidCollider;
            break;

        case 4:
            pc2 = rectangleCollider;
            break;

        case 5:
            pc2 = starCollider;
            break;
        }

        // don't act if type is circle
        if (gameObject.GetComponent<PlayerController> ().playerType != 1){
        //Render thing
        int pointCount = 0;
        pointCount = pc2.GetTotalPointCount();
        MeshFilter mf = GetComponent<MeshFilter>();
        Mesh mesh = new Mesh();
        Vector2[] points = pc2.points;
        Vector3[] vertices = new Vector3[pointCount];
        for(int j=0; j<pointCount; j++){
            Vector2 actual = points[j];
            vertices[j] = new Vector3(actual.x, actual.y, 0);
        }
        Triangulator tr = new Triangulator(points);
        int [] triangles = tr.Triangulate();
        mesh.vertices = vertices;
        mesh.triangles = triangles;
        mf.mesh = mesh;
        //Render thing
        }
    }
Beispiel #6
0
 static int QPYX_GetTotalPointCount_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         UnityEngine.PolygonCollider2D QPYX_obj_YXQP = (UnityEngine.PolygonCollider2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.PolygonCollider2D));
         int QPYX_o_YXQP = QPYX_obj_YXQP.GetTotalPointCount();
         LuaDLL.lua_pushinteger(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
 static int GetTotalPointCount(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.PolygonCollider2D obj = (UnityEngine.PolygonCollider2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.PolygonCollider2D));
         int o = obj.GetTotalPointCount();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #8
0
 void Start()
 {
     pc2 = gameObject.GetComponent<PolygonCollider2D>();
     int pointCount = 0;
     pointCount = pc2.GetTotalPointCount();
     MeshFilter mf = GetComponent<MeshFilter>();
     Mesh mesh = new Mesh();
     Vector2[] points = pc2.points;
     Vector3[] vertices = new Vector3[pointCount];
     for(int j=0; j<pointCount; j++){
         Vector2 actual = points[j];
         vertices[j] = new Vector3(actual.x, actual.y, 0);
     }
     Triangulator tr = new Triangulator(points);
     int [] triangles = tr.Triangulate();
     mesh.vertices = vertices;
     mesh.triangles = triangles;
     mf.mesh = mesh;
     //Render thing
 }
	// The default collider is a pentagon, but its position and size changes based on the sprite
	private static bool IsDefaultPolygonCollider2D(PolygonCollider2D polygonCollider2D)
	{
		if (polygonCollider2D == null) return false;
		
		if (polygonCollider2D.GetTotalPointCount() != 5) return false;
		
		var points  = polygonCollider2D.points;
		var spacing = Vector2.Distance(points[0], points[4]);
		
		// Same spacing?
		for (var i = 0; i < 4; i++)
		{
			var spacing2 = Vector2.Distance(points[i], points[i + 1]);
			
			if (Mathf.Approximately(spacing, spacing2) == false)
			{
				return false;
			}
		}
		
		var midpoint = (points[0] + points[1] + points[2] + points[3] + points[4]) * 0.2f;
		var radius   = Vector2.Distance(points[0], midpoint);
		
		// Same radius?
		for (var i = 1; i < 5; i++)
		{
			var radius2 = Vector2.Distance(points[i], midpoint);
			
			if (Mathf.Approximately(radius, radius2) == false)
			{
				return false;
			}
		}
		
		// Must be a pentagon then!
		return true;
	}
Beispiel #10
0
 private Vector2[] GetPolygonCollider2DPoints(PolygonCollider2D col)
 {
     int size = col.GetTotalPointCount();
     Vector2[] points = new Vector2[size];
     Vector2[] local_points = col.points;
     for (int i = 0; i < size; i++)
     {
         points[i] = col.transform.TransformPoint(local_points[i]);
     }
     if (!colList.Contains(col))
     {
         colList.Add(col);
         CircleCollider2D circle;
         GameObject empty = new GameObject();
         empty.transform.parent = col.transform;
         empty.layer = LayerMask.NameToLayer("LumColl");
         for (int i = 0; i < points.Length; i++)
         {
             circle = empty.AddComponent<CircleCollider2D>();
             circle.radius = 0.005f;
             circle.offset = empty.transform.InverseTransformPoint(points[i]);
         }
     }
     return points;
 }