From a7742a27e48955e622ee1450ec92e8f943ead2f0 Mon Sep 17 00:00:00 2001
From: Thien Trandinh <trandit@mcmaster.ca>
Date: Sun, 30 Oct 2016 16:34:15 -0400
Subject: [PATCH] Added tile highlight for moving and attacking

---
 src/Blaze-Brigade/Blaze_Brigade/Game.cs       | 40 +++++++++++++++++--
 .../Blaze_Brigade/MouseHandler.cs             |  1 +
 src/Blaze-Brigade/Blaze_Brigade/Node.cs       | 12 +++++-
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs
index 46d4564..9068455 100644
--- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs
+++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs
@@ -49,7 +49,7 @@ namespace Controller
 
         GraphicsDeviceManager graphics;
         SpriteBatch spriteBatch;
-        Texture2D backGround;
+        Texture2D backGround, moveableNode, attackableNode;
         private SpriteFont font; //custom font
 
         // constructor for game
@@ -86,8 +86,12 @@ namespace Controller
             initializeGame();
 
             backGround = Content.Load<Texture2D>("Game_Map"); // load background
+            moveableNode = Content.Load<Texture2D>("moveableNode");
+            attackableNode = Content.Load<Texture2D>("attackableNode");
+
             font = Content.Load<SpriteFont>("PixelFont"); //loads font PixelFont
 
+
             graphics.PreferredBackBufferWidth = gameFunction.SCREEN_WIDTH; // width of screen
             graphics.PreferredBackBufferHeight = gameFunction.SCREEN_HEIGHT; //height of screen
 
@@ -213,16 +217,37 @@ namespace Controller
                         Unit unit = player1.getUnits().ElementAt(i); //gets unit at i
 
                         spriteBatch.Draw(unit.getSpriteImage(), unit.getPixelCoordinates(), Color.White);//draws sprite
-                        
+
+
 
                         //if unit is currently clicked on, draw char info screen
                         if (unit.getClickedOn())
                         {
 
+                            //Highlight movable nodes in blue
+                            LinkedList<Node> moveableNodes = gameFunction.getMovableNodes(graph, unit);
+                            foreach(Node move in moveableNodes)
+                            {
+                                spriteBatch.Draw(moveableNode, move.getPosition(), Color.White * 0.3f);
+                            }
+
+                            //Highlight attackable nodes in red
+                            LinkedList<Node> attackableNodes = gameFunction.getAttackableNodes(graph, unit);
+                            foreach (Node attack in attackableNodes)
+                            {
+                                if (!moveableNodes.Contains(attack))
+                                {
+                                    spriteBatch.Draw(attackableNode, attack.getPosition(), Color.White * 0.2f);
+                                }
+                            }
+
+
+
                             if (unit.getMenuOpen()) //if dropDowMenu should be opened, draw dropDownMenu
                             {
                                 Vector2 menuIncrement = new Vector2(0, 32); //increment downwards for successive button
-                                Vector2 currentButtonPosition = Vector2.Add(unit.getPixelCoordinates(), menuIncrement); //starting location for button
+                                Vector2 initialOffset = new Vector2(32, 0);
+                                Vector2 currentButtonPosition = Vector2.Add(unit.getPixelCoordinates(), initialOffset); //starting location for button
                                 for (int j = 0; j < 4; j++)
                                 {
                                     spriteBatch.Draw(unit.getButtonImage(j), currentButtonPosition, Color.White); //draws each button
@@ -256,10 +281,17 @@ namespace Controller
                         spriteBatch.Draw(unit.getSpriteImage(), unit.getPixelCoordinates(), Color.White);
                         
                     }
+
+
+                    
+                    //spriteBatch.Draw(backGround, Vector2.Zero, Color.White);    // draws background
+                    
                     break;
+
+                    
             }
 
-            //spriteBatch.Draw(backGround, Vector2.Zero, Color.White);    // draws background
+            
             spriteBatch.End();  // end spriteBatch
             base.Draw(gameTime);    // repeatedly calls draw
         }
diff --git a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
index 5089d3f..52dc8b4 100644
--- a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
+++ b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
@@ -109,6 +109,7 @@ namespace Controller
             isAnimating = animating;
         }
 
+        //which dropdownmenu is selected
         void buttonAction(int i)
         {
             //take action corresponding to which button was clicked
diff --git a/src/Blaze-Brigade/Blaze_Brigade/Node.cs b/src/Blaze-Brigade/Blaze_Brigade/Node.cs
index 7a1dbb8..7cb9591 100644
--- a/src/Blaze-Brigade/Blaze_Brigade/Node.cs
+++ b/src/Blaze-Brigade/Blaze_Brigade/Node.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Xna.Framework;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -9,6 +10,8 @@ namespace Model
     {
         private int movabilityObstruction;  // index for hindrance of the movability of a unit; 0 = no hindrance
         private bool isObstacle;            // indicates whether a unit can stand inside the tile
+        private bool highlightMove;
+        private bool highlightAttack;
          
         private int positionX;              // position x on the grid
         private int positionY;              // position y on the grid
@@ -43,6 +46,12 @@ namespace Model
             return isObstacle;
         }
 
+        public Vector2 getPosition()
+        {
+            Vector2 position = new Vector2(getPositionX()*32, getPositionY()*32);
+            return position;
+        }
+
         public int getPositionX()
         {
             return positionX;
@@ -74,5 +83,6 @@ namespace Model
                 return false;
             }
         }
+
     }
 }
-- 
GitLab