Skip to content

Commit

Permalink
Refactored CreateWindow
Browse files Browse the repository at this point in the history
Using the new methods in UIElement, the buttons have been refactored to be inactive to solve issue NPBruce#1560 if the monster's health is fully damaged. This will prevent some unintended behavior going forward, but more work will be needed in other scripts to prevent this.
  • Loading branch information
Hobbeslionheart committed Apr 2, 2022
1 parent 30a7243 commit a278699
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions unity/Assets/Scripts/Quest/MonsterDialogMoM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,29 @@ public override void CreateWindow()

//Attack Button
UIElement ui = new UIElement();
ui.SetGameObjectName("Attack");
ui.SetLocation(UIScaler.GetHCenter(-8f), 2, 16, 2);
ui.SetText(new StringKey("val","ACTION_X",ATTACK));
ui.SetText(ATTACK);
ui.SetFontSize(UIScaler.GetMediumFont());
ui.SetButton(Attack);
ui.SetGameObjectName("Attack");
new UIElementBorder(ui);

ui.SetActiveState(monster.damage == monster.GetHealth(), false, Attack);

//Evade Button
ui = new UIElement();
ui.SetGameObjectName("Evade");
ui.SetLocation(UIScaler.GetHCenter(-8f), 4.5f, 16, 2);
ui.SetText(EVADE);
ui.SetFontSize(UIScaler.GetMediumFont());
ui.SetButton(Evade);
ui.SetGameObjectName("Evade");
new UIElementBorder(ui);

ui.SetActiveState(monster.damage == monster.GetHealth(), false, Evade);

//Cancel Button
ui = new UIElement();
ui.SetGameObjectName("Cancel");
ui.SetLocation(UIScaler.GetHCenter(-5f), 7, 10, 2);
if (monster.damage == monster.GetHealth())
ui.SetText(CommonStringKeys.CANCEL);
ui.SetFontSize(UIScaler.GetMediumFont());
ui.SetActiveState(monster.damage == monster.GetHealth(), false, OnCancel);

/*if (monster.damage == monster.GetHealth())
{
//Cancel inactive
ui.SetText(CommonStringKeys.CANCEL, Color.gray);
Expand All @@ -82,8 +85,8 @@ public override void CreateWindow()
ui.SetText(CommonStringKeys.CANCEL);
ui.SetButton(OnCancel);
new UIElementBorder(ui);
}
ui.SetFontSize(UIScaler.GetMediumFont());
}*/

}
}

Expand Down

0 comments on commit a278699

Please sign in to comment.