public void InitBlockTransform(Vector3 pos, int width, int height) { transform.position = pos; this.width = width; this.height = height; aabbox = GetComponent <AABBox>(); aabbox.resetAABBox(new Vector2(pos.x, pos.y), new Vector2(pos.x + width, pos.y + height)); }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); animator.SetInteger("Type", (int)type); animator.SetTrigger("Change"); AABBox box = GetComponent <AABBox>(); Vector2 min = new Vector2(transform.position.x - 20, transform.position.y - 20); Vector2 max = new Vector2(transform.position.x + 20, transform.position.y + 20); box.resetAABBox(min, max); createTime = TimeUtils.GetTimeStampNow(); }
static void GenerateAABBoxToCollsionLayer(Transform collision) { PolygonCollider2D[] colliders = collision.GetComponents <PolygonCollider2D>(); foreach (PolygonCollider2D collider in colliders) { for (int i = 0; i < collider.pathCount; i++) { Vector2 [] paths = collider.GetPath(i); int count = (int)(paths[2].x - paths[0].x) / tileWidth; for (int n = 0; n < count; n++) { AABBox box = collision.gameObject.AddComponent <AABBox>(); Vector2 min = new Vector2(paths[0].x + tileWidth * n, paths[1].y); Vector2 max = new Vector2(paths[0].x + tileWidth * (n + 1), paths[0].y); box.resetAABBox(min, max); } } } for (int i = 0; i < colliders.Length; i++) { GameObject.DestroyImmediate(colliders[i]); } }