Exemplo n.º 1
0
        public void Render(Graphics objGraphics)
        {
            if (isFollowPathOn())
            {
                MovingEntity objSharkie = getVehicleByID(m_intSharkieID);
                RenderPath2D(objSharkie.Steering().GetPath(), objGraphics, objPathPen);
            }

            foreach (MovingEntity objVehicle in m_Vehicles)
            {
                Pen objDrawPen = objVehiclePen;

                if (isPursuitOn() && (objVehicle.ID() == m_intVictimID))
                {
                    objDrawPen = objTargetPen;
                }

                if (m_blnNonePenetrationOn)
                {
                    List <MovingEntity> ListTouched = MovingEntity.EnforceNonPenetrationConstraint(objVehicle, m_Vehicles);

                    if (ListTouched.Count > 0)
                    {
                        if (objVehicle.ID() == m_intSharkieID)
                        {
                            objDrawPen = objRedPen;
                        }
                        else
                        {
                            objDrawPen = objDarkPen;
                        }
                    }
                }

                RenderVehicle(objVehicle, objGraphics, objDrawPen);

                if (m_blnRenderAids)
                {
                    if ((objVehicle.ID() == m_intSharkieID))
                    {
                        Vector2D vecForce = (Vector2D)(objVehicle.Steering().Force() / SteerParams.Instance.SteeringForceTweaker);
                        vecForce.X = (vecForce.X * 2) * objVehicle.Scale().X;
                        vecForce.Y = (vecForce.Y * 2) * objVehicle.Scale().Y;

                        objGraphics.DrawLine(objRedPen, (PointF)objVehicle.Pos, (PointF)(objVehicle.Pos + vecForce));


                        objGraphics.DrawEllipse(objVehiclePen, (int)(objVehicle.Pos.X - SteerParams.Instance.ViewDistance), (int)(objVehicle.Pos.Y - SteerParams.Instance.ViewDistance),
                                                (int)SteerParams.Instance.ViewDistance * 2, (int)SteerParams.Instance.ViewDistance * 2);

                        renderDetectionBox(objVehicle, objGraphics, objVehiclePen);
                    }
                    else if ((objVehicle.ID() == m_intVictimID) && GameWorld.Instance.SpacePartitioningOn && isPursuitOn())
                    {
                        InvertedAABBox2D box = new InvertedAABBox2D(objVehicle.Pos - new Vector2D(SteerParams.Instance.ViewDistance, SteerParams.Instance.ViewDistance),
                                                                    objVehicle.Pos + new Vector2D(SteerParams.Instance.ViewDistance, SteerParams.Instance.ViewDistance));

                        renderBox(box, objGraphics, objTargetPen);

                        GameWorld.Instance.CellSpaces.CalculateNeighbors(objVehicle.Pos, SteerParams.Instance.ViewDistance);

                        foreach (MovingEntity objNeighbour in GameWorld.Instance.CellSpaces.ListOfNeighbours())
                        {
                            if (objNeighbour.ID() != m_intSharkieID)
                            {
                                RenderObstacle(objNeighbour, objGraphics, objGrayPen);
                            }
                        }

                        objGraphics.DrawEllipse(objGrayPen, (int)(objVehicle.Pos.X - SteerParams.Instance.ViewDistance), (int)(objVehicle.Pos.Y - SteerParams.Instance.ViewDistance),
                                                (int)SteerParams.Instance.ViewDistance * 2, (int)SteerParams.Instance.ViewDistance * 2);
                    }
                }
            }

            if (GameWorld.Instance.SpacePartitioningOn)
            {
                foreach (Cell objCell in m_pCellSpace.ListOfCells())
                {
                    renderCell(objCell, objGraphics, objCellPen, true);
                }
            }

            foreach (Wall2D objWall in m_Walls)
            {
                RenderWall2D(objWall, objGraphics, objWallPen, true);
            }

            foreach (BaseGameEntity objObs in m_Obstacles)
            {
                RenderObstacle(objObs, objGraphics, objObstaclePen);
            }

            if (!isPursuitOn() && !isFollowPathOn())
            {
                RenderTarget(GameWorld.Instance.TargetPos, objGraphics, objTargetPen);
            }
        }