Beispiel #1
0
        //Draw the nodes and connections associated with all the rigidbodies, and any current AI paths through the rigidbody graph
        private void DrawRigidbodyGraph(Graphics displayDevice)
        {
            Physics.RigidBody temp = new Physics.RigidBody();
            temp.Shape = new Physics.Circle(5);

            AI.NodeIndex previousNode;

            //for each rigidbody, draw it's core node, all its child nodes, and all its connections
            foreach (AI.Node rb in AIgraph.topLevelNode.internalNodes)
            {
                //draw the node
                temp.SetPosition(AIgraph.topLevelNode.GetNodePosition(rb.index));
                temp.Shape.mColor = Color.DarkOrange;
                mRenderer.Draw(temp, displayDevice);

                //draw its children
                foreach (AI.Node nd in rb.internalNodes)
                {
                    temp.SetPosition(AIgraph.topLevelNode.GetNodePosition(nd.index));
                    temp.Shape.mColor = Color.Chocolate;
                    mRenderer.Draw(temp, displayDevice);
                }

                //draw its connections
                foreach (AI.Connection rbconn in rb.connections)
                {
                    mRenderer.DrawLine(rb.position, AIgraph.topLevelNode.GetNodePosition(rbconn.destination), displayDevice, Color.FromArgb(9, Color.Black));
                }

                //draw each Ai's current high level path
                if (AIgraph.topLevelNode.lastPaths != null)
                {
                    foreach (List <AI.NodeIndex> lastPath in AIgraph.topLevelNode.lastPaths)
                    {
                        previousNode = null;
                        if (lastPath != null)
                        {
                            foreach (AI.NodeIndex node in lastPath)
                            {
                                previousNode = AIgraph.topLevelNode.GetNode(node).previousNode;

                                if (previousNode != null)
                                {
                                    mRenderer.DrawLine(AIgraph.topLevelNode.GetNodePosition(previousNode), AIgraph.topLevelNode.GetNodePosition(node), displayDevice, Color.FromArgb(129, Color.Black));
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void MainWindow_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            //Update the position of the camera
            mRenderer.cameraLocation = (mScene.thePlayer.playerBody.Position - new Physics.Vector2D(GlobalConstants.WINDOW_WIDTH / 2, GlobalConstants.WINDOW_HEIGHT / 2)) * -1;
            //Do not allow the camera below a certain position
            if (mRenderer.cameraLocation.Y < 0)
            {
                mRenderer.cameraLocation.Y = 0;
            }


            //draw all AI spawn locations
            foreach (Physics.Vector2D spawn in mScene.theAIManager.AISpawnLocations)
            {
                mRenderer.DrawAISpawn(spawn, graphics);
            }

            //Draw all physical objects in the scene
            foreach (var prop in mScene.thePhysicsEngine.dynamicPhysicsObjects)
            {
                mRenderer.Draw(prop, graphics);
            }
            foreach (var prop in mScene.thePhysicsEngine.staticPhysicsObjects)
            {
                mRenderer.Draw(prop, graphics);
            }

            //draw all spring joints
            foreach (var spring in mScene.thePhysicsEngine.springs)
            {
                mRenderer.DrawLine(spring.BodyA.Position, spring.BodyB.Position, graphics);
            }


            //draw any debug information to the screen
            dbgDisp.DisplayDebugGraphics(graphics);

            //Draw the HUD
            mScene.headsUpDisplay.DrawUI(mRenderer, graphics);
        }