Ejemplo n.º 1
0
    public void createTree()
    {
        TrashManRecycleBin bin = new TrashManRecycleBin();

        bin.instancesToPreallocate = 20;
        bin.prefab     = ballPrefab.gameObject;
        ballPrefab.tag = ObjectType.Player;
        TrashMan.manageRecycleBin(bin);
        Rectangle bound = new Rectangle(0, 0, 800, 480);

        quardTree = new QuardTree(bound, 0);
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                ObjectView objectView = TrashMan.spawn(ballPrefab.gameObject).GetComponent <ObjectView>();
                Rectangle  rect       = new Rectangle(200 + i * 50, 120 + j * 50, 20, 20);
                //Rectangle rect = new Rectangle(i * 50, j * 50, 20, 20);
                objectView.setCollisionHandler(rect);
                //objectView.transform.SetParent(this.transform, false);
                Vector3 localPotion = new Vector3(objectView.rect.center.x, objectView.rect.center.y, 0);
                objectView.transform.localPosition = localPotion;
                quardTree.Insert(objectView.rect);
            }
        }
        drawQuardTree(quardTree);
    }