Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
NPBruce committed Apr 5, 2017
2 parents b559c16 + a3b1ac8 commit a736d1e
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 175 deletions.
2 changes: 1 addition & 1 deletion Assets/Resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.2
0.8.3
2 changes: 1 addition & 1 deletion Assets/Scripts/Content/AssetImport/RtLFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ override public string DataDirectory()
{
if (Application.platform == RuntimePlatform.OSXPlayer)
{
return "/Contents/Resources";
return "/Contents/Resources/Data";
}
return "/Road to Legend_Data";
}
Expand Down
36 changes: 17 additions & 19 deletions Assets/Scripts/Quest/ActivateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ public ActivateDialog(Quest.Monster m, bool masterIn, bool singleStep = false)
virtual public void CreateWindow(bool singleStep = false)
{
// If a dialog window is open we force it closed (this shouldn't happen)
foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
Object.Destroy(go);
Destroyer.Dialog();

// ability box - name header
DialogBox db = new DialogBox(
TextButton tb = new TextButton(
new Vector2(15, 0.5f),
new Vector2(UIScaler.GetWidthUnits() - 30, 2),
monster.monsterData.name.Translate());
db.textObj.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
db.AddBorder();
monster.monsterData.name.Translate(),
delegate { new InfoDialog(monster); });
tb.ApplyTag("activation");

DialogBox db = null;
float offset = 2.5f;
if (monster.currentActivation.effect.Length > 0)
{
// ability text
db = new DialogBox(new Vector2(10, offset), new Vector2(UIScaler.GetWidthUnits() - 20, 4), monster.currentActivation.effect.Replace("\\n", "\n"));
db.AddBorder();
db.ApplyTag("activation");
offset += 4.5f;
}

Expand Down Expand Up @@ -62,6 +63,7 @@ virtual public void CreateWindow(bool singleStep = false)
activationText = monster.currentActivation.ad.minionActions.Translate().Replace("\\n", "\n");
}
db.AddBorder();
db.ApplyTag("activation");
db.textObj.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
offset += 2;

Expand All @@ -75,37 +77,33 @@ virtual public void CreateWindow(bool singleStep = false)
{
db.AddBorder();
}
db.ApplyTag("activation");

offset += 7.5f;

// Create finished button
if (singleStep)
{
new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Activated", delegate { activated(); });
tb = new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Activated", delegate { activated(); });
}
else if (master)
{
new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Masters Activated", delegate { activated(); }, Color.red);
tb = new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Masters Activated", delegate { activated(); }, Color.red);
}
else
{
new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Minions Activated", delegate { activated(); });
tb = new TextButton(new Vector2(15, offset), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Minions Activated", delegate { activated(); });
}
tb.ApplyTag("activation");
}

public void activated()
{
// Destroy this dialog to close
destroy();
// Disable if there is a menu open
if (GameObject.FindGameObjectWithTag("dialog") != null) return;

Game.Get().roundControl.MonsterActivated();
}

public void destroy()
{
// Clean up everything marked as 'dialog'
foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
foreach (GameObject go in GameObject.FindGameObjectsWithTag("activation"))
Object.Destroy(go);
Game.Get().roundControl.MonsterActivated();
}

}
5 changes: 5 additions & 0 deletions Assets/Scripts/Quest/GameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public static void Create()
return;
}

if (GameObject.FindGameObjectWithTag("activation") != null)
{
return;
}

