コード例 #1
0
 public void DrawPieces(SpriteBatch spriteBatch, Camera cam, List<CheckerPiece> allPieces, int tileScale)
 {
     spriteBatch.Begin(SpriteSortMode.BackToFront,
                   BlendState.AlphaBlend,
                   null,
                   null,
                   null,
                   null,
                   cam.get_transformation(_device));
     for (int i = 0; i < allPieces.Count(); i++)
     {
         CheckerPiece currentPiece = allPieces[i];
         if (currentPiece != null)
         {
             spriteBatch.Draw(_checkerTileTexture, new Vector2((currentPiece.Col * tileScale + tileScale * .5f), currentPiece.Row * tileScale + tileScale * .5f), new Rectangle(currentPiece.Color * tileScale, (int)currentPiece.Status * tileScale, tileScale, tileScale), Color.White, 0, new Vector2(tileScale / 2.0f, tileScale / 2.0f), 1, SpriteEffects.None, 0);
         }
     }
     spriteBatch.End();
 }
コード例 #2
0
        public void DrawCheckerBoard(CheckerTile[,] tileBoard, List<CheckerPiece> allPieces, CheckerPiece selectedPiece, List<CheckerPiece>[] movablePieces, Dictionary<CheckerPiece, List<MoveSet>> MoveDict, int TILE_SCALE, SpriteBatch spriteBatch, Camera cam)
        {
            if (!_contentLoaded)
                return;
            spriteBatch.Begin(SpriteSortMode.BackToFront,
                          BlendState.AlphaBlend,
                          null,
                          null,
                          null,
                          null,
                          cam.get_transformation(_device));
            //Checker Tiles
            for (var row = 0; row < tileBoard.GetLength(0); row++)
            {
                for (int col = 0; col < tileBoard.GetLength(1); col++)
                {
                    spriteBatch.Draw(_blankTexture, new Rectangle(col * TILE_SCALE, row * TILE_SCALE, TILE_SCALE, TILE_SCALE), null, (tileBoard[row, col].Color == 1)?Color.Gray:Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
                }
            }
            //Lines
            for (var row = 0; row <= tileBoard.GetLength(0); row++)
            {
                spriteBatch.Draw(_blankTexture, new Rectangle(0, row * TILE_SCALE, tileBoard.GetLength(1) * TILE_SCALE, 1), null, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 0);
            }
            for (var col = 0; col <= tileBoard.GetLength(1); col++)
            {
                spriteBatch.Draw(_blankTexture, new Rectangle(col * TILE_SCALE, 0, 1, tileBoard.GetLength(0) * TILE_SCALE), null, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 0);
            }
            spriteBatch.End();

            //Draw Pieces
            DrawPieces(spriteBatch, cam, allPieces, TILE_SCALE);

            //Draw the possible moves
            if (selectedPiece != null && movablePieces != null && movablePieces[selectedPiece.Color].Contains(selectedPiece) && MoveDict.ContainsKey(selectedPiece))
            {
                DrawPossibleMoves(spriteBatch, cam, MoveDict[selectedPiece], TILE_SCALE, selectedPiece);
            }
        }
コード例 #3
0
        public void Update(GameTime gameTime, Camera cam)
        {
            foreach(var piece in AllPieces)
            {
                if(piece.Status == CheckerPieceStatus.Dying)
                {
                    if((DateTime.Now - piece.TimeDead).TotalSeconds > 1 )
                        piece.Status = CheckerPieceStatus.Dead;

                }

            }
        }
コード例 #4
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     _maxPruning = 0;
     _minPruning = 0;
     _maxDepth = 0;
     _timer = 0;
     _nodeGeneration = 0;
     _checkerBoard = new CheckerBoard(Rows, Cols);
     _cam = new Camera {Pos = new Vector2(0, 0)};
     _particleManager = new ParticleManager();
     _screenManager = new UIScreenManager();
     _setupForm = new SetupForm(this);
     _drawDriver = new DrawDriver();
     base.Initialize();
 }
コード例 #5
0
 public void DrawPossibleMoves(SpriteBatch spriteBatch, Camera cam, List<MoveSet> allTile, int TILE_SCALE, CheckerPiece SelectedPiece)
 {
     spriteBatch.Begin(SpriteSortMode.BackToFront,
                   BlendState.AlphaBlend,
                   null,
                   null,
                   null,
                   null,
                   cam.get_transformation(_device));
     for (int i = 0; i < allTile.Count(); i++)
     {
         for (int j = 0; j < allTile[i].MoveList.Count(); j++)
         {
             Color color = (j == 0) ? new Color(255, 255, 255, 127) : new Color(255, 255, 255, 50);
             spriteBatch.Draw(_checkerTileTexture,
                              new Vector2((allTile[i].MoveList[j].Col * TILE_SCALE + TILE_SCALE * .5f),
                                          allTile[i].MoveList[j].Row * TILE_SCALE + TILE_SCALE * .5f),
                              new Rectangle(SelectedPiece.Color*TILE_SCALE, 0, TILE_SCALE, TILE_SCALE),
                              color, 0, new Vector2(TILE_SCALE * .5f, TILE_SCALE * .5f), 1,
                              SpriteEffects.None, 0);
         }
     }
     spriteBatch.End();
 }
コード例 #6
0
 public void Draw(SpriteBatch spriteBatch, Camera cam)
 {
     foreach (ParticleSystem particleSystem in particleSystems)
         particleSystem.Draw(spriteBatch, cam);
 }
コード例 #7
0
        public void Draw(SpriteBatch spriteBatch, Camera cam)
        {
            spriteBatch.Begin(SpriteSortMode.Immediate, particleInfo.BlendState, null, null, null, null, cam.get_transformation(device));
            for (var i = 0; i < particles.Count; i++)
            {
                spriteBatch.Draw(contentManager.Load<Texture2D>("Textures/" + particleInfo.TextureName), new Vector2((int)particles[i].Position.X, (int)particles[i].Position.Y), null, particles[i].Color, particles[i].Rotation, new Vector2(5f, 5f), particles[i].Scale, SpriteEffects.None, 0 );

            }
            spriteBatch.End();
        }