mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:35:42 +00:00
Add morale to custom battle units
This commit is contained in:
@@ -17,7 +17,8 @@ auto ConvertBattalion(const net::eagle0::common::CommonBattalion &battalion) ->
|
||||
shardokBattalion.mutate_size(battalion.size());
|
||||
shardokBattalion.mutate_type(
|
||||
static_cast<net::eagle0::shardok::storage::fb::BattalionTypeId>(battalion.type()));
|
||||
shardokBattalion.mutate_morale(kDefaultMorale);
|
||||
shardokBattalion.mutate_morale(
|
||||
static_cast<float>(battalion.has_morale() ? battalion.morale() : kDefaultMorale));
|
||||
shardokBattalion.mutate_armament(static_cast<float>(battalion.armament()));
|
||||
shardokBattalion.mutate_training(static_cast<float>(battalion.training()));
|
||||
|
||||
@@ -125,4 +126,4 @@ auto ConvertUnit(
|
||||
return shardokUnit;
|
||||
}
|
||||
|
||||
} // namespace shardok
|
||||
} // namespace shardok
|
||||
|
||||
+26
-1
@@ -20,6 +20,7 @@ namespace eagle {
|
||||
public TMP_InputField sizeLabel;
|
||||
public TMP_InputField trainingLabel;
|
||||
public TMP_InputField armamentLabel;
|
||||
public TMP_InputField moraleLabel;
|
||||
public TMP_Dropdown startingPosition;
|
||||
public Toggle isVip;
|
||||
public Toggle canFlee;
|
||||
@@ -38,8 +39,30 @@ namespace eagle {
|
||||
set => battalionTypeDropdown.value = (int)value;
|
||||
}
|
||||
|
||||
private void Awake() { EnsureMoraleField(); }
|
||||
|
||||
private void Start() {}
|
||||
|
||||
private void EnsureMoraleField() {
|
||||
if (moraleLabel != null) { return; }
|
||||
|
||||
var armamentColumn = armamentLabel.transform.parent;
|
||||
var moraleColumn = Instantiate(armamentColumn.gameObject, armamentColumn.parent);
|
||||
moraleColumn.name = "MOR";
|
||||
moraleColumn.transform.SetSiblingIndex(armamentColumn.GetSiblingIndex() + 1);
|
||||
|
||||
moraleLabel = moraleColumn.GetComponentInChildren<TMP_InputField>();
|
||||
moraleLabel.name = "MOR input";
|
||||
foreach (var text in moraleColumn.GetComponentsInChildren<TMP_Text>(true)) {
|
||||
if (!text.transform.IsChildOf(moraleLabel.transform)) {
|
||||
text.text = "MOR";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
moraleLabel.text = armamentLabel.text;
|
||||
}
|
||||
|
||||
public void DeleteButtonClicked() {
|
||||
GetComponentInParent<EventBasedTable>().RemoveRow(this);
|
||||
}
|
||||
@@ -85,7 +108,8 @@ namespace eagle {
|
||||
Type = SelectedBattalionTypeId,
|
||||
Size = int.Parse(sizeLabel.text),
|
||||
Training = double.Parse(trainingLabel.text),
|
||||
Armament = double.Parse(armamentLabel.text)
|
||||
Armament = double.Parse(armamentLabel.text),
|
||||
Morale = double.Parse(moraleLabel.text)
|
||||
};
|
||||
|
||||
return new CommonUnit {
|
||||
@@ -118,6 +142,7 @@ namespace eagle {
|
||||
sizeLabel.text = value.Battalion.Size.ToString();
|
||||
trainingLabel.text = value.Battalion.Training.ToString();
|
||||
armamentLabel.text = value.Battalion.Armament.ToString();
|
||||
moraleLabel.text = value.Battalion.Morale.ToString();
|
||||
|
||||
startingPosition.value = (value.StartingPositionIndex.HasValue &&
|
||||
_availableStartingPositions != null)
|
||||
|
||||
@@ -88,6 +88,7 @@ message CommonBattalion {
|
||||
|
||||
double training = 4;
|
||||
double armament = 5;
|
||||
optional double morale = 6;
|
||||
}
|
||||
|
||||
enum UnitStatus {
|
||||
|
||||
Reference in New Issue
Block a user