// Border around menu items
DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 6), new Vector2(12, 13), "");
db.AddBorder();
Expand Down
35 changes: 15 additions & 20 deletions Assets/Scripts/Quest/HeroDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public void CreateWindow()
{
float offset = ((hero.id - 0.9f) * (HeroCanvas.heroSize + 0.5f)) + HeroCanvas.offsetStart;
// Has this hero been activated?
if (hero.activated)
if (hero.activated || (GameObject.FindGameObjectWithTag("activation") != null))
{
// Grey button with no action
new TextButton(new Vector2(HeroCanvas.heroSize + 0.5f, offset), new Vector2(10, 2), "End Turn", delegate { noAction(); }, Color.gray);
new TextButton(new Vector2(HeroCanvas.heroSize + 0.5f, offset), new Vector2(10, 2), "End Turn", delegate { ; }, Color.gray);
}
else
{
Expand All @@ -38,28 +38,30 @@ public void CreateWindow()
new TextButton(new Vector2(HeroCanvas.heroSize + 0.5f, offset + 5f), new Vector2(10, 2), "Cancel", delegate { onCancel(); });
}

// Null function for activated hero
public void noAction()
{
}

// Hero defeated
public void defeated()
{
destroy();
Destroyer.Dialog();
Game game = Game.Get();
// Save to undo stack
game.quest.Save();
hero.defeated = true;
updateDisplay();
// This can trigger events
game.quest.AdjustMorale(-1);
// This can trigger events, delay events if activation present
if (GameObject.FindGameObjectWithTag("activation") != null)
{
game.quest.AdjustMorale(-1, true);
}
else
{
game.quest.AdjustMorale(-1);
}
}

// Hero restored
public void restored()
{
destroy();
Destroyer.Dialog();
Game game = Game.Get();
// Save to undo stack
game.quest.Save();
Expand All @@ -70,7 +72,7 @@ public void restored()
// Activated hero
public void activated()
{
destroy();
Destroyer.Dialog();
Game game = Game.Get();
// Save state to undo stack
game.quest.Save();
Expand All @@ -86,19 +88,12 @@ public void activated()
// Cancel cleans up
public void onCancel()
{
destroy();
Destroyer.Dialog();
}

public void updateDisplay()
{
Game game = Game.Get();
game.heroCanvas.UpdateStatus();
}

public void destroy()
{
// Clean up everything marked as 'dialog'
foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
Object.Destroy(go);
}
}
38 changes: 21 additions & 17 deletions Assets/Scripts/Quest/MonsterDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,34 @@ public virtual void CreateWindow()
// Work out where on the screen to display
float offset = (index + 0.1f - game.monsterCanvas.offset) * (MonsterCanvas.monsterSize + 0.5f);

if (GameObject.FindGameObjectWithTag("activation") != null)
{
offset += 2.8f;
}

new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), "Information", delegate { Info(); });
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset + 2.5f), new Vector2(10, 2), "Force Activate", delegate { Activate(); });
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset + 5f), new Vector2(10, 2), "Defeated", delegate { Defeated(); });
if (monster.unique)
offset += 2.5f;
if (GameObject.FindGameObjectWithTag("activation") == null)
{
// If there is a unique option the offset needs to be increased
offset += 3.5f;
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset + 4f), new Vector2(10, 3), "Unique\nDefeated", delegate { UniqueDefeated(); });
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), "Force Activate", delegate { Activate(); });
offset += 2.5f;
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), "Defeated", delegate { Defeated(); });
offset += 2.5f;
if (monster.unique)
{
// If there is a unique option the offset needs to be increased
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 3), "Unique\nDefeated", delegate { UniqueDefeated(); });
offset += 3.5f;
}
}
// FIXME: This doesn't fit if there is a unique monster in the last space
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset + 7.5f), new Vector2(10, 2), "Cancel", delegate { OnCancel(); });
new TextButton(new Vector2(UIScaler.GetRight(-10.5f - MonsterCanvas.monsterSize), offset), new Vector2(10, 2), "Cancel", delegate { OnCancel(); });
}

// Monster Information
public void Info()
{
Destroy();
Destroyer.Dialog();
new InfoDialog(monster);
}

Expand Down Expand Up @@ -87,7 +98,7 @@ public void Defeated()
public void UniqueDefeated()
{
Game game = Game.Get();
Destroy();
Destroyer.Dialog();
// Add to undo stack
game.quest.Save();
// Monster is no longer unique
Expand All @@ -100,7 +111,7 @@ public void UniqueDefeated()
// Cancel cleans up
public void OnCancel()
{
Destroy();
Destroyer.Dialog();
}

// Update the list of monsters
Expand All @@ -109,11 +120,4 @@ public void updateDisplay()
Game game = Game.Get();
game.monsterCanvas.UpdateList();
}

public void Destroy()
{
// Clean up everything marked as 'dialog'
foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
Object.Destroy(go);
}
}
9 changes: 8 additions & 1 deletion Assets/Scripts/Quest/Quest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ public void Undo()
}

// This function adjusts morale. We don't write directly so that NoMorale can be triggered
public void AdjustMorale(int m)
// Delay is used if we can't raise the nomorale event at this point (need to recall this later)
public void AdjustMorale(int m, bool delay = false)
{
Game game = Game.Get();
morale += m;
Expand All @@ -473,6 +474,12 @@ public void AdjustMorale(int m)
{
morale = 0;
game.moraleDisplay.Update();
// Hold loss during activation
if (delay)
{
morale = -1;
return;
}
eManager.EventTriggerType("NoMorale");
}
game.moraleDisplay.Update();
Expand Down
6 changes: 6 additions & 0 deletions Assets/Scripts/Quest/RoundController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ virtual public void MonsterActivated()
{
// Evenyone has finished, move to next round
activationsFinished = true;
game.quest.AdjustMorale(0);
EndRound();
}
}
else
{
// Trigger morale event if required
game.quest.AdjustMorale(0);
}
}

// Activate a monster (if any left) and return true if all monsters activated
Expand Down
Loading

0 comments on commit a736d1e

Please sign in to comment.