Exemplo n.º 1
0
        public TreeNode(TreeNode par, List<Circle> update, List<Circle> draw, int no)
        {
            parent = par;
            updateList = update;
            drawList = draw;
            Main.nodeCount++;

            item = new Circle(this, parent.item.getColour(), parent.item.getLocXY(), parent.item.getDia(), no);
            updateList.Add(item);
            drawList.Add(item);
            ready = false;
        }
Exemplo n.º 2
0
        public Circle(TreeNode tNode, Color upperColor, Vector2 upperLoc, int upperDia, int no)
        {
            circleColour = upperColor;
            diameter = upperDia / 2;
            node = tNode;

            if (no == 0)
            {
                locXY = upperLoc;
                destLocXY = locXY;
                diameter *= 2;
            }
            else
            {
                /*
                 1 2
                 3 4
                */
                locXY = new Vector2(upperLoc.X + diameter / 2, upperLoc.Y + diameter / 2);
                destLocXY = new Vector2();
                switch (no)
                {
                    case 1:
                        destLocXY.X = upperLoc.X;
                        destLocXY.Y = upperLoc.Y;
                        break;
                    case 2:
                        destLocXY.X = upperLoc.X + diameter;
                        destLocXY.Y = upperLoc.Y;
                        break;
                    case 3:
                        destLocXY.X = upperLoc.X;
                        destLocXY.Y = upperLoc.Y + diameter;
                        break;
                    case 4:
                        destLocXY.X = upperLoc.X + diameter;
                        destLocXY.Y = upperLoc.Y + diameter;
                        break;
                }
                locXY = (destLocXY - locXY) / 2 + locXY;
            }
            velocity = new Vector2();
            velocity.X = (destLocXY.X - locXY.X) / 16;
            velocity.Y = (destLocXY.Y - locXY.Y) / 16;

            drawRect = new Rectangle((int)locXY.X, (int)locXY.Y, diameter, diameter);
        }
Exemplo n.º 3
0
        public void split()
        {
            if (children == null && item.getDia() > 2 && ready && item.getColour() != Color.Black)
            {
                children = new TreeNode[5];
                //children[0] = new TreeNode(new Vector2(item.getLocXY().X + item.getDia() / 2, item.getLocXY().X + item.getDia() / 2), updateList, drawList);
                //children[0].item.setDia(item.getDia() / 2);
                for (int i = 1; i < 5; i++)
                {
                    children[i] = new TreeNode(this, updateList, drawList, i);
                }
                drawList.Remove(item);
                item.setColour(Color.Black);

                Main.nodeCount--;
            }
        }
Exemplo n.º 4
0
Arquivo: Main.cs Projeto: jhedin/Orbs
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            populateColourList();
            randGenerator = new Random();
            O = new Vector2();
            updateList = new List<Circle>();
            drawList = new List<Circle>();

            counter = 0;
            nodeCount = 0;
            counterCmp = 1075;

            top = new TreeNode(new Vector2(16, 0), updateList, drawList);
            bottom = new TreeNode(new Vector2(16, 240), updateList, drawList);

            base.Initialize();
        }