Exemple #1
0
        private CollisionManager()
        {
            this.currentDrawType = DRAW_TYPE.DRAW_ALL;
            this.bodyGlobalSet = new XboxHashSet<CollisionBody>();
            this.bodyGroupList = new List<CollisionBody>();
            this.bodyGroupHashSet = new XboxHashSet<CollisionBody>();
            this.primitiveBatch = new PrimitiveBatch(Program.GAME.GraphicsDevice);
            font = Program.GAME.Content.Load<SpriteFont>("MenuFont");

            int poolSize = (int)Math.Pow(4, nodeDepth - 2);

            this.nodeArrayPool = new List<QuadTreeNode[]>(poolSize);
            for (int i = 0; i < poolSize; i++)
            {
                QuadTreeNode[] array = new QuadTreeNode[4];
                array[0] = new QuadTreeNode();
                array[1] = new QuadTreeNode();
                array[2] = new QuadTreeNode();
                array[3] = new QuadTreeNode();
                this.nodeArrayPool.Add(array);
            }

            this.bodySetPool = new List<XboxHashSet<CollisionBody>>(poolSize);
            for (int i = 0; i < poolSize; i++)
            {
                this.bodySetPool.Add(new XboxHashSet<CollisionBody>(maxNodeCapacity + 1));
            }
        }
Exemple #2
0
        public void SetSharp(DRAW_TYPE type)
        {
            switch (type)
            {
            case DRAW_TYPE.dotSquare:
                m_MouseHandler.End();
                m_MouseHandler      = m_MouseDot;
                m_MouseDot.isSquare = true;
                break;

            case DRAW_TYPE.dotCircle:
                m_MouseHandler.End();
                m_MouseHandler      = m_MouseDot;
                m_MouseDot.isSquare = false;
                break;

            case DRAW_TYPE.line:
                m_MouseHandler.End();
                m_MouseHandler = m_MouseLine;
                break;

            case DRAW_TYPE.rectangle:
                m_MouseHandler.End();
                m_MouseHandler = m_MouseRect;
                break;

            case DRAW_TYPE.eclipse:
                m_MouseHandler.End();
                m_MouseHandler = m_MouseEclipse;
                break;

            case DRAW_TYPE.polygon:
                m_MouseHandler.End();
                m_MouseHandler = m_MousePolygon;
                break;

            case DRAW_TYPE.region:
                m_MouseHandler.End();
                m_MouseHandler = m_MouseRegion;
                break;

            default:
                break;
            }
            Invalidate();
        }
Exemple #3
0
        /*public XboxHashSet<CollisionBody> BodyList
        {
            get
            {
                XboxHashSet<CollisionBody> bodyList = new XboxHashSet<CollisionBody>();
                foreach (float layer in layersRoots.Keys)
                {
                    bodyList = layersRoots[layer].GetObjectList(bodyList);
                }
                return bodyList;
            }
        }*/
        /// <summary>
        /// Cambia el modo de dibujado de CollisionBodies
        /// </summary>
        public void changeDrawingLayer()
        {
            if (currentDrawType == DRAW_TYPE.DRAW_ONE)
            {
                bool isGreaterThan = false;
                Dictionary<float, QuadTreeNode>.KeyCollection keyColl = this.layersRoots.Keys;
                foreach (float key in keyColl)
                {
                    if (key > this.currentDrawingLayer)
                    {
                        this.currentDrawingLayer = key;
                        layerText = "Collisions: DRAWING LAYER " + currentDrawingLayer.ToString();
                        isGreaterThan = true;
                        break;
                    }
                }

                if (!isGreaterThan)
                {
                    this.currentDrawingLayer = 0.0f;
                    layerText = "Collisions: DRAW ALL LAYERS";
                    this.currentDrawType = DRAW_TYPE.DRAW_ALL;
                }
            }
            else if (currentDrawType == DRAW_TYPE.DRAW_ALL)
            {
                layerText = "Collisions: DRAW ALL LAYERS";
                this.currentDrawType = DRAW_TYPE.DRAW_NONE;
            }
            else if (currentDrawType == DRAW_TYPE.DRAW_NONE)
            {
                layerText = "Collisions: NOT DRAWING ANY LAYER";
                this.currentDrawType = DRAW_TYPE.DRAW_ONE;
            }
        }