ui/Panels/ChoicePanel.razor
@using Sandbox;
@using Sandbox.UI;
@namespace SS1
@inherits Panel
@attribute [StyleSheet("ChoicePanel.razor.scss")]
<root>
<div class="choice_modal">
@{
Color labelColor = Player.IsLevelCursed( Player.Level ) ? new Color(0.8f, 0f, 0f) : new Color(1f, 1f, 1f, 0.9f);
}
<div class="choice_lvl_label" style="color: @(labelColor.Rgba);">
@($"Level {Player.Level}")
</div>
<div class="choice_button_container">
@for(int i = 0; i < Player.LevelUpChoices.Count; i++)
{
var status = Player.LevelUpChoices[i];
<div class="choice_button" onclick=@(() => ChoiceButtonClicked(TypeLibrary.GetType( status.GetType() )))>
<div class="choice_icon" style="background-image: url(@(status.IconPath));">
@if(status.Level > 1)
{
<div class="status_level_label" style="color:@((status.Level == status.MaxLevel ? new Color(0.75f, 0.75f, 0f) : new Color(1f, 1f, 1f)).Rgba);">
@status.Level
</div>
}
</div>
<div class="choice_title">
@($"[{i + 1}] {status.Title}")
</div>
<div class="choice_description">
@status.GetUpgradeDescription(status.Level)
</div>
</div>
}
</div>
<div class="reroll_button @(Player.NumRerollAvailable <= 0 ? "disabled" : "")" onclick=@(() => RerollButtonClicked())>
<div class="reroll_button_label @(Player.NumRerollAvailable <= 0 ? "disabled_text" : "")">
@($"[R]eroll - {Player.NumRerollAvailable}")
</div>
</div>
</div>
</root>
@code
{
public Player Player { get; set; }
protected override int BuildHash()
{
return HashCode.Combine(
Player.ChoiceHash,
Player.NumRerollAvailable
);
}
void ChoiceButtonClicked(TypeDescription type)
{
if (!Manager.Instance.ShouldUpdatePlayer)
return;
Player.AddStatus(type);
}
void RerollButtonClicked()
{
if(!Manager.Instance.ShouldUpdatePlayer)
return;
Player.UseReroll();
}
}