public void Draw(CustomSpriteBatch g) { PolygonEffect.View = Camera.View; g.GraphicsDevice.DepthStencilState = DepthStencilState.Default; g.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; g.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; foreach (KeyValuePair <Texture2D, List <Tile3D> > ActiveTileSet in DicTile3D) { PolygonEffect.Texture = ActiveTileSet.Key; PolygonEffect.CurrentTechnique.Passes[0].Apply(); foreach (Tile3D ActiveTile in ActiveTileSet.Value) { ActiveTile.Draw(g.GraphicsDevice); } } PolygonEffect.Texture = sprCursor; PolygonEffect.CurrentTechnique.Passes[0].Apply(); Cursor.Draw(g.GraphicsDevice); g.End(); GameScreen.GraphicsDevice.DepthStencilState = DepthStencilState.Default; for (int P = 0; P < Map.ListPlayer.Count; P++) { //If the selected unit have the order to move, draw the possible positions it can go to. for (int U = 0; U < Map.ListPlayer[P].ListSquad.Count; U++) {//If it's dead, don't draw it unless it's an event unit. if ((Map.ListPlayer[P].ListSquad[U].CurrentLeader == null && !Map.ListPlayer[P].ListSquad[U].IsEventSquad) || Map.ListPlayer[P].ListSquad[U].IsDead) { continue; } Color UnitColor; if (Constants.UnitRepresentationState == Constants.UnitRepresentationStates.Colored) { UnitColor = Map.ListPlayer[P].Color; } else { UnitColor = Color.White; } Map.ListPlayer[P].ListSquad[U].Unit3D.SetViewMatrix(Camera.View); Map.ListPlayer[P].ListSquad[U].Unit3D.SetPosition( -Map.MapSize.X / 2 + 0.5f + Map.ListPlayer[P].ListSquad[U].Position.X, Radius, -Map.MapSize.Y / 2 + 0.5f + Map.ListPlayer[P].ListSquad[U].Y); Map.ListPlayer[P].ListSquad[U].Unit3D.Draw(GameScreen.GraphicsDevice); } } g.Begin(); }
public void Draw(CustomSpriteBatch g) { g.GraphicsDevice.DepthStencilState = DepthStencilState.Default; g.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; g.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; PolygonEffect.View = Camera.View; Matrix ViewProjection = Camera.View * PolygonEffect.Projection; foreach (KeyValuePair <int, Tile3DHolder> ActiveTileSet in DicTile3DByTileset) { ActiveTileSet.Value.SetViewMatrix(ViewProjection, Camera.CameraPosition3D); ActiveTileSet.Value.Draw(g.GraphicsDevice); } if (Map.ShowLayerIndex == -1) { for (int L = 0; L < Map.LayerManager.ListLayer.Count; L++) { Draw(g, Map.LayerManager.ListLayer[L], false); } } else { Draw(g, Map.LayerManager.ListLayer[Map.ShowLayerIndex], false); } DrawDrawablePoints(g); g.GraphicsDevice.DepthStencilState = DepthStencilState.None; PolygonEffect.Texture = sprCursor; PolygonEffect.CurrentTechnique.Passes[0].Apply(); Cursor.Draw(g.GraphicsDevice); for (int P = 0; P < Map.ListPlayer.Count; P++) { //If the selected unit have the order to move, draw the possible positions it can go to. for (int U = 0; U < Map.ListPlayer[P].ListSquad.Count; U++) { //If it's dead, don't draw it unless it's an event unit. if ((Map.ListPlayer[P].ListSquad[U].CurrentLeader == null && !Map.ListPlayer[P].ListSquad[U].IsEventSquad) || Map.ListPlayer[P].ListSquad[U].IsDead) { continue; } Color UnitColor; if (Constants.UnitRepresentationState == Constants.UnitRepresentationStates.Colored) { UnitColor = Map.ListPlayer[P].Color; } else { UnitColor = Color.White; } Map.ListPlayer[P].ListSquad[U].Unit3D.SetViewMatrix(Camera.View); float TerrainZ = Map.LayerManager.ListLayer[(int)Map.ListPlayer[P].ListSquad[U].Z].ArrayTerrain[(int)Map.ListPlayer[P].ListSquad[U].Position.X, (int)Map.ListPlayer[P].ListSquad[U].Position.Y].Position.Z; Map.ListPlayer[P].ListSquad[U].Unit3D.SetPosition( Map.ListPlayer[P].ListSquad[U].Position.X + 0.5f, (Map.ListPlayer[P].ListSquad[U].Position.Z + TerrainZ * 32), Map.ListPlayer[P].ListSquad[U].Position.Y + 0.5f); Map.ListPlayer[P].ListSquad[U].Unit3D.Draw(GameScreen.GraphicsDevice); } } DrawDelayedAttacks(g); DrawPERAttacks(g); g.GraphicsDevice.DepthStencilState = DepthStencilState.Default; g.End(); g.Begin(); }