Beispiel #1
0
        public AIMainGame(int teamCount, GraphicsDevice gd)
        {
            rand = new Random();

            pd = new PrimitiveDrawer(gd);
            Matrix proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45f), (float)gd.Viewport.Width / gd.Viewport.Height, 0.1f, 1000f);

            cam = new Camera(new Vector3(gridLength/2, gridLength/2, 30), proj);
            map = new Map(gd, gridLength, gridLength);

            if (teamCount > teamColors.Length)
            {
                teamCount = teamColors.Length;
            }

            //Initialize all the game objects
            units = new List<Unit>();
            resources = new List<ResourceChunk>();
            towers = new List<RadioTower>();
            removeChunks = new List<ResourceChunk>();
            hqs = new List<HQ>();
            bullets = new List<Bullet>(200);

            initializeTeams(teamCount);
            initializeResources();
            initializeTowers();
        }
Beispiel #2
0
        public void Begin(PrimitiveType primType, Camera cam)
        {
            if (hasBegun)
            {
                throw new Exception("Can't call Begin until current batch has ended");
            }

            vertCounter = 0;
            vertsPerPrimitive = numVertsPerPrimitive(primType);
            currentCam = cam;
            currentType = primType;

            hasBegun = true;
        }
Beispiel #3
0
        public void Draw(PrimitiveDrawer pd, GameTime g, Camera cam)
        {
            Color color = Color.FromNonPremultiplied(0, 120, 200, 45);

            //Draw the grid
            pd.Begin(PrimitiveType.LineList, cam);
            for (int i = 0; i <= width; i++)
            {
                pd.DrawLine(new Vector3(i, 0, depth), new Vector3(i, height, depth), color);
            }

            for (int i = 0; i <= height; i++)
            {
                pd.DrawLine(new Vector3(0, i, depth), new Vector3(width, i, depth), color);
            }
            pd.End();
        }
Beispiel #4
0
        //Draw a rotated triangle for our unit
        public void Draw(PrimitiveDrawer pd, GameTime g, Camera cam)
        {
            Vector3 v1 = new Vector3(0.5f, 0, 0);
            Vector3 v2 = new Vector3(-0.5f, -0.25f, 0);
            Vector3 v3 = new Vector3(-0.5f, 0.25f, 0);

            Matrix rotMatrix = Matrix.CreateRotationZ(Rotation);
            v1 = Vector3.Transform(v1, rotMatrix);
            v2 = Vector3.Transform(v2, rotMatrix);
            v3 = Vector3.Transform(v3, rotMatrix);

            pd.FillTriangle(Pos + v1, Pos + v2, Pos + v3, TeamColor);
        }
Beispiel #5
0
        public void DrawVertexBuffer(VertexBuffer buffer, PrimitiveType primType, Camera cam)
        {
            device.SetVertexBuffer(buffer);
            effect.View = currentCam.View;
            effect.Projection = currentCam.Projection;

            effect.CurrentTechnique.Passes[0].Apply();
            int passes = buffer.VertexCount / maxVertsPerDraw;
            int remainder = buffer.VertexCount % maxVertsPerDraw;
            int offset = 0;
            for (int i = 0; i < passes; i++)
            {
                device.DrawPrimitives(primType, offset, maxVertsPerDraw / numVertsPerPrimitive(primType));
                offset += maxVertsPerDraw;
            }

            device.DrawPrimitives(primType, offset, remainder / numVertsPerPrimitive(primType));
        }