M FNAGame.cs => FNAGame.cs +1 -0
@@ 79,6 79,7 @@ namespace Kabul
{
// Clean up after yourself!
base.UnloadContent();
+ TextureManager.UnloadContent();
}
protected override void Update(GameTime gameTime)
M GameState.cs => GameState.cs +58 -11
@@ 82,8 82,13 @@ namespace Kabul
int currentAggro = 5;
+ bool unitGrabbed = false;
+ Color playSpaceColour = Color.Transparent;
+
DynamicSpriteFont font30, font24;
+ bool unitUITutorial = false;
+ bool unitPlaceTutorial = false;
bool dispositionTutorial = false;
bool burnesDispositionTutorial = false;
bool endTurnTutorial = false;
@@ 104,6 109,10 @@ namespace Kabul
currentTurnState = turnState.playerTurn;
+ playSpaceColour.R = 100;
+ playSpaceColour.G = 100;
+ playSpaceColour.A = 10;
+
alexanderBurnesToken = new UnitToken(this, tokenType.AlexanderBurnes);
charlieBurnesToken = new UnitToken(this, tokenType.CharlieBurnes);
sepoyToken = new UnitToken(this, tokenType.Sepoy);
@@ 165,8 174,9 @@ namespace Kabul
currentlyGrabbing = false;
- gameUI.addTimedPopup(LanguageManager.firstHelpBox, 10000);
- gameUI.addTimedPopup(LanguageManager.secondHelpBox, 10000);
+ gameUI.addTimedPopup(LanguageManager.firstHelpBox, 7500);
+ gameUI.addTimedPopup(LanguageManager.secondHelpBox, 7500);
+ gameUI.addTimedPopup(LanguageManager.thirdHelpBox, 7500);
}
@@ 192,6 202,18 @@ namespace Kabul
background.Draw();
+ if (unitGrabbed && !unitPlaceTutorial)
+ {
+ spriteBatch.DrawFilledRectangle(shujahRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(mcnaughtenRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(courtyardRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(leftRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(rightRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(ammoRect, playSpaceColour, playSpaceColour);
+ spriteBatch.DrawFilledRectangle(balconyRect, playSpaceColour, playSpaceColour);
+
+ }
+
spriteBatch.DrawString(font30, LanguageManager.McNaughten, mcnaughtenPoint, Color.Black);
spriteBatch.DrawString(font30, LanguageManager.ReturnJourney, mcnaughtenBackPoint, Color.Black);
spriteBatch.DrawString(font30, LanguageManager.balaHissar, shujahPoint, Color.Black);
@@ 261,15 283,22 @@ namespace Kabul
{
if (token.currentLocation != tokenLocation.mcnaughtenreturn && token.currentLocation != tokenLocation.shujahreturn)
{
+
if (token.isGrabbed())
{
currentlyGrabbing = true;
token.dragTo(Utilities.PointToVector2(input.cursorPosition));
+ unitGrabbed = true;
break;
}
else if (token.grabRectangle.Contains(input.cursorPosition) && !currentlyGrabbing)
{
token.dragTo(Utilities.PointToVector2(input.cursorPosition));
+ unitGrabbed = true;
+ if (!unitPlaceTutorial)
+ {
+ gameUI.addTimedPopup(LanguageManager.unitPlace, 5000);
+ }
break;
}
}
@@ 279,6 308,8 @@ namespace Kabul
}
if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
{
+ unitGrabbed = false;
+
foreach (UnitToken token in tokensInPlay)
{
if (token.isGrabbed())
@@ 293,6 324,11 @@ namespace Kabul
}
token.Update();
+ if (!unitPlaceTutorial)
+ {
+ unitPlaceTutorial = true;
+ }
+
placeTokensInLocation(tokenLocation.unassigned);
currentlyGrabbing = false;
}
@@ 333,7 369,16 @@ namespace Kabul
if (input.IsNewKeyRelease(Keys.A))
{
- Console.WriteLine("t");
+ if (debug)
+ {
+ gameUI.addTimedPopup("Just testing a highlighting background for\nthe eh popups.", 5000, true);
+ }
+ }
+
+ if (input.IsNewKeyRelease(Keys.Escape))
+ {
+ this.UnloadContent();
+ stateManager.ExitAndLoad(new MainMenu(stateManager));
}
}
@@ 858,16 903,16 @@ namespace Kabul
{
if (random.Next(6) < 4)
{
+ token.setLocation(tokenLocation.unassigned);
+ placeTokensInLocation(tokenLocation.unassigned);
if (token.helpComing)
{
- gameUI.addTimedPopup(LanguageManager.successfulSeekHelp, 3500);
+ gameUI.addTimedPopup(LanguageManager.successfulSeekHelp, 3500, true, Utilities.Vector2ToPoint(token.Position));
}
else
{
- gameUI.addTimedPopup(LanguageManager.failedSeekHelp, 3500);
+ gameUI.addTimedPopup(LanguageManager.failedSeekHelp, 3500, true, Utilities.Vector2ToPoint(token.Position));
}
- token.setLocation(tokenLocation.unassigned);
- placeTokensInLocation(tokenLocation.unassigned);
}
}
else if (token.currentLocation == tokenLocation.mcnaughtenscamp)
@@ 896,16 941,18 @@ namespace Kabul
{
if (random.Next(6) < 4)
{
+ token.setLocation(tokenLocation.unassigned);
+ placeTokensInLocation(tokenLocation.unassigned);
+
if (token.helpComing)
{
- gameUI.addTimedPopup(LanguageManager.successfulSeekHelp, 2500);
+ gameUI.addTimedPopup(LanguageManager.successfulSeekHelp, 2500, true, Utilities.Vector2ToPoint(token.Position));
}
else
{
- gameUI.addTimedPopup(LanguageManager.failedSeekHelp, 2500);
+ gameUI.addTimedPopup(LanguageManager.failedSeekHelp, 2500, true, Utilities.Vector2ToPoint(token.Position));
}
- token.setLocation(tokenLocation.unassigned);
- placeTokensInLocation(tokenLocation.unassigned);
+
}
}
M LanguageManager.cs => LanguageManager.cs +7 -1
@@ 51,6 51,7 @@ namespace Sionnach
public static string firstHelpBox = "Drag and drop units on boxes. Press end turn when done.";
public static string secondHelpBox = "Right click to cycle through actions for units in spaces.";
+ public static string thirdHelpBox = "The red bar below a unit's portrait is it's health. The yellow bar is it's ammunition supply.";
public static string successfulSeekHelp = "They're on their way!";
public static string failedSeekHelp = "I don't think they're coming.";
@@ 63,6 64,7 @@ namespace Sionnach
public static string DispositionTutorial = "There are two actions to toggle between\nfor most units: Fire, and Blockade.\nBlockade makes units take cover in squares\nother than the Courtyard,\nwhere they will attempt to barricade the gate.\nFire shoots at enemies outside.";
public static string BurnesDispositionTutorial = "Burnes has an additional disposition\nmarker, Speech. From the balcony, he can attempt to calm down the crowd outside,\nbut while there he is more vulnerable to gunfire.";
public static string endTurnTutorial = "On turn end, your units will act out their effects,\nthen the enemy turn will occur. Enemies\nwill appear, move forward, or attack.";
+ public static string unitPlace = "Units can be placed in each of the highlighted boxes.";
public static void setLanguage(language desLanguage)
{
@@ 92,6 94,7 @@ namespace Sionnach
firstHelpBox = "Tarraing na aonaid chun na spásanna. Cliceáil deireadh seala nuair a bheidh tú críochnaithe.";
secondHelpBox = "Dheis-cliceáil le timthriall tri’na gníomhartha.";
+ thirdHelpBox = "Is é a shláinte an bosca dearg faoi pictúir a aonaid. Is é an cuntas a armlón an bosca buí faoi pictúir a aonaid";
McNaughten = "An Campa na Kabul";
ReturnJourney = "Aistear";
@@ 113,6 116,7 @@ namespace Sionnach
DispositionTutorial = "Beidh dhá gníomhartha go timthriall ó\nle na aoinaid: a lámhach, agus a chosaint.\nDéanann cosaint aonaid a cheilt in áiteanna\nseachas an gclós. Má tá siad sa chlós cuirfidh\nsiad baracáid ar an ngeata. Tá an\nlámhach ag naimhde taobh amuigh";
BurnesDispositionTutorial = "Tá gníomh eile ag Burnes, óráid.\nIs féidir leis iarracht a dhéanamh\nna naimhde ar an mbalcóin a mhaolú, ach tá\nsé níos leochailí ó ionsaí.";
endTurnTutorial = "Tar éis do seala, gníomhóidh d’aonaid,\nansin gníomhóidh na naimhde. Beidh namhaid\nle feiceáil, ag bogadh ar aghaidh,\nnó ag ionsaí.";
+ unitPlace = "Is féidir chur ar aonaid in aon cheann na spásanna a lasta.";
}
else if (desLanguage == language.bearla)
{
@@ 138,6 142,7 @@ namespace Sionnach
firstHelpBox = "Drag and drop units on boxes. Press end turn when done.";
secondHelpBox = "Right click to cycle through actions for units in spaces.";
+ thirdHelpBox = "The red bar below a unit's portrait is it's health.\nThe yellow bar is it's ammunition supply.";
McNaughten = "Kabul Encampment";
ReturnJourney = "Return";
@@ 159,7 164,8 @@ namespace Sionnach
DispositionTutorial = "There are two actions to toggle between\nfor most units: Fire, and Blockade.\nBlockade makes units take cover in squares\nother than the Courtyard,\nwhere they will attempt to barricade the gate.\nFire shoots at enemies outside.";
BurnesDispositionTutorial = "Burnes has an additional disposition\nmarker, Speech. He can attempt to calm down the crowd outside,\nbut on the balcony he is more vulnerable to gunfire.";
endTurnTutorial = "On turn end, your units will act out their effects,\nthen the enemy turn will occur. Enemies\nwill appear, move forward, or attack.";
- }
+ unitPlace = "Units can be placed in each of the highlighted boxes.";
+ }
}
}
}
M LogoState.cs => LogoState.cs +7 -0
@@ 43,6 43,12 @@ namespace Kabul
spriteBatch = stateManager.spriteBatch;
}
+ public override void UnloadContent()
+ {
+ base.UnloadContent();
+ logo.texture.Dispose();
+ }
+
public override void Draw(GameTime gameTime)
{
//base.Draw(gameTime);
@@ 69,6 75,7 @@ namespace Kabul
}
else
{
+ UnloadContent();
stateManager.ExitAndLoad(new MainMenu(stateManager));
}
}
M => +70 -3
@@ 11,6 11,7 @@ using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using FontStashSharp;
using LineBatch;
namespace Sionnach
{
@@ 38,6 39,10 @@ namespace Sionnach
public Point targetPosition;
public bool moving;
bool highlighted = false;
int highlightLifetime = 2500;
Rectangle highlightRect;
Texture2D backgroundTexture, selectedTexture, normalTexture, imageTexture;
DynamicSpriteFont textFont;
@@ 48,7 53,7 @@ namespace Sionnach
public enum popUpState { In, Solid, Out } //up = normal, over = mouse over, down = mouse click
public popUpState popupState = popUpState.Solid;
public PopUp(StateManager StateManager, string Text, DynamicSpriteFont desFont, Utilities.UILocationAnchor anchorPoint, List<PopUp> popups, int desLife = 1000)
public PopUp(StateManager StateManager, string Text, DynamicSpriteFont desFont, Utilities.UILocationAnchor anchorPoint, List<PopUp> popups, int desLife = 1000, bool isHighlighted = false)
{
stateManager = StateManager;
@@ 73,6 78,7 @@ namespace Sionnach
foreach (PopUp p in popups)
{
yOffset += p.size.Y;
yOffset += 2;
}
@@ 80,6 86,7 @@ namespace Sionnach
{
//rectangle = new Rectangle
position = new Point(0 + ((size.X / 2) + 6), (size.Y / 2) + yOffset + 6);
rectangle = new Rectangle(position.X - (size.X / 2), position.Y - (size.Y / 2), size.X, size.Y);
}
else if (anchorPoint == Utilities.UILocationAnchor.topRight)
{
@@ 89,7 96,7 @@ namespace Sionnach
{
position = new Point(Utilities.gameWindowWidth / 2, (Utilities.gameWindowHeight / 2) + yOffset + 6);
}
rectangle = new Rectangle(Utilities.gameWindowWidth - (size.X / 2), position.Y - (size.Y / 2), size.X, size.Y);
//rectangle = new Rectangle(Utilities.gameWindowWidth - (size.X / 2), position.Y - (size.Y / 2), size.X, size.Y);
//position = new Point(Utilities.gameWindowWidth - size.X, 100);
@@ 105,6 112,46 @@ namespace Sionnach
lifeTime = desLife;
highlightLifetime = lifeTime - highlightLifetime;
highlighted = isHighlighted;
highlightRect = new Rectangle(rectangle.X - 2, rectangle.Y - 2, rectangle.Width + 4, rectangle.Height + 4);
LoadContent();
}
public PopUp(StateManager StateManager, string Text, DynamicSpriteFont desFont, Point anchorPoint, List<PopUp> popups, int desLife = 1000, bool isHighlighted = false)
{
stateManager = StateManager;
textString = Text;
textFont = desFont;
int widthHolder = (int)textFont.MeasureString(textString).X;
size.X = widthHolder + 24;
size.Y = (int)textFont.MeasureString(textString).Y + 24;
int yOffset = 64;
position = anchorPoint;
position.Y -= yOffset;
rectangle = new Rectangle(position.X - (size.X / 2), position.Y - (size.Y / 2), size.X, size.Y);
textPosition = position;
CenterText();
drawColor = upColor;
selectedColor = downColor;
soundManager = stateManager.game.soundManager;
spriteBatch = stateManager.spriteBatch;
moving = false;
lifeTime = desLife;
highlightLifetime = lifeTime - highlightLifetime;
highlighted = isHighlighted;
highlightRect = new Rectangle(rectangle.X - 2, rectangle.Y - 2, rectangle.Width + 4, rectangle.Height + 4);
LoadContent();
}
@@ 135,6 182,11 @@ namespace Sionnach
int bottomElementOffset = position.Y + (size.Y / 2) - 20;
int elementOffset = backgroundTexture.Width/3;
if (highlighted)
{
spriteBatch.DrawRectangle(highlightRect, Color.Yellow, 2);
}
spriteBatch.Draw(backgroundTexture, new Vector2(leftElementOffset, topElementOffset), new Rectangle(0, 0, elementOffset, elementOffset), Color.White);
spriteBatch.Draw(backgroundTexture, new Vector2(rightElementOffset, topElementOffset), new Rectangle(elementOffset * 2, 0, elementOffset, elementOffset), Color.White);
spriteBatch.Draw(backgroundTexture, new Vector2(leftElementOffset, bottomElementOffset), new Rectangle(0, (elementOffset * 2), elementOffset, elementOffset), Color.White);
@@ 165,6 217,11 @@ namespace Sionnach
dead = true;
}
if (lifeTime < highlightLifetime && highlighted)
{
highlighted = false;
}
if (position != targetPosition && moving)
{
int xDelta = targetPosition.X - position.X;
@@ 172,7 229,11 @@ namespace Sionnach
position.X += (int)(xDelta * 0.1);
position.Y += (int)(yDelta * 0.1);
CenterText();
textPosition.X += (int)(xDelta * 0.1);
textPosition.Y += (int)(yDelta * 0.1);
highlightRect.X = position.X - (size.X / 2) - 2;
highlightRect.Y = position.Y - (size.Y / 2) - 2;
if (position == targetPosition)
{
@@ 186,6 247,12 @@ namespace Sionnach
targetPosition = newPoint;
moving = true;
}
public void setTargetPosition(int newY)
{
targetPosition = new Point(position.X, newY);
moving = true;
}
public void Click()
{
M TextureManager.cs => TextureManager.cs +17 -0
@@ 100,5 100,22 @@ namespace Sionnach
fileStream.Close();
*/
}
+
+ public static void UnloadContent()
+ {
+ cursorTexture.Dispose();
+ gameBackground.Dispose();
+ menuBackgroundTexture.Dispose();
+ AlexanderBurnes.Dispose();
+ CharlieBurnes.Dispose();
+ EICSepoy.Dispose();
+ AfghanRioter.Dispose();
+ AfghanWarrior.Dispose();
+ healthBarSheet.Dispose();
+ ammoBarSheet.Dispose();
+ cbAmmoBarSheet.Dispose();
+ iconSheet.Dispose();
+ PucaLogo.Dispose();
+ }
}
}
M UI.cs => UI.cs +49 -6
@@ 19,6 19,7 @@ namespace Sionnach
List<Button> buttons = new List<Button>();
List<PopUp> popups = new List<PopUp>();
List<PopUp> centrePopups = new List<PopUp>();
+ List<PopUp> responsePopups = new List<PopUp>();
Tooltip toolTip;
DynamicSpriteFont popupFont, turnAnnounceFont;
@@ 59,6 60,12 @@ namespace Sionnach
p.Draw();
}
+ foreach (PopUp p in responsePopups)
+ {
+ p.Draw();
+ }
+
+
if (toolTip.toDraw)
{
toolTip.Draw();
@@ 107,6 114,7 @@ namespace Sionnach
public void Update(GameTime gameTime)
{
+ bool leftieRemoved = false;
for (int i = popups.Count - 1; i > -1; i--)
{
popups[i].Update(gameTime.ElapsedGameTime.Milliseconds);
@@ 114,10 122,23 @@ namespace Sionnach
if (popups[i].dead)
{
popups.RemoveAt(i);
- foreach (PopUp p in popups)
- {
- p.setTargetPosition(p.position - new Point(0, p.size.Y + 6));
- }
+ leftieRemoved = true;
+ }
+ }
+
+ if (leftieRemoved)
+ {
+ int yOffset = 0;
+
+ if (popups.Count > 0)
+ {
+ yOffset = popups.First().size.Y / 2;
+ }
+
+ foreach (PopUp p in popups)
+ {
+ p.setTargetPosition(yOffset);
+ yOffset += p.size.Y + 2;
}
}
@@ 130,10 151,20 @@ namespace Sionnach
centrePopups.RemoveAt(i);
foreach (PopUp p in centrePopups)
{
- p.setTargetPosition(p.position - new Point(0, p.size.Y + 6));
+ p.setTargetPosition(p.position - new Point(0, p.size.Y + 2));
}
}
}
+
+ for (int i = responsePopups.Count - 1; i > -1; i--)
+ {
+ responsePopups[i].Update(gameTime.ElapsedGameTime.Milliseconds);
+
+ if (responsePopups[i].dead)
+ {
+ responsePopups.RemoveAt(i);
+ }
+ }
}
public void addTimedPopup(string desText, int lifetime)
@@ 142,9 173,21 @@ namespace Sionnach
popups.Add(p);
}
+ public void addTimedPopup(string desText, int lifetime, bool highlighted)
+ {
+ PopUp p = new PopUp(stateManager, desText, popupFont, Utilities.UILocationAnchor.topLeft, popups, lifetime, highlighted);
+ popups.Add(p);
+ }
+
+ public void addTimedPopup(string desText, int lifetime, bool highlighted, Point desAnchor)
+ {
+ PopUp p = new PopUp(stateManager, desText, popupFont, desAnchor, popups, lifetime, highlighted);
+ responsePopups.Add(p);
+ }
+
public void addBigPopup(string desText)
{
- PopUp p = new PopUp(stateManager, desText, turnAnnounceFont, Utilities.UILocationAnchor.centre, popups, 2000);
+ PopUp p = new PopUp(stateManager, desText, turnAnnounceFont, Utilities.UILocationAnchor.centre, centrePopups, 2000);
centrePopups.Add(p);
}