mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
format all files with clang-format (#2471)
* format all files with clang-format * indent c# namespaces Former-commit-id: c66108e7576cd6d938aaa0615718706958d9f474
This commit is contained in:
+154
@@ -153,6 +153,160 @@ StatementMacros:
|
|||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
---
|
---
|
||||||
|
Language: CSharp
|
||||||
|
# BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Always
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
# AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 100
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<ext/.*\.h>'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCBinPackProtocolList: Never
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
RawStringFormats:
|
||||||
|
- Language: Cpp
|
||||||
|
Delimiters:
|
||||||
|
- cc
|
||||||
|
- CC
|
||||||
|
- cpp
|
||||||
|
- Cpp
|
||||||
|
- CPP
|
||||||
|
- 'c++'
|
||||||
|
- 'C++'
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
- Language: TextProto
|
||||||
|
Delimiters:
|
||||||
|
- pb
|
||||||
|
- PB
|
||||||
|
- proto
|
||||||
|
- PROTO
|
||||||
|
EnclosingFunctions:
|
||||||
|
- EqualsProto
|
||||||
|
- EquivToProto
|
||||||
|
- PARSE_PARTIAL_TEXT_PROTO
|
||||||
|
- PARSE_TEST_PROTO
|
||||||
|
- PARSE_TEXT_PROTO
|
||||||
|
- ParseTextOrDie
|
||||||
|
- ParseTextProtoOrDie
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
---
|
||||||
Language: Proto
|
Language: Proto
|
||||||
BasedOnStyle: Google
|
BasedOnStyle: Google
|
||||||
AlignConsecutiveDeclarations: true
|
AlignConsecutiveDeclarations: true
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class ButtonColors
|
public class ButtonColors {
|
||||||
{
|
public static ColorBlock SelectedColorBlock() {
|
||||||
public static ColorBlock SelectedColorBlock()
|
|
||||||
{
|
|
||||||
ColorBlock block = new ColorBlock();
|
ColorBlock block = new ColorBlock();
|
||||||
block.colorMultiplier = 1.0f;
|
block.colorMultiplier = 1.0f;
|
||||||
block.normalColor = Color.gray;
|
block.normalColor = Color.gray;
|
||||||
@@ -14,8 +12,7 @@ public class ButtonColors
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ColorBlock UnselectedColorBlock()
|
public static ColorBlock UnselectedColorBlock() {
|
||||||
{
|
|
||||||
ColorBlock block = new ColorBlock();
|
ColorBlock block = new ColorBlock();
|
||||||
|
|
||||||
block.colorMultiplier = 1.0f;
|
block.colorMultiplier = 1.0f;
|
||||||
|
|||||||
+16
-25
@@ -6,8 +6,7 @@ using TMPro;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
public class AvailableGameItem : MonoBehaviour
|
public class AvailableGameItem : MonoBehaviour {
|
||||||
{
|
|
||||||
public GameObject item;
|
public GameObject item;
|
||||||
public TextMeshProUGUI gameIdField;
|
public TextMeshProUGUI gameIdField;
|
||||||
public eagle.HeroDropdownController heroDropdownController;
|
public eagle.HeroDropdownController heroDropdownController;
|
||||||
@@ -20,34 +19,24 @@ public class AvailableGameItem : MonoBehaviour
|
|||||||
private List<AvailableLeader> availableLeaders;
|
private List<AvailableLeader> availableLeaders;
|
||||||
private long gameId;
|
private long gameId;
|
||||||
|
|
||||||
public string SelectedLeader
|
public string SelectedLeader {
|
||||||
{
|
get {
|
||||||
get
|
if (heroDropdownController.SelectedHeroId == 0) {
|
||||||
{
|
|
||||||
if (heroDropdownController.SelectedHeroId == 0)
|
|
||||||
{
|
|
||||||
var index = new System.Random().Next(availableLeaders.Count);
|
var index = new System.Random().Next(availableLeaders.Count);
|
||||||
return availableLeaders[index].Name;
|
return availableLeaders[index].Name;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return availableLeaders[heroDropdownController.SelectedHeroId - 1].Name;
|
return availableLeaders[heroDropdownController.SelectedHeroId - 1].Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void JoinClicked()
|
public void JoinClicked() { JoinCallback(gameId, SelectedLeader); }
|
||||||
{
|
|
||||||
JoinCallback(gameId, SelectedLeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAvailableNewGame(long gameId, string playersString, List<AvailableLeader> leaders)
|
public void
|
||||||
{
|
SetAvailableNewGame(long gameId, string playersString, List<AvailableLeader> leaders) {
|
||||||
availableLeaders = leaders;
|
availableLeaders = leaders;
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
|
|
||||||
@@ -56,12 +45,14 @@ public class AvailableGameItem : MonoBehaviour
|
|||||||
joinButton.interactable = true;
|
joinButton.interactable = true;
|
||||||
buttonText.text = "JOIN";
|
buttonText.text = "JOIN";
|
||||||
|
|
||||||
List<HeroView> heroOptions = new List<HeroView> { new HeroView { Name = "Random", Id = 0, Profession = Net.Eagle0.Eagle.Common.Profession.NoProfession } };
|
List<HeroView> heroOptions = new List<HeroView> { new HeroView {
|
||||||
for (int i = 0; i < leaders.Count; i++)
|
Name = "Random",
|
||||||
{
|
Id = 0,
|
||||||
|
Profession = Net.Eagle0.Eagle.Common.Profession.NoProfession
|
||||||
|
} };
|
||||||
|
for (int i = 0; i < leaders.Count; i++) {
|
||||||
var leader = leaders[i];
|
var leader = leaders[i];
|
||||||
heroOptions.Add(new HeroView
|
heroOptions.Add(new HeroView {
|
||||||
{
|
|
||||||
Name = leader.Name,
|
Name = leader.Name,
|
||||||
Profession = leader.Profession,
|
Profession = leader.Profession,
|
||||||
Id = i + 1
|
Id = i + 1
|
||||||
|
|||||||
+129
-196
@@ -14,48 +14,61 @@ using System.Threading;
|
|||||||
using eagle;
|
using eagle;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
public class AuthInterceptor : Interceptor
|
public class AuthInterceptor : Interceptor {
|
||||||
{
|
|
||||||
private readonly string headerName = "Authorization";
|
private readonly string headerName = "Authorization";
|
||||||
private string headerValue;
|
private string headerValue;
|
||||||
|
|
||||||
public AuthInterceptor(String name, String password)
|
public AuthInterceptor(String name, String password) {
|
||||||
{
|
|
||||||
String toEncode = name + ":" + password;
|
String toEncode = name + ":" + password;
|
||||||
headerValue = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(toEncode));
|
headerValue = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(toEncode));
|
||||||
}
|
}
|
||||||
public override TResponse BlockingUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, BlockingUnaryCallContinuation<TRequest, TResponse> continuation)
|
public override TResponse BlockingUnaryCall<TRequest, TResponse>(
|
||||||
{
|
TRequest request,
|
||||||
|
ClientInterceptorContext<TRequest, TResponse> context,
|
||||||
|
BlockingUnaryCallContinuation<TRequest, TResponse> continuation) {
|
||||||
return continuation(request, ContextWithHeaders(context));
|
return continuation(request, ContextWithHeaders(context));
|
||||||
}
|
}
|
||||||
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, AsyncUnaryCallContinuation<TRequest, TResponse> continuation)
|
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(
|
||||||
{
|
TRequest request,
|
||||||
|
ClientInterceptorContext<TRequest, TResponse> context,
|
||||||
|
AsyncUnaryCallContinuation<TRequest, TResponse> continuation) {
|
||||||
return continuation(request, ContextWithHeaders(context));
|
return continuation(request, ContextWithHeaders(context));
|
||||||
}
|
}
|
||||||
public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(TRequest request, ClientInterceptorContext<TRequest, TResponse> context, AsyncServerStreamingCallContinuation<TRequest, TResponse> continuation)
|
public override AsyncServerStreamingCall<TResponse>
|
||||||
{
|
AsyncServerStreamingCall<TRequest, TResponse>(
|
||||||
|
TRequest request,
|
||||||
|
ClientInterceptorContext<TRequest, TResponse> context,
|
||||||
|
AsyncServerStreamingCallContinuation<TRequest, TResponse> continuation) {
|
||||||
return continuation(request, ContextWithHeaders(context));
|
return continuation(request, ContextWithHeaders(context));
|
||||||
}
|
}
|
||||||
public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, AsyncClientStreamingCallContinuation<TRequest, TResponse> continuation)
|
public override AsyncClientStreamingCall<TRequest, TResponse>
|
||||||
{
|
AsyncClientStreamingCall<TRequest, TResponse>(
|
||||||
|
ClientInterceptorContext<TRequest, TResponse> context,
|
||||||
|
AsyncClientStreamingCallContinuation<TRequest, TResponse> continuation) {
|
||||||
return continuation(ContextWithHeaders(context));
|
return continuation(ContextWithHeaders(context));
|
||||||
}
|
}
|
||||||
public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, AsyncDuplexStreamingCallContinuation<TRequest, TResponse> continuation)
|
public override AsyncDuplexStreamingCall<TRequest, TResponse>
|
||||||
{
|
AsyncDuplexStreamingCall<TRequest, TResponse>(
|
||||||
|
ClientInterceptorContext<TRequest, TResponse> context,
|
||||||
|
AsyncDuplexStreamingCallContinuation<TRequest, TResponse> continuation) {
|
||||||
return continuation(ContextWithHeaders(context));
|
return continuation(ContextWithHeaders(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientInterceptorContext<TRequest, TResponse> ContextWithHeaders<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> original) where TRequest : class where TResponse : class
|
private ClientInterceptorContext<TRequest, TResponse> ContextWithHeaders<TRequest, TResponse>(
|
||||||
{
|
ClientInterceptorContext<TRequest, TResponse> original)
|
||||||
|
where TRequest : class
|
||||||
|
where TResponse : class {
|
||||||
var headers = new Metadata();
|
var headers = new Metadata();
|
||||||
headers.Add(headerName, headerValue);
|
headers.Add(headerName, headerValue);
|
||||||
|
|
||||||
return new ClientInterceptorContext<TRequest, TResponse>(original.Method, original.Host, original.Options.WithHeaders(headers));
|
return new ClientInterceptorContext<TRequest, TResponse>(
|
||||||
|
original.Method,
|
||||||
|
original.Host,
|
||||||
|
original.Options.WithHeaders(headers));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public class ConnectionHandler : MonoBehaviour
|
public class ConnectionHandler : MonoBehaviour {
|
||||||
{
|
|
||||||
public TMP_InputField urlField;
|
public TMP_InputField urlField;
|
||||||
public TMP_InputField nameField;
|
public TMP_InputField nameField;
|
||||||
public TMP_InputField passwordField;
|
public TMP_InputField passwordField;
|
||||||
@@ -95,13 +108,13 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
const String nameKey = "nameKey";
|
const String nameKey = "nameKey";
|
||||||
const String passwordKey = "passwordKey";
|
const String passwordKey = "passwordKey";
|
||||||
|
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
var currentResolution = Screen.currentResolution;
|
var currentResolution = Screen.currentResolution;
|
||||||
var resolutions = Screen.resolutions;
|
var resolutions = Screen.resolutions;
|
||||||
|
|
||||||
resolutionDropdown.ClearOptions();
|
resolutionDropdown.ClearOptions();
|
||||||
resolutionDropdown.AddOptions(resolutions.Select(r => $"{r.width} x {r.height} @{r.refreshRate}").ToList());
|
resolutionDropdown.AddOptions(
|
||||||
|
resolutions.Select(r => $"{r.width} x {r.height} @{r.refreshRate}").ToList());
|
||||||
resolutionDropdown.value = resolutions.ToList().IndexOf(currentResolution);
|
resolutionDropdown.value = resolutions.ToList().IndexOf(currentResolution);
|
||||||
|
|
||||||
urlField.text = PlayerPrefs.GetString(urlKey, defaultUrl);
|
urlField.text = PlayerPrefs.GetString(urlKey, defaultUrl);
|
||||||
@@ -118,38 +131,29 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
customBattlePanel.gameObject.SetActive(false);
|
customBattlePanel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EditorButtonClicked()
|
public void EditorButtonClicked() { SceneManager.LoadScene("Map Editor"); }
|
||||||
{
|
|
||||||
SceneManager.LoadScene("Map Editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConnectEagle()
|
public void ConnectEagle() { _internalConnectEagle(); }
|
||||||
{
|
|
||||||
_internalConnectEagle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CustomBattle()
|
public void CustomBattle() { _internalCustomBattle(); }
|
||||||
{
|
|
||||||
_internalCustomBattle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnApplicationQuit()
|
public void OnApplicationQuit() {
|
||||||
{
|
if (lobbyUpdatesThread != null) {
|
||||||
if (lobbyUpdatesThread != null)
|
|
||||||
{
|
|
||||||
lobbyUpdatesThread.Abort();
|
lobbyUpdatesThread.Abort();
|
||||||
lobbyUpdatesThread = null;
|
lobbyUpdatesThread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnResolutionChanged(int dropdownIndex)
|
public void OnResolutionChanged(int dropdownIndex) {
|
||||||
{
|
|
||||||
var newResolution = Screen.resolutions[dropdownIndex];
|
var newResolution = Screen.resolutions[dropdownIndex];
|
||||||
Screen.SetResolution(newResolution.width, newResolution.height, true, newResolution.refreshRate);
|
Screen.SetResolution(
|
||||||
|
newResolution.width,
|
||||||
|
newResolution.height,
|
||||||
|
true,
|
||||||
|
newResolution.refreshRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _handleGamesReply(GamesReply gamesReply)
|
private void _handleGamesReply(GamesReply gamesReply) {
|
||||||
{
|
|
||||||
fetchedRunningGames = new List<Net.Eagle0.Eagle.Api.GameInfo>();
|
fetchedRunningGames = new List<Net.Eagle0.Eagle.Api.GameInfo>();
|
||||||
fetchedRunningGames.AddRange(gamesReply.RunningGames);
|
fetchedRunningGames.AddRange(gamesReply.RunningGames);
|
||||||
|
|
||||||
@@ -158,100 +162,84 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
|
|
||||||
fetchedMaxPlayerCount = gamesReply.NewGameOptions.MaxSupportedPlayers;
|
fetchedMaxPlayerCount = gamesReply.NewGameOptions.MaxSupportedPlayers;
|
||||||
|
|
||||||
MainQueue.Q.Enqueue(() =>
|
MainQueue.Q.Enqueue(() => {
|
||||||
{
|
|
||||||
awsResourceFetcher.Prefetch(fetchedNewGameLeaders.Select(a => a.ImagePath));
|
awsResourceFetcher.Prefetch(fetchedNewGameLeaders.Select(a => a.ImagePath));
|
||||||
|
|
||||||
connectionPanel.gameObject.SetActive(false);
|
connectionPanel.gameObject.SetActive(false);
|
||||||
gameSelectionPanel.gameObject.SetActive(true);
|
gameSelectionPanel.gameObject.SetActive(true);
|
||||||
|
|
||||||
// Set up running games table
|
// Set up running games table
|
||||||
foreach (Transform row in runningGamesListArea.transform)
|
foreach (Transform row in runningGamesListArea.transform) { Destroy(row.gameObject); }
|
||||||
{
|
foreach (var runningGame in gamesReply.RunningGames) {
|
||||||
Destroy(row.gameObject);
|
|
||||||
}
|
|
||||||
foreach (var runningGame in gamesReply.RunningGames)
|
|
||||||
{
|
|
||||||
var listItem = Instantiate(runningGamesListItemPrefab);
|
var listItem = Instantiate(runningGamesListItemPrefab);
|
||||||
listItem.transform.SetParent(runningGamesListArea.transform);
|
listItem.transform.SetParent(runningGamesListArea.transform);
|
||||||
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
||||||
listItem.GetComponent<RunningGameItem>().SetRunningGame(
|
listItem.GetComponent<RunningGameItem>().SetRunningGame(
|
||||||
runningGame.GameId,
|
runningGame.GameId,
|
||||||
runningGame.Leader);
|
runningGame.Leader);
|
||||||
listItem.GetComponent<RunningGameItem>().GoCallback = this.SelectEagleGame;
|
listItem.GetComponent<RunningGameItem>().GoCallback = this.SelectEagleGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up available/waiting games table
|
// Set up available/waiting games table
|
||||||
foreach (Transform row in availableGamesListArea.transform)
|
foreach (Transform row in availableGamesListArea.transform) { Destroy(row.gameObject); }
|
||||||
{
|
|
||||||
Destroy(row.gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var waitingGame in gamesReply.WaitingGames)
|
foreach (var waitingGame in gamesReply.WaitingGames) {
|
||||||
{
|
|
||||||
var listItem = Instantiate(waitingGamesListItemPrefab);
|
var listItem = Instantiate(waitingGamesListItemPrefab);
|
||||||
listItem.transform.SetParent(availableGamesListArea.transform);
|
listItem.transform.SetParent(availableGamesListArea.transform);
|
||||||
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
||||||
listItem.GetComponent<WaitingGameItem>().SetWaitingGame(
|
listItem.GetComponent<WaitingGameItem>().SetWaitingGame(
|
||||||
waitingGame.GameId,
|
waitingGame.GameId,
|
||||||
string.Format("{0} / {1}", waitingGame.CurrentHumanPlayerCount, waitingGame.MaxHumanPlayerCount),
|
string.Format(
|
||||||
waitingGame.SelectedLeader);
|
"{0} / {1}",
|
||||||
|
waitingGame.CurrentHumanPlayerCount,
|
||||||
|
waitingGame.MaxHumanPlayerCount),
|
||||||
|
waitingGame.SelectedLeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
var createGameItem = Instantiate(createGameListItemPrefab);
|
var createGameItem = Instantiate(createGameListItemPrefab);
|
||||||
//var singlePlayerListItem = Instantiate(availableGamesListItemPrefab);
|
// var singlePlayerListItem = Instantiate(availableGamesListItemPrefab);
|
||||||
createGameItem.transform.SetParent(availableGamesListArea.transform);
|
createGameItem.transform.SetParent(availableGamesListArea.transform);
|
||||||
createGameItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
createGameItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
||||||
createGameItem.GetComponent<CreateGameItem>().SetCreationOptions(
|
createGameItem.GetComponent<CreateGameItem>().SetCreationOptions(
|
||||||
fetchedNewGameLeaders,
|
fetchedNewGameLeaders,
|
||||||
fetchedMaxPlayerCount
|
fetchedMaxPlayerCount);
|
||||||
);
|
|
||||||
createGameItem.GetComponent<CreateGameItem>().CreateCallback = this.CreateGame;
|
createGameItem.GetComponent<CreateGameItem>().CreateCallback = this.CreateGame;
|
||||||
|
|
||||||
foreach (var availableGame in gamesReply.AvailableGames)
|
foreach (var availableGame in gamesReply.AvailableGames) {
|
||||||
{
|
|
||||||
var listItem = Instantiate(availableGamesListItemPrefab);
|
var listItem = Instantiate(availableGamesListItemPrefab);
|
||||||
listItem.transform.SetParent(availableGamesListArea.transform);
|
listItem.transform.SetParent(availableGamesListArea.transform);
|
||||||
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
listItem.transform.localScale = new Vector3 { x = 1.0f, y = 1.0f, z = 1.0f };
|
||||||
listItem.GetComponent<AvailableGameItem>().SetAvailableNewGame(
|
listItem.GetComponent<AvailableGameItem>().SetAvailableNewGame(
|
||||||
availableGame.GameId,
|
availableGame.GameId,
|
||||||
string.Format("{0} / {1}", availableGame.CurrentHumanPlayerCount, availableGame.MaxHumanPlayerCount),
|
string.Format(
|
||||||
availableGame.AvailableLeaders.ToList());
|
"{0} / {1}",
|
||||||
|
availableGame.CurrentHumanPlayerCount,
|
||||||
|
availableGame.MaxHumanPlayerCount),
|
||||||
|
availableGame.AvailableLeaders.ToList());
|
||||||
listItem.GetComponent<AvailableGameItem>().JoinCallback = this.JoinGame;
|
listItem.GetComponent<AvailableGameItem>().JoinCallback = this.JoinGame;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _handleLobbyAction(GamesReply reply, StatusCode sc)
|
private void _handleLobbyAction(GamesReply reply, StatusCode sc) {
|
||||||
{
|
if (sc == StatusCode.OK) {
|
||||||
if (sc == StatusCode.OK)
|
lock (pendingReplyLock) {
|
||||||
{
|
|
||||||
lock (pendingReplyLock)
|
|
||||||
{
|
|
||||||
pendingReply = reply;
|
pendingReply = reply;
|
||||||
Monitor.Pulse(pendingReplyLock);
|
Monitor.Pulse(pendingReplyLock);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// display something
|
// display something
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GamesReply WaitForGamesReply()
|
private GamesReply WaitForGamesReply() {
|
||||||
{
|
lock (pendingReplyLock) {
|
||||||
lock (pendingReplyLock)
|
while (listen) {
|
||||||
{
|
if (pendingReply != null) {
|
||||||
while (listen)
|
|
||||||
{
|
|
||||||
if (pendingReply != null)
|
|
||||||
{
|
|
||||||
var reply = pendingReply;
|
var reply = pendingReply;
|
||||||
pendingReply = null;
|
pendingReply = null;
|
||||||
return reply;
|
return reply;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Monitor.Wait(pendingReplyLock);
|
Monitor.Wait(pendingReplyLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,27 +247,18 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePendingLobbyUpdates()
|
public void HandlePendingLobbyUpdates() {
|
||||||
{
|
|
||||||
listen = true;
|
listen = true;
|
||||||
var _ = eagleConnection.EnterLobby(_handleLobbyAction);
|
var _ = eagleConnection.EnterLobby(_handleLobbyAction);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
while (listen) {
|
||||||
while (listen)
|
|
||||||
{
|
|
||||||
var reply = WaitForGamesReply();
|
var reply = WaitForGamesReply();
|
||||||
|
|
||||||
if (reply != null)
|
if (reply != null) { _handleGamesReply(reply); }
|
||||||
{
|
|
||||||
_handleGamesReply(reply);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally
|
lock (pendingReplyLock) {
|
||||||
{
|
|
||||||
lock (pendingReplyLock)
|
|
||||||
{
|
|
||||||
eagleConnection.LeaveLobby();
|
eagleConnection.LeaveLobby();
|
||||||
listen = false;
|
listen = false;
|
||||||
pendingReply = null;
|
pendingReply = null;
|
||||||
@@ -287,14 +266,9 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartListeningForLobbyUpdates()
|
public void StartListeningForLobbyUpdates() {
|
||||||
{
|
lock (pendingReplyLock) {
|
||||||
lock (pendingReplyLock)
|
if (lobbyUpdatesThread != null) { Debug.Log("Handle updates thread already exists!"); }
|
||||||
{
|
|
||||||
if (lobbyUpdatesThread != null)
|
|
||||||
{
|
|
||||||
Debug.Log("Handle updates thread already exists!");
|
|
||||||
}
|
|
||||||
lobbyUpdatesThread = new Thread(HandlePendingLobbyUpdates);
|
lobbyUpdatesThread = new Thread(HandlePendingLobbyUpdates);
|
||||||
lobbyUpdatesThread.Start();
|
lobbyUpdatesThread.Start();
|
||||||
|
|
||||||
@@ -302,12 +276,9 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopListeningForLobbyUpdates()
|
public void StopListeningForLobbyUpdates() {
|
||||||
{
|
lock (pendingReplyLock) {
|
||||||
lock (pendingReplyLock)
|
if (lobbyUpdatesThread != null) {
|
||||||
{
|
|
||||||
if (lobbyUpdatesThread != null)
|
|
||||||
{
|
|
||||||
listen = false;
|
listen = false;
|
||||||
Monitor.Pulse(pendingReplyLock);
|
Monitor.Pulse(pendingReplyLock);
|
||||||
lobbyUpdatesThread.Join(50);
|
lobbyUpdatesThread.Join(50);
|
||||||
@@ -316,9 +287,7 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _createConnection()
|
private void _createConnection() {
|
||||||
{
|
|
||||||
|
|
||||||
PlayerPrefs.SetString(urlKey, urlField.text);
|
PlayerPrefs.SetString(urlKey, urlField.text);
|
||||||
PlayerPrefs.SetString(nameKey, nameField.text);
|
PlayerPrefs.SetString(nameKey, nameField.text);
|
||||||
PlayerPrefs.SetString(passwordKey, passwordField.text);
|
PlayerPrefs.SetString(passwordKey, passwordField.text);
|
||||||
@@ -326,8 +295,7 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
eagleConnection = new EagleConnection(nameField.text, passwordField.text, urlField.text);
|
eagleConnection = new EagleConnection(nameField.text, passwordField.text, urlField.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _internalCustomBattle()
|
private void _internalCustomBattle() {
|
||||||
{
|
|
||||||
_createConnection();
|
_createConnection();
|
||||||
|
|
||||||
setCustomBattleActive(true);
|
setCustomBattleActive(true);
|
||||||
@@ -336,128 +304,93 @@ public class ConnectionHandler : MonoBehaviour
|
|||||||
customBattlePanel.SetActive(true);
|
customBattlePanel.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _internalConnectEagle()
|
private void _internalConnectEagle() {
|
||||||
{
|
|
||||||
setLobbyActive(true);
|
setLobbyActive(true);
|
||||||
|
|
||||||
_createConnection();
|
_createConnection();
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
StartListeningForLobbyUpdates();
|
StartListeningForLobbyUpdates();
|
||||||
}
|
} catch (RpcException e) {
|
||||||
catch (RpcException e)
|
MainQueue.Q.Enqueue(() => { errorPanel.Add(e); });
|
||||||
{
|
} catch (Exception e) {
|
||||||
MainQueue.Q.Enqueue(() =>
|
MainQueue.Q.Enqueue(() => { errorPanel.Add(e); });
|
||||||
{
|
|
||||||
errorPanel.Add(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MainQueue.Q.Enqueue(() =>
|
|
||||||
{
|
|
||||||
errorPanel.Add(e);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinGame(long gameId, string leaderName)
|
public void JoinGame(long gameId, string leaderName) {
|
||||||
{
|
|
||||||
var game = _internalJoinEagleGame(gameId, leaderName);
|
var game = _internalJoinEagleGame(gameId, leaderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateGame(string leaderName, int humanPlayerCount, int totalPlayerCount)
|
public void CreateGame(string leaderName, int humanPlayerCount, int totalPlayerCount) {
|
||||||
{
|
|
||||||
var game = _internalCreateGame(leaderName, humanPlayerCount, totalPlayerCount);
|
var game = _internalCreateGame(leaderName, humanPlayerCount, totalPlayerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QuitButtonClicked()
|
public void QuitButtonClicked() { Application.Quit(); }
|
||||||
{
|
|
||||||
Application.Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _handleJoinGameResponse(JoinGameResponse response)
|
private void _handleJoinGameResponse(JoinGameResponse response) {
|
||||||
{
|
try {
|
||||||
try
|
switch (response.Result) {
|
||||||
{
|
case JoinGameResult.SuccessJoinGameResult: break;
|
||||||
switch (response.Result)
|
|
||||||
{
|
|
||||||
case JoinGameResult.SuccessJoinGameResult:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// FIXME: display something
|
// FIXME: display something
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) { Console.WriteLine(e.ToString()); }
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task _internalCreateGame(string desiredLeader, int humanPlayerCount, int totalPlayerCount)
|
private async Task
|
||||||
{
|
_internalCreateGame(string desiredLeader, int humanPlayerCount, int totalPlayerCount) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
var joinGameResponse = await eagleConnection.EagleGrpcClient.CreateGameAsync(
|
var joinGameResponse = await eagleConnection.EagleGrpcClient.CreateGameAsync(
|
||||||
new CreateGameRequest
|
new CreateGameRequest {
|
||||||
{
|
DesiredLeader = desiredLeader,
|
||||||
DesiredLeader = desiredLeader,
|
TotalPlayerCount = totalPlayerCount,
|
||||||
TotalPlayerCount = totalPlayerCount,
|
HumanPlayerCount = humanPlayerCount
|
||||||
HumanPlayerCount = humanPlayerCount
|
},
|
||||||
},
|
cancellationToken: EagleConnection.EagleCancellationToken);
|
||||||
cancellationToken: EagleConnection.EagleCancellationToken
|
|
||||||
);
|
|
||||||
|
|
||||||
_handleJoinGameResponse(joinGameResponse);
|
_handleJoinGameResponse(joinGameResponse);
|
||||||
}
|
} catch (WebException e) {
|
||||||
catch (WebException e)
|
|
||||||
{
|
|
||||||
Debug.Log(String.Format("Caught exception in BeginGetResponse {0}", e.Message));
|
Debug.Log(String.Format("Caught exception in BeginGetResponse {0}", e.Message));
|
||||||
setLobbyActive(true);
|
setLobbyActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task _internalJoinEagleGame(long gameId, string leaderName)
|
private async Task _internalJoinEagleGame(long gameId, string leaderName) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
var joinGameResponse = await eagleConnection.EagleGrpcClient.JoinGameAsync(
|
var joinGameResponse = await eagleConnection.EagleGrpcClient.JoinGameAsync(
|
||||||
new JoinGameRequest { GameId = gameId, DesiredLeader = leaderName },
|
new JoinGameRequest { GameId = gameId, DesiredLeader = leaderName },
|
||||||
cancellationToken: EagleConnection.EagleCancellationToken
|
cancellationToken: EagleConnection.EagleCancellationToken);
|
||||||
);
|
|
||||||
|
|
||||||
_handleJoinGameResponse(joinGameResponse);
|
_handleJoinGameResponse(joinGameResponse);
|
||||||
}
|
} catch (WebException e) {
|
||||||
catch (WebException e)
|
|
||||||
{
|
|
||||||
Debug.Log(String.Format("Caught exception in BeginGetResponse {0}", e.Message));
|
Debug.Log(String.Format("Caught exception in BeginGetResponse {0}", e.Message));
|
||||||
setLobbyActive(true);
|
setLobbyActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLobbyActive(bool active)
|
private void setLobbyActive(bool active) {
|
||||||
{
|
|
||||||
runningGamesListArea.SetActive(active);
|
runningGamesListArea.SetActive(active);
|
||||||
availableGamesListArea.SetActive(active);
|
availableGamesListArea.SetActive(active);
|
||||||
StopListeningForLobbyUpdates();
|
StopListeningForLobbyUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCustomBattleActive(bool active)
|
private void setCustomBattleActive(bool active) {
|
||||||
{
|
|
||||||
StopListeningForLobbyUpdates();
|
StopListeningForLobbyUpdates();
|
||||||
|
|
||||||
customBattleHandler.SetActive(eagleConnection);
|
customBattleHandler.SetActive(eagleConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectEagleGame(long gameId)
|
public void SelectEagleGame(long gameId) {
|
||||||
{
|
|
||||||
setLobbyActive(false);
|
setLobbyActive(false);
|
||||||
var gameInfo = fetchedRunningGames.Find(gi => gi.GameId == gameId);
|
var gameInfo = fetchedRunningGames.Find(gi => gi.GameId == gameId);
|
||||||
|
|
||||||
eagleCanvas.GetComponent<EagleGameController>().SetUpGame(gameInfo.GameId, gameInfo.FactionId, eagleConnection);
|
eagleCanvas.GetComponent<EagleGameController>().SetUpGame(
|
||||||
|
gameInfo.GameId,
|
||||||
|
gameInfo.FactionId,
|
||||||
|
eagleConnection);
|
||||||
connectionCanvas.enabled = false;
|
connectionCanvas.enabled = false;
|
||||||
connectionCanvas.gameObject.SetActive(false);
|
connectionCanvas.gameObject.SetActive(false);
|
||||||
eagleCanvas.gameObject.SetActive(true);
|
eagleCanvas.gameObject.SetActive(true);
|
||||||
|
|||||||
+29
-42
@@ -6,8 +6,7 @@ using TMPro;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
public class CreateGameItem : MonoBehaviour
|
public class CreateGameItem : MonoBehaviour {
|
||||||
{
|
|
||||||
public eagle.HeroDropdownController heroDropdownController;
|
public eagle.HeroDropdownController heroDropdownController;
|
||||||
public TMP_Dropdown totalHumansDropdown;
|
public TMP_Dropdown totalHumansDropdown;
|
||||||
public TMP_Dropdown totalPlayersDropdown;
|
public TMP_Dropdown totalPlayersDropdown;
|
||||||
@@ -18,64 +17,53 @@ public class CreateGameItem : MonoBehaviour
|
|||||||
|
|
||||||
private List<AvailableLeader> availableLeaders;
|
private List<AvailableLeader> availableLeaders;
|
||||||
|
|
||||||
public string SelectedLeader
|
public string SelectedLeader {
|
||||||
{
|
get {
|
||||||
get
|
if (heroDropdownController.SelectedHeroId == 0) {
|
||||||
{
|
|
||||||
if (heroDropdownController.SelectedHeroId == 0)
|
|
||||||
{
|
|
||||||
var index = new System.Random().Next(availableLeaders.Count);
|
var index = new System.Random().Next(availableLeaders.Count);
|
||||||
return availableLeaders[index].Name;
|
return availableLeaders[index].Name;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return availableLeaders[heroDropdownController.SelectedHeroId - 1].Name;
|
return availableLeaders[heroDropdownController.SelectedHeroId - 1].Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
public void LeaderDropdownSelected(TMP_Dropdown dropdown) {}
|
||||||
|
|
||||||
|
public void TotalPlayersDropdownSelected(TMP_Dropdown dropdown) { SetHumanPlayersDropdown(); }
|
||||||
|
|
||||||
|
public void CreateClicked() {
|
||||||
|
CreateCallback(
|
||||||
|
SelectedLeader,
|
||||||
|
totalHumansDropdown.value + 1,
|
||||||
|
totalPlayersDropdown.value + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LeaderDropdownSelected(TMP_Dropdown dropdown)
|
public void SetHumanPlayersDropdown() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TotalPlayersDropdownSelected(TMP_Dropdown dropdown)
|
|
||||||
{
|
|
||||||
SetHumanPlayersDropdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateClicked()
|
|
||||||
{
|
|
||||||
CreateCallback(SelectedLeader, totalHumansDropdown.value + 1, totalPlayersDropdown.value + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetHumanPlayersDropdown()
|
|
||||||
{
|
|
||||||
var currentValue = totalHumansDropdown.value;
|
var currentValue = totalHumansDropdown.value;
|
||||||
totalHumansDropdown.ClearOptions();
|
totalHumansDropdown.ClearOptions();
|
||||||
totalHumansDropdown.AddOptions(
|
totalHumansDropdown.AddOptions(Enumerable.Range(1, totalPlayersDropdown.value + 1)
|
||||||
Enumerable.Range(1, totalPlayersDropdown.value + 1).Select(i => i.ToString()).ToList()
|
.Select(i => i.ToString())
|
||||||
);
|
.ToList());
|
||||||
totalHumansDropdown.value = Math.Min(totalPlayersDropdown.value, currentValue);
|
totalHumansDropdown.value = Math.Min(totalPlayersDropdown.value, currentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCreationOptions(List<AvailableLeader> leaders, int maxPlayerCount)
|
public void SetCreationOptions(List<AvailableLeader> leaders, int maxPlayerCount) {
|
||||||
{
|
|
||||||
this.availableLeaders = leaders;
|
this.availableLeaders = leaders;
|
||||||
|
|
||||||
buttonText.text = "CREATE";
|
buttonText.text = "CREATE";
|
||||||
|
|
||||||
List<HeroView> heroOptions = new List<HeroView> { new HeroView { Name = "Random", Id = 0, Profession = Net.Eagle0.Eagle.Common.Profession.NoProfession } };
|
List<HeroView> heroOptions = new List<HeroView> { new HeroView {
|
||||||
for (int i = 0; i < leaders.Count; i++)
|
Name = "Random",
|
||||||
{
|
Id = 0,
|
||||||
|
Profession = Net.Eagle0.Eagle.Common.Profession.NoProfession
|
||||||
|
} };
|
||||||
|
for (int i = 0; i < leaders.Count; i++) {
|
||||||
var leader = leaders[i];
|
var leader = leaders[i];
|
||||||
heroOptions.Add(new HeroView
|
heroOptions.Add(new HeroView {
|
||||||
{
|
|
||||||
Name = leader.Name,
|
Name = leader.Name,
|
||||||
Profession = leader.Profession,
|
Profession = leader.Profession,
|
||||||
Id = i + 1,
|
Id = i + 1,
|
||||||
@@ -88,8 +76,7 @@ public class CreateGameItem : MonoBehaviour
|
|||||||
|
|
||||||
totalPlayersDropdown.ClearOptions();
|
totalPlayersDropdown.ClearOptions();
|
||||||
totalPlayersDropdown.AddOptions(
|
totalPlayersDropdown.AddOptions(
|
||||||
Enumerable.Range(1, maxPlayerCount).Select(i => i.ToString()).ToList()
|
Enumerable.Range(1, maxPlayerCount).Select(i => i.ToString()).ToList());
|
||||||
);
|
|
||||||
totalPlayersDropdown.value = Math.Min(6, maxPlayerCount - 1);
|
totalPlayersDropdown.value = Math.Min(6, maxPlayerCount - 1);
|
||||||
|
|
||||||
SetHumanPlayersDropdown();
|
SetHumanPlayersDropdown();
|
||||||
|
|||||||
+153
-211
@@ -16,8 +16,7 @@ using UnityEngine.UI;
|
|||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
||||||
|
|
||||||
public class CustomBattleHandler : MonoBehaviour
|
public class CustomBattleHandler : MonoBehaviour {
|
||||||
{
|
|
||||||
public GameObject yourArmiesArea;
|
public GameObject yourArmiesArea;
|
||||||
public GameObject aiArmiesArea;
|
public GameObject aiArmiesArea;
|
||||||
public Canvas shardokCanvas;
|
public Canvas shardokCanvas;
|
||||||
@@ -46,27 +45,26 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
private AWSResourceFetcher resourceFetcher;
|
private AWSResourceFetcher resourceFetcher;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetActive(EagleConnection conn)
|
public void SetActive(EagleConnection conn) {
|
||||||
{
|
|
||||||
eagleConnection = conn;
|
eagleConnection = conn;
|
||||||
resourceFetcher = GetComponent<AWSResourceFetcher>();
|
resourceFetcher = GetComponent<AWSResourceFetcher>();
|
||||||
resourceFetcher.EagleConnection = conn;
|
resourceFetcher.EagleConnection = conn;
|
||||||
|
|
||||||
var random = new System.Random();
|
var random = new System.Random();
|
||||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
string gameId = new string(Enumerable.Repeat(chars, 25).Select(s => s[random.Next(s.Length)]).ToArray());
|
string gameId = new string(
|
||||||
|
Enumerable.Repeat(chars, 25).Select(s => s[random.Next(s.Length)]).ToArray());
|
||||||
|
|
||||||
gameRequest = new Net.Eagle0.Common.NewGameRequest
|
gameRequest = new Net.Eagle0.Common.NewGameRequest {
|
||||||
{
|
|
||||||
GameId = gameId,
|
GameId = gameId,
|
||||||
Month = monthDropdown.value + 1
|
Month = monthDropdown.value + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
MapNames = eagleConnection.EagleGrpcClient.GetHexMapNames(new Net.Eagle0.Eagle.Api.HexMapNamesRequest()).MapNames.ToList();
|
MapNames = eagleConnection.EagleGrpcClient
|
||||||
|
.GetHexMapNames(new Net.Eagle0.Eagle.Api.HexMapNamesRequest())
|
||||||
|
.MapNames.ToList();
|
||||||
MapNames.Sort();
|
MapNames.Sort();
|
||||||
|
|
||||||
mapDropdown.options = MapNames.Select(name => new TMP_Dropdown.OptionData(name)).ToList();
|
mapDropdown.options = MapNames.Select(name => new TMP_Dropdown.OptionData(name)).ToList();
|
||||||
@@ -77,18 +75,15 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
|
|
||||||
AddAIArmy();
|
AddAIArmy();
|
||||||
aiArmiesArea.SetActive(true);
|
aiArmiesArea.SetActive(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void StartCustomBattle()
|
public async void StartCustomBattle() {
|
||||||
{
|
|
||||||
Dictionary<int, string> heroNames = new Dictionary<int, string>();
|
Dictionary<int, string> heroNames = new Dictionary<int, string>();
|
||||||
int nextEagleHeroId = 1;
|
int nextEagleHeroId = 1;
|
||||||
|
|
||||||
bool youAreDefender = defenderToggle.isOn;
|
bool youAreDefender = defenderToggle.isOn;
|
||||||
|
|
||||||
var yourSetupInfo = new Net.Eagle0.Common.PlayerSetupInfo
|
var yourSetupInfo = new Net.Eagle0.Common.PlayerSetupInfo {
|
||||||
{
|
|
||||||
UserName = eagleConnection.PlayerName,
|
UserName = eagleConnection.PlayerName,
|
||||||
Defender = youAreDefender,
|
Defender = youAreDefender,
|
||||||
EagleFactionId = 1,
|
EagleFactionId = 1,
|
||||||
@@ -97,18 +92,15 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
};
|
};
|
||||||
|
|
||||||
yourSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.LastPlayerStanding);
|
yourSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.LastPlayerStanding);
|
||||||
if (youAreDefender)
|
if (youAreDefender) {
|
||||||
{
|
yourSetupInfo.VictoryConditions.Add(
|
||||||
yourSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.WinAfterMaxRounds);
|
Net.Eagle0.Common.VictoryCondition.WinAfterMaxRounds);
|
||||||
}
|
} else {
|
||||||
else
|
yourSetupInfo.VictoryConditions.Add(
|
||||||
{
|
Net.Eagle0.Common.VictoryCondition.HoldsCriticalTiles);
|
||||||
yourSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.HoldsCriticalTiles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < yourUnitsController.RowCount; i++)
|
for (int i = 0; i < yourUnitsController.RowCount; i++) {
|
||||||
{
|
|
||||||
|
|
||||||
var unit = yourUnitsController.ComponentAt<CustomUnitRowController>(i).Unit;
|
var unit = yourUnitsController.ComponentAt<CustomUnitRowController>(i).Unit;
|
||||||
unit.Hero.EagleHeroId = nextEagleHeroId;
|
unit.Hero.EagleHeroId = nextEagleHeroId;
|
||||||
yourSetupInfo.Units.Add(unit);
|
yourSetupInfo.Units.Add(unit);
|
||||||
@@ -116,8 +108,7 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
nextEagleHeroId++;
|
nextEagleHeroId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var aiSetupInfo = new Net.Eagle0.Common.PlayerSetupInfo
|
var aiSetupInfo = new Net.Eagle0.Common.PlayerSetupInfo {
|
||||||
{
|
|
||||||
UserName = "AI",
|
UserName = "AI",
|
||||||
Defender = !youAreDefender,
|
Defender = !youAreDefender,
|
||||||
EagleFactionId = 2,
|
EagleFactionId = 2,
|
||||||
@@ -126,17 +117,14 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
};
|
};
|
||||||
|
|
||||||
aiSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.LastPlayerStanding);
|
aiSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.LastPlayerStanding);
|
||||||
if (youAreDefender)
|
if (youAreDefender) {
|
||||||
{
|
aiSetupInfo.VictoryConditions.Add(
|
||||||
aiSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.HoldsCriticalTiles);
|
Net.Eagle0.Common.VictoryCondition.HoldsCriticalTiles);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
aiSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.WinAfterMaxRounds);
|
aiSetupInfo.VictoryConditions.Add(Net.Eagle0.Common.VictoryCondition.WinAfterMaxRounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < aiUnitsController.RowCount; i++)
|
for (int i = 0; i < aiUnitsController.RowCount; i++) {
|
||||||
{
|
|
||||||
var unit = aiUnitsController.ComponentAt<CustomUnitRowController>(i).Unit;
|
var unit = aiUnitsController.ComponentAt<CustomUnitRowController>(i).Unit;
|
||||||
unit.Hero.EagleHeroId = nextEagleHeroId;
|
unit.Hero.EagleHeroId = nextEagleHeroId;
|
||||||
aiSetupInfo.Units.Add(unit);
|
aiSetupInfo.Units.Add(unit);
|
||||||
@@ -148,43 +136,36 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
|
|
||||||
gameRequest.UserInfos.Clear();
|
gameRequest.UserInfos.Clear();
|
||||||
List<Net.Eagle0.Common.PlayerSetupInfo> userInfos =
|
List<Net.Eagle0.Common.PlayerSetupInfo> userInfos =
|
||||||
youAreDefender ?
|
youAreDefender ? new List<Net.Eagle0.Common
|
||||||
new List<Net.Eagle0.Common.PlayerSetupInfo>()
|
.PlayerSetupInfo>() { aiSetupInfo, yourSetupInfo }
|
||||||
{
|
: new List<Net.Eagle0.Common.PlayerSetupInfo>() {
|
||||||
aiSetupInfo,
|
yourSetupInfo,
|
||||||
yourSetupInfo
|
aiSetupInfo
|
||||||
} : new List<Net.Eagle0.Common.PlayerSetupInfo>()
|
};
|
||||||
{
|
|
||||||
yourSetupInfo,
|
|
||||||
aiSetupInfo
|
|
||||||
};
|
|
||||||
gameRequest.UserInfos.Add(userInfos);
|
gameRequest.UserInfos.Add(userInfos);
|
||||||
|
|
||||||
var newGameResponse = eagleConnection.EagleGrpcClient.CreateCustomBattle(new CustomBattleRequest { NewGameRequest = gameRequest });
|
var newGameResponse = eagleConnection.EagleGrpcClient.CreateCustomBattle(
|
||||||
|
new CustomBattleRequest { NewGameRequest = gameRequest });
|
||||||
|
|
||||||
Int16 yourPid = (Int16)(youAreDefender ? 1 : 0);
|
Int16 yourPid = (Int16)(youAreDefender ? 1 : 0);
|
||||||
|
|
||||||
HexMap map = null;
|
HexMap map = null;
|
||||||
|
|
||||||
if (gameRequest.CustomMapBytes.IsEmpty)
|
if (gameRequest.CustomMapBytes.IsEmpty) {
|
||||||
{
|
map = (await eagleConnection.EagleGrpcClient.GetHexMapAsync(
|
||||||
map = (await eagleConnection.EagleGrpcClient.GetHexMapAsync(new HexMapRequest { MapName = gameRequest.HexMapName })).Map;
|
new HexMapRequest { MapName = gameRequest.HexMapName }))
|
||||||
}
|
.Map;
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
map = HexMap.Parser.ParseFrom(gameRequest.CustomMapBytes);
|
map = HexMap.Parser.ParseFrom(gameRequest.CustomMapBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
var players = new List<ShardokGameModel.PlayerWithHostility>()
|
var players = new List<ShardokGameModel.PlayerWithHostility>() {
|
||||||
{
|
new ShardokGameModel.PlayerWithHostility {
|
||||||
new ShardokGameModel.PlayerWithHostility
|
|
||||||
{
|
|
||||||
playerId = yourPid,
|
playerId = yourPid,
|
||||||
factionName = "You",
|
factionName = "You",
|
||||||
hostility = Net.Eagle0.Common.Hostility.SelfHostility
|
hostility = Net.Eagle0.Common.Hostility.SelfHostility
|
||||||
},
|
},
|
||||||
new ShardokGameModel.PlayerWithHostility
|
new ShardokGameModel.PlayerWithHostility {
|
||||||
{
|
|
||||||
playerId = youAreDefender ? 0 : 1,
|
playerId = youAreDefender ? 0 : 1,
|
||||||
factionName = "AI",
|
factionName = "AI",
|
||||||
hostility = Net.Eagle0.Common.Hostility.EnemyHostility
|
hostility = Net.Eagle0.Common.Hostility.EnemyHostility
|
||||||
@@ -192,54 +173,54 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
};
|
};
|
||||||
|
|
||||||
shardokModel = new ShardokGameModel(
|
shardokModel = new ShardokGameModel(
|
||||||
gameId: newGameResponse.ShardokGameId,
|
gameId: newGameResponse.ShardokGameId,
|
||||||
playerId: yourPid,
|
|
||||||
ecI: new RemoteEagleClient(
|
|
||||||
gameId: newGameResponse.EagleGameId,
|
|
||||||
client: eagleConnection.EagleGrpcClient,
|
|
||||||
creds: eagleConnection.Credentials,
|
|
||||||
playerId: yourPid,
|
playerId: yourPid,
|
||||||
token: EagleConnection.EagleCancellationToken),
|
ecI: new RemoteEagleClient(
|
||||||
map: map,
|
gameId: newGameResponse.EagleGameId,
|
||||||
locationName: "Custom Map",
|
client: eagleConnection.EagleGrpcClient,
|
||||||
month: gameRequest.Month,
|
creds: eagleConnection.Credentials,
|
||||||
players: players,
|
playerId: yourPid,
|
||||||
heroNames: heroNames,
|
token: EagleConnection.EagleCancellationToken),
|
||||||
battalionNames: new Dictionary<int, string> { { 0, "no name" } },
|
map: map,
|
||||||
headshotFetcher: (id) => resourceFetcher.GetImage("no_profession/male/000107.1333771077.png"));
|
locationName: "Custom Map",
|
||||||
|
month: gameRequest.Month,
|
||||||
|
players: players,
|
||||||
|
heroNames: heroNames,
|
||||||
|
battalionNames: new Dictionary<int, string> { { 0, "no name" } },
|
||||||
|
headshotFetcher: (id) =>
|
||||||
|
resourceFetcher.GetImage("no_profession/male/000107.1333771077.png"));
|
||||||
|
|
||||||
shardokCanvas.gameObject.SetActive(true);
|
shardokCanvas.gameObject.SetActive(true);
|
||||||
shardokCanvas.GetComponent<ShardokGameController>().SetUpGame(shardokModel);
|
shardokCanvas.GetComponent<ShardokGameController>().SetUpGame(shardokModel);
|
||||||
|
|
||||||
clientInterface = new RemoteEagleClient(newGameResponse.EagleGameId, eagleConnection.EagleGrpcClient, eagleConnection.Credentials, 1, EagleConnection.EagleCancellationToken);
|
clientInterface = new RemoteEagleClient(
|
||||||
|
newGameResponse.EagleGameId,
|
||||||
|
eagleConnection.EagleGrpcClient,
|
||||||
|
eagleConnection.Credentials,
|
||||||
|
1,
|
||||||
|
EagleConnection.EagleCancellationToken);
|
||||||
Register();
|
Register();
|
||||||
this.gameObject.SetActive(false);
|
this.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Register()
|
private void Register() {
|
||||||
{
|
clientInterface.RegisterForUpdates(
|
||||||
clientInterface.RegisterForUpdates(callback, 0, new List<ShardokViewStatus> {
|
callback,
|
||||||
new ShardokViewStatus
|
0,
|
||||||
{
|
new List<ShardokViewStatus> { new ShardokViewStatus {
|
||||||
ShardokGameId = shardokModel.GameId,
|
ShardokGameId = shardokModel.GameId,
|
||||||
FilteredResultCount = shardokModel.History.Count
|
FilteredResultCount = shardokModel.History.Count
|
||||||
}
|
} });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback(UpdateStreamResponse response, StatusCode statusCode)
|
void callback(UpdateStreamResponse response, StatusCode statusCode) {
|
||||||
{
|
if (response == null) {
|
||||||
if (response == null)
|
|
||||||
{
|
|
||||||
Register();
|
Register();
|
||||||
}
|
} else {
|
||||||
else
|
switch (response.ResponseDetailsCase) {
|
||||||
{
|
|
||||||
switch (response.ResponseDetailsCase)
|
|
||||||
{
|
|
||||||
case UpdateStreamResponse.ResponseDetailsOneofCase.ShardokActionResultResponse:
|
case UpdateStreamResponse.ResponseDetailsOneofCase.ShardokActionResultResponse:
|
||||||
foreach (var resp in response.ShardokActionResultResponse.ShardokGameResponses)
|
foreach (var resp in response.ShardokActionResultResponse
|
||||||
{
|
.ShardokGameResponses) {
|
||||||
shardokModel.HandleUpdates(resp.ActionResultViews, resp.NewResultViewCount);
|
shardokModel.HandleUpdates(resp.ActionResultViews, resp.NewResultViewCount);
|
||||||
shardokModel.HandleAvailableCommands(resp.AvailableCommands);
|
shardokModel.HandleAvailableCommands(resp.AvailableCommands);
|
||||||
}
|
}
|
||||||
@@ -251,13 +232,11 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpMap(HexMap hexMap, string mapName, Google.Protobuf.ByteString mapBytes)
|
private void SetUpMap(HexMap hexMap, string mapName, Google.Protobuf.ByteString mapBytes) {
|
||||||
{
|
|
||||||
attackerStartingPositions = new List<int>();
|
attackerStartingPositions = new List<int>();
|
||||||
for (int i = 0; i < hexMap.AttackerStartingPositions.Count; i++)
|
for (int i = 0; i < hexMap.AttackerStartingPositions.Count; i++) {
|
||||||
{
|
if (hexMap.AttackerStartingPositions[i] != null &&
|
||||||
if (hexMap.AttackerStartingPositions[i] != null && hexMap.AttackerStartingPositions[i].Positions.Count > 0)
|
hexMap.AttackerStartingPositions[i].Positions.Count > 0) {
|
||||||
{
|
|
||||||
attackerStartingPositions.Add(i);
|
attackerStartingPositions.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,74 +246,65 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
UpdateStartingPositions();
|
UpdateStartingPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MapSelected(int index)
|
public void MapSelected(int index) {
|
||||||
{
|
|
||||||
string mapName = MapNames[index];
|
string mapName = MapNames[index];
|
||||||
|
|
||||||
var mapResponse = eagleConnection.EagleGrpcClient.GetHexMap(new Net.Eagle0.Eagle.Api.HexMapRequest
|
var mapResponse = eagleConnection.EagleGrpcClient.GetHexMap(
|
||||||
{
|
new Net.Eagle0.Eagle.Api.HexMapRequest { MapName = mapName });
|
||||||
MapName = mapName
|
|
||||||
});
|
|
||||||
|
|
||||||
SetUpMap(mapResponse.Map, mapName, Google.Protobuf.ByteString.Empty);
|
SetUpMap(mapResponse.Map, mapName, Google.Protobuf.ByteString.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DefenderToggleClicked()
|
public void DefenderToggleClicked() { UpdateStartingPositions(); }
|
||||||
{
|
|
||||||
UpdateStartingPositions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateStartingPositions()
|
public void UpdateStartingPositions() {
|
||||||
{
|
var yourStartingPositions =
|
||||||
var yourStartingPositions = defenderToggle.isOn ? defenderStartingPositions : attackerStartingPositions;
|
defenderToggle.isOn ? defenderStartingPositions : attackerStartingPositions;
|
||||||
for (int i = 0; i < yourUnitsController.RowCount; i++)
|
for (int i = 0; i < yourUnitsController.RowCount; i++) {
|
||||||
{
|
yourUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions =
|
||||||
yourUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions = yourStartingPositions;
|
yourStartingPositions;
|
||||||
yourUnitsController.ComponentAt<CustomUnitRowController>(i).startingPosition.value = i / 10;
|
yourUnitsController.ComponentAt<CustomUnitRowController>(i).startingPosition.value =
|
||||||
|
i / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
var aiStartingPositions = defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
var aiStartingPositions =
|
||||||
for (int i = 0; i < aiUnitsController.RowCount; i++)
|
defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
||||||
{
|
for (int i = 0; i < aiUnitsController.RowCount; i++) {
|
||||||
aiUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions = aiStartingPositions;
|
aiUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions =
|
||||||
aiUnitsController.ComponentAt<CustomUnitRowController>(i).startingPosition.value = i / 10;
|
aiStartingPositions;
|
||||||
|
aiUnitsController.ComponentAt<CustomUnitRowController>(i).startingPosition.value =
|
||||||
|
i / 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int nextStartingPositionIndex(int startingPositionCount, EventBasedTable unitsTable)
|
private static int nextStartingPositionIndex(
|
||||||
{
|
int startingPositionCount,
|
||||||
|
EventBasedTable unitsTable) {
|
||||||
int[] currentCounts = new int[startingPositionCount];
|
int[] currentCounts = new int[startingPositionCount];
|
||||||
for (int i = 0; i < unitsTable.RowCount; i++)
|
for (int i = 0; i < unitsTable.RowCount; i++) {
|
||||||
{
|
currentCounts[unitsTable.ComponentAt<CustomUnitRowController>(i)
|
||||||
currentCounts[unitsTable.ComponentAt<CustomUnitRowController>(i).startingPosition.value]++;
|
.startingPosition.value]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < startingPositionCount; i++)
|
for (int i = 0; i < startingPositionCount; i++) {
|
||||||
{
|
if (currentCounts[i] < 10) { return i; }
|
||||||
if (currentCounts[i] < 10)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// we couldn't find an available starting position
|
// we couldn't find an available starting position
|
||||||
throw new ArgumentException("too many units");
|
throw new ArgumentException("too many units");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddYourArmy()
|
public void AddYourArmy() {
|
||||||
{
|
|
||||||
int index = yourUnitsController.RowCount;
|
int index = yourUnitsController.RowCount;
|
||||||
|
|
||||||
List<int> startingPositions;
|
List<int> startingPositions;
|
||||||
int nextStartingPos;
|
int nextStartingPos;
|
||||||
if (defenderToggle.isOn)
|
if (defenderToggle.isOn) {
|
||||||
{
|
|
||||||
startingPositions = defenderStartingPositions;
|
startingPositions = defenderStartingPositions;
|
||||||
nextStartingPos = 0;
|
nextStartingPos = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
startingPositions = attackerStartingPositions;
|
startingPositions = attackerStartingPositions;
|
||||||
nextStartingPos = nextStartingPositionIndex(startingPositions.Count, yourUnitsController);
|
nextStartingPos =
|
||||||
|
nextStartingPositionIndex(startingPositions.Count, yourUnitsController);
|
||||||
}
|
}
|
||||||
|
|
||||||
var row = yourUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
var row = yourUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
||||||
@@ -342,19 +312,15 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
row.startingPosition.value = nextStartingPos;
|
row.startingPosition.value = nextStartingPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAIArmy()
|
public void AddAIArmy() {
|
||||||
{
|
|
||||||
int index = aiUnitsController.RowCount;
|
int index = aiUnitsController.RowCount;
|
||||||
|
|
||||||
List<int> startingPositions;
|
List<int> startingPositions;
|
||||||
int nextStartingPos;
|
int nextStartingPos;
|
||||||
if (defenderToggle.isOn)
|
if (defenderToggle.isOn) {
|
||||||
{
|
|
||||||
startingPositions = attackerStartingPositions;
|
startingPositions = attackerStartingPositions;
|
||||||
nextStartingPos = nextStartingPositionIndex(startingPositions.Count, aiUnitsController);
|
nextStartingPos = nextStartingPositionIndex(startingPositions.Count, aiUnitsController);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
startingPositions = defenderStartingPositions;
|
startingPositions = defenderStartingPositions;
|
||||||
nextStartingPos = 0;
|
nextStartingPos = 0;
|
||||||
}
|
}
|
||||||
@@ -364,53 +330,43 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
row.startingPosition.value = nextStartingPos;
|
row.startingPosition.value = nextStartingPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadGameRequest()
|
public void LoadGameRequest() { StartCoroutine(ShowLoadGameRequestCoroutine()); }
|
||||||
{
|
|
||||||
StartCoroutine(ShowLoadGameRequestCoroutine());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadGameRequest(Net.Eagle0.Common.NewGameRequest request)
|
private void LoadGameRequest(Net.Eagle0.Common.NewGameRequest request) {
|
||||||
{
|
|
||||||
var gameId = request.GameId + gameRequest.GameId;
|
var gameId = request.GameId + gameRequest.GameId;
|
||||||
gameRequest = request;
|
gameRequest = request;
|
||||||
gameRequest.GameId = gameId;
|
gameRequest.GameId = gameId;
|
||||||
|
|
||||||
monthDropdown.value = gameRequest.Month - 1;
|
monthDropdown.value = gameRequest.Month - 1;
|
||||||
mapDropdown.value = mapDropdown.options.Select(opt => opt.text).ToList().IndexOf(gameRequest.HexMapName);
|
mapDropdown.value = mapDropdown.options.Select(opt => opt.text)
|
||||||
|
.ToList()
|
||||||
|
.IndexOf(gameRequest.HexMapName);
|
||||||
MapSelected(mapDropdown.value);
|
MapSelected(mapDropdown.value);
|
||||||
|
|
||||||
// FIXME: two hardcoded players
|
// FIXME: two hardcoded players
|
||||||
var yourInfo = gameRequest.UserInfos.Last();
|
var yourInfo = gameRequest.UserInfos.Last();
|
||||||
var aiInfo = gameRequest.UserInfos.First();
|
var aiInfo = gameRequest.UserInfos.First();
|
||||||
|
|
||||||
if (!yourInfo.Defender)
|
if (!yourInfo.Defender) { throw new ArgumentException("Second player must be defender"); }
|
||||||
{
|
|
||||||
throw new ArgumentException("Second player must be defender");
|
|
||||||
}
|
|
||||||
defenderToggle.isOn = true;
|
defenderToggle.isOn = true;
|
||||||
|
|
||||||
// FIXME: put some of this stuff straight into the gameinfo
|
// FIXME: put some of this stuff straight into the gameinfo
|
||||||
yourUnitsController.RowCount = yourInfo.Units.Count();
|
yourUnitsController.RowCount = yourInfo.Units.Count();
|
||||||
for (int i = 0; i < yourInfo.Units.Count(); i++)
|
for (int i = 0; i < yourInfo.Units.Count(); i++) {
|
||||||
{
|
yourUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions =
|
||||||
yourUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions = defenderToggle.isOn
|
defenderToggle.isOn ? defenderStartingPositions : attackerStartingPositions;
|
||||||
? defenderStartingPositions
|
|
||||||
: attackerStartingPositions;
|
|
||||||
yourUnitsController.ComponentAt<CustomUnitRowController>(i).Unit = yourInfo.Units[i];
|
yourUnitsController.ComponentAt<CustomUnitRowController>(i).Unit = yourInfo.Units[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
aiUnitsController.RowCount = aiInfo.Units.Count();
|
aiUnitsController.RowCount = aiInfo.Units.Count();
|
||||||
for (int i = 0; i < aiInfo.Units.Count(); i++)
|
for (int i = 0; i < aiInfo.Units.Count(); i++) {
|
||||||
{
|
aiUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions =
|
||||||
aiUnitsController.ComponentAt<CustomUnitRowController>(i).AvailableStartingPositions = defenderToggle.isOn
|
defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
||||||
? attackerStartingPositions
|
|
||||||
: defenderStartingPositions;
|
|
||||||
aiUnitsController.ComponentAt<CustomUnitRowController>(i).Unit = aiInfo.Units[i];
|
aiUnitsController.ComponentAt<CustomUnitRowController>(i).Unit = aiInfo.Units[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PerfButtonClicked()
|
public void PerfButtonClicked() {
|
||||||
{
|
|
||||||
var index = MapNames.IndexOf("Alah");
|
var index = MapNames.IndexOf("Alah");
|
||||||
mapDropdown.value = index;
|
mapDropdown.value = index;
|
||||||
MapSelected(index);
|
MapSelected(index);
|
||||||
@@ -418,21 +374,21 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
yourUnitsController.RowCount = 0;
|
yourUnitsController.RowCount = 0;
|
||||||
aiUnitsController.RowCount = 0;
|
aiUnitsController.RowCount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++) {
|
||||||
{
|
|
||||||
var rowIndex = i;
|
var rowIndex = i;
|
||||||
|
|
||||||
var aiRow = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
var aiRow = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
||||||
aiRow.AvailableStartingPositions = defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
aiRow.AvailableStartingPositions =
|
||||||
|
defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
||||||
aiRow.professionDropdown.value = i + 1;
|
aiRow.professionDropdown.value = i + 1;
|
||||||
|
|
||||||
var yourRow = yourUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
var yourRow = yourUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
||||||
yourRow.AvailableStartingPositions = defenderToggle.isOn ? defenderStartingPositions : attackerStartingPositions;
|
yourRow.AvailableStartingPositions =
|
||||||
|
defenderToggle.isOn ? defenderStartingPositions : attackerStartingPositions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RiversButtonClicked()
|
public void RiversButtonClicked() {
|
||||||
{
|
|
||||||
var index = MapNames.IndexOf("Chipingia");
|
var index = MapNames.IndexOf("Chipingia");
|
||||||
mapDropdown.value = index;
|
mapDropdown.value = index;
|
||||||
MapSelected(index);
|
MapSelected(index);
|
||||||
@@ -442,51 +398,41 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
var firstRow = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
var firstRow = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
||||||
firstRow.SelectedProfession = Net.Eagle0.Common.CommonProfession.Engineer;
|
firstRow.SelectedProfession = Net.Eagle0.Common.CommonProfession.Engineer;
|
||||||
firstRow.SelectedBattalionTypeId = Net.Eagle0.Common.CommonBattalionTypeId.HeavyInfantry;
|
firstRow.SelectedBattalionTypeId = Net.Eagle0.Common.CommonBattalionTypeId.HeavyInfantry;
|
||||||
firstRow.AvailableStartingPositions = defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
firstRow.AvailableStartingPositions =
|
||||||
|
defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
||||||
|
|
||||||
for (int i = 1; i < 5; i++)
|
for (int i = 1; i < 5; i++) {
|
||||||
{
|
|
||||||
var rowIndex = i;
|
var rowIndex = i;
|
||||||
|
|
||||||
var row = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
var row = aiUnitsController.AddRowWithComponent<CustomUnitRowController>();
|
||||||
row.SelectedBattalionTypeId = Net.Eagle0.Common.CommonBattalionTypeId.HeavyCavalry;
|
row.SelectedBattalionTypeId = Net.Eagle0.Common.CommonBattalionTypeId.HeavyCavalry;
|
||||||
row.AvailableStartingPositions = defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
row.AvailableStartingPositions =
|
||||||
|
defenderToggle.isOn ? attackerStartingPositions : defenderStartingPositions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CustomMapToggleClicked()
|
public void CustomMapToggleClicked() {
|
||||||
{
|
|
||||||
chooseMapButton.gameObject.SetActive(customMapToggle.isOn);
|
chooseMapButton.gameObject.SetActive(customMapToggle.isOn);
|
||||||
mapDropdown.gameObject.SetActive(!customMapToggle.isOn);
|
mapDropdown.gameObject.SetActive(!customMapToggle.isOn);
|
||||||
|
|
||||||
if (customMapToggle.isOn)
|
if (customMapToggle.isOn) {
|
||||||
{
|
if (gameRequest.CustomMapBytes.IsEmpty) { ChooseCustomMapButtonClicked(); }
|
||||||
if (gameRequest.CustomMapBytes.IsEmpty)
|
} else {
|
||||||
{
|
|
||||||
ChooseCustomMapButtonClicked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gameRequest.CustomMapBytes = ByteString.Empty;
|
gameRequest.CustomMapBytes = ByteString.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChooseCustomMapButtonClicked()
|
public void ChooseCustomMapButtonClicked() { StartCoroutine(ShowLoadCustomMapCoroutine()); }
|
||||||
{
|
|
||||||
StartCoroutine(ShowLoadCustomMapCoroutine());
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator ShowLoadGameRequestCoroutine()
|
IEnumerator ShowLoadGameRequestCoroutine() {
|
||||||
{
|
|
||||||
var initialPath = PlayerPrefs.GetString("gameRequestLocation", null);
|
var initialPath = PlayerPrefs.GetString("gameRequestLocation", null);
|
||||||
|
|
||||||
FileBrowser.SetFilters(true, new FileBrowser.Filter("Game Requests", ".e0gr"));
|
FileBrowser.SetFilters(true, new FileBrowser.Filter("Game Requests", ".e0gr"));
|
||||||
FileBrowser.SetDefaultFilter(".e0gr");
|
FileBrowser.SetDefaultFilter(".e0gr");
|
||||||
yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
yield return FileBrowser
|
||||||
|
.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
||||||
|
|
||||||
if (FileBrowser.Success)
|
if (FileBrowser.Success) {
|
||||||
{
|
|
||||||
var path = FileBrowser.Result[0];
|
var path = FileBrowser.Result[0];
|
||||||
var dirPath = Path.GetDirectoryName(path);
|
var dirPath = Path.GetDirectoryName(path);
|
||||||
PlayerPrefs.SetString("gameRequestLocation", dirPath);
|
PlayerPrefs.SetString("gameRequestLocation", dirPath);
|
||||||
@@ -496,16 +442,15 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator ShowLoadCustomMapCoroutine()
|
IEnumerator ShowLoadCustomMapCoroutine() {
|
||||||
{
|
|
||||||
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
||||||
|
|
||||||
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
||||||
FileBrowser.SetDefaultFilter(".e0mj");
|
FileBrowser.SetDefaultFilter(".e0mj");
|
||||||
yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
yield return FileBrowser
|
||||||
|
.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
||||||
|
|
||||||
if (FileBrowser.Success)
|
if (FileBrowser.Success) {
|
||||||
{
|
|
||||||
var path = FileBrowser.Result[0];
|
var path = FileBrowser.Result[0];
|
||||||
|
|
||||||
var mapJson = File.ReadAllText(path);
|
var mapJson = File.ReadAllText(path);
|
||||||
@@ -514,16 +459,13 @@ public class CustomBattleHandler : MonoBehaviour
|
|||||||
var map = jp.Parse<HexMap>(mapJson);
|
var map = jp.Parse<HexMap>(mapJson);
|
||||||
|
|
||||||
Google.Protobuf.ByteString bs = null;
|
Google.Protobuf.ByteString bs = null;
|
||||||
using (var stream = new MemoryStream())
|
using (var stream = new MemoryStream()) {
|
||||||
{
|
|
||||||
map.WriteTo(stream);
|
map.WriteTo(stream);
|
||||||
bs = Google.Protobuf.ByteString.CopyFrom(stream.ToArray());
|
bs = Google.Protobuf.ByteString.CopyFrom(stream.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpMap(map, "Custom", bs);
|
SetUpMap(map, "Custom", bs);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
customMapToggle.isOn = false;
|
customMapToggle.isOn = false;
|
||||||
CustomMapToggleClicked();
|
CustomMapToggleClicked();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-13
@@ -4,8 +4,7 @@ using TMPro;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
public class RunningGameItem : MonoBehaviour
|
public class RunningGameItem : MonoBehaviour {
|
||||||
{
|
|
||||||
public GameObject item;
|
public GameObject item;
|
||||||
public TextMeshProUGUI gameIdField;
|
public TextMeshProUGUI gameIdField;
|
||||||
public TextMeshProUGUI leaderField;
|
public TextMeshProUGUI leaderField;
|
||||||
@@ -16,21 +15,17 @@ public class RunningGameItem : MonoBehaviour
|
|||||||
private long gameId;
|
private long gameId;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void GoClicked() { GoCallback(gameId); }
|
||||||
|
|
||||||
public void GoClicked()
|
public void SetRunningGame(long gameId, AvailableLeader leader) {
|
||||||
{
|
|
||||||
GoCallback(gameId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRunningGame(long gameId, AvailableLeader leader)
|
|
||||||
{
|
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
|
|
||||||
gameIdField.text = string.Format("{0:X}", gameId);
|
gameIdField.text = string.Format("{0:X}", gameId);
|
||||||
leaderField.text = string.Format("{0} ({1})", leader.Name, eagle.DisplayNames.ProfessionNames[leader.Profession]);
|
leaderField.text = string.Format(
|
||||||
|
"{0} ({1})",
|
||||||
|
leader.Name,
|
||||||
|
eagle.DisplayNames.ProfessionNames[leader.Profession]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-9
@@ -2,24 +2,22 @@
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
public class WaitingGameItem : MonoBehaviour
|
public class WaitingGameItem : MonoBehaviour {
|
||||||
{
|
|
||||||
public GameObject item;
|
public GameObject item;
|
||||||
public TextMeshProUGUI gameIdField;
|
public TextMeshProUGUI gameIdField;
|
||||||
public TextMeshProUGUI leaderField;
|
public TextMeshProUGUI leaderField;
|
||||||
public TextMeshProUGUI playerCountField;
|
public TextMeshProUGUI playerCountField;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void SetWaitingGame(long gameId, string playersString, AvailableLeader leader) {
|
||||||
|
|
||||||
public void SetWaitingGame(long gameId, string playersString, AvailableLeader leader)
|
|
||||||
{
|
|
||||||
gameIdField.text = string.Format("{0:X}", gameId);
|
gameIdField.text = string.Format("{0:X}", gameId);
|
||||||
playerCountField.text = playersString;
|
playerCountField.text = playersString;
|
||||||
|
|
||||||
leaderField.text = string.Format("{0} ({1})", leader.Name, eagle.DisplayNames.ProfessionNames[leader.Profession]);
|
leaderField.text = string.Format(
|
||||||
|
"{0} ({1})",
|
||||||
|
leader.Name,
|
||||||
|
eagle.DisplayNames.ProfessionNames[leader.Profession]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,36 +3,29 @@ using Grpc.Core;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ConnectionKiller : MonoBehaviour
|
public class ConnectionKiller : MonoBehaviour {
|
||||||
{
|
private static CancellationTokenSource EagleGlobalShutdownTokenSource =
|
||||||
private static CancellationTokenSource EagleGlobalShutdownTokenSource = new CancellationTokenSource();
|
new CancellationTokenSource();
|
||||||
private static CancellationTokenSource ShardokGlobalShutdownTokenSource = new CancellationTokenSource();
|
private static CancellationTokenSource ShardokGlobalShutdownTokenSource =
|
||||||
|
new CancellationTokenSource();
|
||||||
public static CancellationToken EagleCancellationToken => EagleGlobalShutdownTokenSource.Token;
|
public static CancellationToken EagleCancellationToken => EagleGlobalShutdownTokenSource.Token;
|
||||||
public static CancellationToken ShardokCancellationToken => ShardokGlobalShutdownTokenSource.Token;
|
public static CancellationToken ShardokCancellationToken =>
|
||||||
|
ShardokGlobalShutdownTokenSource.Token;
|
||||||
|
|
||||||
public void OnApplicationQuit()
|
public void OnApplicationQuit() { ShutdownAll(); }
|
||||||
{
|
|
||||||
ShutdownAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
void OnPlayModeStateChanged(PlayModeStateChange state)
|
void OnPlayModeStateChanged(PlayModeStateChange state) {
|
||||||
{
|
if (state == PlayModeStateChange.ExitingPlayMode) { ShutdownAll(); }
|
||||||
if (state == PlayModeStateChange.ExitingPlayMode)
|
|
||||||
{
|
|
||||||
ShutdownAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static void ShutdownShardok()
|
public static void ShutdownShardok() {
|
||||||
{
|
|
||||||
ShardokGlobalShutdownTokenSource.Cancel();
|
ShardokGlobalShutdownTokenSource.Cancel();
|
||||||
ShardokGlobalShutdownTokenSource = new CancellationTokenSource();
|
ShardokGlobalShutdownTokenSource = new CancellationTokenSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShutdownAll()
|
private static void ShutdownAll() {
|
||||||
{
|
|
||||||
System.Console.Out.WriteLine("Attempting GRPC shutdown.");
|
System.Console.Out.WriteLine("Attempting GRPC shutdown.");
|
||||||
EagleGlobalShutdownTokenSource.Cancel();
|
EagleGlobalShutdownTokenSource.Cancel();
|
||||||
ShardokGlobalShutdownTokenSource.Cancel();
|
ShardokGlobalShutdownTokenSource.Cancel();
|
||||||
|
|||||||
@@ -3,30 +3,20 @@ using System.Collections.Generic;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public static class BattalionUtils {
|
||||||
public static class BattalionUtils
|
public static readonly IComparer<BattalionView> BattalionComparer =
|
||||||
{
|
new _BattalionComparer();
|
||||||
public static readonly IComparer<BattalionView> BattalionComparer = new _BattalionComparer();
|
|
||||||
|
|
||||||
private class _BattalionComparer : Comparer<BattalionView>
|
private class _BattalionComparer : Comparer<BattalionView> {
|
||||||
{
|
public override int Compare(BattalionView x, BattalionView y) {
|
||||||
public override int Compare(BattalionView x, BattalionView y)
|
if (x.Type.CompareTo(y.Type) != 0) {
|
||||||
{
|
|
||||||
if (x.Type.CompareTo(y.Type) != 0)
|
|
||||||
{
|
|
||||||
return x.Type.CompareTo(y.Type);
|
return x.Type.CompareTo(y.Type);
|
||||||
}
|
} else if (x.Size.CompareTo(y.Size) != 0) {
|
||||||
else if (x.Size.CompareTo(y.Size) != 0)
|
|
||||||
{
|
|
||||||
return -x.Size.CompareTo(y.Size);
|
return -x.Size.CompareTo(y.Size);
|
||||||
}
|
} else if ((x.Training + x.Armament).CompareTo(y.Training + y.Armament) != 0) {
|
||||||
else if ((x.Training + x.Armament).CompareTo(y.Training + y.Armament) != 0)
|
|
||||||
{
|
|
||||||
return -(x.Training + x.Armament).CompareTo(y.Training + y.Armament);
|
return -(x.Training + x.Armament).CompareTo(y.Training + y.Armament);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-14
@@ -1,23 +1,17 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class CommandButtonController : MonoBehaviour
|
public class CommandButtonController : MonoBehaviour {
|
||||||
{
|
|
||||||
public Button buttonPrefab;
|
public Button buttonPrefab;
|
||||||
public eagle.EagleGameController gameController;
|
public eagle.EagleGameController gameController;
|
||||||
|
|
||||||
void Start()
|
void Start() { ClearButtonContents(); }
|
||||||
{
|
|
||||||
ClearButtonContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetButtonContents(GUIContent[] contents)
|
public void SetButtonContents(GUIContent[] contents) {
|
||||||
{
|
|
||||||
ClearButtonContents();
|
ClearButtonContents();
|
||||||
|
|
||||||
int contentsCount = contents.Length;
|
int contentsCount = contents.Length;
|
||||||
for (int i = 0; i < contentsCount; i++)
|
for (int i = 0; i < contentsCount; i++) {
|
||||||
{
|
|
||||||
int buttonIndex = i;
|
int buttonIndex = i;
|
||||||
var newButton = Instantiate(buttonPrefab, gameObject.transform);
|
var newButton = Instantiate(buttonPrefab, gameObject.transform);
|
||||||
newButton.GetComponentInChildren<RawImage>().texture = contents[i].image;
|
newButton.GetComponentInChildren<RawImage>().texture = contents[i].image;
|
||||||
@@ -25,11 +19,9 @@ public class CommandButtonController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearButtonContents()
|
public void ClearButtonContents() {
|
||||||
{
|
|
||||||
int childCount = gameObject.transform.childCount;
|
int childCount = gameObject.transform.childCount;
|
||||||
for (int i = childCount - 1; i >= 0; i--)
|
for (int i = childCount - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
GameObject.Destroy(transform.GetChild(i).gameObject);
|
GameObject.Destroy(transform.GetChild(i).gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-94
@@ -6,29 +6,27 @@ using TMPro;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using CommandType = AvailableCommand.SealedValueOneofCase;
|
using CommandType = AvailableCommand.SealedValueOneofCase;
|
||||||
|
|
||||||
public class CommandPanelController : MonoBehaviour
|
public class CommandPanelController : MonoBehaviour {
|
||||||
{
|
|
||||||
public EagleGameController mainController;
|
public EagleGameController mainController;
|
||||||
|
|
||||||
public CommandSelector _selector;
|
public CommandSelector _selector;
|
||||||
public CommandSelector Selector
|
public CommandSelector Selector {
|
||||||
{
|
|
||||||
get => _selector;
|
get => _selector;
|
||||||
private set
|
private
|
||||||
{
|
set {
|
||||||
if (_selector != value)
|
if (_selector != value) {
|
||||||
{
|
|
||||||
if (_selector != null) _selector.Hide();
|
if (_selector != null) _selector.Hide();
|
||||||
_selector = value;
|
_selector = value;
|
||||||
if (_selector != null) _selector.Show();
|
if (_selector != null) _selector.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SelectedCommand SelectedCommand { get { return Selector == null ? null : Selector.Command; } }
|
public SelectedCommand SelectedCommand {
|
||||||
|
get { return Selector == null ? null : Selector.Command; }
|
||||||
|
}
|
||||||
|
|
||||||
public TMP_Text headerLabel;
|
public TMP_Text headerLabel;
|
||||||
public Button commitCommandButton;
|
public Button commitCommandButton;
|
||||||
@@ -39,27 +37,20 @@ namespace eagle
|
|||||||
public CommandWarningPanelController commandWarningPanelController;
|
public CommandWarningPanelController commandWarningPanelController;
|
||||||
|
|
||||||
private AvailableCommand _availableCommand;
|
private AvailableCommand _availableCommand;
|
||||||
public AvailableCommand AvailableCommand
|
public AvailableCommand AvailableCommand {
|
||||||
{
|
|
||||||
get => _availableCommand;
|
get => _availableCommand;
|
||||||
private set
|
private
|
||||||
{
|
set {
|
||||||
if (_availableCommand != value)
|
if (_availableCommand != value) { _availableCommand = value; }
|
||||||
{
|
|
||||||
_availableCommand = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAvailableCommandAndSelector(AvailableCommand cmd, CommandSelector sel)
|
public void SetAvailableCommandAndSelector(AvailableCommand cmd, CommandSelector sel) {
|
||||||
{
|
|
||||||
AvailableCommand = cmd;
|
AvailableCommand = cmd;
|
||||||
Selector = sel;
|
Selector = sel;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (AvailableCommand == null) {
|
||||||
if (AvailableCommand == null)
|
|
||||||
{
|
|
||||||
Selector = null;
|
Selector = null;
|
||||||
headerLabel.text = null;
|
headerLabel.text = null;
|
||||||
return;
|
return;
|
||||||
@@ -67,18 +58,13 @@ namespace eagle
|
|||||||
|
|
||||||
Selector.UpdateAvailableCommand(Model, AvailableCommand);
|
Selector.UpdateAvailableCommand(Model, AvailableCommand);
|
||||||
headerLabel.text = Selector.HeaderString;
|
headerLabel.text = Selector.HeaderString;
|
||||||
}
|
} catch (Exception e) { errorPanel.Add(e); }
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
errorPanel.Add(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CommandSelector> AppropriateSelectors(AvailableCommand cmd) =>
|
public List<CommandSelector> AppropriateSelectors(AvailableCommand cmd) =>
|
||||||
commandSelectors.FindAll(sel => sel.IsAppropriateFor(cmd));
|
commandSelectors.FindAll(sel => sel.IsAppropriateFor(cmd));
|
||||||
|
|
||||||
public List<GUIContent> ButtonContentsForCommand(AvailableCommand cmd)
|
public List<GUIContent> ButtonContentsForCommand(AvailableCommand cmd) {
|
||||||
{
|
|
||||||
return (from sel in AppropriateSelectors(cmd)
|
return (from sel in AppropriateSelectors(cmd)
|
||||||
where sel.ButtonImage != null
|
where sel.ButtonImage != null
|
||||||
select new GUIContent(sel.ButtonImage, sel.HeaderString)).ToList();
|
select new GUIContent(sel.ButtonImage, sel.HeaderString)).ToList();
|
||||||
@@ -86,97 +72,71 @@ namespace eagle
|
|||||||
|
|
||||||
private List<CommandSelector> commandSelectors;
|
private List<CommandSelector> commandSelectors;
|
||||||
|
|
||||||
public void Awake()
|
public void Awake() {
|
||||||
{
|
|
||||||
commandSelectors = new List<CommandSelector>();
|
commandSelectors = new List<CommandSelector>();
|
||||||
|
|
||||||
foreach (Transform child in gameObject.transform)
|
foreach (Transform child in gameObject.transform) {
|
||||||
{
|
|
||||||
var sel = child.gameObject.GetComponent<CommandSelector>();
|
var sel = child.gameObject.GetComponent<CommandSelector>();
|
||||||
if (sel != null)
|
if (sel != null) { commandSelectors.Add(sel); }
|
||||||
{
|
|
||||||
commandSelectors.Add(sel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var kvp in commandSelectors)
|
foreach (var kvp in commandSelectors) {
|
||||||
{
|
|
||||||
kvp.SetFocusInfoPanelController(focusPanel);
|
kvp.SetFocusInfoPanelController(focusPanel);
|
||||||
kvp.gameObject.SetActive(true);
|
kvp.gameObject.SetActive(true);
|
||||||
kvp.Hide();
|
kvp.Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start() {
|
||||||
{
|
foreach (var kvp in commandSelectors) { kvp.gameObject.SetActive(false); }
|
||||||
foreach (var kvp in commandSelectors)
|
|
||||||
{
|
|
||||||
kvp.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PointerEnteredCommitButton()
|
public void PointerEnteredCommitButton() {
|
||||||
{
|
if (Selector != null) {
|
||||||
if (Selector != null)
|
if (!Selector.EnableCommitButton) {
|
||||||
{
|
if (Selector.DisabledCommitButtonReason == null ||
|
||||||
if (!Selector.EnableCommitButton)
|
Selector.DisabledCommitButtonReason == "") {
|
||||||
{
|
commandWarningPanelController.SetWarning(
|
||||||
if (Selector.DisabledCommitButtonReason == null || Selector.DisabledCommitButtonReason == "")
|
"Invalid",
|
||||||
{
|
"CROSBY NEEDS TO PUT SOME TEXT HERE");
|
||||||
commandWarningPanelController.SetWarning("Invalid", "CROSBY NEEDS TO PUT SOME TEXT HERE");
|
} else {
|
||||||
|
commandWarningPanelController.SetWarning(
|
||||||
|
"Invalid",
|
||||||
|
Selector.DisabledCommitButtonReason);
|
||||||
}
|
}
|
||||||
else
|
} else if (Selector.WarnOnCommitButton) {
|
||||||
{
|
commandWarningPanelController.SetWarning(
|
||||||
commandWarningPanelController.SetWarning("Invalid", Selector.DisabledCommitButtonReason);
|
"Are you sure?",
|
||||||
}
|
Selector.CommitWarningText);
|
||||||
}
|
|
||||||
else if (Selector.WarnOnCommitButton)
|
|
||||||
{
|
|
||||||
commandWarningPanelController.SetWarning("Are you sure?", Selector.CommitWarningText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PointerExitedCommitButton()
|
public void PointerExitedCommitButton() { commandWarningPanelController.ClearWarning(); }
|
||||||
{
|
|
||||||
commandWarningPanelController.ClearWarning();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnGUI()
|
public void OnGUI() {
|
||||||
{
|
|
||||||
var eventType = Event.current.type;
|
var eventType = Event.current.type;
|
||||||
try
|
try {
|
||||||
{
|
if (Selector == null) {
|
||||||
if (Selector == null)
|
|
||||||
{
|
|
||||||
commitCommandButton.gameObject.SetActive(false);
|
commitCommandButton.gameObject.SetActive(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
bool disableWarningPanel = !commitCommandButton.gameObject.activeSelf;
|
bool disableWarningPanel = !commitCommandButton.gameObject.activeSelf;
|
||||||
|
|
||||||
if (Selector.WarnOnCommitButton)
|
if (Selector.WarnOnCommitButton) {
|
||||||
{
|
commitButtonText.text =
|
||||||
commitButtonText.text = $"<color=#FF0000FF>{Selector.CommitButtonString}</color>";
|
$"<color=#FF0000FF>{Selector.CommitButtonString}</color>";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
commitButtonText.text = Selector.CommitButtonString;
|
commitButtonText.text = Selector.CommitButtonString;
|
||||||
}
|
}
|
||||||
commitCommandButton.gameObject.SetActive(true);
|
commitCommandButton.gameObject.SetActive(true);
|
||||||
commitCommandButton.interactable = Selector.EnableCommitButton;
|
commitCommandButton.interactable = Selector.EnableCommitButton;
|
||||||
|
|
||||||
if (disableWarningPanel)
|
if (disableWarningPanel) {
|
||||||
{
|
MainQueue.Q.EnqueueForNextUpdate(
|
||||||
MainQueue.Q.EnqueueForNextUpdate(() =>
|
() => { commandWarningPanelController.ClearWarning(); });
|
||||||
{
|
|
||||||
commandWarningPanelController.ClearWarning();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Log($"Event type is {eventType}");
|
Debug.Log($"Event type is {eventType}");
|
||||||
errorPanel.Add(e);
|
errorPanel.Add(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-23
@@ -5,13 +5,11 @@ using TMPro;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class AlmsCommandSelector : CommandSelector
|
public class AlmsCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public Slider foodSlider;
|
public Slider foodSlider;
|
||||||
public TMP_Text foodGivenLabel;
|
public TMP_Text foodGivenLabel;
|
||||||
@@ -24,7 +22,8 @@ namespace eagle
|
|||||||
|
|
||||||
private int SelectedFoodAmount => (int)foodSlider.value;
|
private int SelectedFoodAmount => (int)foodSlider.value;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.AlmsCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.AlmsCommand;
|
||||||
public override string HeaderString => "Give Alms";
|
public override string HeaderString => "Give Alms";
|
||||||
public override string CommitButtonString => "Commit Alms";
|
public override string CommitButtonString => "Commit Alms";
|
||||||
|
|
||||||
@@ -32,38 +31,35 @@ namespace eagle
|
|||||||
public override string DisabledCommitButtonReason => "Must include some food";
|
public override string DisabledCommitButtonReason => "Must include some food";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => AlmsCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
AlmsCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes =
|
||||||
heroDropdownController.AvailableHeroes = AlmsCommand.AvailableHeroIds
|
AlmsCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid]).ToList();
|
||||||
.Select(hid => _model.Heroes[hid])
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foodSlider.maxValue = AvailableFoodAmount;
|
foodSlider.maxValue = AvailableFoodAmount;
|
||||||
foodSlider.value = 0;
|
foodSlider.value = 0;
|
||||||
foodGivenLabel.text = "0";
|
foodGivenLabel.text = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectedProvinceChanged(int newValue)
|
public void SelectedProvinceChanged(int newValue) {
|
||||||
{
|
|
||||||
foodSlider.value = Math.Min(foodSlider.value, AvailableFoodAmount);
|
foodSlider.value = Math.Min(foodSlider.value, AvailableFoodAmount);
|
||||||
foodSlider.maxValue = AvailableFoodAmount;
|
foodSlider.maxValue = AvailableFoodAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FoodSliderChanged(float newValue)
|
public void FoodSliderChanged(float newValue) {
|
||||||
{
|
|
||||||
foodGivenLabel.text = ((int)newValue).ToString();
|
foodGivenLabel.text = ((int)newValue).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
AlmsCommand =
|
||||||
AlmsCommand = new AlmsSelectedCommand
|
new AlmsSelectedCommand {
|
||||||
{
|
Amount = SelectedFoodAmount,
|
||||||
Amount = SelectedFoodAmount,
|
ActingHeroId = SelectedHeroId
|
||||||
ActingHeroId = SelectedHeroId
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+47
-45
@@ -5,20 +5,22 @@ using System.Collections.Generic;
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using FactionId = Int32;
|
using FactionId = Int32;
|
||||||
|
|
||||||
public class ApprehendOutlawCommandSelector : CommandSelector
|
public class ApprehendOutlawCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
private HeroId SelectedHeroId => actingHeroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => actingHeroDropdownController.SelectedHeroId;
|
||||||
private BattalionId? SelectedBattalionId => actingBattalionDropdown.value == 0 ? null : (BattalionId?)AvailableBattalions[actingBattalionDropdown.value - 1].Id;
|
private BattalionId? SelectedBattalionId =>
|
||||||
|
actingBattalionDropdown.value == 0
|
||||||
|
? null
|
||||||
|
: (BattalionId?)AvailableBattalions[actingBattalionDropdown.value - 1].Id;
|
||||||
private HeroId TargetedHeroId => AvailableTargetHeroIds[targetOutlawDropdown.value];
|
private HeroId TargetedHeroId => AvailableTargetHeroIds[targetOutlawDropdown.value];
|
||||||
|
|
||||||
private ApprehendOutlawAvailableCommand ApprehendOutlawCommand => _availableCommand.ApprehendOutlawCommand;
|
private ApprehendOutlawAvailableCommand ApprehendOutlawCommand =>
|
||||||
|
_availableCommand.ApprehendOutlawCommand;
|
||||||
private ProvinceId ActingProvinceId => ApprehendOutlawCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ApprehendOutlawCommand.ActingProvinceId;
|
||||||
|
|
||||||
public HeroDropdownController actingHeroDropdownController;
|
public HeroDropdownController actingHeroDropdownController;
|
||||||
@@ -27,76 +29,76 @@ namespace eagle
|
|||||||
|
|
||||||
public EagleCommonTextures textures;
|
public EagleCommonTextures textures;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ApprehendOutlawCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ApprehendOutlawCommand;
|
||||||
public override string HeaderString => "Apprehend Outlaw";
|
public override string HeaderString => "Apprehend Outlaw";
|
||||||
public override string CommitButtonString => "Commit Apprehend Outlaw";
|
public override string CommitButtonString => "Commit Apprehend Outlaw";
|
||||||
|
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => ApprehendOutlawCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => actingHeroDropdownController.SelectedHeroId = heroId;
|
ApprehendOutlawCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
actingHeroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private List<HeroId> AvailableTargetHeroIds { get; set; }
|
private List<HeroId> AvailableTargetHeroIds { get; set; }
|
||||||
private ProvinceView Province => _model.Provinces[ActingProvinceId];
|
private ProvinceView Province => _model.Provinces[ActingProvinceId];
|
||||||
private List<BattalionView> AvailableBattalions =>
|
private List<BattalionView> AvailableBattalions =>
|
||||||
ApprehendOutlawCommand.AvailableBattalionIds
|
ApprehendOutlawCommand.AvailableBattalionIds
|
||||||
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
||||||
.OrderBy(batt => batt.Type)
|
.OrderBy(batt => batt.Type)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
private string outlawDropdownString(ResidentOutlaw outlaw)
|
private string outlawDropdownString(ResidentOutlaw outlaw) {
|
||||||
{
|
|
||||||
string lastFactionString = "";
|
string lastFactionString = "";
|
||||||
|
|
||||||
if (outlaw.LastFactionId is FactionId fid)
|
if (outlaw.LastFactionId is FactionId fid) {
|
||||||
{
|
|
||||||
lastFactionString = $" ({_model.FactionName(fid)})";
|
lastFactionString = $" ({_model.FactionName(fid)})";
|
||||||
}
|
}
|
||||||
return $"{outlaw.Hero.Name}{lastFactionString}";
|
return $"{outlaw.Hero.Name}{lastFactionString}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private TMP_Dropdown.OptionData BattalionOption(BattalionView bv)
|
private TMP_Dropdown.OptionData BattalionOption(BattalionView bv) {
|
||||||
{
|
|
||||||
var texture = textures.BattalionType(bv.Type);
|
var texture = textures.BattalionType(bv.Type);
|
||||||
return new TMP_Dropdown.OptionData
|
return new TMP_Dropdown.OptionData {
|
||||||
{
|
image = Sprite.Create(
|
||||||
image = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)),
|
texture,
|
||||||
|
new Rect(0, 0, texture.width, texture.height),
|
||||||
|
new Vector2(0.5f, 0.5f)),
|
||||||
text = bv.Size.ToString()
|
text = bv.Size.ToString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
actingHeroDropdownController.AvailableHeroes =
|
||||||
actingHeroDropdownController.AvailableHeroes = ApprehendOutlawCommand.AvailableHeroIds
|
ApprehendOutlawCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid])
|
||||||
.Select(hid => _model.Heroes[hid])
|
.ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
AvailableTargetHeroIds = ApprehendOutlawCommand
|
AvailableTargetHeroIds =
|
||||||
.Outlaws
|
ApprehendOutlawCommand.Outlaws.Select(uh => uh.Hero.Id).ToList();
|
||||||
.Select(uh => uh.Hero.Id)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
actingBattalionDropdown.ClearOptions();
|
actingBattalionDropdown.ClearOptions();
|
||||||
actingBattalionDropdown.AddOptions(new List<TMP_Dropdown.OptionData> { new TMP_Dropdown.OptionData { text = "No Battalion" } });
|
actingBattalionDropdown.AddOptions(new List<TMP_Dropdown.OptionData> {
|
||||||
actingBattalionDropdown.AddOptions(AvailableBattalions.Select(BattalionOption).ToList());
|
new TMP_Dropdown.OptionData { text = "No Battalion" }
|
||||||
|
});
|
||||||
|
actingBattalionDropdown.AddOptions(
|
||||||
|
AvailableBattalions.Select(BattalionOption).ToList());
|
||||||
actingBattalionDropdown.value = Math.Min(1, AvailableBattalions.Count);
|
actingBattalionDropdown.value = Math.Min(1, AvailableBattalions.Count);
|
||||||
|
|
||||||
targetOutlawDropdown.ClearOptions();
|
targetOutlawDropdown.ClearOptions();
|
||||||
var outlawNames = ApprehendOutlawCommand
|
var outlawNames =
|
||||||
.Outlaws
|
ApprehendOutlawCommand.Outlaws.Select(opt => outlawDropdownString(opt))
|
||||||
.Select(opt => outlawDropdownString(opt))
|
.ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
targetOutlawDropdown.AddOptions(outlawNames);
|
targetOutlawDropdown.AddOptions(outlawNames);
|
||||||
targetOutlawDropdown.value = 0;
|
targetOutlawDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
ApprehendOutlawSelectedCommand =
|
||||||
ApprehendOutlawSelectedCommand = new ApprehendOutlawSelectedCommand
|
new ApprehendOutlawSelectedCommand {
|
||||||
{
|
HeroIdToApprehend = TargetedHeroId,
|
||||||
HeroIdToApprehend = TargetedHeroId,
|
BattalionId = SelectedBattalionId,
|
||||||
BattalionId = SelectedBattalionId,
|
ActingHeroId = SelectedHeroId
|
||||||
ActingHeroId = SelectedHeroId
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-62
@@ -8,12 +8,10 @@ using TMPro;
|
|||||||
using common;
|
using common;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class ArmTroopsCommandSelector : CommandSelector
|
public class ArmTroopsCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
List<double> costs;
|
List<double> costs;
|
||||||
List<int> newArmaments;
|
List<int> newArmaments;
|
||||||
List<BattalionView> battalions;
|
List<BattalionView> battalions;
|
||||||
@@ -26,23 +24,24 @@ namespace eagle
|
|||||||
public TMP_Text availableText;
|
public TMP_Text availableText;
|
||||||
public TMP_Text maxLabel;
|
public TMP_Text maxLabel;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ArmTroopsCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ArmTroopsCommand;
|
||||||
|
|
||||||
private ArmTroopsAvailableCommand ArmTroopsAvailableCommand => _availableCommand.ArmTroopsCommand;
|
private ArmTroopsAvailableCommand ArmTroopsAvailableCommand =>
|
||||||
|
_availableCommand.ArmTroopsCommand;
|
||||||
private ProvinceId ActingProvinceId => ArmTroopsAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ArmTroopsAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
override protected void SetUpUI()
|
override protected void SetUpUI() {
|
||||||
{
|
|
||||||
var province = _model.Provinces[ActingProvinceId];
|
var province = _model.Provinces[ActingProvinceId];
|
||||||
battalions = ArmTroopsAvailableCommand.AvailableBattalions
|
battalions =
|
||||||
.Select(bid => province.FullInfo.Battalions.First(b => b.Id == bid))
|
ArmTroopsAvailableCommand.AvailableBattalions
|
||||||
.OrderBy(b => b, BattalionUtils.BattalionComparer)
|
.Select(bid => province.FullInfo.Battalions.First(b => b.Id == bid))
|
||||||
.ToList();
|
.OrderBy(b => b, BattalionUtils.BattalionComparer)
|
||||||
|
.ToList();
|
||||||
newArmaments = battalions.Select(b => (int)b.Armament).ToList();
|
newArmaments = battalions.Select(b => (int)b.Armament).ToList();
|
||||||
|
|
||||||
var costDict = new Dictionary<BattalionTypeId, double>();
|
var costDict = new Dictionary<BattalionTypeId, double>();
|
||||||
foreach (var t in ArmTroopsAvailableCommand.ArmamentCosts)
|
foreach (var t in ArmTroopsAvailableCommand.ArmamentCosts) {
|
||||||
{
|
|
||||||
costDict[t.Type] = t.Cost;
|
costDict[t.Type] = t.Cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +65,7 @@ namespace eagle
|
|||||||
private string _disabledCommitButtonReason;
|
private string _disabledCommitButtonReason;
|
||||||
public override string DisabledCommitButtonReason => _disabledCommitButtonReason;
|
public override string DisabledCommitButtonReason => _disabledCommitButtonReason;
|
||||||
|
|
||||||
private void PopulateRow(int index)
|
private void PopulateRow(int index) {
|
||||||
{
|
|
||||||
var row = armTroopsTable.ComponentAt<ArmTroopsRowController>(index);
|
var row = armTroopsTable.ComponentAt<ArmTroopsRowController>(index);
|
||||||
var battalion = battalions[index];
|
var battalion = battalions[index];
|
||||||
row.BattalionImage = textures.BattalionType(battalion.Type);
|
row.BattalionImage = textures.BattalionType(battalion.Type);
|
||||||
@@ -82,8 +80,7 @@ namespace eagle
|
|||||||
SetValuesAndButtons(index);
|
SetValuesAndButtons(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetValuesAndButtons(int index)
|
private void SetValuesAndButtons(int index) {
|
||||||
{
|
|
||||||
var row = armTroopsTable.ComponentAt<ArmTroopsRowController>(index);
|
var row = armTroopsTable.ComponentAt<ArmTroopsRowController>(index);
|
||||||
var battalion = battalions[index];
|
var battalion = battalions[index];
|
||||||
var newArmament = newArmaments[index];
|
var newArmament = newArmaments[index];
|
||||||
@@ -100,86 +97,67 @@ namespace eagle
|
|||||||
UpdateCost();
|
UpdateCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCost()
|
private void UpdateCost() {
|
||||||
{
|
|
||||||
_enableCommit = true;
|
_enableCommit = true;
|
||||||
totalCostText.color = Color.black;
|
totalCostText.color = Color.black;
|
||||||
int cost = Cost();
|
int cost = Cost();
|
||||||
|
|
||||||
totalCostText.text = cost.ToString();
|
totalCostText.text = cost.ToString();
|
||||||
if (cost > availableGold)
|
if (cost > availableGold) {
|
||||||
{
|
|
||||||
totalCostText.color = Color.red;
|
totalCostText.color = Color.red;
|
||||||
_enableCommit = false;
|
_enableCommit = false;
|
||||||
_disabledCommitButtonReason = "Not enough gold";
|
_disabledCommitButtonReason = "Not enough gold";
|
||||||
}
|
}
|
||||||
if (cost == 0)
|
if (cost == 0) {
|
||||||
{
|
|
||||||
_enableCommit = false;
|
_enableCommit = false;
|
||||||
_disabledCommitButtonReason = "No battalions have changed";
|
_disabledCommitButtonReason = "No battalions have changed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTableAndCost()
|
private void UpdateTableAndCost() {
|
||||||
{
|
|
||||||
armTroopsTable.RowCount = battalions.Count;
|
armTroopsTable.RowCount = battalions.Count;
|
||||||
|
|
||||||
for (int i = 0; i < battalions.Count; i++)
|
for (int i = 0; i < battalions.Count; i++) { PopulateRow(i); }
|
||||||
{
|
|
||||||
PopulateRow(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateCost();
|
UpdateCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlusClicked(int index)
|
public void PlusClicked(int index) {
|
||||||
{
|
|
||||||
newArmaments[index] = Math.Min(maxArmament, newArmaments[index] + 1);
|
newArmaments[index] = Math.Min(maxArmament, newArmaments[index] + 1);
|
||||||
SetValuesAndButtons(index);
|
SetValuesAndButtons(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MinusClicked(int index) {
|
||||||
public void MinusClicked(int index)
|
newArmaments[index] =
|
||||||
{
|
Math.Max((int)battalions[index].Armament, newArmaments[index] - 1);
|
||||||
newArmaments[index] = Math.Max((int)battalions[index].Armament, newArmaments[index] - 1);
|
|
||||||
SetValuesAndButtons(index);
|
SetValuesAndButtons(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetClicked(int index) {
|
||||||
public void ResetClicked(int index)
|
|
||||||
{
|
|
||||||
newArmaments[index] = (int)battalions[index].Armament;
|
newArmaments[index] = (int)battalions[index].Armament;
|
||||||
SetValuesAndButtons(index);
|
SetValuesAndButtons(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MaxClicked(int index) {
|
||||||
public void MaxClicked(int index)
|
|
||||||
{
|
|
||||||
newArmaments[index] = maxArmament;
|
newArmaments[index] = maxArmament;
|
||||||
SetValuesAndButtons(index);
|
SetValuesAndButtons(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MaxAllClicked()
|
public void MaxAllClicked() {
|
||||||
{
|
|
||||||
newArmaments = battalions.Select(b => maxArmament).ToList();
|
newArmaments = battalions.Select(b => maxArmament).ToList();
|
||||||
UpdateTableAndCost();
|
UpdateTableAndCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetAllClicked()
|
public void ResetAllClicked() {
|
||||||
{
|
|
||||||
newArmaments = battalions.Select(b => (int)b.Armament).ToList();
|
newArmaments = battalions.Select(b => (int)b.Armament).ToList();
|
||||||
UpdateTableAndCost();
|
UpdateTableAndCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var atc = new ArmTroopsSelectedCommand();
|
var atc = new ArmTroopsSelectedCommand();
|
||||||
for (int i = 0; i < newArmaments.Count; i++)
|
for (int i = 0; i < newArmaments.Count; i++) {
|
||||||
{
|
if (newArmaments[i] > battalions[i].Armament) {
|
||||||
if (newArmaments[i] > battalions[i].Armament)
|
|
||||||
{
|
|
||||||
var ab = new ArmedBattalion();
|
var ab = new ArmedBattalion();
|
||||||
ab.Id = battalions[i].Id;
|
ab.Id = battalions[i].Id;
|
||||||
ab.NewArmament = (int)newArmaments[i];
|
ab.NewArmament = (int)newArmaments[i];
|
||||||
@@ -187,21 +165,16 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmd = new SelectedCommand
|
var cmd = new SelectedCommand { ArmTroopsCommand = atc };
|
||||||
{
|
|
||||||
ArmTroopsCommand = atc
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int Cost()
|
private int Cost() {
|
||||||
{
|
|
||||||
double totalCost = 0.0;
|
double totalCost = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < newArmaments.Count; i++)
|
for (int i = 0; i < newArmaments.Count; i++) {
|
||||||
{
|
|
||||||
var battalion = battalions[i];
|
var battalion = battalions[i];
|
||||||
|
|
||||||
totalCost += costs[i] * Math.Max(newArmaments[i] - battalion.Armament, 0.0);
|
totalCost += costs[i] * Math.Max(newArmaments[i] - battalion.Armament, 0.0);
|
||||||
|
|||||||
+45
-48
@@ -7,27 +7,29 @@ using TMPro;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class AttackDecisionCommandSelector : CommandSelector
|
public class AttackDecisionCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public EventBasedTable unitsTable;
|
public EventBasedTable unitsTable;
|
||||||
public EventBasedTable armiesTable;
|
public EventBasedTable armiesTable;
|
||||||
|
|
||||||
private static Dictionary<AttackDecisionType, string> commitStrings = new Dictionary<AttackDecisionType, string>
|
private static Dictionary<AttackDecisionType, string> commitStrings =
|
||||||
{
|
new Dictionary<AttackDecisionType, string> {
|
||||||
{AttackDecisionType.AdvanceDecision, "Commit Advance"},
|
{ AttackDecisionType.AdvanceDecision, "Commit Advance" },
|
||||||
{AttackDecisionType.DemandTributeDecision, "Commit Demand Tribute"},
|
{ AttackDecisionType.DemandTributeDecision, "Commit Demand Tribute" },
|
||||||
{AttackDecisionType.WithdrawDecision, "Commit Withdraw"},
|
{ AttackDecisionType.WithdrawDecision, "Commit Withdraw" },
|
||||||
};
|
};
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.AttackDecisionCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.AttackDecisionCommand;
|
||||||
public override string HeaderString => "Attack Decision";
|
public override string HeaderString => "Attack Decision";
|
||||||
public override string CommitButtonString => commitStrings[SelectedDecision];
|
public override string CommitButtonString => commitStrings[SelectedDecision];
|
||||||
public override bool EnableCommitButton => SelectedDecision != AttackDecisionType.DemandTributeDecision || FoodDemanded > 0 || GoldDemanded > 0;
|
public override bool EnableCommitButton =>
|
||||||
public override string DisabledCommitButtonReason => "Must select some food or gold for tribute";
|
SelectedDecision != AttackDecisionType.DemandTributeDecision || FoodDemanded > 0 ||
|
||||||
|
GoldDemanded > 0;
|
||||||
|
public override string DisabledCommitButtonReason =>
|
||||||
|
"Must select some food or gold for tribute";
|
||||||
|
|
||||||
public Toggle AdvanceToggle;
|
public Toggle AdvanceToggle;
|
||||||
public Toggle DemandTributeToggle;
|
public Toggle DemandTributeToggle;
|
||||||
@@ -44,49 +46,48 @@ namespace eagle
|
|||||||
public TMP_Text GoldLabel;
|
public TMP_Text GoldLabel;
|
||||||
public TMP_Text FoodLabel;
|
public TMP_Text FoodLabel;
|
||||||
|
|
||||||
private AttackDecisionAvailableCommand AttackDecisionCommand => _availableCommand.AttackDecisionCommand;
|
private AttackDecisionAvailableCommand AttackDecisionCommand =>
|
||||||
|
_availableCommand.AttackDecisionCommand;
|
||||||
private ProvinceId ActingProvinceId => AttackDecisionCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => AttackDecisionCommand.ActingProvinceId;
|
||||||
|
|
||||||
private AttackDecisionType SelectedDecision =>
|
private AttackDecisionType SelectedDecision =>
|
||||||
(AdvanceToggle.isOn) ? AttackDecisionType.AdvanceDecision :
|
(AdvanceToggle.isOn) ? AttackDecisionType.AdvanceDecision
|
||||||
(DemandTributeToggle.isOn) ? AttackDecisionType.DemandTributeDecision :
|
: (DemandTributeToggle.isOn) ? AttackDecisionType.DemandTributeDecision
|
||||||
AttackDecisionType.WithdrawDecision;
|
: AttackDecisionType.WithdrawDecision;
|
||||||
|
|
||||||
private int FoodDemanded => (int)FoodSlider.value;
|
private int FoodDemanded => (int)FoodSlider.value;
|
||||||
private int GoldDemanded => (int)GoldSlider.value;
|
private int GoldDemanded => (int)GoldSlider.value;
|
||||||
|
|
||||||
private TributeAmount Tribute => DemandTributeToggle.isOn ? new TributeAmount { Food = FoodDemanded, Gold = GoldDemanded } : null;
|
private TributeAmount Tribute =>
|
||||||
|
DemandTributeToggle.isOn
|
||||||
|
? new TributeAmount { Food = FoodDemanded, Gold = GoldDemanded }
|
||||||
|
: null;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
AttackDecisionCommand =
|
||||||
AttackDecisionCommand = new AttackDecisionSelectedCommand
|
new AttackDecisionSelectedCommand {
|
||||||
{
|
Decision = SelectedDecision,
|
||||||
Decision = SelectedDecision,
|
Tribute = Tribute
|
||||||
Tribute = Tribute
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
unitsTable.RowCount = AttackDecisionCommand.ActingUnits.Count;
|
unitsTable.RowCount = AttackDecisionCommand.ActingUnits.Count;
|
||||||
ProvinceView province = _model.Provinces[ActingProvinceId];
|
ProvinceView province = _model.Provinces[ActingProvinceId];
|
||||||
|
|
||||||
AttackDecisionCommand.ActingUnits.Each((cu, idx) =>
|
AttackDecisionCommand.ActingUnits.Each((cu, idx) => {
|
||||||
{
|
|
||||||
CombatUnitRowController row = unitsTable.ComponentAt<CombatUnitRowController>(idx);
|
CombatUnitRowController row = unitsTable.ComponentAt<CombatUnitRowController>(idx);
|
||||||
row.Hero = cu.Hero;
|
row.Hero = cu.Hero;
|
||||||
row.Battalion = cu.Battalion;
|
row.Battalion = cu.Battalion;
|
||||||
});
|
});
|
||||||
|
|
||||||
armiesTable.RowCount = AttackDecisionCommand.Armies.Count;
|
armiesTable.RowCount = AttackDecisionCommand.Armies.Count;
|
||||||
AttackDecisionCommand.Armies.Each((army, idx) =>
|
AttackDecisionCommand.Armies.Each((army, idx) => {
|
||||||
{
|
|
||||||
IncomingArmyTableRow row = armiesTable.ComponentAt<IncomingArmyTableRow>(idx);
|
IncomingArmyTableRow row = armiesTable.ComponentAt<IncomingArmyTableRow>(idx);
|
||||||
row.Faction = _model.FactionName(army.FactionId);
|
row.Faction = _model.FactionName(army.FactionId);
|
||||||
row.HeroCount = army.HeroCount;
|
row.HeroCount = army.HeroCount;
|
||||||
row.TroopCount = army.TroopCount;
|
row.TroopCount = army.TroopCount;
|
||||||
switch (army.Hostility)
|
switch (army.Hostility) {
|
||||||
{
|
|
||||||
case Net.Eagle0.Common.Hostility.AlliedHostility:
|
case Net.Eagle0.Common.Hostility.AlliedHostility:
|
||||||
row.TextColor = Color.green;
|
row.TextColor = Color.green;
|
||||||
break;
|
break;
|
||||||
@@ -100,17 +101,20 @@ namespace eagle
|
|||||||
row.Origin = _model.Provinces[army.OriginProvinceId].Name;
|
row.Origin = _model.Provinces[army.OriginProvinceId].Name;
|
||||||
});
|
});
|
||||||
|
|
||||||
var enableAttack = AttackDecisionCommand.AvailableDecisions.Contains(AttackDecisionType.AdvanceDecision);
|
var enableAttack = AttackDecisionCommand.AvailableDecisions.Contains(
|
||||||
|
AttackDecisionType.AdvanceDecision);
|
||||||
AdvanceToggle.enabled = enableAttack;
|
AdvanceToggle.enabled = enableAttack;
|
||||||
AdvanceToggle.gameObject.SetActive(enableAttack);
|
AdvanceToggle.gameObject.SetActive(enableAttack);
|
||||||
AdvanceImage.SetActive(enableAttack);
|
AdvanceImage.SetActive(enableAttack);
|
||||||
|
|
||||||
var enableWithdraw = AttackDecisionCommand.AvailableDecisions.Contains(AttackDecisionType.WithdrawDecision);
|
var enableWithdraw = AttackDecisionCommand.AvailableDecisions.Contains(
|
||||||
|
AttackDecisionType.WithdrawDecision);
|
||||||
WithdrawToggle.enabled = enableWithdraw;
|
WithdrawToggle.enabled = enableWithdraw;
|
||||||
WithdrawToggle.gameObject.SetActive(enableWithdraw);
|
WithdrawToggle.gameObject.SetActive(enableWithdraw);
|
||||||
WithdrawImage.SetActive(enableWithdraw);
|
WithdrawImage.SetActive(enableWithdraw);
|
||||||
|
|
||||||
var enableDemandTribute = AttackDecisionCommand.AvailableDecisions.Contains(AttackDecisionType.DemandTributeDecision);
|
var enableDemandTribute = AttackDecisionCommand.AvailableDecisions.Contains(
|
||||||
|
AttackDecisionType.DemandTributeDecision);
|
||||||
DemandTributeToggle.enabled = enableDemandTribute;
|
DemandTributeToggle.enabled = enableDemandTribute;
|
||||||
DemandTributeToggle.gameObject.SetActive(enableDemandTribute);
|
DemandTributeToggle.gameObject.SetActive(enableDemandTribute);
|
||||||
DemandTributeImage.SetActive(enableDemandTribute);
|
DemandTributeImage.SetActive(enableDemandTribute);
|
||||||
@@ -133,18 +137,15 @@ namespace eagle
|
|||||||
EnableSliders(false);
|
EnableSliders(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoldSliderChanged(float newValue)
|
public void GoldSliderChanged(float newValue) {
|
||||||
{
|
|
||||||
GoldLabel.text = ((int)newValue).ToString();
|
GoldLabel.text = ((int)newValue).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FoodSliderChanged(float newValue)
|
public void FoodSliderChanged(float newValue) {
|
||||||
{
|
|
||||||
FoodLabel.text = ((int)newValue).ToString();
|
FoodLabel.text = ((int)newValue).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnableSliders(bool enabled)
|
private void EnableSliders(bool enabled) {
|
||||||
{
|
|
||||||
GoldIcon.gameObject.SetActive(enabled);
|
GoldIcon.gameObject.SetActive(enabled);
|
||||||
FoodIcon.gameObject.SetActive(enabled);
|
FoodIcon.gameObject.SetActive(enabled);
|
||||||
GoldSlider.gameObject.SetActive(enabled);
|
GoldSlider.gameObject.SetActive(enabled);
|
||||||
@@ -153,17 +154,13 @@ namespace eagle
|
|||||||
FoodLabel.gameObject.SetActive(enabled);
|
FoodLabel.gameObject.SetActive(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleChanged(bool value)
|
public void ToggleChanged(bool value) {
|
||||||
{
|
|
||||||
bool enableSliders = (SelectedDecision == AttackDecisionType.DemandTributeDecision);
|
bool enableSliders = (SelectedDecision == AttackDecisionType.DemandTributeDecision);
|
||||||
|
|
||||||
EnableSliders(enableSliders);
|
EnableSliders(enableSliders);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-45
@@ -3,60 +3,52 @@ using System.Collections.Generic;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
using FactionId = Int32;
|
using FactionId = Int32;
|
||||||
|
|
||||||
public abstract class CommandSelector : MonoBehaviour
|
public abstract class CommandSelector : MonoBehaviour {
|
||||||
{
|
|
||||||
public Texture ButtonImage;
|
public Texture ButtonImage;
|
||||||
|
|
||||||
public abstract AvailableCommand.SealedValueOneofCase CommandType { get; }
|
public abstract AvailableCommand.SealedValueOneofCase CommandType { get; }
|
||||||
public virtual bool IsAppropriateFor(AvailableCommand cmd) => cmd.SealedValueCase == CommandType;
|
public virtual bool IsAppropriateFor(AvailableCommand cmd) => cmd.SealedValueCase
|
||||||
|
== CommandType;
|
||||||
public abstract string HeaderString { get; }
|
public abstract string HeaderString { get; }
|
||||||
public abstract string CommitButtonString { get; }
|
public abstract string CommitButtonString { get; }
|
||||||
public abstract SelectedCommand Command { get; }
|
public abstract SelectedCommand Command { get; }
|
||||||
protected abstract void SetUpUI();
|
protected abstract void SetUpUI();
|
||||||
|
|
||||||
// Optional accessors
|
// Optional accessors
|
||||||
protected virtual ProvinceId? TargetedProvince
|
protected virtual ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => null;
|
get => null;
|
||||||
set { }
|
set {}
|
||||||
}
|
}
|
||||||
public virtual List<ProvinceId> TargetedProvinces
|
public virtual List<ProvinceId> TargetedProvinces {
|
||||||
{
|
get {
|
||||||
get
|
if (TargetedFactionIds.Count > 0) {
|
||||||
{
|
|
||||||
if (TargetedFactionIds.Count > 0)
|
|
||||||
{
|
|
||||||
var list = new List<ProvinceId>();
|
var list = new List<ProvinceId>();
|
||||||
foreach (ProvinceView province in _model.Provinces.Values)
|
foreach (ProvinceView province in _model.Provinces.Values) {
|
||||||
{
|
if (province.RulingFactionId is FactionId fid &&
|
||||||
if (province.RulingFactionId is FactionId fid && TargetedFactionIds.Contains(fid))
|
TargetedFactionIds.Contains(fid)) {
|
||||||
{
|
|
||||||
list.Add(province.Id);
|
list.Add(province.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
if (TargetedProvince is ProvinceId pid)
|
if (TargetedProvince is ProvinceId pid) {
|
||||||
{
|
|
||||||
return new List<ProvinceId> { pid };
|
return new List<ProvinceId> { pid };
|
||||||
}
|
} else
|
||||||
else return new List<ProvinceId>();
|
return new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
switch (value.Count) {
|
||||||
switch (value.Count)
|
|
||||||
{
|
|
||||||
case 0: return;
|
case 0: return;
|
||||||
case 1: TargetedProvince = value[0]; break;
|
case 1: TargetedProvince = value[0]; break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException("Unable to handle multiple targeted provinces in default");
|
throw new ArgumentException(
|
||||||
|
"Unable to handle multiple targeted provinces in default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,42 +59,34 @@ namespace eagle
|
|||||||
|
|
||||||
public virtual List<HeroId> TargetedHeroIds => new List<HeroId>();
|
public virtual List<HeroId> TargetedHeroIds => new List<HeroId>();
|
||||||
public virtual bool HeroIsTargetable(HeroId heroId) => false;
|
public virtual bool HeroIsTargetable(HeroId heroId) => false;
|
||||||
public virtual void AddTargetedHero(HeroId heroId) { }
|
public virtual void AddTargetedHero(HeroId heroId) {}
|
||||||
public virtual void RemoveTargetedHero(HeroId heroId) { }
|
public virtual void RemoveTargetedHero(HeroId heroId) {}
|
||||||
|
|
||||||
public virtual List<HeroId> TargetedBattalionIds => new List<BattalionId>();
|
public virtual List<HeroId> TargetedBattalionIds => new List<BattalionId>();
|
||||||
public virtual bool BattalionIsTargetable(BattalionId battalionId) => false;
|
public virtual bool BattalionIsTargetable(BattalionId battalionId) => false;
|
||||||
public virtual void AddTargetedBattalion(BattalionId battalionId) { }
|
public virtual void AddTargetedBattalion(BattalionId battalionId) {}
|
||||||
public virtual void RemoveTargetedBattalion(BattalionId battalionId) { }
|
public virtual void RemoveTargetedBattalion(BattalionId battalionId) {}
|
||||||
|
|
||||||
public virtual List<FactionId> TargetedFactionIds => new List<FactionId>();
|
public virtual List<FactionId> TargetedFactionIds => new List<FactionId>();
|
||||||
public virtual bool FactionIsTargetable(FactionId factionId) => false;
|
public virtual bool FactionIsTargetable(FactionId factionId) => false;
|
||||||
public virtual void AddTargetedFaction(FactionId factionId) { }
|
public virtual void AddTargetedFaction(FactionId factionId) {}
|
||||||
public virtual void RemoveTargetedFaction(FactionId factionId) { }
|
public virtual void RemoveTargetedFaction(FactionId factionId) {}
|
||||||
|
|
||||||
public GameObject Panel => gameObject;
|
public GameObject Panel => gameObject;
|
||||||
|
|
||||||
protected FocusInfoPanelController _focusInfoPanelController;
|
protected FocusInfoPanelController _focusInfoPanelController;
|
||||||
public void SetFocusInfoPanelController(FocusInfoPanelController newController)
|
public void SetFocusInfoPanelController(FocusInfoPanelController newController) {
|
||||||
{
|
|
||||||
_focusInfoPanelController = newController;
|
_focusInfoPanelController = newController;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GameModel _model = null;
|
protected GameModel _model = null;
|
||||||
protected AvailableCommand _availableCommand = null;
|
protected AvailableCommand _availableCommand = null;
|
||||||
|
|
||||||
public void Show()
|
public void Show() { Panel.gameObject.SetActive(true); }
|
||||||
{
|
|
||||||
Panel.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Hide()
|
public void Hide() { Panel.gameObject.SetActive(false); }
|
||||||
{
|
|
||||||
Panel.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateAvailableCommand(GameModel model, AvailableCommand ac)
|
public void UpdateAvailableCommand(GameModel model, AvailableCommand ac) {
|
||||||
{
|
|
||||||
_model = model;
|
_model = model;
|
||||||
_availableCommand = ac;
|
_availableCommand = ac;
|
||||||
SetUpUI();
|
SetUpUI();
|
||||||
|
|||||||
+44
-47
@@ -6,77 +6,77 @@ using Net.Eagle0.Eagle.Api.Command.Util;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using static Net.Eagle0.Eagle.Api.ControlWeatherAvailableCommand.Types;
|
using static Net.Eagle0.Eagle.Api.ControlWeatherAvailableCommand.Types;
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class ControlWeatherCommandSelector : CommandSelector
|
public class ControlWeatherCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public TMP_Dropdown targetDropdown;
|
public TMP_Dropdown targetDropdown;
|
||||||
public TMP_Dropdown actionDropdown;
|
public TMP_Dropdown actionDropdown;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ControlWeatherAvailableCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ControlWeatherAvailableCommand;
|
||||||
public override string HeaderString => "Control Weather";
|
public override string HeaderString => "Control Weather";
|
||||||
public override string CommitButtonString => $"Commit {DisplayNames.ControlWeatherTypeName(SelectedOption.ControlWeatherTypes[actionDropdown.value])}";
|
public override string CommitButtonString =>
|
||||||
|
$"Commit {DisplayNames.ControlWeatherTypeName(SelectedOption.ControlWeatherTypes[actionDropdown.value])}";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => ControlWeatherAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
ControlWeatherAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private ControlWeatherAvailableCommand ControlWeatherAvailableCommand => _availableCommand.ControlWeatherAvailableCommand;
|
private ControlWeatherAvailableCommand ControlWeatherAvailableCommand =>
|
||||||
|
_availableCommand.ControlWeatherAvailableCommand;
|
||||||
|
|
||||||
private TargetProvinceOptions SelectedOption => ControlWeatherAvailableCommand.Options[targetDropdown.value];
|
private TargetProvinceOptions SelectedOption =>
|
||||||
private ControlWeatherType SelectedType => SelectedOption.ControlWeatherTypes[actionDropdown.value];
|
ControlWeatherAvailableCommand.Options[targetDropdown.value];
|
||||||
|
private ControlWeatherType SelectedType =>
|
||||||
|
SelectedOption.ControlWeatherTypes[actionDropdown.value];
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => SelectedOption.ProvinceId;
|
get => SelectedOption.ProvinceId;
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
int index = ControlWeatherAvailableCommand.Options.ToList().FindIndex(
|
||||||
{
|
tpo => tpo.ProvinceId == value.Value);
|
||||||
int index = ControlWeatherAvailableCommand.Options.ToList().FindIndex(tpo => tpo.ProvinceId == value.Value);
|
if (index != -1) targetDropdown.value = index;
|
||||||
if (index != -1)
|
|
||||||
targetDropdown.value = index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command =>
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
new SelectedCommand
|
ControlWeatherSelectedCommand =
|
||||||
{
|
new ControlWeatherSelectedCommand {
|
||||||
ControlWeatherSelectedCommand = new ControlWeatherSelectedCommand
|
SelectedProvinceId = SelectedOption.ProvinceId,
|
||||||
{
|
SelectedType = SelectedType,
|
||||||
SelectedProvinceId = SelectedOption.ProvinceId,
|
ActingHeroId = SelectedHeroId
|
||||||
SelectedType = SelectedType,
|
}
|
||||||
ActingHeroId = SelectedHeroId
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void SetOptions()
|
public void SetOptions() {
|
||||||
{
|
|
||||||
var availableTypes = SelectedOption.ControlWeatherTypes;
|
var availableTypes = SelectedOption.ControlWeatherTypes;
|
||||||
actionDropdown.ClearOptions();
|
actionDropdown.ClearOptions();
|
||||||
actionDropdown.AddOptions(availableTypes.Select(tp => DisplayNames.ControlWeatherTypeName(tp)).ToList());
|
actionDropdown.AddOptions(
|
||||||
|
availableTypes.Select(tp => DisplayNames.ControlWeatherTypeName(tp)).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes = ControlWeatherAvailableCommand.AvailableHeroIds
|
||||||
heroDropdownController.AvailableHeroes = ControlWeatherAvailableCommand
|
.Select(hid => _model.Heroes[hid])
|
||||||
.AvailableHeroIds
|
.ToList();
|
||||||
.Select(hid => _model.Heroes[hid])
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
targetDropdown.ClearOptions();
|
targetDropdown.ClearOptions();
|
||||||
var destinationProvinceNames = ControlWeatherAvailableCommand.Options
|
var destinationProvinceNames =
|
||||||
.Select(opt => opt.ProvinceId)
|
ControlWeatherAvailableCommand.Options.Select(opt => opt.ProvinceId)
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.ToList();
|
_model.Provinces[id],
|
||||||
|
_model.PlayerId.Value))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
targetDropdown.AddOptions(destinationProvinceNames);
|
targetDropdown.AddOptions(destinationProvinceNames);
|
||||||
targetDropdown.value = 0;
|
targetDropdown.value = 0;
|
||||||
@@ -84,9 +84,6 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+81
-84
@@ -5,65 +5,73 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using BattalionId = System.Int32;
|
using BattalionId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
|
|
||||||
public class DefendCommandSelector : CommandSelector
|
public class DefendCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
private int RallyPointProvinceIndex => rallyPointDropdown.value;
|
private int RallyPointProvinceIndex => rallyPointDropdown.value;
|
||||||
private List<CombatUnit> SelectedActingUnits => unitSelector.SelectedActingUnits;
|
private List<CombatUnit> SelectedActingUnits => unitSelector.SelectedActingUnits;
|
||||||
|
|
||||||
public EventBasedUnitSelector unitSelector;
|
public EventBasedUnitSelector unitSelector;
|
||||||
public TMP_Dropdown rallyPointDropdown;
|
public TMP_Dropdown rallyPointDropdown;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.DefendCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.DefendCommand;
|
||||||
public override string HeaderString => "Defend";
|
public override string HeaderString => "Defend";
|
||||||
public override string CommitButtonString => "Commit Defend";
|
public override string CommitButtonString => "Commit Defend";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => unitSelector.SelectedIds.Where(u => u.heroId.HasValue).Select(u => u.heroId.Value).ToList();
|
public override List<HeroId> TargetedHeroIds =>
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => unitSelector.HeroIsTargetable(heroId);
|
unitSelector.SelectedIds.Where(u => u.heroId.HasValue)
|
||||||
|
.Select(u => u.heroId.Value)
|
||||||
|
.ToList();
|
||||||
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
|
unitSelector.HeroIsTargetable(heroId);
|
||||||
public override void AddTargetedHero(HeroId heroId) => unitSelector.AddTargetedHero(heroId);
|
public override void AddTargetedHero(HeroId heroId) => unitSelector.AddTargetedHero(heroId);
|
||||||
public override void RemoveTargetedHero(HeroId heroId) => unitSelector.RemoveTargetedHero(heroId);
|
public override void RemoveTargetedHero(HeroId heroId) =>
|
||||||
|
unitSelector.RemoveTargetedHero(heroId);
|
||||||
|
|
||||||
public override List<BattalionId> TargetedBattalionIds => unitSelector.SelectedIds.Where(u => u.battalion != null).Select(u => u.battalion.Id).ToList();
|
public override List<BattalionId> TargetedBattalionIds =>
|
||||||
public override bool BattalionIsTargetable(BattalionId bid) => unitSelector.BattalionIsTargetable(bid);
|
unitSelector.SelectedIds.Where(u => u.battalion != null)
|
||||||
public override void AddTargetedBattalion(BattalionId bid) => unitSelector.AddTargetedBattalion(bid);
|
.Select(u => u.battalion.Id)
|
||||||
public override void RemoveTargetedBattalion(BattalionId bid) => unitSelector.RemoveTargetedBattalion(bid);
|
.ToList();
|
||||||
|
public override bool BattalionIsTargetable(BattalionId bid) =>
|
||||||
|
unitSelector.BattalionIsTargetable(bid);
|
||||||
|
public override void AddTargetedBattalion(BattalionId bid) =>
|
||||||
|
unitSelector.AddTargetedBattalion(bid);
|
||||||
|
public override void RemoveTargetedBattalion(BattalionId bid) =>
|
||||||
|
unitSelector.RemoveTargetedBattalion(bid);
|
||||||
|
|
||||||
private DefendAvailableCommand DefendCommand => _availableCommand.DefendCommand;
|
private DefendAvailableCommand DefendCommand => _availableCommand.DefendCommand;
|
||||||
private ProvinceId ActingProvinceId => DefendCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => DefendCommand.ActingProvinceId;
|
||||||
|
|
||||||
private ProvinceId? RallyPointProvinceId => DefendCommand.AvailableFleeProvinceIds.Count > 0 ? DefendCommand.AvailableFleeProvinceIds[RallyPointProvinceIndex] : (ProvinceId?)null;
|
private ProvinceId? RallyPointProvinceId =>
|
||||||
|
DefendCommand.AvailableFleeProvinceIds.Count >
|
||||||
|
0? DefendCommand.AvailableFleeProvinceIds[RallyPointProvinceIndex]
|
||||||
|
: (ProvinceId?)null;
|
||||||
|
|
||||||
private bool BadlyConstructedUnits => unitSelector.HeroIdsLeadingInappropriateUnits.Count > 0;
|
private bool BadlyConstructedUnits =>
|
||||||
|
unitSelector.HeroIdsLeadingInappropriateUnits.Count > 0;
|
||||||
|
|
||||||
private bool NoBattalions => unitSelector.BattalionCount == 0 && DefendCommand.AvailableBattalions.Count > 0;
|
private bool NoBattalions =>
|
||||||
|
unitSelector.BattalionCount == 0 && DefendCommand.AvailableBattalions.Count > 0;
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => BadlyConstructedUnits || NoBattalions;
|
public override bool WarnOnCommitButton => BadlyConstructedUnits || NoBattalions;
|
||||||
public override string CommitWarningText
|
public override string CommitWarningText {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!(WarnOnCommitButton)) return null;
|
if (!(WarnOnCommitButton)) return null;
|
||||||
|
|
||||||
string txt = "";
|
string txt = "";
|
||||||
if (NoBattalions)
|
if (NoBattalions) { txt = txt + "You have not selected any troops.\n\n"; }
|
||||||
{
|
if (BadlyConstructedUnits) {
|
||||||
txt = txt + "You have not selected any troops.\n\n";
|
|
||||||
}
|
|
||||||
if (BadlyConstructedUnits)
|
|
||||||
{
|
|
||||||
var count = unitSelector.HeroIdsLeadingInappropriateUnits.Count;
|
var count = unitSelector.HeroIdsLeadingInappropriateUnits.Count;
|
||||||
if (count == 1)
|
if (count == 1) {
|
||||||
{
|
txt = txt +
|
||||||
txt = txt + $"{_model.Heroes[unitSelector.HeroIdsLeadingInappropriateUnits[0]].Name} is leading a battalion type that would restrict their abilities.\n\n";
|
$"{_model.Heroes[unitSelector.HeroIdsLeadingInappropriateUnits[0]].Name} is leading a battalion type that would restrict their abilities.\n\n";
|
||||||
}
|
} else {
|
||||||
else
|
txt = txt +
|
||||||
{
|
$"Some of your heroes are leading battalion types that would restrict their abilities.\n\n";
|
||||||
txt = txt + $"Some of your heroes are leading battalion types that would restrict their abilities.\n\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,17 +79,13 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => RallyPointProvinceId;
|
get => RallyPointProvinceId;
|
||||||
|
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
|
||||||
{
|
|
||||||
int index = DefendCommand.AvailableFleeProvinceIds.IndexOf(value.Value);
|
int index = DefendCommand.AvailableFleeProvinceIds.IndexOf(value.Value);
|
||||||
if (index != -1)
|
if (index != -1) rallyPointDropdown.value = index;
|
||||||
rallyPointDropdown.value = index;
|
|
||||||
else
|
else
|
||||||
rallyPointDropdown.value = 0;
|
rallyPointDropdown.value = 0;
|
||||||
}
|
}
|
||||||
@@ -91,80 +95,73 @@ namespace eagle
|
|||||||
public override bool EnableCommitButton => unitSelector.UnitsAreValid;
|
public override bool EnableCommitButton => unitSelector.UnitsAreValid;
|
||||||
public override string DisabledCommitButtonReason => unitSelector.InvalidUnitsReason;
|
public override string DisabledCommitButtonReason => unitSelector.InvalidUnitsReason;
|
||||||
|
|
||||||
private void SetUpRallyPointProvinceDropdown()
|
private void SetUpRallyPointProvinceDropdown() {
|
||||||
{
|
var destinationProvinceNames = DefendCommand.AvailableFleeProvinceIds
|
||||||
var destinationProvinceNames = DefendCommand
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.AvailableFleeProvinceIds
|
_model.Provinces[id],
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
_model.PlayerId.Value))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
rallyPointDropdown.ClearOptions();
|
rallyPointDropdown.ClearOptions();
|
||||||
rallyPointDropdown.AddOptions(destinationProvinceNames);
|
rallyPointDropdown.AddOptions(destinationProvinceNames);
|
||||||
rallyPointDropdown.value = 0;
|
rallyPointDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpUnitSelector()
|
private void SetUpUnitSelector() {
|
||||||
{
|
var dict = new Dictionary<
|
||||||
var dict = new Dictionary<HeroId, List<Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types.BattalionIdWithSuitability>>();
|
HeroId,
|
||||||
foreach (var kv in DefendCommand.SuitableBattalionsForHeroes)
|
List<Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types
|
||||||
{
|
.BattalionIdWithSuitability>>();
|
||||||
|
foreach (var kv in DefendCommand.SuitableBattalionsForHeroes) {
|
||||||
dict.Add(kv.Key, kv.Value.BattalionIdsWithSuitability.ToList());
|
dict.Add(kv.Key, kv.Value.BattalionIdsWithSuitability.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CombatUnit> recommendedUnits = DefendCommand.RecommendedUnits == null ? new List<CombatUnit>() : DefendCommand.RecommendedUnits.ToList();
|
List<CombatUnit> recommendedUnits = DefendCommand.RecommendedUnits == null
|
||||||
|
? new List<CombatUnit>()
|
||||||
|
: DefendCommand.RecommendedUnits.ToList();
|
||||||
|
|
||||||
var province = _model.Provinces[ActingProvinceId];
|
var province = _model.Provinces[ActingProvinceId];
|
||||||
var availableBattalionIds = DefendCommand.AvailableBattalions.Select(b => b.BattalionId).ToList();
|
var availableBattalionIds =
|
||||||
var orderedBattalions = ProvinceUtils.OrderedBattalions(province).Where(batt => availableBattalionIds.Contains(batt.Id)).ToList();
|
DefendCommand.AvailableBattalions.Select(b => b.BattalionId).ToList();
|
||||||
|
var orderedBattalions = ProvinceUtils.OrderedBattalions(province)
|
||||||
|
.Where(batt => availableBattalionIds.Contains(batt.Id))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
unitSelector.SetUpUnits(
|
unitSelector.SetUpUnits(
|
||||||
_model,
|
_model,
|
||||||
DefendCommand.AvailableHeroIds.ToList(),
|
DefendCommand.AvailableHeroIds.ToList(),
|
||||||
orderedBattalions,
|
orderedBattalions,
|
||||||
dict,
|
dict,
|
||||||
recommendedUnits);
|
recommendedUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
if (DefendCommand.AvailableFleeProvinceIds.Count > 0) {
|
||||||
if (DefendCommand.AvailableFleeProvinceIds.Count > 0)
|
var availableRallyPointProvinceNames =
|
||||||
{
|
DefendCommand.AvailableFleeProvinceIds
|
||||||
var availableRallyPointProvinceNames = DefendCommand
|
.Select(pid => _model.Provinces[pid].Name)
|
||||||
.AvailableFleeProvinceIds
|
.ToList();
|
||||||
.Select(pid => _model.Provinces[pid].Name)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
rallyPointDropdown.ClearOptions();
|
rallyPointDropdown.ClearOptions();
|
||||||
rallyPointDropdown.AddOptions(availableRallyPointProvinceNames);
|
rallyPointDropdown.AddOptions(availableRallyPointProvinceNames);
|
||||||
rallyPointDropdown.value = 0;
|
rallyPointDropdown.value = 0;
|
||||||
rallyPointDropdown.gameObject.SetActive(true);
|
rallyPointDropdown.gameObject.SetActive(true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rallyPointDropdown.gameObject.SetActive(false);
|
rallyPointDropdown.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpUnitSelector();
|
SetUpUnitSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var dc = new DefendSelectedCommand();
|
var dc = new DefendSelectedCommand();
|
||||||
if (RallyPointProvinceId.HasValue)
|
if (RallyPointProvinceId.HasValue) {
|
||||||
{
|
dc = new DefendSelectedCommand { FleeProvinceId = RallyPointProvinceId.Value };
|
||||||
dc = new DefendSelectedCommand
|
|
||||||
{
|
|
||||||
FleeProvinceId = RallyPointProvinceId.Value
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
dc.DefendingUnits.AddRange(SelectedActingUnits);
|
dc.DefendingUnits.AddRange(SelectedActingUnits);
|
||||||
|
|
||||||
var cmd = new SelectedCommand
|
var cmd = new SelectedCommand { DefendCommand = dc };
|
||||||
{
|
|
||||||
DefendCommand = dc
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|||||||
+74
-88
@@ -7,19 +7,21 @@ using UnityEngine.UI;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using FactionId = System.Int32;
|
using FactionId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class DiplomacyCommandSelector : CommandSelector
|
public class DiplomacyCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
private HeroId SelectedHeroId => ambassadorDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => ambassadorDropdownController.SelectedHeroId;
|
||||||
private FactionId SelectedFactionId => AvailableTargetFactionIds[targetFactionDropdown.value];
|
private FactionId SelectedFactionId =>
|
||||||
|
AvailableTargetFactionIds[targetFactionDropdown.value];
|
||||||
|
|
||||||
public override bool IsAppropriateFor(AvailableCommand cmd) =>
|
public override bool IsAppropriateFor(AvailableCommand cmd) =>
|
||||||
cmd.SealedValueCase == CommandType && cmd.DiplomacyCommand.Options.Any(opt => opt.SealedValueCase != DiplomacyOption.SealedValueOneofCase.RansomOfferOption);
|
cmd.SealedValueCase == CommandType
|
||||||
|
&& cmd.DiplomacyCommand.Options.Any(
|
||||||
|
opt => opt.SealedValueCase !=
|
||||||
|
DiplomacyOption.SealedValueOneofCase.RansomOfferOption);
|
||||||
|
|
||||||
private DiplomacyAvailableCommand DiplomacyCommand => _availableCommand.DiplomacyCommand;
|
private DiplomacyAvailableCommand DiplomacyCommand => _availableCommand.DiplomacyCommand;
|
||||||
private ProvinceId ActingProvinceId => DiplomacyCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => DiplomacyCommand.ActingProvinceId;
|
||||||
@@ -34,59 +36,59 @@ namespace eagle
|
|||||||
public TMP_Text allianceLabel;
|
public TMP_Text allianceLabel;
|
||||||
public TMP_Text inviteLabel;
|
public TMP_Text inviteLabel;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.DiplomacyCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.DiplomacyCommand;
|
||||||
public override string HeaderString => "Diplomacy";
|
public override string HeaderString => "Diplomacy";
|
||||||
public override string CommitButtonString
|
public override string CommitButtonString {
|
||||||
{
|
get {
|
||||||
get
|
switch (SelectedDiplomacyOptionType) {
|
||||||
{
|
|
||||||
switch (SelectedDiplomacyOptionType)
|
|
||||||
{
|
|
||||||
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
||||||
return "Commit Treaty Offer";
|
return "Commit Treaty Offer";
|
||||||
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
||||||
return "Commit Invite";
|
return "Commit Invite";
|
||||||
default:
|
default: throw new KeyNotFoundException("Unknown diplomacy option");
|
||||||
throw new KeyNotFoundException("Unknown diplomacy option");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => DiplomacyCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => ambassadorDropdownController.SelectedHeroId = heroId;
|
DiplomacyCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
ambassadorDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
public override List<FactionId> TargetedFactionIds => new List<FactionId> { SelectedFactionId };
|
public override List<FactionId> TargetedFactionIds =>
|
||||||
public override bool FactionIsTargetable(FactionId factionId) => AvailableTargetFactionIds.Contains(factionId);
|
new List<FactionId> { SelectedFactionId };
|
||||||
public override void AddTargetedFaction(FactionId factionId) => targetFactionDropdown.value = AvailableTargetFactionIds.IndexOf(factionId);
|
public override bool FactionIsTargetable(FactionId factionId) =>
|
||||||
|
AvailableTargetFactionIds.Contains(factionId);
|
||||||
|
public override void AddTargetedFaction(FactionId factionId) =>
|
||||||
|
targetFactionDropdown.value = AvailableTargetFactionIds.IndexOf(factionId);
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => _model.ActiveFactions[_model.PlayerId.Value].Leaders.Contains(ambassadorDropdownController.SelectedHeroId);
|
public override bool WarnOnCommitButton =>
|
||||||
public override string CommitWarningText => "You're putting your faction leader at risk. Are you sure?";
|
_model.ActiveFactions[_model.PlayerId.Value].Leaders.Contains(
|
||||||
|
ambassadorDropdownController.SelectedHeroId);
|
||||||
|
public override string CommitWarningText =>
|
||||||
|
"You're putting your faction leader at risk. Are you sure?";
|
||||||
|
|
||||||
private List<FactionId> AvailableTargetFactionIds { get; set; }
|
private List<FactionId> AvailableTargetFactionIds { get; set; }
|
||||||
|
|
||||||
private DiplomacyOption.SealedValueOneofCase SelectedDiplomacyOptionType
|
private DiplomacyOption.SealedValueOneofCase SelectedDiplomacyOptionType {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
if (allianceToggle.isOn) return DiplomacyOption.SealedValueOneofCase.TreatyOption;
|
if (allianceToggle.isOn) return DiplomacyOption.SealedValueOneofCase.TreatyOption;
|
||||||
else if (inviteToggle.isOn) return DiplomacyOption.SealedValueOneofCase.InvitationOption;
|
else if (inviteToggle.isOn)
|
||||||
else throw new KeyNotFoundException("Unknown diplomacy option");
|
return DiplomacyOption.SealedValueOneofCase.InvitationOption;
|
||||||
|
else
|
||||||
|
throw new KeyNotFoundException("Unknown diplomacy option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => null;
|
get => null;
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
|
||||||
{
|
|
||||||
var targetFaction = _model.Provinces[value.Value].RulingFactionId;
|
var targetFaction = _model.Provinces[value.Value].RulingFactionId;
|
||||||
if (targetFaction.HasValue)
|
if (targetFaction.HasValue) {
|
||||||
{
|
|
||||||
var dropdownIndex = AvailableTargetFactionIds.IndexOf(targetFaction.Value);
|
var dropdownIndex = AvailableTargetFactionIds.IndexOf(targetFaction.Value);
|
||||||
if (dropdownIndex != -1)
|
if (dropdownIndex != -1) {
|
||||||
{
|
|
||||||
targetFactionDropdown.value = dropdownIndex;
|
targetFactionDropdown.value = dropdownIndex;
|
||||||
SetOptions();
|
SetOptions();
|
||||||
costText.text = SelectedOptionCost.ToString();
|
costText.text = SelectedOptionCost.ToString();
|
||||||
@@ -96,86 +98,73 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FactionId TargetFactionId(DiplomacyOption option)
|
private FactionId TargetFactionId(DiplomacyOption option) {
|
||||||
{
|
switch (option.SealedValueCase) {
|
||||||
switch (option.SealedValueCase)
|
|
||||||
{
|
|
||||||
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
||||||
return option.TreatyOption.TargetFactionId;
|
return option.TreatyOption.TargetFactionId;
|
||||||
|
|
||||||
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
||||||
return option.InvitationOption.TargetFactionId;
|
return option.InvitationOption.TargetFactionId;
|
||||||
|
|
||||||
default:
|
default: throw new System.ArgumentException("Unknown diplomacy option");
|
||||||
throw new System.ArgumentException("Unknown diplomacy option");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GoldCost(DiplomacyOption option)
|
private int GoldCost(DiplomacyOption option) {
|
||||||
{
|
switch (option.SealedValueCase) {
|
||||||
switch (option.SealedValueCase)
|
|
||||||
{
|
|
||||||
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
case DiplomacyOption.SealedValueOneofCase.TreatyOption:
|
||||||
return option.TreatyOption.GoldCost;
|
return option.TreatyOption.GoldCost;
|
||||||
|
|
||||||
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
case DiplomacyOption.SealedValueOneofCase.InvitationOption:
|
||||||
return option.InvitationOption.GoldCost;
|
return option.InvitationOption.GoldCost;
|
||||||
|
|
||||||
default:
|
default: throw new System.ArgumentException("Unknown diplomacy option");
|
||||||
throw new System.ArgumentException("Unknown diplomacy option");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiplomacyOption SelectedOption =>
|
private DiplomacyOption SelectedOption => DiplomacyCommand.Options.First(
|
||||||
DiplomacyCommand.Options.First(opt => opt.SealedValueCase == SelectedDiplomacyOptionType && TargetFactionId(opt) == SelectedFactionId);
|
opt => opt.SealedValueCase == SelectedDiplomacyOptionType &&
|
||||||
|
TargetFactionId(opt) == SelectedFactionId);
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
ambassadorDropdownController.AvailableHeroes =
|
||||||
ambassadorDropdownController.AvailableHeroes = DiplomacyCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid]).ToList();
|
DiplomacyCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid]).ToList();
|
||||||
ambassadorDropdownController.SelectedHeroId = DiplomacyCommand.RecommendedHeroId;
|
ambassadorDropdownController.SelectedHeroId = DiplomacyCommand.RecommendedHeroId;
|
||||||
|
|
||||||
AvailableTargetFactionIds = DiplomacyCommand
|
AvailableTargetFactionIds =
|
||||||
.Options
|
DiplomacyCommand.Options
|
||||||
.Where(opt => opt.SealedValueCase != DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
.Where(opt => opt.SealedValueCase !=
|
||||||
.Select(opt => TargetFactionId(opt))
|
DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
||||||
.Distinct()
|
.Select(opt => TargetFactionId(opt))
|
||||||
.ToList();
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
targetFactionDropdown.ClearOptions();
|
targetFactionDropdown.ClearOptions();
|
||||||
targetFactionDropdown.AddOptions(
|
targetFactionDropdown.AddOptions(
|
||||||
AvailableTargetFactionIds
|
AvailableTargetFactionIds.Select(fid => _model.FactionName(fid)).ToList());
|
||||||
.Select(fid => _model.FactionName(fid))
|
|
||||||
.ToList());
|
|
||||||
targetFactionDropdown.value = 0;
|
targetFactionDropdown.value = 0;
|
||||||
|
|
||||||
SetOptions();
|
SetOptions();
|
||||||
costText.text = SelectedOptionCost.ToString();
|
costText.text = SelectedOptionCost.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleChanged()
|
public void ToggleChanged() { costText.text = SelectedOptionCost.ToString(); }
|
||||||
{
|
|
||||||
costText.text = SelectedOptionCost.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
DiplomacyCommand =
|
||||||
DiplomacyCommand = new DiplomacySelectedCommand
|
new DiplomacySelectedCommand {
|
||||||
{
|
SentHeroId = SelectedHeroId,
|
||||||
SentHeroId = SelectedHeroId,
|
TargetFactionId = SelectedFactionId,
|
||||||
TargetFactionId = SelectedFactionId,
|
SelectedOption = SelectedOption
|
||||||
SelectedOption = SelectedOption
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void TargetDropdownChanged(int value)
|
public void TargetDropdownChanged(int value) { SetOptions(); }
|
||||||
{
|
|
||||||
SetOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetOptions()
|
private void SetOptions() {
|
||||||
{
|
|
||||||
var targetFid = SelectedFactionId;
|
var targetFid = SelectedFactionId;
|
||||||
var enableInvite = DiplomacyCommand.Options.Any(opt => opt.InvitationOption != null && TargetFactionId(opt) == targetFid);
|
var enableInvite = DiplomacyCommand.Options.Any(
|
||||||
|
opt => opt.InvitationOption != null && TargetFactionId(opt) == targetFid);
|
||||||
|
|
||||||
if (!enableInvite) allianceToggle.isOn = true;
|
if (!enableInvite) allianceToggle.isOn = true;
|
||||||
ConditionallyEnable(inviteToggle, inviteLabel, enableInvite);
|
ConditionallyEnable(inviteToggle, inviteLabel, enableInvite);
|
||||||
@@ -183,16 +172,13 @@ namespace eagle
|
|||||||
costText.text = SelectedOptionCost.ToString();
|
costText.text = SelectedOptionCost.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConditionallyEnable(Toggle toggle, TMP_Text label, bool enable)
|
private void ConditionallyEnable(Toggle toggle, TMP_Text label, bool enable) {
|
||||||
{
|
|
||||||
toggle.gameObject.SetActive(enable);
|
toggle.gameObject.SetActive(enable);
|
||||||
Color color = label.color;
|
Color color = label.color;
|
||||||
color.a = enable ? 1.0f : 0.25f;
|
color.a = enable ? 1.0f : 0.25f;
|
||||||
label.color = color;
|
label.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int SelectedOptionCost => _availableCommand != null
|
private int SelectedOptionCost => _availableCommand != null ? GoldCost(SelectedOption) : 0;
|
||||||
? GoldCost(SelectedOption)
|
|
||||||
: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-45
@@ -5,13 +5,11 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class DivineCommandSelector : CommandSelector
|
public class DivineCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDetailsController heroDetails;
|
public HeroDetailsController heroDetails;
|
||||||
public TMP_Text goldCostLabel;
|
public TMP_Text goldCostLabel;
|
||||||
public Button nextHeroButton;
|
public Button nextHeroButton;
|
||||||
@@ -23,29 +21,31 @@ namespace eagle
|
|||||||
private DivineAvailableCommand DivineCommand => _availableCommand.DivineCommand;
|
private DivineAvailableCommand DivineCommand => _availableCommand.DivineCommand;
|
||||||
private ProvinceId ActingProvinceId => DivineCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => DivineCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.DivineCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.DivineCommand;
|
||||||
public override string HeaderString => "Divine Heroes";
|
public override string HeaderString => "Divine Heroes";
|
||||||
public override string CommitButtonString => divineAllSelected ? "Commit Divine All" : "Commit Divine";
|
public override string CommitButtonString =>
|
||||||
|
divineAllSelected ? "Commit Divine All" : "Commit Divine";
|
||||||
|
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => DivineCommand.DivinableHeroes.Any(uh => uh.Hero.Id == heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
|
DivineCommand.DivinableHeroes.Any(uh => uh.Hero.Id == heroId);
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
|
|
||||||
private int _selectedHeroIndex;
|
private int _selectedHeroIndex;
|
||||||
private HeroView SelectedHero => DivineCommand.DivinableHeroes.ToArray()[_selectedHeroIndex].Hero;
|
private HeroView SelectedHero =>
|
||||||
|
DivineCommand.DivinableHeroes.ToArray()[_selectedHeroIndex].Hero;
|
||||||
private HeroId SelectedHeroId => SelectedHero.Id;
|
private HeroId SelectedHeroId => SelectedHero.Id;
|
||||||
private int DivinableCount => DivineCommand.DivinableHeroes.Count;
|
private int DivinableCount => DivineCommand.DivinableHeroes.Count;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
if (_selectedHeroIndex >= DivinableCount) { _selectedHeroIndex = 0; }
|
||||||
if (_selectedHeroIndex >= DivinableCount)
|
|
||||||
{
|
|
||||||
_selectedHeroIndex = 0;
|
|
||||||
}
|
|
||||||
heroDetails.SetHero(SelectedHero, _model);
|
heroDetails.SetHero(SelectedHero, _model);
|
||||||
|
|
||||||
nextHeroButton.gameObject.SetActive(DivinableCount > 1);
|
nextHeroButton.gameObject.SetActive(DivinableCount > 1);
|
||||||
|
|
||||||
bool enableDivineAll = DivinableCount > 1 && _model.Provinces[ActingProvinceId].FullInfo.Gold >= DivinableCount * DivineCommand.CostPerHero;
|
bool enableDivineAll =
|
||||||
|
DivinableCount > 1 && _model.Provinces[ActingProvinceId].FullInfo.Gold >=
|
||||||
|
DivinableCount * DivineCommand.CostPerHero;
|
||||||
divineAllToggle.enabled = enableDivineAll;
|
divineAllToggle.enabled = enableDivineAll;
|
||||||
divineAllToggle.gameObject.SetActive(enableDivineAll);
|
divineAllToggle.gameObject.SetActive(enableDivineAll);
|
||||||
divineAllText.text = $"Divine All ({DivinableCount})";
|
divineAllText.text = $"Divine All ({DivinableCount})";
|
||||||
@@ -56,53 +56,34 @@ namespace eagle
|
|||||||
SetCostLabel();
|
SetCostLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var dc = new DivineSelectedCommand();
|
var dc = new DivineSelectedCommand();
|
||||||
if (divineAllSelected)
|
if (divineAllSelected) {
|
||||||
{
|
|
||||||
dc.HeroIds.Add(DivineCommand.DivinableHeroes.Select(h => h.Hero.Id));
|
dc.HeroIds.Add(DivineCommand.DivinableHeroes.Select(h => h.Hero.Id));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
dc.HeroIds.Add(SelectedHeroId);
|
dc.HeroIds.Add(SelectedHeroId);
|
||||||
}
|
}
|
||||||
var cmd = new SelectedCommand
|
var cmd = new SelectedCommand { DivineCommand = dc };
|
||||||
{
|
|
||||||
DivineCommand = dc
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NextHero()
|
public void NextHero() {
|
||||||
{
|
|
||||||
_selectedHeroIndex++;
|
_selectedHeroIndex++;
|
||||||
if (_selectedHeroIndex >= DivinableCount)
|
if (_selectedHeroIndex >= DivinableCount) { _selectedHeroIndex = 0; }
|
||||||
{
|
|
||||||
_selectedHeroIndex = 0;
|
|
||||||
}
|
|
||||||
heroDetails.SetHero(SelectedHero, _model);
|
heroDetails.SetHero(SelectedHero, _model);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCostLabel()
|
private void SetCostLabel() {
|
||||||
{
|
if (divineAllToggle.isOn) {
|
||||||
if (divineAllToggle.isOn)
|
|
||||||
{
|
|
||||||
goldCostLabel.text = (DivineCommand.CostPerHero * DivinableCount).ToString();
|
goldCostLabel.text = (DivineCommand.CostPerHero * DivinableCount).ToString();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
goldCostLabel.text = DivineCommand.CostPerHero.ToString();
|
goldCostLabel.text = DivineCommand.CostPerHero.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleClicked(bool value)
|
public void ToggleClicked(bool value) { SetCostLabel(); }
|
||||||
{
|
|
||||||
SetCostLabel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-25
@@ -4,19 +4,18 @@ using System.Linq;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class ExileVassalCommandSelector : CommandSelector
|
public class ExileVassalCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
// Unity accessors
|
// Unity accessors
|
||||||
public HeroDropdownController heroSelectionDropdownController;
|
public HeroDropdownController heroSelectionDropdownController;
|
||||||
|
|
||||||
public HeroDetailsController heroDetails;
|
public HeroDetailsController heroDetails;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ExileVassalCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ExileVassalCommand;
|
||||||
public override string HeaderString => "Exile Vassal";
|
public override string HeaderString => "Exile Vassal";
|
||||||
public override string CommitButtonString => $"Commit Exile";
|
public override string CommitButtonString => $"Commit Exile";
|
||||||
|
|
||||||
@@ -24,34 +23,28 @@ namespace eagle
|
|||||||
public HeroView SelectedHero => _model.Heroes[SelectedHeroId];
|
public HeroView SelectedHero => _model.Heroes[SelectedHeroId];
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => ExileVassalAvailableCommand.ExilableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroSelectionDropdownController.SelectedHeroId = heroId;
|
ExileVassalAvailableCommand.ExilableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroSelectionDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private ExileVassalAvailableCommand ExileVassalAvailableCommand => _availableCommand.ExileVassalCommand;
|
private ExileVassalAvailableCommand ExileVassalAvailableCommand =>
|
||||||
|
_availableCommand.ExileVassalCommand;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroSelectionDropdownController.AvailableHeroes =
|
||||||
heroSelectionDropdownController.AvailableHeroes = ExileVassalAvailableCommand.ExilableHeroIds.Select(hid => _model.Heroes[hid]).ToList();
|
ExileVassalAvailableCommand.ExilableHeroIds.Select(hid => _model.Heroes[hid])
|
||||||
|
.ToList();
|
||||||
heroSelectionDropdownController.SelectedHeroIdUpdated = () => DisplaySelectedHero();
|
heroSelectionDropdownController.SelectedHeroIdUpdated = () => DisplaySelectedHero();
|
||||||
DisplaySelectedHero();
|
DisplaySelectedHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
ExileVassalCommand = new ExileVassalSelectedCommand { ExiledHeroId = SelectedHeroId }
|
||||||
ExileVassalCommand = new ExileVassalSelectedCommand
|
|
||||||
{
|
|
||||||
ExiledHeroId = SelectedHeroId
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void DropdownSelected(int value)
|
public void DropdownSelected(int value) { DisplaySelectedHero(); }
|
||||||
{
|
|
||||||
DisplaySelectedHero();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisplaySelectedHero()
|
private void DisplaySelectedHero() { heroDetails.SetHero(SelectedHero, _model); }
|
||||||
{
|
|
||||||
heroDetails.SetHero(SelectedHero, _model);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-11
@@ -3,13 +3,12 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class FeastCommandSelector : CommandSelector
|
public class FeastCommandSelector : CommandSelector {
|
||||||
{
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.FeastCommand;
|
AvailableCommand.SealedValueOneofCase.FeastCommand;
|
||||||
public override string HeaderString => "Feast";
|
public override string HeaderString => "Feast";
|
||||||
public override string CommitButtonString => "Commit Feast";
|
public override string CommitButtonString => "Commit Feast";
|
||||||
|
|
||||||
@@ -18,13 +17,10 @@ namespace eagle
|
|||||||
private FeastAvailableCommand FeastAvailableCommand => _availableCommand.FeastCommand;
|
private FeastAvailableCommand FeastAvailableCommand => _availableCommand.FeastCommand;
|
||||||
private ProvinceId ActingProvinceId => FeastAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => FeastAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command =>
|
||||||
{
|
new SelectedCommand { FeastCommand = new FeastSelectedCommand() };
|
||||||
FeastCommand = new FeastSelectedCommand()
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
GoldCostLabel.text = _availableCommand.FeastCommand.GoldCost.ToString();
|
GoldCostLabel.text = _availableCommand.FeastCommand.GoldCost.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-27
@@ -6,55 +6,52 @@ using Net.Eagle0.Eagle.Api.Command.Util;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class FreeForAllDecisionCommandSelector : CommandSelector
|
public class FreeForAllDecisionCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public EventBasedTable unitsTable;
|
public EventBasedTable unitsTable;
|
||||||
public EventBasedTable armiesTable;
|
public EventBasedTable armiesTable;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.FreeForAllDecisionCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.FreeForAllDecisionCommand;
|
||||||
public override string HeaderString => "Free-For-All Decision";
|
public override string HeaderString => "Free-For-All Decision";
|
||||||
public override string CommitButtonString => AdvanceToggle.isOn ? "Commit Advance" : "Commit Withdraw";
|
public override string CommitButtonString =>
|
||||||
|
AdvanceToggle.isOn ? "Commit Advance" : "Commit Withdraw";
|
||||||
|
|
||||||
public Toggle AdvanceToggle;
|
public Toggle AdvanceToggle;
|
||||||
public Toggle WithdrawToggle;
|
public Toggle WithdrawToggle;
|
||||||
|
|
||||||
private FreeForAllDecisionAvailableCommand FreeForAllDecisionCommand => _availableCommand.FreeForAllDecisionCommand;
|
private FreeForAllDecisionAvailableCommand FreeForAllDecisionCommand =>
|
||||||
|
_availableCommand.FreeForAllDecisionCommand;
|
||||||
private ProvinceId ActingProvinceId => FreeForAllDecisionCommand.ProvinceId;
|
private ProvinceId ActingProvinceId => FreeForAllDecisionCommand.ProvinceId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
FreeForAllDecisionCommand =
|
||||||
FreeForAllDecisionCommand = new FreeForAllDecisionSelectedCommand
|
new FreeForAllDecisionSelectedCommand {
|
||||||
{
|
ProvinceId = ActingProvinceId,
|
||||||
ProvinceId = ActingProvinceId,
|
Decision = AdvanceToggle.isOn ? AttackDecisionType.AdvanceDecision
|
||||||
Decision = AdvanceToggle.isOn ? AttackDecisionType.AdvanceDecision : AttackDecisionType.WithdrawDecision
|
: AttackDecisionType.WithdrawDecision
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
unitsTable.RowCount = FreeForAllDecisionCommand.ActingUnits.Count;
|
unitsTable.RowCount = FreeForAllDecisionCommand.ActingUnits.Count;
|
||||||
ProvinceView province = _model.Provinces[ActingProvinceId];
|
ProvinceView province = _model.Provinces[ActingProvinceId];
|
||||||
|
|
||||||
FreeForAllDecisionCommand.ActingUnits.Each((cu, idx) =>
|
FreeForAllDecisionCommand.ActingUnits.Each((cu, idx) => {
|
||||||
{
|
|
||||||
CombatUnitRowController row = unitsTable.ComponentAt<CombatUnitRowController>(idx);
|
CombatUnitRowController row = unitsTable.ComponentAt<CombatUnitRowController>(idx);
|
||||||
row.Hero = cu.Hero;
|
row.Hero = cu.Hero;
|
||||||
row.Battalion = cu.Battalion;
|
row.Battalion = cu.Battalion;
|
||||||
});
|
});
|
||||||
|
|
||||||
armiesTable.RowCount = FreeForAllDecisionCommand.Armies.Count;
|
armiesTable.RowCount = FreeForAllDecisionCommand.Armies.Count;
|
||||||
FreeForAllDecisionCommand.Armies.Each((army, idx) =>
|
FreeForAllDecisionCommand.Armies.Each((army, idx) => {
|
||||||
{
|
|
||||||
IncomingArmyTableRow row = armiesTable.ComponentAt<IncomingArmyTableRow>(idx);
|
IncomingArmyTableRow row = armiesTable.ComponentAt<IncomingArmyTableRow>(idx);
|
||||||
row.Faction = _model.FactionName(army.FactionId);
|
row.Faction = _model.FactionName(army.FactionId);
|
||||||
row.HeroCount = army.HeroCount;
|
row.HeroCount = army.HeroCount;
|
||||||
row.TroopCount = army.TroopCount;
|
row.TroopCount = army.TroopCount;
|
||||||
switch (army.Hostility)
|
switch (army.Hostility) {
|
||||||
{
|
|
||||||
case Net.Eagle0.Common.Hostility.AlliedHostility:
|
case Net.Eagle0.Common.Hostility.AlliedHostility:
|
||||||
row.TextColor = Color.green;
|
row.TextColor = Color.green;
|
||||||
break;
|
break;
|
||||||
@@ -70,13 +67,11 @@ namespace eagle
|
|||||||
|
|
||||||
AdvanceToggle.isOn = true;
|
AdvanceToggle.isOn = true;
|
||||||
AdvanceToggle.enabled = true;
|
AdvanceToggle.enabled = true;
|
||||||
WithdrawToggle.enabled = FreeForAllDecisionCommand.AvailableDecisions.Contains(AttackDecisionType.WithdrawDecision);
|
WithdrawToggle.enabled = FreeForAllDecisionCommand.AvailableDecisions.Contains(
|
||||||
|
AttackDecisionType.WithdrawDecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+63
-53
@@ -5,12 +5,10 @@ using UnityEngine.UI;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class HandleCapturedHeroesCommandSelector : CommandSelector
|
public class HandleCapturedHeroesCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
// Unity accessors
|
// Unity accessors
|
||||||
public Toggle RecruitToggle;
|
public Toggle RecruitToggle;
|
||||||
public Toggle ImprisonToggle;
|
public Toggle ImprisonToggle;
|
||||||
@@ -32,88 +30,101 @@ namespace eagle
|
|||||||
|
|
||||||
public HeroView SelectedHero => SelectedHeroWithOptions.Hero;
|
public HeroView SelectedHero => SelectedHeroWithOptions.Hero;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.HandleCapturedHeroCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.HandleCapturedHeroCommand;
|
||||||
public override string HeaderString => "Handle Captured Hero";
|
public override string HeaderString => "Handle Captured Hero";
|
||||||
public override string CommitButtonString => $"Commit {DisplayNames.CapturedHeroOptionNames[SelectedOption]}";
|
public override string CommitButtonString =>
|
||||||
|
$"Commit {DisplayNames.CapturedHeroOptionNames[SelectedOption]}";
|
||||||
|
|
||||||
private int _selectedHeroIndex;
|
private int _selectedHeroIndex;
|
||||||
private ExpandedCapturedHero SelectedHeroWithOptions => HandleCapturedHeroCommand.AvailableHeroes[_selectedHeroIndex];
|
private ExpandedCapturedHero SelectedHeroWithOptions =>
|
||||||
|
HandleCapturedHeroCommand.AvailableHeroes[_selectedHeroIndex];
|
||||||
|
|
||||||
private HandleCapturedHeroAvailableCommand HandleCapturedHeroCommand => _availableCommand.HandleCapturedHeroCommand;
|
private HandleCapturedHeroAvailableCommand HandleCapturedHeroCommand =>
|
||||||
|
_availableCommand.HandleCapturedHeroCommand;
|
||||||
private ProvinceId ActingProvinceId => HandleCapturedHeroCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => HandleCapturedHeroCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => SelectedOption == CapturedHeroOption.ReturnCapturedHeroOption;
|
public override bool WarnOnCommitButton =>
|
||||||
public override string CommitWarningText => $"This will create a treaty with {_model.FactionName(SelectedHero.FactionId.Value)}";
|
SelectedOption == CapturedHeroOption.ReturnCapturedHeroOption;
|
||||||
|
public override string CommitWarningText =>
|
||||||
|
$"This will create a treaty with {_model.FactionName(SelectedHero.FactionId.Value)}";
|
||||||
|
|
||||||
private CapturedHeroOption SelectedOption
|
private CapturedHeroOption SelectedOption {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
if (RecruitToggle.isOn) return CapturedHeroOption.RecruitCapturedHeroOption;
|
if (RecruitToggle.isOn) return CapturedHeroOption.RecruitCapturedHeroOption;
|
||||||
else if (ImprisonToggle.isOn) return CapturedHeroOption.ImprisonCapturedHeroOption;
|
else if (ImprisonToggle.isOn)
|
||||||
else if (ExileToggle.isOn) return CapturedHeroOption.ExileCapturedHeroOption;
|
return CapturedHeroOption.ImprisonCapturedHeroOption;
|
||||||
else if (ExecuteToggle.isOn) return CapturedHeroOption.ExecuteCapturedHeroOption;
|
else if (ExileToggle.isOn)
|
||||||
else if (ReturnToggle.isOn) return CapturedHeroOption.ReturnCapturedHeroOption;
|
return CapturedHeroOption.ExileCapturedHeroOption;
|
||||||
else throw new ArgumentOutOfRangeException("Unknown captured hero option");
|
else if (ExecuteToggle.isOn)
|
||||||
|
return CapturedHeroOption.ExecuteCapturedHeroOption;
|
||||||
|
else if (ReturnToggle.isOn)
|
||||||
|
return CapturedHeroOption.ReturnCapturedHeroOption;
|
||||||
|
else
|
||||||
|
throw new ArgumentOutOfRangeException("Unknown captured hero option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
if (_selectedHeroIndex >= HandleCapturedHeroCommand.AvailableHeroes.Count)
|
||||||
if (_selectedHeroIndex >= HandleCapturedHeroCommand.AvailableHeroes.Count) _selectedHeroIndex = 0;
|
_selectedHeroIndex = 0;
|
||||||
NextHeroButton.gameObject.SetActive(HandleCapturedHeroCommand.AvailableHeroes.Count > 1);
|
NextHeroButton.gameObject.SetActive(
|
||||||
|
HandleCapturedHeroCommand.AvailableHeroes.Count > 1);
|
||||||
DisplaySelectedHero();
|
DisplaySelectedHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
HandleCapturedHeroCommand =
|
||||||
HandleCapturedHeroCommand = new HandleCapturedHeroSelectedCommand()
|
new HandleCapturedHeroSelectedCommand() {
|
||||||
{
|
HeroId = SelectedHero.Id,
|
||||||
HeroId = SelectedHero.Id,
|
SelectedOption = SelectedOption
|
||||||
SelectedOption = SelectedOption
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void NextHeroButtonClicked()
|
public void NextHeroButtonClicked() {
|
||||||
{
|
|
||||||
_selectedHeroIndex++;
|
_selectedHeroIndex++;
|
||||||
if (_selectedHeroIndex >= HandleCapturedHeroCommand.AvailableHeroes.Count)
|
if (_selectedHeroIndex >= HandleCapturedHeroCommand.AvailableHeroes.Count) {
|
||||||
{
|
|
||||||
_selectedHeroIndex = 0;
|
_selectedHeroIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplaySelectedHero();
|
DisplaySelectedHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplaySelectedHero()
|
private void DisplaySelectedHero() {
|
||||||
{
|
|
||||||
heroDetails.SetHero(SelectedHero, _model);
|
heroDetails.SetHero(SelectedHero, _model);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(SelectedHeroWithOptions.Message))
|
if (String.IsNullOrEmpty(SelectedHeroWithOptions.Message)) {
|
||||||
{
|
|
||||||
MessageText.text = $"What should we do with {SelectedHero.Name}?";
|
MessageText.text = $"What should we do with {SelectedHero.Name}?";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageText.text = SelectedHeroWithOptions.Message;
|
MessageText.text = SelectedHeroWithOptions.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The order here is important: the last available toggle in this list
|
// The order here is important: the last available toggle in this list
|
||||||
// will be on by default
|
// will be on by default
|
||||||
ConditionallyEnable(ExecuteToggle, ExecuteIcon, CapturedHeroOption.ExecuteCapturedHeroOption);
|
ConditionallyEnable(
|
||||||
|
ExecuteToggle,
|
||||||
|
ExecuteIcon,
|
||||||
|
CapturedHeroOption.ExecuteCapturedHeroOption);
|
||||||
ConditionallyEnable(ExileToggle, ExileIcon, CapturedHeroOption.ExileCapturedHeroOption);
|
ConditionallyEnable(ExileToggle, ExileIcon, CapturedHeroOption.ExileCapturedHeroOption);
|
||||||
ConditionallyEnable(ReturnToggle, ReturnIcon, CapturedHeroOption.ReturnCapturedHeroOption);
|
ConditionallyEnable(
|
||||||
ConditionallyEnable(ImprisonToggle, ImprisonIcon, CapturedHeroOption.ImprisonCapturedHeroOption);
|
ReturnToggle,
|
||||||
ConditionallyEnable(RecruitToggle, RecruitIcon, CapturedHeroOption.RecruitCapturedHeroOption);
|
ReturnIcon,
|
||||||
|
CapturedHeroOption.ReturnCapturedHeroOption);
|
||||||
|
ConditionallyEnable(
|
||||||
|
ImprisonToggle,
|
||||||
|
ImprisonIcon,
|
||||||
|
CapturedHeroOption.ImprisonCapturedHeroOption);
|
||||||
|
ConditionallyEnable(
|
||||||
|
RecruitToggle,
|
||||||
|
RecruitIcon,
|
||||||
|
CapturedHeroOption.RecruitCapturedHeroOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ConditionallyEnable(Toggle toggle, CapturedHeroOption option)
|
private bool ConditionallyEnable(Toggle toggle, CapturedHeroOption option) {
|
||||||
{
|
|
||||||
bool enable = SelectedHeroWithOptions.Options.Contains(option);
|
bool enable = SelectedHeroWithOptions.Options.Contains(option);
|
||||||
toggle.gameObject.SetActive(enable);
|
toggle.gameObject.SetActive(enable);
|
||||||
|
|
||||||
if (enable)
|
if (enable) {
|
||||||
{
|
|
||||||
ExecuteToggle.isOn = false;
|
ExecuteToggle.isOn = false;
|
||||||
ExileToggle.isOn = false;
|
ExileToggle.isOn = false;
|
||||||
ImprisonToggle.isOn = false;
|
ImprisonToggle.isOn = false;
|
||||||
@@ -121,14 +132,13 @@ namespace eagle
|
|||||||
ReturnToggle.isOn = false;
|
ReturnToggle.isOn = false;
|
||||||
|
|
||||||
toggle.isOn = true;
|
toggle.isOn = true;
|
||||||
}
|
} else
|
||||||
else toggle.isOn = false;
|
toggle.isOn = false;
|
||||||
|
|
||||||
return enable;
|
return enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConditionallyEnable(Toggle toggle, RawImage img, CapturedHeroOption option)
|
private void ConditionallyEnable(Toggle toggle, RawImage img, CapturedHeroOption option) {
|
||||||
{
|
|
||||||
bool enable = ConditionallyEnable(toggle, option);
|
bool enable = ConditionallyEnable(toggle, option);
|
||||||
|
|
||||||
Color color = img.color;
|
Color color = img.color;
|
||||||
|
|||||||
+34
-28
@@ -6,18 +6,17 @@ using Net.Eagle0.Eagle.Api.Command;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class HandleRiotCrackDownCommandSelector : CommandSelector
|
public class HandleRiotCrackDownCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public BattalionDropdownController battalionDropdownController;
|
public BattalionDropdownController battalionDropdownController;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.HandleRiotCrackDownAvailableCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.HandleRiotCrackDownAvailableCommand;
|
||||||
|
|
||||||
public override string HeaderString => "Crack Down";
|
public override string HeaderString => "Crack Down";
|
||||||
public override string CommitButtonString => "Commit Crack Down";
|
public override string CommitButtonString => "Commit Crack Down";
|
||||||
@@ -26,42 +25,49 @@ namespace eagle
|
|||||||
public override string CommitWarningText => "You aren't sending a battalion. Are you sure?";
|
public override string CommitWarningText => "You aren't sending a battalion. Are you sure?";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => HandleRiotCrackDownAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
HandleRiotCrackDownAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
public override List<BattalionId> TargetedBattalionIds => SelectedBattalionId.HasValue ? new List<BattalionId> { SelectedBattalionId.Value } : new List<BattalionId>();
|
public override List<BattalionId> TargetedBattalionIds =>
|
||||||
public override bool BattalionIsTargetable(BattalionId bid) => HandleRiotCrackDownAvailableCommand.BattalionIdsAvailable.Contains(bid);
|
SelectedBattalionId.HasValue ? new List<BattalionId> { SelectedBattalionId.Value }
|
||||||
public override void AddTargetedBattalion(BattalionId bid) => battalionDropdownController.SelectedBattalionId = bid;
|
: new List<BattalionId>();
|
||||||
|
public override bool BattalionIsTargetable(BattalionId bid) =>
|
||||||
|
HandleRiotCrackDownAvailableCommand.BattalionIdsAvailable.Contains(bid);
|
||||||
|
public override void AddTargetedBattalion(BattalionId bid) =>
|
||||||
|
battalionDropdownController.SelectedBattalionId = bid;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
private BattalionId? SelectedBattalionId => battalionDropdownController.SelectedBattalionId;
|
private BattalionId? SelectedBattalionId => battalionDropdownController.SelectedBattalionId;
|
||||||
|
|
||||||
private HandleRiotCrackDownAvailableCommand HandleRiotCrackDownAvailableCommand => _availableCommand.HandleRiotCrackDownAvailableCommand;
|
private HandleRiotCrackDownAvailableCommand HandleRiotCrackDownAvailableCommand =>
|
||||||
|
_availableCommand.HandleRiotCrackDownAvailableCommand;
|
||||||
private ProvinceId ActingProvinceId => HandleRiotCrackDownAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => HandleRiotCrackDownAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
private ProvinceView Province => _model.Provinces[ActingProvinceId];
|
private ProvinceView Province => _model.Provinces[ActingProvinceId];
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
HandleRiotCrackDownSelectedCommand =
|
||||||
HandleRiotCrackDownSelectedCommand = new HandleRiotCrackDownSelectedCommand
|
new HandleRiotCrackDownSelectedCommand {
|
||||||
{
|
HeroId = SelectedHeroId,
|
||||||
HeroId = SelectedHeroId,
|
BattalionId = SelectedBattalionId
|
||||||
BattalionId = SelectedBattalionId
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes =
|
||||||
heroDropdownController.AvailableHeroes = HandleRiotCrackDownAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
HandleRiotCrackDownAvailableCommand.AvailableHeroIds
|
||||||
battalionDropdownController.AvailableBattalions = HandleRiotCrackDownAvailableCommand.BattalionIdsAvailable
|
.Select(id => _model.Heroes[id])
|
||||||
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
.ToList();
|
||||||
.OrderBy(batt => batt.Type)
|
battalionDropdownController.AvailableBattalions =
|
||||||
.ToList();
|
HandleRiotCrackDownAvailableCommand.BattalionIdsAvailable
|
||||||
|
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
||||||
|
.OrderBy(batt => batt.Type)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-14
@@ -1,30 +1,25 @@
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class HandleRiotDoNothingCommandSelector : CommandSelector {
|
||||||
public class HandleRiotDoNothingCommandSelector : CommandSelector
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
{
|
AvailableCommand.SealedValueOneofCase.HandleRiotDoNothingAvailableCommand;
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.HandleRiotDoNothingAvailableCommand;
|
|
||||||
|
|
||||||
public override string HeaderString => "Ignore Imminent Riot";
|
public override string HeaderString => "Ignore Imminent Riot";
|
||||||
|
|
||||||
public override string CommitButtonString => "Commit Ignore";
|
public override string CommitButtonString => "Commit Ignore";
|
||||||
|
|
||||||
private HandleRiotDoNothingAvailableCommand HandleRiotDoNothingCommand => _availableCommand.HandleRiotDoNothingAvailableCommand;
|
private HandleRiotDoNothingAvailableCommand HandleRiotDoNothingCommand =>
|
||||||
|
_availableCommand.HandleRiotDoNothingAvailableCommand;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
|
||||||
HandleRiotDoNothingSelectedCommand = new HandleRiotDoNothingSelectedCommand()
|
HandleRiotDoNothingSelectedCommand = new HandleRiotDoNothingSelectedCommand()
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+23
-50
@@ -3,12 +3,10 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class HandleRiotGiveCommandSelector : CommandSelector
|
public class HandleRiotGiveCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public Toggle foodToggle;
|
public Toggle foodToggle;
|
||||||
public Toggle goldToggle;
|
public Toggle goldToggle;
|
||||||
|
|
||||||
@@ -17,39 +15,33 @@ namespace eagle
|
|||||||
public Slider goldTakenSlider;
|
public Slider goldTakenSlider;
|
||||||
public TMP_Text goldTakenLabel;
|
public TMP_Text goldTakenLabel;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.HandleRiotGiveAvailableCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.HandleRiotGiveAvailableCommand;
|
||||||
|
|
||||||
public override string HeaderString => "Give to Populace";
|
public override string HeaderString => "Give to Populace";
|
||||||
|
|
||||||
public override string CommitButtonString => "Commit Gift";
|
public override string CommitButtonString => "Commit Gift";
|
||||||
|
|
||||||
private HandleRiotGiveSelectedCommand SpecializedCommand()
|
private HandleRiotGiveSelectedCommand SpecializedCommand() {
|
||||||
{
|
|
||||||
var spc = new HandleRiotGiveSelectedCommand();
|
var spc = new HandleRiotGiveSelectedCommand();
|
||||||
if (foodToggle.isOn)
|
if (foodToggle.isOn) {
|
||||||
{
|
|
||||||
spc.FoodAmount = (int)foodTakenSlider.value;
|
spc.FoodAmount = (int)foodTakenSlider.value;
|
||||||
}
|
} else if (goldToggle.isOn) {
|
||||||
else if (goldToggle.isOn)
|
|
||||||
{
|
|
||||||
spc.GoldAmount = (int)goldTakenSlider.value;
|
spc.GoldAmount = (int)goldTakenSlider.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spc;
|
return spc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command =>
|
||||||
{
|
new SelectedCommand { HandleRiotGiveSelectedCommand = SpecializedCommand() };
|
||||||
HandleRiotGiveSelectedCommand = SpecializedCommand()
|
|
||||||
};
|
|
||||||
|
|
||||||
private HandleRiotGiveAvailableCommand HandleRiotCommand => _availableCommand.HandleRiotGiveAvailableCommand;
|
private HandleRiotGiveAvailableCommand HandleRiotCommand =>
|
||||||
|
_availableCommand.HandleRiotGiveAvailableCommand;
|
||||||
private ProvinceId ActingProvinceId => HandleRiotCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => HandleRiotCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
if (HandleRiotCommand.GoldAvailable > 0) {
|
||||||
if (HandleRiotCommand.GoldAvailable > 0)
|
|
||||||
{
|
|
||||||
goldTakenSlider.maxValue = HandleRiotCommand.GoldAvailable;
|
goldTakenSlider.maxValue = HandleRiotCommand.GoldAvailable;
|
||||||
goldTakenSlider.minValue = 1;
|
goldTakenSlider.minValue = 1;
|
||||||
goldTakenSlider.value = HandleRiotCommand.GoldAvailable;
|
goldTakenSlider.value = HandleRiotCommand.GoldAvailable;
|
||||||
@@ -58,15 +50,12 @@ namespace eagle
|
|||||||
goldToggle.gameObject.SetActive(true);
|
goldToggle.gameObject.SetActive(true);
|
||||||
foodToggle.isOn = false;
|
foodToggle.isOn = false;
|
||||||
goldToggle.isOn = true;
|
goldToggle.isOn = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
goldToggle.enabled = false;
|
goldToggle.enabled = false;
|
||||||
goldToggle.gameObject.SetActive(false);
|
goldToggle.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HandleRiotCommand.FoodAvailable > 0)
|
if (HandleRiotCommand.FoodAvailable > 0) {
|
||||||
{
|
|
||||||
foodTakenSlider.maxValue = HandleRiotCommand.FoodAvailable;
|
foodTakenSlider.maxValue = HandleRiotCommand.FoodAvailable;
|
||||||
foodTakenSlider.minValue = 1;
|
foodTakenSlider.minValue = 1;
|
||||||
foodTakenSlider.value = HandleRiotCommand.FoodAvailable;
|
foodTakenSlider.value = HandleRiotCommand.FoodAvailable;
|
||||||
@@ -75,57 +64,41 @@ namespace eagle
|
|||||||
foodToggle.gameObject.SetActive(true);
|
foodToggle.gameObject.SetActive(true);
|
||||||
goldToggle.isOn = false;
|
goldToggle.isOn = false;
|
||||||
foodToggle.isOn = true;
|
foodToggle.isOn = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
foodToggle.enabled = false;
|
foodToggle.enabled = false;
|
||||||
foodToggle.gameObject.SetActive(false);
|
foodToggle.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void FoodSliderMoved(float value) { foodTakenLabel.text = $"{(int)value}"; }
|
||||||
|
|
||||||
|
public void GoldSliderMoved(float value) { goldTakenLabel.text = $"{(int)value}"; }
|
||||||
|
|
||||||
public void FoodSliderMoved(float value)
|
public void FoodToggleSelected() {
|
||||||
{
|
|
||||||
foodTakenLabel.text = $"{(int)value}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GoldSliderMoved(float value)
|
|
||||||
{
|
|
||||||
goldTakenLabel.text = $"{(int)value}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FoodToggleSelected()
|
|
||||||
{
|
|
||||||
foodTakenSlider.gameObject.SetActive(true);
|
foodTakenSlider.gameObject.SetActive(true);
|
||||||
foodTakenLabel.gameObject.SetActive(true);
|
foodTakenLabel.gameObject.SetActive(true);
|
||||||
goldTakenSlider.gameObject.SetActive(false);
|
goldTakenSlider.gameObject.SetActive(false);
|
||||||
goldTakenLabel.gameObject.SetActive(false);
|
goldTakenLabel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoldToggleSelected()
|
public void GoldToggleSelected() {
|
||||||
{
|
|
||||||
foodTakenSlider.gameObject.SetActive(false);
|
foodTakenSlider.gameObject.SetActive(false);
|
||||||
foodTakenLabel.gameObject.SetActive(false);
|
foodTakenLabel.gameObject.SetActive(false);
|
||||||
goldTakenSlider.gameObject.SetActive(true);
|
goldTakenSlider.gameObject.SetActive(true);
|
||||||
goldTakenLabel.gameObject.SetActive(true);
|
goldTakenLabel.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CrackDownToggleSelected()
|
public void CrackDownToggleSelected() {
|
||||||
{
|
|
||||||
foodTakenSlider.gameObject.SetActive(false);
|
foodTakenSlider.gameObject.SetActive(false);
|
||||||
foodTakenLabel.gameObject.SetActive(false);
|
foodTakenLabel.gameObject.SetActive(false);
|
||||||
goldTakenSlider.gameObject.SetActive(false);
|
goldTakenSlider.gameObject.SetActive(false);
|
||||||
goldTakenLabel.gameObject.SetActive(false);
|
goldTakenLabel.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NothingToggleSelected()
|
public void NothingToggleSelected() {
|
||||||
{
|
|
||||||
foodTakenSlider.gameObject.SetActive(false);
|
foodTakenSlider.gameObject.SetActive(false);
|
||||||
foodTakenLabel.gameObject.SetActive(false);
|
foodTakenLabel.gameObject.SetActive(false);
|
||||||
goldTakenSlider.gameObject.SetActive(false);
|
goldTakenSlider.gameObject.SetActive(false);
|
||||||
|
|||||||
+58
-60
@@ -6,13 +6,11 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
|
|
||||||
public class HeroGiftCommandSelector : CommandSelector
|
public class HeroGiftCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public TMP_Dropdown provinceDropdown;
|
public TMP_Dropdown provinceDropdown;
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public Slider goldSlider;
|
public Slider goldSlider;
|
||||||
@@ -21,51 +19,62 @@ namespace eagle
|
|||||||
private HeroGiftAvailableCommand HeroGiftCommand => _availableCommand.HeroGiftCommand;
|
private HeroGiftAvailableCommand HeroGiftCommand => _availableCommand.HeroGiftCommand;
|
||||||
private ProvinceId ActingProvinceId => HeroGiftCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => HeroGiftCommand.ActingProvinceId;
|
||||||
|
|
||||||
private ProvinceId? FilterProvince => provinceDropdown.value == 0 ? null : (ProvinceId?)HeroGiftCommand.EligibleGifts.GroupBy(eg => eg.RecipientProvinceId).ToList()[provinceDropdown.value - 1].Key;
|
private ProvinceId? FilterProvince =>
|
||||||
|
provinceDropdown.value == 0 ? null
|
||||||
|
: (ProvinceId?)HeroGiftCommand.EligibleGifts
|
||||||
|
.GroupBy(eg => eg.RecipientProvinceId)
|
||||||
|
.ToList()[provinceDropdown.value - 1]
|
||||||
|
.Key;
|
||||||
|
|
||||||
private List<EligibleGift> FilteredEligibleGifts => FilterProvince == null ? HeroGiftCommand.EligibleGifts.ToList() : HeroGiftCommand
|
private List<EligibleGift> FilteredEligibleGifts =>
|
||||||
.EligibleGifts
|
FilterProvince == null
|
||||||
.Where(eg => eg.RecipientProvinceId == FilterProvince.Value)
|
? HeroGiftCommand.EligibleGifts.ToList()
|
||||||
.ToList();
|
: HeroGiftCommand.EligibleGifts
|
||||||
|
.Where(eg => eg.RecipientProvinceId == FilterProvince.Value)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
private List<HeroId> AvailableHeroIds => FilteredEligibleGifts
|
private List<HeroId> AvailableHeroIds =>
|
||||||
.Select(eg => eg.RecipientHeroId)
|
FilteredEligibleGifts.Select(eg => eg.RecipientHeroId).ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private int AvailableGold => HeroGiftCommand.EligibleGifts.ToList().Find(eg => eg.RecipientHeroId == SelectedHeroId).GoldAvailable;
|
private int AvailableGold => HeroGiftCommand.EligibleGifts.ToList()
|
||||||
|
.Find(eg => eg.RecipientHeroId == SelectedHeroId)
|
||||||
|
.GoldAvailable;
|
||||||
private int SelectedGoldAmount => (int)goldSlider.value;
|
private int SelectedGoldAmount => (int)goldSlider.value;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.HeroGiftCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.HeroGiftCommand;
|
||||||
public override string HeaderString => "Give to Hero";
|
public override string HeaderString => "Give to Hero";
|
||||||
public override string CommitButtonString => "Commit Gift";
|
public override string CommitButtonString => "Commit Gift";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => HeroGiftCommand.EligibleGifts.Where(eg => eg.RecipientHeroId == heroId).Count() > 0;
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId)
|
HeroGiftCommand.EligibleGifts.Where(eg => eg.RecipientHeroId == heroId).Count() > 0;
|
||||||
{
|
public override void AddTargetedHero(HeroId heroId) {
|
||||||
var eligibleGift = HeroGiftCommand.EligibleGifts.Where(eg => eg.RecipientHeroId == heroId).First();
|
var eligibleGift =
|
||||||
if (TargetedProvince.HasValue && TargetedProvince != eligibleGift.RecipientProvinceId) TargetedProvince = null;
|
HeroGiftCommand.EligibleGifts.Where(eg => eg.RecipientHeroId == heroId).First();
|
||||||
else heroDropdownController.SelectedHeroId = heroId;
|
if (TargetedProvince.HasValue && TargetedProvince != eligibleGift.RecipientProvinceId)
|
||||||
|
TargetedProvince = null;
|
||||||
|
else
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool EnableCommitButton => SelectedGoldAmount > 0;
|
public override bool EnableCommitButton => SelectedGoldAmount > 0;
|
||||||
public override string DisabledCommitButtonReason => "Must send some gold";
|
public override string DisabledCommitButtonReason => "Must send some gold";
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => FilterProvince;
|
get => FilterProvince;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
var newIndex = 0;
|
var newIndex = 0;
|
||||||
if (value is ProvinceId pid)
|
if (value is ProvinceId pid) {
|
||||||
{
|
var index = HeroGiftCommand.EligibleGifts.GroupBy(eg => eg.RecipientProvinceId)
|
||||||
var index = HeroGiftCommand.EligibleGifts.GroupBy(eg => eg.RecipientProvinceId).Select(x => x.Key).ToList().IndexOf(pid);
|
.Select(x => x.Key)
|
||||||
|
.ToList()
|
||||||
|
.IndexOf(pid);
|
||||||
if (index != -1) newIndex = index + 1;
|
if (index != -1) newIndex = index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newIndex != provinceDropdown.value)
|
if (newIndex != provinceDropdown.value) {
|
||||||
{
|
|
||||||
provinceDropdown.value = newIndex;
|
provinceDropdown.value = newIndex;
|
||||||
SetUpHeroDropdown();
|
SetUpHeroDropdown();
|
||||||
}
|
}
|
||||||
@@ -74,16 +83,17 @@ namespace eagle
|
|||||||
public override bool WarnOnCommitButton => false;
|
public override bool WarnOnCommitButton => false;
|
||||||
public override string CommitWarningText => null;
|
public override string CommitWarningText => null;
|
||||||
|
|
||||||
void Awake()
|
void Awake() {
|
||||||
{
|
|
||||||
heroDropdownController.ConditionAccessor = hero => hero.Loyalty;
|
heroDropdownController.ConditionAccessor = hero => hero.Loyalty;
|
||||||
heroDropdownController.ConditionName = "LOY";
|
heroDropdownController.ConditionName = "LOY";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
provinceDropdown.ClearOptions();
|
provinceDropdown.ClearOptions();
|
||||||
var availableProvinces = HeroGiftCommand.EligibleGifts.GroupBy(eg => eg.RecipientProvinceId).Select(x => x.Key).ToList();
|
var availableProvinces =
|
||||||
|
HeroGiftCommand.EligibleGifts.GroupBy(eg => eg.RecipientProvinceId)
|
||||||
|
.Select(x => x.Key)
|
||||||
|
.ToList();
|
||||||
var optionsList = new List<string> { "All" };
|
var optionsList = new List<string> { "All" };
|
||||||
optionsList.AddRange(availableProvinces.Select(pid => _model.Provinces[pid].Name));
|
optionsList.AddRange(availableProvinces.Select(pid => _model.Provinces[pid].Name));
|
||||||
provinceDropdown.AddOptions(optionsList);
|
provinceDropdown.AddOptions(optionsList);
|
||||||
@@ -96,47 +106,35 @@ namespace eagle
|
|||||||
goldSlider.maxValue = AvailableGold;
|
goldSlider.maxValue = AvailableGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUpHeroDropdown()
|
public void SetUpHeroDropdown() {
|
||||||
{
|
var heroes = AvailableHeroIds.Select(hid => _model.Heroes[hid]).ToList();
|
||||||
var heroes = AvailableHeroIds
|
|
||||||
.Select(hid => _model.Heroes[hid])
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
heroDropdownController.AvailableHeroes = heroes;
|
heroDropdownController.AvailableHeroes = heroes;
|
||||||
|
|
||||||
HeroView minLoyaltyHero = null;
|
HeroView minLoyaltyHero = null;
|
||||||
foreach (HeroView hero in heroes)
|
foreach (HeroView hero in heroes) {
|
||||||
{
|
if (minLoyaltyHero == null || hero.Loyalty.Stat < minLoyaltyHero.Loyalty.Stat) {
|
||||||
if (minLoyaltyHero == null || hero.Loyalty.Stat < minLoyaltyHero.Loyalty.Stat)
|
|
||||||
{
|
|
||||||
minLoyaltyHero = hero;
|
minLoyaltyHero = hero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
heroDropdownController.SelectedHeroId = minLoyaltyHero.Id;
|
heroDropdownController.SelectedHeroId = minLoyaltyHero.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HeroSelected()
|
public void HeroSelected() {
|
||||||
{
|
|
||||||
goldSlider.maxValue = AvailableGold;
|
goldSlider.maxValue = AvailableGold;
|
||||||
goldSlider.value = Math.Min(goldSlider.value, AvailableGold);
|
goldSlider.value = Math.Min(goldSlider.value, AvailableGold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoldSliderMoved(float value)
|
public void GoldSliderMoved(float value) { goldGivenLabel.text = ((int)value).ToString(); }
|
||||||
{
|
|
||||||
goldGivenLabel.text = ((int)value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
var cmd = new SelectedCommand {
|
||||||
{
|
HeroGiftCommand =
|
||||||
var cmd = new SelectedCommand
|
new HeroGiftSelectedCommand {
|
||||||
{
|
RecipientHeroId = SelectedHeroId,
|
||||||
HeroGiftCommand = new HeroGiftSelectedCommand
|
Amount = SelectedGoldAmount
|
||||||
{
|
}
|
||||||
RecipientHeroId = SelectedHeroId,
|
|
||||||
Amount = SelectedGoldAmount
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
|
|||||||
+50
-69
@@ -8,13 +8,11 @@ using TMPro;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
|
|
||||||
public class ImproveCommandSelector : CommandSelector
|
public class ImproveCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public TMP_Dropdown typeDropdown;
|
public TMP_Dropdown typeDropdown;
|
||||||
public Toggle lockToggle;
|
public Toggle lockToggle;
|
||||||
@@ -24,32 +22,32 @@ namespace eagle
|
|||||||
private int SelectedTypeIndex => typeDropdown.value;
|
private int SelectedTypeIndex => typeDropdown.value;
|
||||||
private ImproveAvailableCommand ImproveAvailableCommand => _availableCommand.ImproveCommand;
|
private ImproveAvailableCommand ImproveAvailableCommand => _availableCommand.ImproveCommand;
|
||||||
private ProvinceId ActingProvinceId => ImproveAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ImproveAvailableCommand.ActingProvinceId;
|
||||||
private ImprovementType SelectedType => ImproveAvailableCommand.AvailableTypes[SelectedTypeIndex];
|
private ImprovementType SelectedType =>
|
||||||
|
ImproveAvailableCommand.AvailableTypes[SelectedTypeIndex];
|
||||||
|
|
||||||
private Dictionary<ProvinceId, ImprovementType> lockedTypes = new Dictionary<ProvinceId, ImprovementType>();
|
private Dictionary<ProvinceId, ImprovementType> lockedTypes =
|
||||||
|
new Dictionary<ProvinceId, ImprovementType>();
|
||||||
|
|
||||||
private double ImprovementValueForType(ImprovementType type)
|
private double ImprovementValueForType(ImprovementType type) {
|
||||||
{
|
|
||||||
var province = _model.Provinces[ActingProvinceId];
|
var province = _model.Provinces[ActingProvinceId];
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case ImprovementType.Agriculture: return province.FullInfo.Agriculture;
|
case ImprovementType.Agriculture: return province.FullInfo.Agriculture;
|
||||||
case ImprovementType.Economy: return province.FullInfo.Economy;
|
case ImprovementType.Economy: return province.FullInfo.Economy;
|
||||||
case ImprovementType.Infrastructure: return province.FullInfo.Infrastructure;
|
case ImprovementType.Infrastructure: return province.FullInfo.Infrastructure;
|
||||||
case ImprovementType.Devastation: return province.FullInfo.EconomyDevastation + province.FullInfo.AgricultureDevastation + province.FullInfo.InfrastructureDevastation;
|
case ImprovementType.Devastation:
|
||||||
|
return province.FullInfo.EconomyDevastation +
|
||||||
|
province.FullInfo.AgricultureDevastation +
|
||||||
|
province.FullInfo.InfrastructureDevastation;
|
||||||
default: throw new InvalidOperationException($"unknown type {type}");
|
default: throw new InvalidOperationException($"unknown type {type}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int MinimumImprovementIndex(ProvinceView province)
|
private int MinimumImprovementIndex(ProvinceView province) {
|
||||||
{
|
|
||||||
var minIndex = 0;
|
var minIndex = 0;
|
||||||
double minValue = ImprovementValueForType(ImproveAvailableCommand.AvailableTypes[0]);
|
double minValue = ImprovementValueForType(ImproveAvailableCommand.AvailableTypes[0]);
|
||||||
for (int i = 1; i < ImproveAvailableCommand.AvailableTypes.Count; i++)
|
for (int i = 1; i < ImproveAvailableCommand.AvailableTypes.Count; i++) {
|
||||||
{
|
|
||||||
double thisVal = ImprovementValueForType(ImproveAvailableCommand.AvailableTypes[i]);
|
double thisVal = ImprovementValueForType(ImproveAvailableCommand.AvailableTypes[i]);
|
||||||
if (thisVal < minValue)
|
if (thisVal < minValue) {
|
||||||
{
|
|
||||||
minIndex = i;
|
minIndex = i;
|
||||||
minValue = thisVal;
|
minValue = thisVal;
|
||||||
}
|
}
|
||||||
@@ -57,111 +55,94 @@ namespace eagle
|
|||||||
return minIndex;
|
return minIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
var province = _model.Provinces[ImproveAvailableCommand.ActingProvinceId];
|
var province = _model.Provinces[ImproveAvailableCommand.ActingProvinceId];
|
||||||
var improveCommand = ImproveAvailableCommand;
|
var improveCommand = ImproveAvailableCommand;
|
||||||
|
|
||||||
typeDropdown.ClearOptions();
|
typeDropdown.ClearOptions();
|
||||||
|
|
||||||
orderedHeroes = ImproveAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
orderedHeroes = ImproveAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id])
|
||||||
|
.ToList();
|
||||||
heroDropdownController.AvailableHeroes = orderedHeroes;
|
heroDropdownController.AvailableHeroes = orderedHeroes;
|
||||||
|
|
||||||
heroDropdownController.SelectedHeroId = improveCommand.RecommendedHeroId;
|
heroDropdownController.SelectedHeroId = improveCommand.RecommendedHeroId;
|
||||||
|
|
||||||
typeDropdown.AddOptions(improveCommand.AvailableTypes.Select(DropdownStringForType).ToList());
|
typeDropdown.AddOptions(
|
||||||
|
improveCommand.AvailableTypes.Select(DropdownStringForType).ToList());
|
||||||
|
|
||||||
var devastationIndex = improveCommand.AvailableTypes.IndexOf(ImprovementType.Devastation);
|
var devastationIndex =
|
||||||
if (devastationIndex == -1)
|
improveCommand.AvailableTypes.IndexOf(ImprovementType.Devastation);
|
||||||
{
|
if (devastationIndex == -1) {
|
||||||
typeDropdown.value = MinimumImprovementIndex(province);
|
typeDropdown.value = MinimumImprovementIndex(province);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
typeDropdown.value = devastationIndex;
|
typeDropdown.value = devastationIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeDropdown.interactable = true;
|
typeDropdown.interactable = true;
|
||||||
|
|
||||||
if (lockedTypes.ContainsKey(province.Id))
|
if (lockedTypes.ContainsKey(province.Id)) {
|
||||||
{
|
|
||||||
var lockedType = lockedTypes[province.Id];
|
var lockedType = lockedTypes[province.Id];
|
||||||
var lockedTypeIndex = improveCommand.AvailableTypes.IndexOf(lockedType);
|
var lockedTypeIndex = improveCommand.AvailableTypes.IndexOf(lockedType);
|
||||||
if (lockedTypeIndex > -1)
|
if (lockedTypeIndex > -1) {
|
||||||
{
|
|
||||||
typeDropdown.value = lockedTypeIndex;
|
typeDropdown.value = lockedTypeIndex;
|
||||||
lockToggle.isOn = true;
|
lockToggle.isOn = true;
|
||||||
typeDropdown.interactable = false;
|
typeDropdown.interactable = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
lockToggle.isOn = false;
|
lockToggle.isOn = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
lockToggle.isOn = false;
|
lockToggle.isOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ImproveCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ImproveCommand;
|
||||||
public override string HeaderString => "Improve Province";
|
public override string HeaderString => "Improve Province";
|
||||||
public override string CommitButtonString => "Commit Improvement";
|
public override string CommitButtonString => "Commit Improvement";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { heroDropdownController.SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds =>
|
||||||
public override bool HeroIsTargetable(HeroId heroId)
|
new List<HeroId> { heroDropdownController.SelectedHeroId };
|
||||||
{
|
public override bool HeroIsTargetable(HeroId heroId) {
|
||||||
var index = orderedHeroes.FindIndex(h => h.Id == heroId);
|
var index = orderedHeroes.FindIndex(h => h.Id == heroId);
|
||||||
return index != -1;
|
return index != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddTargetedHero(int heroId)
|
public override void AddTargetedHero(int heroId) {
|
||||||
{
|
|
||||||
heroDropdownController.SelectedHeroId = heroId;
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LockToggled(bool isLocked)
|
public void LockToggled(bool isLocked) {
|
||||||
{
|
if (isLocked) {
|
||||||
if (isLocked)
|
|
||||||
{
|
|
||||||
lockedTypes[ImproveAvailableCommand.ActingProvinceId] = SelectedType;
|
lockedTypes[ImproveAvailableCommand.ActingProvinceId] = SelectedType;
|
||||||
typeDropdown.interactable = false;
|
typeDropdown.interactable = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
lockedTypes.Remove(ActingProvinceId);
|
lockedTypes.Remove(ActingProvinceId);
|
||||||
typeDropdown.interactable = true;
|
typeDropdown.interactable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
ImproveCommand =
|
||||||
ImproveCommand = new ImproveSelectedCommand
|
new ImproveSelectedCommand {
|
||||||
{
|
ImprovementType = SelectedType,
|
||||||
ImprovementType = SelectedType,
|
ActingHeroId = heroDropdownController.SelectedHeroId
|
||||||
ActingHeroId = heroDropdownController.SelectedHeroId
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private string DropdownStringForType(ImprovementType type)
|
private string DropdownStringForType(ImprovementType type) {
|
||||||
{
|
|
||||||
return $"{type} ({RoundedNonzeroStat(ImprovementValueForType(type))})";
|
return $"{type} ({RoundedNonzeroStat(ImprovementValueForType(type))})";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string RoundedNonzeroStat(double stat)
|
private string RoundedNonzeroStat(double stat) {
|
||||||
{
|
|
||||||
var rounded = Math.Max(1, Math.Round(stat, MidpointRounding.AwayFromZero));
|
var rounded = Math.Max(1, Math.Round(stat, MidpointRounding.AwayFromZero));
|
||||||
return rounded.ToString();
|
return rounded.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string DropdownStringForHero(HeroView hero)
|
private string DropdownStringForHero(HeroView hero) {
|
||||||
{
|
return $"{hero.Name}: " + $"{RoundedNonzeroStat(hero.Strength)} STR, " +
|
||||||
return $"{hero.Name}: "
|
$"{RoundedNonzeroStat(hero.Agility)} AGI, " +
|
||||||
+ $"{RoundedNonzeroStat(hero.Strength)} STR, "
|
$"{GUIUtils.ConditionString(hero.Vigor, true)} / {RoundedNonzeroStat(hero.Constitution)} VIG" +
|
||||||
+ $"{RoundedNonzeroStat(hero.Agility)} AGI, "
|
((hero.Profession == Profession.Engineer) ? " (Engineer)" : "");
|
||||||
+ $"{GUIUtils.ConditionString(hero.Vigor, true)} / {RoundedNonzeroStat(hero.Constitution)} VIG"
|
|
||||||
+ ((hero.Profession == Profession.Engineer) ? " (Engineer)" : "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+43
-45
@@ -8,12 +8,10 @@ using UnityEngine;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class IssueOrdersCommandSelector : CommandSelector
|
public class IssueOrdersCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
IList<ProvinceOrderType> availableOrderTypes;
|
IList<ProvinceOrderType> availableOrderTypes;
|
||||||
Dictionary<ProvinceId, ProvinceOrderType> currentOrders;
|
Dictionary<ProvinceId, ProvinceOrderType> currentOrders;
|
||||||
List<ProvinceOrders> newOrders;
|
List<ProvinceOrders> newOrders;
|
||||||
@@ -27,14 +25,13 @@ namespace eagle
|
|||||||
public GameObject scrollContent;
|
public GameObject scrollContent;
|
||||||
public GameObject provinceOrdersRowPrefab;
|
public GameObject provinceOrdersRowPrefab;
|
||||||
|
|
||||||
private IssueOrdersAvailableCommand IssueOrdersAvailableCommand => _availableCommand.IssueOrdersCommand;
|
private IssueOrdersAvailableCommand IssueOrdersAvailableCommand =>
|
||||||
|
_availableCommand.IssueOrdersCommand;
|
||||||
private ProvinceId ActingProvinceId => IssueOrdersAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => IssueOrdersAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => SelectedFocusProvince;
|
get => SelectedFocusProvince;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
var index = availableFocusProvinces.IndexOf(value);
|
var index = availableFocusProvinces.IndexOf(value);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
|
|
||||||
@@ -42,53 +39,58 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ProvinceId?> GetAvailableFocusProvinces()
|
private List<ProvinceId?> GetAvailableFocusProvinces() {
|
||||||
{
|
|
||||||
var pids = _model.ProvincesForFaction(_model.PlayerId.Value);
|
var pids = _model.ProvincesForFaction(_model.PlayerId.Value);
|
||||||
var optionals = new List<ProvinceId?> { null };
|
var optionals = new List<ProvinceId?> { null };
|
||||||
optionals.AddRange(pids.Select(x => (ProvinceId?)x));
|
optionals.AddRange(pids.Select(x => (ProvinceId?)x));
|
||||||
return optionals;
|
return optionals;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string OptionalProvinceName(ProvinceId? pid)
|
private string OptionalProvinceName(ProvinceId? pid) {
|
||||||
{
|
|
||||||
if (pid.HasValue) return _model.Provinces[pid.Value].Name;
|
if (pid.HasValue) return _model.Provinces[pid.Value].Name;
|
||||||
else return "None";
|
else
|
||||||
|
return "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.IssueOrdersCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.IssueOrdersCommand;
|
||||||
override public string HeaderString => "Issue Orders";
|
override public string HeaderString => "Issue Orders";
|
||||||
override public string CommitButtonString => "Commit Orders";
|
override public string CommitButtonString => "Commit Orders";
|
||||||
|
|
||||||
override public bool EnableCommitButton => (newOrders.Any(x => x.Orders != currentOrders[x.ProvinceId])) || (SelectedFocusProvince != startingFocusProvince);
|
override public bool EnableCommitButton =>
|
||||||
|
(newOrders.Any(x => x.Orders != currentOrders[x.ProvinceId])) ||
|
||||||
|
(SelectedFocusProvince != startingFocusProvince);
|
||||||
public override string DisabledCommitButtonReason => "No province orders have changed";
|
public override string DisabledCommitButtonReason => "No province orders have changed";
|
||||||
|
|
||||||
override protected void SetUpUI()
|
override protected void SetUpUI() {
|
||||||
{
|
|
||||||
availableOrderTypes = IssueOrdersAvailableCommand.AvailableOrders;
|
availableOrderTypes = IssueOrdersAvailableCommand.AvailableOrders;
|
||||||
currentOrders = IssueOrdersAvailableCommand.CurrentOrders.ToDictionary(x => x.ProvinceId, x => x.Orders);
|
currentOrders = IssueOrdersAvailableCommand.CurrentOrders.ToDictionary(
|
||||||
|
x => x.ProvinceId,
|
||||||
|
x => x.Orders);
|
||||||
|
|
||||||
newOrders = IssueOrdersAvailableCommand.CurrentOrders.ToList();
|
newOrders = IssueOrdersAvailableCommand.CurrentOrders.ToList();
|
||||||
newOrders.Sort((x, y) => _model.Provinces[x.ProvinceId].Name.CompareTo(_model.Provinces[y.ProvinceId].Name));
|
newOrders.Sort(
|
||||||
|
(x, y) => _model.Provinces[x.ProvinceId].Name.CompareTo(
|
||||||
|
_model.Provinces[y.ProvinceId].Name));
|
||||||
|
|
||||||
provinceIds = newOrders.Select(x => x.ProvinceId).ToList();
|
provinceIds = newOrders.Select(x => x.ProvinceId).ToList();
|
||||||
|
|
||||||
foreach (Transform row in scrollContent.transform)
|
foreach (Transform row in scrollContent.transform) { Destroy(row.gameObject); }
|
||||||
{
|
|
||||||
Destroy(row.gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
var parentTransform = scrollContent.transform;
|
var parentTransform = scrollContent.transform;
|
||||||
|
|
||||||
var oddColor = provinceOrdersRowPrefab.GetComponent<UnityEngine.UI.Image>().color;
|
var oddColor = provinceOrdersRowPrefab.GetComponent<UnityEngine.UI.Image>().color;
|
||||||
oddColor.a = 0;
|
oddColor.a = 0;
|
||||||
|
|
||||||
for (int i = 0; i < provinceIds.Count; i++)
|
for (int i = 0; i < provinceIds.Count; i++) {
|
||||||
{
|
|
||||||
var pid = provinceIds[i];
|
var pid = provinceIds[i];
|
||||||
var province = _model.Provinces[pid];
|
var province = _model.Provinces[pid];
|
||||||
|
|
||||||
var newRow = Instantiate(provinceOrdersRowPrefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0), parentTransform);
|
var newRow = Instantiate(
|
||||||
|
provinceOrdersRowPrefab,
|
||||||
|
new Vector3(0, 0, 0),
|
||||||
|
new Quaternion(0, 0, 0, 0),
|
||||||
|
parentTransform);
|
||||||
|
|
||||||
// FIXME: I don't know why this reset of the z-position is necessary
|
// FIXME: I don't know why this reset of the z-position is necessary
|
||||||
var position = newRow.GetComponent<RectTransform>().anchoredPosition3D;
|
var position = newRow.GetComponent<RectTransform>().anchoredPosition3D;
|
||||||
@@ -103,43 +105,39 @@ namespace eagle
|
|||||||
|
|
||||||
var ordersDropdown = newRow.GetComponentInChildren<TMP_Dropdown>();
|
var ordersDropdown = newRow.GetComponentInChildren<TMP_Dropdown>();
|
||||||
ordersDropdown.ClearOptions();
|
ordersDropdown.ClearOptions();
|
||||||
ordersDropdown.AddOptions(availableOrderTypes.Select(tp => DisplayNames.ProvinceOrderTypeNames[tp]).ToList());
|
ordersDropdown.AddOptions(
|
||||||
|
availableOrderTypes.Select(tp => DisplayNames.ProvinceOrderTypeNames[tp])
|
||||||
|
.ToList());
|
||||||
ordersDropdown.value = availableOrderTypes.IndexOf(currentOrders[pid]);
|
ordersDropdown.value = availableOrderTypes.IndexOf(currentOrders[pid]);
|
||||||
int index = i;
|
int index = i;
|
||||||
ordersDropdown.onValueChanged.AddListener(newValue => ProvinceOrdersValueChanged(index, newValue));
|
ordersDropdown.onValueChanged.AddListener(
|
||||||
|
newValue => ProvinceOrdersValueChanged(index, newValue));
|
||||||
|
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1) { newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor; }
|
||||||
{
|
|
||||||
newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startingFocusProvince = _model.MaybeDestroyedFaction(_model.PlayerId.Value).FocusProvinceId;
|
startingFocusProvince =
|
||||||
|
_model.MaybeDestroyedFaction(_model.PlayerId.Value).FocusProvinceId;
|
||||||
availableFocusProvinces = GetAvailableFocusProvinces();
|
availableFocusProvinces = GetAvailableFocusProvinces();
|
||||||
availableFocusProvinceNames = availableFocusProvinces.Select(OptionalProvinceName).ToList();
|
availableFocusProvinceNames =
|
||||||
|
availableFocusProvinces.Select(OptionalProvinceName).ToList();
|
||||||
|
|
||||||
focusDropdown.ClearOptions();
|
focusDropdown.ClearOptions();
|
||||||
focusDropdown.AddOptions(availableFocusProvinceNames);
|
focusDropdown.AddOptions(availableFocusProvinceNames);
|
||||||
focusDropdown.value = availableFocusProvinces.IndexOf(startingFocusProvince);
|
focusDropdown.value = availableFocusProvinces.IndexOf(startingFocusProvince);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public SelectedCommand Command
|
override public SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var sentOrders = newOrders.Where(x => x.Orders != currentOrders[x.ProvinceId]);
|
var sentOrders = newOrders.Where(x => x.Orders != currentOrders[x.ProvinceId]);
|
||||||
var ordersCommand = new IssueOrdersSelectedCommand();
|
var ordersCommand = new IssueOrdersSelectedCommand();
|
||||||
ordersCommand.NewOrders.Add(sentOrders);
|
ordersCommand.NewOrders.Add(sentOrders);
|
||||||
ordersCommand.NewFocusProvince = SelectedFocusProvince;
|
ordersCommand.NewFocusProvince = SelectedFocusProvince;
|
||||||
return new SelectedCommand
|
return new SelectedCommand { IssueOrdersCommand = ordersCommand };
|
||||||
{
|
|
||||||
IssueOrdersCommand = ordersCommand
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProvinceOrdersValueChanged(int index, Int32 newValue)
|
public void ProvinceOrdersValueChanged(int index, Int32 newValue) {
|
||||||
{
|
|
||||||
newOrders[index].Orders = availableOrderTypes[newValue];
|
newOrders[index].Orders = availableOrderTypes[newValue];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-24
@@ -31,40 +31,48 @@ namespace eagle {
|
|||||||
|
|
||||||
public HeroView SelectedHero => SelectedPrisonerToManage.Prisoner.Hero;
|
public HeroView SelectedHero => SelectedPrisonerToManage.Prisoner.Hero;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ManagePrisonerCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ManagePrisonerCommand;
|
||||||
public override string HeaderString => "Manage Prisoners";
|
public override string HeaderString => "Manage Prisoners";
|
||||||
public override string CommitButtonString => $"Commit {DisplayNames.PrisonerManagementTypeName(SelectedOption)}";
|
public override string CommitButtonString =>
|
||||||
|
$"Commit {DisplayNames.PrisonerManagementTypeName(SelectedOption)}";
|
||||||
|
|
||||||
private int _selectedHeroIndex;
|
private int _selectedHeroIndex;
|
||||||
private PrisonerToManage SelectedPrisonerToManage => ManagePrisonersCommand.Prisoners[_selectedHeroIndex];
|
private PrisonerToManage SelectedPrisonerToManage =>
|
||||||
|
ManagePrisonersCommand.Prisoners[_selectedHeroIndex];
|
||||||
|
|
||||||
private ManagePrisonersAvailableCommand ManagePrisonersCommand => _availableCommand.ManagePrisonerCommand;
|
private ManagePrisonersAvailableCommand ManagePrisonersCommand =>
|
||||||
|
_availableCommand.ManagePrisonerCommand;
|
||||||
private ProvinceId ActingProvinceId => ManagePrisonersCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ManagePrisonersCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => false;
|
public override bool WarnOnCommitButton => false;
|
||||||
public override string CommitWarningText => $"This will create a treaty with {_model.FactionName(SelectedHero.FactionId.Value)}";
|
public override string CommitWarningText =>
|
||||||
|
$"This will create a treaty with {_model.FactionName(SelectedHero.FactionId.Value)}";
|
||||||
|
|
||||||
private PrisonerManagementOption SelectedOption {
|
private PrisonerManagementOption SelectedOption {
|
||||||
get {
|
get {
|
||||||
if (ExecuteToggle.isOn)
|
if (ExecuteToggle.isOn)
|
||||||
return SelectedPrisonerToManage
|
return SelectedPrisonerToManage.AvailableOptions.First(
|
||||||
.AvailableOptions
|
opt => opt.SealedValueCase ==
|
||||||
.First(opt => opt.SealedValueCase == PrisonerManagementOption.SealedValueOneofCase.Execute);
|
PrisonerManagementOption.SealedValueOneofCase.Execute);
|
||||||
else throw new ArgumentOutOfRangeException("Unknown prisoner management option");
|
else
|
||||||
|
throw new ArgumentOutOfRangeException("Unknown prisoner management option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI() {
|
protected override void SetUpUI() {
|
||||||
if (_selectedHeroIndex >= ManagePrisonersCommand.Prisoners.Count) _selectedHeroIndex = 0;
|
if (_selectedHeroIndex >= ManagePrisonersCommand.Prisoners.Count)
|
||||||
|
_selectedHeroIndex = 0;
|
||||||
NextHeroButton.gameObject.SetActive(ManagePrisonersCommand.Prisoners.Count > 1);
|
NextHeroButton.gameObject.SetActive(ManagePrisonersCommand.Prisoners.Count > 1);
|
||||||
DisplaySelectedHero();
|
DisplaySelectedHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand {
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
ManagePrisonersCommand = new ManagePrisonersSelectedCommand {
|
ManagePrisonersCommand =
|
||||||
PrisonerHeroId = SelectedHero.Id,
|
new ManagePrisonersSelectedCommand {
|
||||||
ChosenOption = SelectedOption
|
PrisonerHeroId = SelectedHero.Id,
|
||||||
}
|
ChosenOption = SelectedOption
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void NextHeroButtonClicked() {
|
public void NextHeroButtonClicked() {
|
||||||
@@ -83,15 +91,33 @@ namespace eagle {
|
|||||||
|
|
||||||
// The order here is important: the last available toggle in this list
|
// The order here is important: the last available toggle in this list
|
||||||
// will be on by default
|
// will be on by default
|
||||||
ConditionallyEnable(ExecuteToggle, ExecuteIcon, PrisonerManagementOption.SealedValueOneofCase.Execute);
|
ConditionallyEnable(
|
||||||
ConditionallyEnable(ExileToggle, ExileIcon, PrisonerManagementOption.SealedValueOneofCase.Exile);
|
ExecuteToggle,
|
||||||
ConditionallyEnable(ReturnToggle, ReturnIcon, PrisonerManagementOption.SealedValueOneofCase.Return);
|
ExecuteIcon,
|
||||||
ConditionallyEnable(MoveToggle, MoveIcon, PrisonerManagementOption.SealedValueOneofCase.Move);
|
PrisonerManagementOption.SealedValueOneofCase.Execute);
|
||||||
ConditionallyEnable(ReleaseToggle, ReleaseIcon, PrisonerManagementOption.SealedValueOneofCase.Release);
|
ConditionallyEnable(
|
||||||
|
ExileToggle,
|
||||||
|
ExileIcon,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase.Exile);
|
||||||
|
ConditionallyEnable(
|
||||||
|
ReturnToggle,
|
||||||
|
ReturnIcon,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase.Return);
|
||||||
|
ConditionallyEnable(
|
||||||
|
MoveToggle,
|
||||||
|
MoveIcon,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase.Move);
|
||||||
|
ConditionallyEnable(
|
||||||
|
ReleaseToggle,
|
||||||
|
ReleaseIcon,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase.Release);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ConditionallyEnable(Toggle toggle, PrisonerManagementOption.SealedValueOneofCase option) {
|
private bool ConditionallyEnable(
|
||||||
bool enable = SelectedPrisonerToManage.AvailableOptions.Any(opt => opt.SealedValueCase == option);
|
Toggle toggle,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase option) {
|
||||||
|
bool enable = SelectedPrisonerToManage.AvailableOptions.Any(
|
||||||
|
opt => opt.SealedValueCase == option);
|
||||||
toggle.gameObject.SetActive(enable);
|
toggle.gameObject.SetActive(enable);
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@@ -102,13 +128,16 @@ namespace eagle {
|
|||||||
ReturnToggle.isOn = false;
|
ReturnToggle.isOn = false;
|
||||||
|
|
||||||
toggle.isOn = true;
|
toggle.isOn = true;
|
||||||
}
|
} else
|
||||||
else toggle.isOn = false;
|
toggle.isOn = false;
|
||||||
|
|
||||||
return enable;
|
return enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConditionallyEnable(Toggle toggle, RawImage img, PrisonerManagementOption.SealedValueOneofCase option) {
|
private void ConditionallyEnable(
|
||||||
|
Toggle toggle,
|
||||||
|
RawImage img,
|
||||||
|
PrisonerManagementOption.SealedValueOneofCase option) {
|
||||||
bool enable = ConditionallyEnable(toggle, option);
|
bool enable = ConditionallyEnable(toggle, option);
|
||||||
|
|
||||||
Color color = img.color;
|
Color color = img.color;
|
||||||
|
|||||||
+145
-160
@@ -7,30 +7,24 @@ using UnityEngine.UI;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using PlayerId = System.Int32;
|
using PlayerId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
using BattalionId = System.Int32;
|
using BattalionId = System.Int32;
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using static Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types;
|
using static Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types;
|
||||||
|
|
||||||
struct Supplies
|
struct Supplies {
|
||||||
{
|
|
||||||
public int gold;
|
public int gold;
|
||||||
public int food;
|
public int food;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MarchCommandSelector : CommandSelector
|
public class MarchCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
private int SelectedOriginProvinceIndex => fromDropdown.value;
|
private int SelectedOriginProvinceIndex => fromDropdown.value;
|
||||||
private int SelectedDestinationProvinceIndex => toDropdown.value;
|
private int SelectedDestinationProvinceIndex => toDropdown.value;
|
||||||
private List<CombatUnit> SelectedActingUnits => unitSelector.SelectedActingUnits;
|
private List<CombatUnit> SelectedActingUnits => unitSelector.SelectedActingUnits;
|
||||||
private Supplies SelectedSupplies => new Supplies
|
private Supplies SelectedSupplies =>
|
||||||
{
|
new Supplies { gold = SelectedGold, food = SelectedFood };
|
||||||
gold = SelectedGold,
|
|
||||||
food = SelectedFood
|
|
||||||
};
|
|
||||||
private int SelectedGold => (int)goldSlider.value;
|
private int SelectedGold => (int)goldSlider.value;
|
||||||
private int SelectedFood => (int)foodSlider.value;
|
private int SelectedFood => (int)foodSlider.value;
|
||||||
|
|
||||||
@@ -48,79 +42,93 @@ namespace eagle
|
|||||||
private int recommendedFood;
|
private int recommendedFood;
|
||||||
private int recommendedGold;
|
private int recommendedGold;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.MarchCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.MarchCommand;
|
||||||
public override string HeaderString => "March";
|
public override string HeaderString => "March";
|
||||||
public override string CommitButtonString => "Commit March";
|
public override string CommitButtonString => "Commit March";
|
||||||
|
|
||||||
private MarchAvailableCommand MarchAvailableCommand => _availableCommand.MarchCommand;
|
private MarchAvailableCommand MarchAvailableCommand => _availableCommand.MarchCommand;
|
||||||
private ProvinceId ActingProvinceId => MarchAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => MarchAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => unitSelector.SelectedIds.Where(u => u.heroId.HasValue).Select(u => u.heroId.Value).ToList();
|
public override List<HeroId> TargetedHeroIds =>
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => unitSelector.HeroIsTargetable(heroId);
|
unitSelector.SelectedIds.Where(u => u.heroId.HasValue)
|
||||||
|
.Select(u => u.heroId.Value)
|
||||||
|
.ToList();
|
||||||
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
|
unitSelector.HeroIsTargetable(heroId);
|
||||||
public override void AddTargetedHero(HeroId heroId) => unitSelector.AddTargetedHero(heroId);
|
public override void AddTargetedHero(HeroId heroId) => unitSelector.AddTargetedHero(heroId);
|
||||||
public override void RemoveTargetedHero(HeroId heroId) => unitSelector.RemoveTargetedHero(heroId);
|
public override void RemoveTargetedHero(HeroId heroId) =>
|
||||||
|
unitSelector.RemoveTargetedHero(heroId);
|
||||||
|
|
||||||
public override List<BattalionId> TargetedBattalionIds => unitSelector.SelectedIds.Where(u => u.battalion != null).Select(u => u.battalion.Id).ToList();
|
public override List<BattalionId> TargetedBattalionIds =>
|
||||||
public override bool BattalionIsTargetable(BattalionId bid) => unitSelector.BattalionIsTargetable(bid);
|
unitSelector.SelectedIds.Where(u => u.battalion != null)
|
||||||
public override void AddTargetedBattalion(BattalionId bid) => unitSelector.AddTargetedBattalion(bid);
|
.Select(u => u.battalion.Id)
|
||||||
public override void RemoveTargetedBattalion(BattalionId bid) => unitSelector.RemoveTargetedBattalion(bid);
|
.ToList();
|
||||||
|
public override bool BattalionIsTargetable(BattalionId bid) =>
|
||||||
|
unitSelector.BattalionIsTargetable(bid);
|
||||||
|
public override void AddTargetedBattalion(BattalionId bid) =>
|
||||||
|
unitSelector.AddTargetedBattalion(bid);
|
||||||
|
public override void RemoveTargetedBattalion(BattalionId bid) =>
|
||||||
|
unitSelector.RemoveTargetedBattalion(bid);
|
||||||
|
|
||||||
private List<MarchCommandFromOneProvince> sortedOneProvinceCommands;
|
private List<MarchCommandFromOneProvince> sortedOneProvinceCommands;
|
||||||
private List<ProvinceId> sortedDestinationProvinceIds;
|
private List<ProvinceId> sortedDestinationProvinceIds;
|
||||||
|
|
||||||
private ProvinceView OriginProvince => _model.Provinces[SelectedOneProvinceCommand.OriginProvinceId];
|
private ProvinceView OriginProvince =>
|
||||||
private ProvinceId DestinationProvinceId => sortedDestinationProvinceIds[SelectedDestinationProvinceIndex];
|
_model.Provinces[SelectedOneProvinceCommand.OriginProvinceId];
|
||||||
|
private ProvinceId DestinationProvinceId =>
|
||||||
|
sortedDestinationProvinceIds[SelectedDestinationProvinceIndex];
|
||||||
private ProvinceView DestinationProvince => _model.Provinces[DestinationProvinceId];
|
private ProvinceView DestinationProvince => _model.Provinces[DestinationProvinceId];
|
||||||
|
|
||||||
private bool WouldAbandonProvince => unitSelector.SelectedActingUnits.Count() == OriginProvince.FullInfo.RulingFactionHeroIds.Count();
|
private bool WouldAbandonProvince => unitSelector.SelectedActingUnits.Count() ==
|
||||||
|
OriginProvince.FullInfo.RulingFactionHeroIds.Count();
|
||||||
|
|
||||||
private bool NotEnoughFood => SelectedFood < Math.Min(2 * FoodCost, SelectedOneProvinceCommand.FoodAvailable);
|
private bool NotEnoughFood =>
|
||||||
|
SelectedFood < Math.Min(2 * FoodCost, SelectedOneProvinceCommand.FoodAvailable);
|
||||||
|
|
||||||
private PlayerId? DestinationRuler = null;
|
private PlayerId? DestinationRuler = null;
|
||||||
private bool MarchingOnTreatyPartner => (
|
private bool MarchingOnTreatyPartner =>
|
||||||
DestinationRuler.HasValue &&
|
(DestinationRuler.HasValue && DestinationRuler.Value != playerId &&
|
||||||
DestinationRuler.Value != playerId &&
|
_model.MaybeDestroyedFaction(playerId).Treaties.ToList().Exists(
|
||||||
_model.MaybeDestroyedFaction(playerId).Treaties.ToList().Exists(t => t.TargetFactionId == DestinationRuler)
|
t => t.TargetFactionId == DestinationRuler));
|
||||||
);
|
|
||||||
|
|
||||||
private bool BadlyConstructedUnits => unitSelector.HeroIdsLeadingInappropriateUnits.Count > 0;
|
private bool BadlyConstructedUnits =>
|
||||||
|
unitSelector.HeroIdsLeadingInappropriateUnits.Count > 0;
|
||||||
|
|
||||||
private bool NoBattalionsIntoEnemy => unitSelector.BattalionCount == 0 && DestinationProvince.RulingFactionId.HasValue && DestinationProvince.RulingFactionId.Value != playerId;
|
private bool NoBattalionsIntoEnemy => unitSelector.BattalionCount == 0 &&
|
||||||
|
DestinationProvince.RulingFactionId.HasValue &&
|
||||||
|
DestinationProvince.RulingFactionId.Value != playerId;
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => WouldAbandonProvince || NotEnoughFood || MarchingOnTreatyPartner || BadlyConstructedUnits || NoBattalionsIntoEnemy;
|
public override bool WarnOnCommitButton => WouldAbandonProvince || NotEnoughFood ||
|
||||||
public override string CommitWarningText
|
MarchingOnTreatyPartner ||
|
||||||
{
|
BadlyConstructedUnits || NoBattalionsIntoEnemy;
|
||||||
get
|
public override string CommitWarningText {
|
||||||
{
|
get {
|
||||||
if (!(WarnOnCommitButton)) return null;
|
if (!(WarnOnCommitButton)) return null;
|
||||||
|
|
||||||
string txt = "";
|
string txt = "";
|
||||||
if (WouldAbandonProvince)
|
if (WouldAbandonProvince) {
|
||||||
{
|
|
||||||
txt = txt + "This action would abandon this province\n\n";
|
txt = txt + "This action would abandon this province\n\n";
|
||||||
}
|
}
|
||||||
if (NotEnoughFood)
|
if (NotEnoughFood) {
|
||||||
{
|
txt = txt +
|
||||||
txt = txt + $"You have not selected enough food for your battalions for 2 months ({2 * FoodCost} needed)\n\n";
|
$"You have not selected enough food for your battalions for 2 months ({2 * FoodCost} needed)\n\n";
|
||||||
}
|
}
|
||||||
if (MarchingOnTreatyPartner)
|
if (MarchingOnTreatyPartner) {
|
||||||
{
|
txt = txt +
|
||||||
txt = txt + $"You have a treaty with {_model.FactionName(DestinationRuler.Value)}.\n\n";
|
$"You have a treaty with {_model.FactionName(DestinationRuler.Value)}.\n\n";
|
||||||
|
} else if (NoBattalionsIntoEnemy) {
|
||||||
|
txt = txt +
|
||||||
|
$"{DestinationProvince.Name} is occupied by a hostile faction, and you have not selected any troops\n\n";
|
||||||
}
|
}
|
||||||
else if (NoBattalionsIntoEnemy)
|
if (BadlyConstructedUnits) {
|
||||||
{
|
|
||||||
txt = txt + $"{DestinationProvince.Name} is occupied by a hostile faction, and you have not selected any troops\n\n";
|
|
||||||
}
|
|
||||||
if (BadlyConstructedUnits)
|
|
||||||
{
|
|
||||||
var count = unitSelector.HeroIdsLeadingInappropriateUnits.Count;
|
var count = unitSelector.HeroIdsLeadingInappropriateUnits.Count;
|
||||||
if (count == 1)
|
if (count == 1) {
|
||||||
{
|
txt = txt +
|
||||||
txt = txt + $"{_model.Heroes[unitSelector.HeroIdsLeadingInappropriateUnits[0]].Name} is leading a battalion type that would restrict their abilities\n\n";
|
$"{_model.Heroes[unitSelector.HeroIdsLeadingInappropriateUnits[0]].Name} is leading a battalion type that would restrict their abilities\n\n";
|
||||||
}
|
} else {
|
||||||
else
|
txt = txt +
|
||||||
{
|
$"Some of your heroes are leading battalion types that would restrict their abilities\n\n";
|
||||||
txt = txt + $"Some of your heroes are leading battalion types that would restrict their abilities\n\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,19 +136,16 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarchCommandFromOneProvince SelectedOneProvinceCommand => sortedOneProvinceCommands[SelectedOriginProvinceIndex];
|
private MarchCommandFromOneProvince SelectedOneProvinceCommand =>
|
||||||
|
sortedOneProvinceCommands[SelectedOriginProvinceIndex];
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => sortedDestinationProvinceIds[SelectedDestinationProvinceIndex];
|
get => sortedDestinationProvinceIds[SelectedDestinationProvinceIndex];
|
||||||
|
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
|
||||||
{
|
|
||||||
int index = sortedDestinationProvinceIds.IndexOf(value.Value);
|
int index = sortedDestinationProvinceIds.IndexOf(value.Value);
|
||||||
if (index != -1)
|
if (index != -1) toDropdown.value = index;
|
||||||
toDropdown.value = index;
|
|
||||||
else
|
else
|
||||||
toDropdown.value = 0;
|
toDropdown.value = 0;
|
||||||
}
|
}
|
||||||
@@ -148,35 +153,27 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int FoodCost => (int)Math.Ceiling(
|
public int FoodCost => (int)Math.Ceiling(
|
||||||
SelectedActingUnits
|
SelectedActingUnits.Where(u => u.BattalionId.HasValue)
|
||||||
.Where(u => u.BattalionId.HasValue)
|
.Select(u => u.BattalionId.Value)
|
||||||
.Select(u => u.BattalionId.Value)
|
.Select(bid => SelectedOneProvinceCommand.AvailableBattalions.First(
|
||||||
.Select(bid => SelectedOneProvinceCommand.AvailableBattalions.First(bwfc => bwfc.BattalionId == bid))
|
bwfc => bwfc.BattalionId == bid))
|
||||||
.Select(bwfc => bwfc.MonthlyFood)
|
.Select(bwfc => bwfc.MonthlyFood)
|
||||||
.Sum()
|
.Sum());
|
||||||
);
|
|
||||||
|
|
||||||
public override bool EnableCommitButton => (
|
public override bool EnableCommitButton =>
|
||||||
unitSelector.UnitsAreValid
|
(unitSelector.UnitsAreValid &&
|
||||||
&& (SelectedFood >= FoodCost || SelectedFood >= SelectedOneProvinceCommand.FoodAvailable)
|
(SelectedFood >= FoodCost ||
|
||||||
&& SelectedFood <= SelectedOneProvinceCommand.FoodAvailable
|
SelectedFood >= SelectedOneProvinceCommand.FoodAvailable) &&
|
||||||
&& SelectedGold >= SelectedOneProvinceCommand.GoldCost
|
SelectedFood <= SelectedOneProvinceCommand.FoodAvailable &&
|
||||||
&& SelectedGold <= SelectedOneProvinceCommand.GoldAvailable
|
SelectedGold >= SelectedOneProvinceCommand.GoldCost &&
|
||||||
);
|
SelectedGold <= SelectedOneProvinceCommand.GoldAvailable);
|
||||||
public override string DisabledCommitButtonReason
|
public override string DisabledCommitButtonReason {
|
||||||
{
|
get {
|
||||||
get
|
if (SelectedGold > SelectedOneProvinceCommand.GoldAvailable) {
|
||||||
{
|
|
||||||
if (SelectedGold > SelectedOneProvinceCommand.GoldAvailable)
|
|
||||||
{
|
|
||||||
return "Trying to send more gold than available";
|
return "Trying to send more gold than available";
|
||||||
}
|
} else if (SelectedFood > SelectedOneProvinceCommand.FoodAvailable) {
|
||||||
else if (SelectedFood > SelectedOneProvinceCommand.FoodAvailable)
|
|
||||||
{
|
|
||||||
return "Trying to send more food than available";
|
return "Trying to send more food than available";
|
||||||
}
|
} else if (SelectedFood < FoodCost) {
|
||||||
else if (SelectedFood < FoodCost)
|
|
||||||
{
|
|
||||||
return $"Must send at least {FoodCost} food";
|
return $"Must send at least {FoodCost} food";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,15 +181,15 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpDestinationProvinceDropdown()
|
private void SetUpDestinationProvinceDropdown() {
|
||||||
{
|
sortedDestinationProvinceIds = SelectedOneProvinceCommand.AvailableDestinationProvinces
|
||||||
sortedDestinationProvinceIds = SelectedOneProvinceCommand
|
.OrderBy(pid => _model.Provinces[pid].Name)
|
||||||
.AvailableDestinationProvinces
|
.ToList();
|
||||||
.OrderBy(pid => _model.Provinces[pid].Name)
|
|
||||||
.ToList();
|
|
||||||
var destinationProvinceNames = sortedDestinationProvinceIds
|
var destinationProvinceNames = sortedDestinationProvinceIds
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.ToList();
|
_model.Provinces[id],
|
||||||
|
_model.PlayerId.Value))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
toDropdown.ClearOptions();
|
toDropdown.ClearOptions();
|
||||||
toDropdown.AddOptions(destinationProvinceNames);
|
toDropdown.AddOptions(destinationProvinceNames);
|
||||||
@@ -201,40 +198,41 @@ namespace eagle
|
|||||||
toDropdown.value = 0;
|
toDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpUnitSelector()
|
private void SetUpUnitSelector() {
|
||||||
{
|
|
||||||
var dict = new Dictionary<HeroId, List<BattalionIdWithSuitability>>();
|
var dict = new Dictionary<HeroId, List<BattalionIdWithSuitability>>();
|
||||||
foreach (var kv in SelectedOneProvinceCommand.SuitableBattalionsForHeroes)
|
foreach (var kv in SelectedOneProvinceCommand.SuitableBattalionsForHeroes) {
|
||||||
{
|
|
||||||
dict.Add(kv.Key, kv.Value.BattalionIdsWithSuitability.ToList());
|
dict.Add(kv.Key, kv.Value.BattalionIdsWithSuitability.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
var recommendedConfig = SelectedOneProvinceCommand.RecommendedBattleConfig;
|
var recommendedConfig = SelectedOneProvinceCommand.RecommendedBattleConfig;
|
||||||
List<CombatUnit> recommendedUnits = recommendedConfig == null ? new List<CombatUnit>() : recommendedConfig.Units.ToList();
|
List<CombatUnit> recommendedUnits = recommendedConfig == null
|
||||||
|
? new List<CombatUnit>()
|
||||||
|
: recommendedConfig.Units.ToList();
|
||||||
recommendedFood = recommendedConfig == null ? 0 : recommendedConfig.Food;
|
recommendedFood = recommendedConfig == null ? 0 : recommendedConfig.Food;
|
||||||
recommendedGold = recommendedConfig == null ? 0 : recommendedConfig.Gold;
|
recommendedGold = recommendedConfig == null ? 0 : recommendedConfig.Gold;
|
||||||
|
|
||||||
var province = _model.Provinces[SelectedOneProvinceCommand.OriginProvinceId];
|
var province = _model.Provinces[SelectedOneProvinceCommand.OriginProvinceId];
|
||||||
var availableBattalionIds = SelectedOneProvinceCommand.AvailableBattalions.Select(b => b.BattalionId).ToList();
|
var availableBattalionIds =
|
||||||
var orderedBattalions = ProvinceUtils.OrderedBattalions(province).Where(batt => availableBattalionIds.Contains(batt.Id)).ToList();
|
SelectedOneProvinceCommand.AvailableBattalions.Select(b => b.BattalionId)
|
||||||
|
.ToList();
|
||||||
|
var orderedBattalions = ProvinceUtils.OrderedBattalions(province)
|
||||||
|
.Where(batt => availableBattalionIds.Contains(batt.Id))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
unitSelector.SetUpUnits(
|
unitSelector.SetUpUnits(
|
||||||
_model,
|
_model,
|
||||||
SelectedOneProvinceCommand.AvailableHeroIds.ToList(),
|
SelectedOneProvinceCommand.AvailableHeroIds.ToList(),
|
||||||
orderedBattalions,
|
orderedBattalions,
|
||||||
dict,
|
dict,
|
||||||
recommendedUnits
|
recommendedUnits);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RecommendedButtonClicked()
|
public void RecommendedButtonClicked() {
|
||||||
{
|
|
||||||
foodSlider.value = recommendedFood;
|
foodSlider.value = recommendedFood;
|
||||||
goldSlider.value = recommendedGold;
|
goldSlider.value = recommendedGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FromDropdownValueChanged(Int32 newValue)
|
public void FromDropdownValueChanged(Int32 newValue) {
|
||||||
{
|
|
||||||
SetUpDestinationProvinceDropdown();
|
SetUpDestinationProvinceDropdown();
|
||||||
SetUpUnitSelector();
|
SetUpUnitSelector();
|
||||||
|
|
||||||
@@ -251,33 +249,29 @@ namespace eagle
|
|||||||
goldSlider.value = SelectedOneProvinceCommand.GoldCost;
|
goldSlider.value = SelectedOneProvinceCommand.GoldCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToDropdownValueChanged(Int32 newValue)
|
public void ToDropdownValueChanged(Int32 newValue) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
sortedOneProvinceCommands =
|
||||||
sortedOneProvinceCommands = MarchAvailableCommand
|
MarchAvailableCommand.OneProvinceCommands
|
||||||
.OneProvinceCommands
|
.OrderBy(cmd => _model.Provinces[cmd.OriginProvinceId].Name)
|
||||||
.OrderBy(cmd => _model.Provinces[cmd.OriginProvinceId].Name)
|
.ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var availableOriginProvinceNames = sortedOneProvinceCommands
|
var availableOriginProvinceNames =
|
||||||
.Select(cmd => _model.Provinces[cmd.OriginProvinceId].Name)
|
sortedOneProvinceCommands
|
||||||
.ToList();
|
.Select(cmd => _model.Provinces[cmd.OriginProvinceId].Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
fromDropdown.ClearOptions();
|
fromDropdown.ClearOptions();
|
||||||
fromDropdown.AddOptions(availableOriginProvinceNames);
|
fromDropdown.AddOptions(availableOriginProvinceNames);
|
||||||
fromDropdown.onValueChanged.RemoveAllListeners();
|
fromDropdown.onValueChanged.RemoveAllListeners();
|
||||||
fromDropdown.onValueChanged.AddListener(FromDropdownValueChanged);
|
fromDropdown.onValueChanged.AddListener(FromDropdownValueChanged);
|
||||||
|
|
||||||
var thisProvinceIndex = sortedOneProvinceCommands.FindIndex(cmd => cmd.OriginProvinceId == ActingProvinceId);
|
var thisProvinceIndex = sortedOneProvinceCommands.FindIndex(
|
||||||
if (thisProvinceIndex == -1)
|
cmd => cmd.OriginProvinceId == ActingProvinceId);
|
||||||
{
|
if (thisProvinceIndex == -1) {
|
||||||
fromDropdown.value = 0;
|
fromDropdown.value = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fromDropdown.value = thisProvinceIndex;
|
fromDropdown.value = thisProvinceIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,51 +289,42 @@ namespace eagle
|
|||||||
goldSlider.maxValue = SelectedOneProvinceCommand.GoldAvailable;
|
goldSlider.maxValue = SelectedOneProvinceCommand.GoldAvailable;
|
||||||
|
|
||||||
foodSlider.value = 0;
|
foodSlider.value = 0;
|
||||||
goldSlider.value = Math.Min(SelectedOneProvinceCommand.GoldCost, SelectedOneProvinceCommand.GoldAvailable);
|
goldSlider.value = Math.Min(
|
||||||
|
SelectedOneProvinceCommand.GoldCost,
|
||||||
|
SelectedOneProvinceCommand.GoldAvailable);
|
||||||
|
|
||||||
setFoodLabels();
|
setFoodLabels();
|
||||||
setGoldLabels();
|
setGoldLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGoldSliderChanged(float value)
|
public void onGoldSliderChanged(float value) { setGoldLabels(); }
|
||||||
{
|
|
||||||
setGoldLabels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onFoodSliderChanged(float value)
|
public void onFoodSliderChanged(float value) { setFoodLabels(); }
|
||||||
{
|
|
||||||
setFoodLabels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGoldLabels()
|
public void setGoldLabels() {
|
||||||
{
|
|
||||||
int taken = (int)goldSlider.value;
|
int taken = (int)goldSlider.value;
|
||||||
int left = (int)goldSlider.maxValue - taken;
|
int left = (int)goldSlider.maxValue - taken;
|
||||||
goldTakenLabel.text = taken.ToString();
|
goldTakenLabel.text = taken.ToString();
|
||||||
goldLeftLabel.text = left.ToString();
|
goldLeftLabel.text = left.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFoodLabels()
|
public void setFoodLabels() {
|
||||||
{
|
|
||||||
int taken = (int)foodSlider.value;
|
int taken = (int)foodSlider.value;
|
||||||
int left = (int)foodSlider.maxValue - taken;
|
int left = (int)foodSlider.maxValue - taken;
|
||||||
foodTakenLabel.text = taken.ToString();
|
foodTakenLabel.text = taken.ToString();
|
||||||
foodLeftLabel.text = left.ToString();
|
foodLeftLabel.text = left.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
var cmd = new SelectedCommand {
|
||||||
{
|
MarchCommand =
|
||||||
var cmd = new SelectedCommand
|
new MarchSelectedCommand {
|
||||||
{
|
DestinationProvinceId = DestinationProvinceId,
|
||||||
MarchCommand = new MarchSelectedCommand
|
Food = SelectedSupplies.food,
|
||||||
{
|
Gold = SelectedSupplies.gold,
|
||||||
DestinationProvinceId = DestinationProvinceId,
|
OriginProvince = SelectedOneProvinceCommand.OriginProvinceId
|
||||||
Food = SelectedSupplies.food,
|
}
|
||||||
Gold = SelectedSupplies.gold,
|
|
||||||
OriginProvince = SelectedOneProvinceCommand.OriginProvinceId
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
cmd.MarchCommand.MarchingUnits.AddRange(SelectedActingUnits);
|
cmd.MarchCommand.MarchingUnits.AddRange(SelectedActingUnits);
|
||||||
|
|
||||||
|
|||||||
+292
-355
File diff suppressed because it is too large
Load Diff
+33
-44
@@ -5,14 +5,11 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using System;
|
using System;
|
||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class PleaseRecruitMeCommandSelector : PopupPanelController
|
public class PleaseRecruitMeCommandSelector : PopupPanelController {
|
||||||
{
|
struct HeroInfo {
|
||||||
struct HeroInfo
|
|
||||||
{
|
|
||||||
public ProvinceId provinceId;
|
public ProvinceId provinceId;
|
||||||
public ExpandedUnaffiliatedHero hero;
|
public ExpandedUnaffiliatedHero hero;
|
||||||
}
|
}
|
||||||
@@ -25,31 +22,29 @@ namespace eagle
|
|||||||
|
|
||||||
public int CommandIndex { get; set; }
|
public int CommandIndex { get; set; }
|
||||||
private AvailableCommand _availableCommand = null;
|
private AvailableCommand _availableCommand = null;
|
||||||
public AvailableCommand AvailableCommand
|
public AvailableCommand AvailableCommand {
|
||||||
{
|
|
||||||
get => _availableCommand;
|
get => _availableCommand;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableCommand = value;
|
_availableCommand = value;
|
||||||
if (value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
_offers = new List<HeroInfo>();
|
_offers = new List<HeroInfo>();
|
||||||
PopupInfos = new List<PopupInfo>();
|
PopupInfos = new List<PopupInfo>();
|
||||||
}
|
} else {
|
||||||
else
|
_offers = _availableCommand.PleaseRecruitMeCommand.AvailableProvinces
|
||||||
{
|
.SelectMany(
|
||||||
_offers = _availableCommand
|
p => p.AvailableHeroes.Select(
|
||||||
.PleaseRecruitMeCommand
|
h => new HeroInfo {
|
||||||
.AvailableProvinces
|
provinceId = p.ProvinceId,
|
||||||
.SelectMany(p => p.AvailableHeroes.Select(h => new HeroInfo { provinceId = p.ProvinceId, hero = h })).ToList();
|
hero = h
|
||||||
|
}))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
PopupInfos = _offers
|
PopupInfos = _offers.Select(heroInfo => new PopupInfo {
|
||||||
.Select(heroInfo => new PopupInfo
|
titleText = "Please Recruit Me!",
|
||||||
{
|
mainText = "",
|
||||||
titleText = "Please Recruit Me!",
|
affectedProvinceIds = new List<ProvinceId>()
|
||||||
mainText = "",
|
})
|
||||||
affectedProvinceIds = new List<ProvinceId>()
|
.ToList();
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
@@ -58,39 +53,33 @@ namespace eagle
|
|||||||
|
|
||||||
private List<HeroInfo> _offers = new List<HeroInfo>();
|
private List<HeroInfo> _offers = new List<HeroInfo>();
|
||||||
|
|
||||||
public SelectedCommand selectedCommand(bool accept)
|
public SelectedCommand selectedCommand(bool accept) {
|
||||||
{
|
return new SelectedCommand {
|
||||||
return new SelectedCommand
|
PleaseRecruitMeCommand =
|
||||||
{
|
new PleaseRecruitMeSelectedCommand {
|
||||||
PleaseRecruitMeCommand = new PleaseRecruitMeSelectedCommand
|
ProvinceId = _offers[DisplayedIndex].provinceId,
|
||||||
{
|
HeroId = _offers[DisplayedIndex].hero.Hero.Id,
|
||||||
ProvinceId = _offers[DisplayedIndex].provinceId,
|
Accept = accept
|
||||||
HeroId = _offers[DisplayedIndex].hero.Hero.Id,
|
}
|
||||||
Accept = accept
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AcceptButtonClicked()
|
public void AcceptButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(true));
|
submissionAction(selectedCommand(true));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RejectButtonClicked()
|
public void RejectButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(false));
|
submissionAction(selectedCommand(false));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void SetUpPanel()
|
override protected void SetUpPanel() {
|
||||||
{
|
|
||||||
base.SetUpPanel();
|
base.SetUpPanel();
|
||||||
|
|
||||||
if (_offers.Count > DisplayedIndex)
|
if (_offers.Count > DisplayedIndex) {
|
||||||
{
|
|
||||||
heroDetailsController.SetHero(_offers[DisplayedIndex].hero.Hero, Model);
|
heroDetailsController.SetHero(_offers[DisplayedIndex].hero.Hero, Model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+93
-115
@@ -8,26 +8,30 @@ using UnityEngine;
|
|||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
using common;
|
using common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using FactionId = System.Int32;
|
using FactionId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class RansomCommandSelector : CommandSelector
|
public class RansomCommandSelector : CommandSelector {
|
||||||
{
|
private FactionId SelectedFactionId =>
|
||||||
private FactionId SelectedFactionId => AvailableTargetFactionIds[targetFactionDropdown.value];
|
AvailableTargetFactionIds[targetFactionDropdown.value];
|
||||||
private PrisonerToBeRansomed SelectedPrisonerToBeRansomed => AvailablePrisonersToBeRansomed[prisonerToBeRansomedDropdown.value];
|
private PrisonerToBeRansomed SelectedPrisonerToBeRansomed =>
|
||||||
|
AvailablePrisonersToBeRansomed[prisonerToBeRansomedDropdown.value];
|
||||||
|
|
||||||
private RansomOffer RansomOffer => DiplomacyCommand
|
private RansomOffer RansomOffer =>
|
||||||
.Options
|
DiplomacyCommand.Options
|
||||||
.Where(opt => opt.SealedValueCase == DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
.Where(opt => opt.SealedValueCase ==
|
||||||
.Select(opt => opt.RansomOfferOption)
|
DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
||||||
.First(opt => opt.TargetFactionId == SelectedFactionId)
|
.Select(opt => opt.RansomOfferOption)
|
||||||
.RansomOffer;
|
.First(opt => opt.TargetFactionId == SelectedFactionId)
|
||||||
|
.RansomOffer;
|
||||||
|
|
||||||
public override bool IsAppropriateFor(AvailableCommand cmd) =>
|
public override bool IsAppropriateFor(AvailableCommand cmd) =>
|
||||||
cmd.SealedValueCase == CommandType && cmd.DiplomacyCommand.Options.Any(opt => opt.SealedValueCase == DiplomacyOption.SealedValueOneofCase.RansomOfferOption);
|
cmd.SealedValueCase == CommandType
|
||||||
|
&& cmd.DiplomacyCommand.Options.Any(
|
||||||
|
opt => opt.SealedValueCase ==
|
||||||
|
DiplomacyOption.SealedValueOneofCase.RansomOfferOption);
|
||||||
|
|
||||||
private DiplomacyAvailableCommand DiplomacyCommand => _availableCommand.DiplomacyCommand;
|
private DiplomacyAvailableCommand DiplomacyCommand => _availableCommand.DiplomacyCommand;
|
||||||
private ProvinceId ActingProvinceId => DiplomacyCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => DiplomacyCommand.ActingProvinceId;
|
||||||
@@ -40,75 +44,65 @@ namespace eagle
|
|||||||
public EventBasedTable hostagesTable;
|
public EventBasedTable hostagesTable;
|
||||||
public EventBasedTable prisonersTable;
|
public EventBasedTable prisonersTable;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.DiplomacyCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.DiplomacyCommand;
|
||||||
public override string HeaderString => "Offer Ransom";
|
public override string HeaderString => "Offer Ransom";
|
||||||
public override string CommitButtonString => "Commit Ransom Offer";
|
public override string CommitButtonString => "Commit Ransom Offer";
|
||||||
|
|
||||||
private List<HeroId> HostageHeroIds { get; set; }
|
private List<HeroId> HostageHeroIds { get; set; }
|
||||||
private List<HeroId> PrisonerHeroIds { get; set; }
|
private List<HeroId> PrisonerHeroIds { get; set; }
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds
|
public override List<HeroId> TargetedHeroIds {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var hids = new List<HeroId>(HostageHeroIds);
|
var hids = new List<HeroId>(HostageHeroIds);
|
||||||
hids.AddRange(PrisonerHeroIds);
|
hids.AddRange(PrisonerHeroIds);
|
||||||
return hids;
|
return hids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => AvailableHostages.Contains(heroId) || AvailablePrisoners.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId)
|
AvailableHostages.Contains(heroId) || AvailablePrisoners.Contains(heroId);
|
||||||
{
|
public override void AddTargetedHero(HeroId heroId) {
|
||||||
if (AvailableHostages.Contains(heroId))
|
if (AvailableHostages.Contains(heroId)) {
|
||||||
{
|
if (!HostageHeroIds.Contains(heroId)) { HostageHeroIds.Add(heroId); }
|
||||||
if (!HostageHeroIds.Contains(heroId))
|
} else if (AvailablePrisoners.Contains(heroId)) {
|
||||||
{
|
if (!PrisonerHeroIds.Contains(heroId)) { PrisonerHeroIds.Add(heroId); }
|
||||||
HostageHeroIds.Add(heroId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (AvailablePrisoners.Contains(heroId))
|
|
||||||
{
|
|
||||||
if (!PrisonerHeroIds.Contains(heroId))
|
|
||||||
{
|
|
||||||
PrisonerHeroIds.Add(heroId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
public override void RemoveTargetedHero(HeroId heroId)
|
public override void RemoveTargetedHero(HeroId heroId) {
|
||||||
{
|
|
||||||
HostageHeroIds.Remove(heroId);
|
HostageHeroIds.Remove(heroId);
|
||||||
PrisonerHeroIds.Remove(heroId);
|
PrisonerHeroIds.Remove(heroId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<FactionId> TargetedFactionIds => new List<FactionId> { SelectedFactionId };
|
public override List<FactionId> TargetedFactionIds =>
|
||||||
public override bool FactionIsTargetable(FactionId factionId) => AvailableTargetFactionIds.Contains(factionId);
|
new List<FactionId> { SelectedFactionId };
|
||||||
public override void AddTargetedFaction(FactionId factionId) => targetFactionDropdown.value = AvailableTargetFactionIds.IndexOf(factionId);
|
public override bool FactionIsTargetable(FactionId factionId) =>
|
||||||
|
AvailableTargetFactionIds.Contains(factionId);
|
||||||
|
public override void AddTargetedFaction(FactionId factionId) =>
|
||||||
|
targetFactionDropdown.value = AvailableTargetFactionIds.IndexOf(factionId);
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => PrisonerHeroIds.Exists(hid => _model.ActiveFactions[_model.PlayerId.Value].Leaders.Contains(hid));
|
public override bool WarnOnCommitButton => PrisonerHeroIds.Exists(
|
||||||
public override string CommitWarningText => "You're offering up a faction leader. Are you sure?";
|
hid => _model.ActiveFactions[_model.PlayerId.Value].Leaders.Contains(hid));
|
||||||
|
public override string CommitWarningText =>
|
||||||
|
"You're offering up a faction leader. Are you sure?";
|
||||||
|
|
||||||
public override bool EnableCommitButton => GoldOffered > 0 || PrisonerHeroIds.Any() || HostageHeroIds.Any();
|
public override bool EnableCommitButton => GoldOffered > 0 ||
|
||||||
|
PrisonerHeroIds.Any() || HostageHeroIds.Any();
|
||||||
|
|
||||||
private List<FactionId> AvailableTargetFactionIds { get; set; }
|
private List<FactionId> AvailableTargetFactionIds { get; set; }
|
||||||
private List<PrisonerToBeRansomed> AvailablePrisonersToBeRansomed { get; set; }
|
private List<PrisonerToBeRansomed> AvailablePrisonersToBeRansomed { get; set; }
|
||||||
private List<HeroId> AvailableHostages { get; set; }
|
private List<HeroId> AvailableHostages { get; set; }
|
||||||
private List<HeroId> AvailablePrisoners { get; set; }
|
private List<HeroId> AvailablePrisoners { get; set; }
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => null;
|
get => null;
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
|
||||||
{
|
|
||||||
var targetFaction = _model.Provinces[value.Value].RulingFactionId;
|
var targetFaction = _model.Provinces[value.Value].RulingFactionId;
|
||||||
if (targetFaction.HasValue)
|
if (targetFaction.HasValue) {
|
||||||
{
|
|
||||||
var dropdownIndex = AvailableTargetFactionIds.IndexOf(targetFaction.Value);
|
var dropdownIndex = AvailableTargetFactionIds.IndexOf(targetFaction.Value);
|
||||||
if (dropdownIndex != -1)
|
if (dropdownIndex != -1) {
|
||||||
{
|
|
||||||
targetFactionDropdown.value = dropdownIndex;
|
targetFactionDropdown.value = dropdownIndex;
|
||||||
SetOptions();
|
SetOptions();
|
||||||
}
|
}
|
||||||
@@ -117,51 +111,47 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FactionId TargetFactionId(DiplomacyOption option)
|
private FactionId TargetFactionId(DiplomacyOption option) {
|
||||||
{
|
|
||||||
return option.RansomOfferOption.TargetFactionId;
|
return option.RansomOfferOption.TargetFactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GoldOffered => (int)goldSlider.value;
|
private int GoldOffered => (int)goldSlider.value;
|
||||||
|
|
||||||
private RansomOfferOption SelectedOption
|
private RansomOfferOption SelectedOption {
|
||||||
{
|
get {
|
||||||
get
|
var opt = new RansomOfferOption {
|
||||||
{
|
|
||||||
var opt = new RansomOfferOption
|
|
||||||
{
|
|
||||||
TargetFactionId = SelectedFactionId,
|
TargetFactionId = SelectedFactionId,
|
||||||
RansomOffer = new RansomOffer
|
RansomOffer =
|
||||||
{
|
new RansomOffer {
|
||||||
OfferingFactionId = _model.PlayerId.Value,
|
OfferingFactionId = _model.PlayerId.Value,
|
||||||
TargetFactionId = SelectedFactionId,
|
TargetFactionId = SelectedFactionId,
|
||||||
MessengerOriginProvinceId = ActingProvinceId,
|
MessengerOriginProvinceId = ActingProvinceId,
|
||||||
PrisonerToBeRansomed = SelectedPrisonerToBeRansomed,
|
PrisonerToBeRansomed = SelectedPrisonerToBeRansomed,
|
||||||
GoldOffered = GoldOffered
|
GoldOffered = GoldOffered
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
opt.RansomOffer.HostagesOffered.AddRange(RansomOffer.HostagesOffered.Where(ho => HostageHeroIds.Contains(ho.HeroId)));
|
opt.RansomOffer.HostagesOffered.AddRange(RansomOffer.HostagesOffered.Where(
|
||||||
opt.RansomOffer.PrisonersOffered.AddRange(RansomOffer.PrisonersOffered.Where(ho => PrisonerHeroIds.Contains(ho.HeroId)));
|
ho => HostageHeroIds.Contains(ho.HeroId)));
|
||||||
|
opt.RansomOffer.PrisonersOffered.AddRange(RansomOffer.PrisonersOffered.Where(
|
||||||
|
ho => PrisonerHeroIds.Contains(ho.HeroId)));
|
||||||
|
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
AvailableTargetFactionIds =
|
||||||
AvailableTargetFactionIds = DiplomacyCommand
|
DiplomacyCommand.Options
|
||||||
.Options
|
.Where(opt => opt.SealedValueCase ==
|
||||||
.Where(opt => opt.SealedValueCase == DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
DiplomacyOption.SealedValueOneofCase.RansomOfferOption)
|
||||||
.Select(opt => TargetFactionId(opt))
|
.Select(opt => TargetFactionId(opt))
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
targetFactionDropdown.ClearOptions();
|
targetFactionDropdown.ClearOptions();
|
||||||
targetFactionDropdown.AddOptions(
|
targetFactionDropdown.AddOptions(
|
||||||
AvailableTargetFactionIds
|
AvailableTargetFactionIds.Select(fid => _model.FactionName(fid)).ToList());
|
||||||
.Select(fid => _model.FactionName(fid))
|
|
||||||
.ToList());
|
|
||||||
targetFactionDropdown.value = 0;
|
targetFactionDropdown.value = 0;
|
||||||
|
|
||||||
goldSlider.minValue = 0;
|
goldSlider.minValue = 0;
|
||||||
@@ -175,41 +165,34 @@ namespace eagle
|
|||||||
SetOptions();
|
SetOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleChanged()
|
public void ToggleChanged() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SliderChanged()
|
public void SliderChanged() { goldAmount.text = ((int)goldSlider.value).ToString(); }
|
||||||
{
|
|
||||||
goldAmount.text = ((int)goldSlider.value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
DiplomacyCommand =
|
||||||
DiplomacyCommand = new DiplomacySelectedCommand
|
new DiplomacySelectedCommand {
|
||||||
{
|
TargetFactionId = SelectedFactionId,
|
||||||
TargetFactionId = SelectedFactionId,
|
SelectedOption = new DiplomacyOption { RansomOfferOption = SelectedOption }
|
||||||
SelectedOption = new DiplomacyOption { RansomOfferOption = SelectedOption }
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void TargetDropdownChanged(int value)
|
public void TargetDropdownChanged(int value) { SetOptions(); }
|
||||||
{
|
|
||||||
SetOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetOptions()
|
private void SetOptions() {
|
||||||
{
|
|
||||||
var targetFid = SelectedFactionId;
|
var targetFid = SelectedFactionId;
|
||||||
var options = _availableCommand.DiplomacyCommand.Options.Select(opt => opt.RansomOfferOption).Where(opt => opt != null && opt.TargetFactionId == targetFid);
|
var options =
|
||||||
|
_availableCommand.DiplomacyCommand.Options.Select(opt => opt.RansomOfferOption)
|
||||||
|
.Where(opt => opt != null && opt.TargetFactionId == targetFid);
|
||||||
goldSlider.maxValue = options.First().RansomOffer.GoldOffered;
|
goldSlider.maxValue = options.First().RansomOffer.GoldOffered;
|
||||||
|
|
||||||
AvailablePrisonersToBeRansomed = options
|
AvailablePrisonersToBeRansomed =
|
||||||
.Select(opt => opt.RansomOffer.PrisonerToBeRansomed).ToList();
|
options.Select(opt => opt.RansomOffer.PrisonerToBeRansomed).ToList();
|
||||||
|
|
||||||
prisonerToBeRansomedDropdown.ClearOptions();
|
prisonerToBeRansomedDropdown.ClearOptions();
|
||||||
prisonerToBeRansomedDropdown.AddOptions(
|
prisonerToBeRansomedDropdown.AddOptions(
|
||||||
AvailablePrisonersToBeRansomed.Select(p => _model.Heroes[p.PrisonerHeroId].Name).ToList());
|
AvailablePrisonersToBeRansomed.Select(p => _model.Heroes[p.PrisonerHeroId].Name)
|
||||||
|
.ToList());
|
||||||
prisonerToBeRansomedDropdown.value = 0;
|
prisonerToBeRansomedDropdown.value = 0;
|
||||||
|
|
||||||
AvailableHostages = RansomOffer.HostagesOffered.Select(p => p.HeroId).ToList();
|
AvailableHostages = RansomOffer.HostagesOffered.Select(p => p.HeroId).ToList();
|
||||||
@@ -218,11 +201,9 @@ namespace eagle
|
|||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTables()
|
private void UpdateTables() {
|
||||||
{
|
|
||||||
prisonersTable.RowCount = 0;
|
prisonersTable.RowCount = 0;
|
||||||
foreach (HeroId prisonerHid in PrisonerHeroIds)
|
foreach (HeroId prisonerHid in PrisonerHeroIds) {
|
||||||
{
|
|
||||||
var row = prisonersTable.AddRowWithComponent<AvailableHeroTableRow>();
|
var row = prisonersTable.AddRowWithComponent<AvailableHeroTableRow>();
|
||||||
row.HeroName = _model.Heroes[prisonerHid].Name;
|
row.HeroName = _model.Heroes[prisonerHid].Name;
|
||||||
row.Selectable = true;
|
row.Selectable = true;
|
||||||
@@ -230,8 +211,7 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
hostagesTable.RowCount = 0;
|
hostagesTable.RowCount = 0;
|
||||||
foreach (HeroId hostageHid in HostageHeroIds)
|
foreach (HeroId hostageHid in HostageHeroIds) {
|
||||||
{
|
|
||||||
var row = hostagesTable.AddRowWithComponent<AvailableHeroTableRow>();
|
var row = hostagesTable.AddRowWithComponent<AvailableHeroTableRow>();
|
||||||
row.HeroName = _model.Heroes[hostageHid].Name;
|
row.HeroName = _model.Heroes[hostageHid].Name;
|
||||||
row.Selectable = true;
|
row.Selectable = true;
|
||||||
@@ -239,14 +219,12 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HostageTableRowClicked(int index)
|
public void HostageTableRowClicked(int index) {
|
||||||
{
|
|
||||||
HostageHeroIds.RemoveAt(index);
|
HostageHeroIds.RemoveAt(index);
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrisonerTableRowClicked(int index)
|
public void PrisonerTableRowClicked(int index) {
|
||||||
{
|
|
||||||
PrisonerHeroIds.RemoveAt(index);
|
PrisonerHeroIds.RemoveAt(index);
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-36
@@ -6,73 +6,65 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class ReconCommandSelector : CommandSelector
|
public class ReconCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public TMP_Dropdown destinationDropdown;
|
public TMP_Dropdown destinationDropdown;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ReconCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ReconCommand;
|
||||||
public override string HeaderString => "Recon";
|
public override string HeaderString => "Recon";
|
||||||
public override string CommitButtonString => "Commit Recon";
|
public override string CommitButtonString => "Commit Recon";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => ReconAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
ReconAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private ReconAvailableCommand ReconAvailableCommand => _availableCommand.ReconCommand;
|
private ReconAvailableCommand ReconAvailableCommand => _availableCommand.ReconCommand;
|
||||||
private ProvinceId ActingProvinceId => ReconAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ReconAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => ReconAvailableCommand.AvailableTargetProvinces[destinationDropdown.value];
|
get => ReconAvailableCommand.AvailableTargetProvinces[destinationDropdown.value];
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
|
||||||
{
|
|
||||||
int index = ReconAvailableCommand.AvailableTargetProvinces.IndexOf(value.Value);
|
int index = ReconAvailableCommand.AvailableTargetProvinces.IndexOf(value.Value);
|
||||||
if (index != -1)
|
if (index != -1) destinationDropdown.value = index;
|
||||||
destinationDropdown.value = index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command =>
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
new SelectedCommand
|
ReconSelectedCommand =
|
||||||
{
|
new ReconSelectedCommand {
|
||||||
ReconSelectedCommand = new ReconSelectedCommand
|
ActingHeroId = SelectedHeroId,
|
||||||
{
|
TargetProvinceId = TargetedProvince.Value
|
||||||
ActingHeroId = SelectedHeroId,
|
}
|
||||||
TargetProvinceId = TargetedProvince.Value
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes =
|
||||||
heroDropdownController.AvailableHeroes = ReconAvailableCommand
|
ReconAvailableCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid])
|
||||||
.AvailableHeroIds
|
.ToList();
|
||||||
.Select(hid => _model.Heroes[hid])
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
destinationDropdown.ClearOptions();
|
destinationDropdown.ClearOptions();
|
||||||
var destinationProvinceNames = ReconAvailableCommand.AvailableTargetProvinces
|
var destinationProvinceNames = ReconAvailableCommand.AvailableTargetProvinces
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.ToList();
|
_model.Provinces[id],
|
||||||
|
_model.PlayerId.Value))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
destinationDropdown.AddOptions(destinationProvinceNames);
|
destinationDropdown.AddOptions(destinationProvinceNames);
|
||||||
destinationDropdown.value = 0;
|
destinationDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-30
@@ -5,71 +5,59 @@ using TMPro;
|
|||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class RecruitHeroesCommandSelector : CommandSelector
|
public class RecruitHeroesCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDetailsController heroDetails;
|
public HeroDetailsController heroDetails;
|
||||||
public Button nextHeroButton;
|
public Button nextHeroButton;
|
||||||
public TMP_Text statusText;
|
public TMP_Text statusText;
|
||||||
|
|
||||||
private int selectedHeroIndex;
|
private int selectedHeroIndex;
|
||||||
|
|
||||||
private RecruitHeroesAvailableCommand RecruitHeroesCommand => _availableCommand.RecruitHeroesCommand;
|
private RecruitHeroesAvailableCommand RecruitHeroesCommand =>
|
||||||
|
_availableCommand.RecruitHeroesCommand;
|
||||||
private ProvinceId ActingProvinceId => RecruitHeroesCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => RecruitHeroesCommand.ActingProvinceId;
|
||||||
private ExpandedUnaffiliatedHero SelectedHero => RecruitHeroesCommand.AvailableHeroes.ToList()[selectedHeroIndex];
|
private ExpandedUnaffiliatedHero SelectedHero =>
|
||||||
|
RecruitHeroesCommand.AvailableHeroes.ToList()[selectedHeroIndex];
|
||||||
private int HeroCount => RecruitHeroesCommand.AvailableHeroes.Count;
|
private int HeroCount => RecruitHeroesCommand.AvailableHeroes.Count;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.RecruitHeroesCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.RecruitHeroesCommand;
|
||||||
public override string HeaderString => "Recruit Heroes";
|
public override string HeaderString => "Recruit Heroes";
|
||||||
public override string CommitButtonString => "Commit Recruit";
|
public override string CommitButtonString => "Commit Recruit";
|
||||||
|
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => RecruitHeroesCommand.AvailableHeroes.Any(euh => euh.Hero.Id == heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
|
RecruitHeroesCommand.AvailableHeroes.Any(euh => euh.Hero.Id == heroId);
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHero.Hero.Id };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHero.Hero.Id };
|
||||||
|
|
||||||
void DisplayHero()
|
void DisplayHero() {
|
||||||
{
|
|
||||||
heroDetails.SetHero(SelectedHero.Hero, _model);
|
heroDetails.SetHero(SelectedHero.Hero, _model);
|
||||||
statusText.text = DisplayNames.UnaffiliatedHeroStatus(SelectedHero.Type);
|
statusText.text = DisplayNames.UnaffiliatedHeroStatus(SelectedHero.Type);
|
||||||
nextHeroButton.gameObject.SetActive(HeroCount > 1);
|
nextHeroButton.gameObject.SetActive(HeroCount > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
if (selectedHeroIndex >= HeroCount) { selectedHeroIndex = 0; }
|
||||||
if (selectedHeroIndex >= HeroCount)
|
|
||||||
{
|
|
||||||
selectedHeroIndex = 0;
|
|
||||||
}
|
|
||||||
DisplayHero();
|
DisplayHero();
|
||||||
nextHeroButton.gameObject.SetActive(HeroCount > 1);
|
nextHeroButton.gameObject.SetActive(HeroCount > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command
|
public override SelectedCommand Command {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var rhc = new RecruitHeroesSelectedCommand();
|
var rhc = new RecruitHeroesSelectedCommand();
|
||||||
rhc.HeroIds.Add(SelectedHero.Hero.Id);
|
rhc.HeroIds.Add(SelectedHero.Hero.Id);
|
||||||
|
|
||||||
var cmd = new SelectedCommand
|
var cmd = new SelectedCommand { RecruitHeroesCommand = rhc };
|
||||||
{
|
|
||||||
RecruitHeroesCommand = rhc
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NextHero()
|
public void NextHero() {
|
||||||
{
|
|
||||||
selectedHeroIndex++;
|
selectedHeroIndex++;
|
||||||
if (selectedHeroIndex >= HeroCount)
|
if (selectedHeroIndex >= HeroCount) { selectedHeroIndex = 0; }
|
||||||
{
|
|
||||||
selectedHeroIndex = 0;
|
|
||||||
}
|
|
||||||
DisplayHero();
|
DisplayHero();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-40
@@ -6,12 +6,10 @@ using System.Linq;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class ResolveInvitationCommandSelector : PopupPanelController
|
public class ResolveInvitationCommandSelector : PopupPanelController {
|
||||||
{
|
|
||||||
public GameObject panel;
|
public GameObject panel;
|
||||||
|
|
||||||
public Action<SelectedCommand> submissionAction;
|
public Action<SelectedCommand> submissionAction;
|
||||||
@@ -23,71 +21,67 @@ namespace eagle
|
|||||||
|
|
||||||
public int CommandIndex { get; set; }
|
public int CommandIndex { get; set; }
|
||||||
private AvailableCommand _availableCommand = null;
|
private AvailableCommand _availableCommand = null;
|
||||||
public AvailableCommand AvailableCommand
|
public AvailableCommand AvailableCommand {
|
||||||
{
|
|
||||||
get => _availableCommand;
|
get => _availableCommand;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableCommand = value;
|
_availableCommand = value;
|
||||||
if (value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
PopupInfos = new List<PopupInfo>();
|
PopupInfos = new List<PopupInfo>();
|
||||||
}
|
} else {
|
||||||
else
|
PopupInfos =
|
||||||
{
|
_availableCommand.ResolveInvitationCommand.Invitations
|
||||||
PopupInfos = _availableCommand.ResolveInvitationCommand.Invitations.Select(invite => new PopupInfo
|
.Select(invite => new PopupInfo {
|
||||||
{
|
titleText = "Invited",
|
||||||
titleText = "Invited",
|
mainText =
|
||||||
mainText = $"{Model.Heroes[invite.MessengerHeroId].Name} brings an invitation to join {Model.FactionName(invite.OriginatingFactionId)}. This would end your game. Don't accept this bullshit.",
|
$"{Model.Heroes[invite.MessengerHeroId].Name} brings an invitation to join {Model.FactionName(invite.OriginatingFactionId)}. This would end your game. Don't accept this bullshit.",
|
||||||
affectedProvinceIds = new List<ProvinceId>()
|
affectedProvinceIds = new List<ProvinceId>()
|
||||||
}).ToList();
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedCommand selectedCommand(DiplomacyOfferStatus resolution) => new SelectedCommand
|
public SelectedCommand selectedCommand(DiplomacyOfferStatus resolution) =>
|
||||||
{
|
new SelectedCommand {
|
||||||
ResolveInvitationCommand = new ResolveInvitationSelectedCommand
|
ResolveInvitationCommand =
|
||||||
{
|
new ResolveInvitationSelectedCommand {
|
||||||
Resolution = resolution,
|
Resolution = resolution,
|
||||||
OriginatingFactionId = _availableCommand.ResolveInvitationCommand.Invitations[DisplayedIndex].OriginatingFactionId
|
OriginatingFactionId = _availableCommand.ResolveInvitationCommand
|
||||||
}
|
.Invitations[DisplayedIndex]
|
||||||
};
|
.OriginatingFactionId
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void AcceptButtonClicked() {
|
||||||
public void AcceptButtonClicked()
|
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RejectButtonClicked()
|
public void RejectButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImprisonButtonClicked()
|
public void ImprisonButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void SetUpPanel()
|
override protected void SetUpPanel() {
|
||||||
{
|
|
||||||
base.SetUpPanel();
|
base.SetUpPanel();
|
||||||
|
|
||||||
if (_availableCommand?.ResolveInvitationCommand?.Invitations.Count > DisplayedIndex)
|
if (_availableCommand?.ResolveInvitationCommand?.Invitations.Count > DisplayedIndex) {
|
||||||
{
|
var invitation =
|
||||||
var invitation = _availableCommand.ResolveInvitationCommand.Invitations[DisplayedIndex];
|
_availableCommand.ResolveInvitationCommand.Invitations[DisplayedIndex];
|
||||||
heroDetailsController.SetHero(Model.Heroes[invitation.MessengerHeroId], Model);
|
heroDetailsController.SetHero(Model.Heroes[invitation.MessengerHeroId], Model);
|
||||||
var invitingFaction = Model.ActiveFactions[invitation.OriginatingFactionId];
|
var invitingFaction = Model.ActiveFactions[invitation.OriginatingFactionId];
|
||||||
FactionHeadshot.texture = GetComponentInParent<AWSResourceFetcher>().GetImage(Model.Heroes[invitingFaction.FactionHeadId].ImagePath);
|
FactionHeadshot.texture = GetComponentInParent<AWSResourceFetcher>().GetImage(
|
||||||
|
Model.Heroes[invitingFaction.FactionHeadId].ImagePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-67
@@ -6,12 +6,10 @@ using System.Linq;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using common;
|
using common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class ResolveRansomOfferCommandSelector : PopupPanelController
|
public class ResolveRansomOfferCommandSelector : PopupPanelController {
|
||||||
{
|
|
||||||
public Action<SelectedCommand> submissionAction;
|
public Action<SelectedCommand> submissionAction;
|
||||||
|
|
||||||
public GameModel Model { get; set; }
|
public GameModel Model { get; set; }
|
||||||
@@ -24,8 +22,7 @@ namespace eagle
|
|||||||
|
|
||||||
public EventBasedTable exchangedHeroesTable;
|
public EventBasedTable exchangedHeroesTable;
|
||||||
|
|
||||||
private string MainText(RansomOffer offer)
|
private string MainText(RansomOffer offer) {
|
||||||
{
|
|
||||||
var originatingFactionId = offer.OfferingFactionId;
|
var originatingFactionId = offer.OfferingFactionId;
|
||||||
var offeringFactionHeadId = Model.ActiveFactions[originatingFactionId].FactionHeadId;
|
var offeringFactionHeadId = Model.ActiveFactions[originatingFactionId].FactionHeadId;
|
||||||
var messengerName = Model.Heroes[offeringFactionHeadId].Name;
|
var messengerName = Model.Heroes[offeringFactionHeadId].Name;
|
||||||
@@ -35,27 +32,18 @@ namespace eagle
|
|||||||
|
|
||||||
var hostageCount = offer.HostagesOffered.Count + offer.PrisonersOffered.Count;
|
var hostageCount = offer.HostagesOffered.Count + offer.PrisonersOffered.Count;
|
||||||
string hostageString = "";
|
string hostageString = "";
|
||||||
if (hostageCount == 1)
|
if (hostageCount == 1) {
|
||||||
{
|
|
||||||
hostageString = "a hostage ";
|
hostageString = "a hostage ";
|
||||||
}
|
} else if (hostageCount > 1) {
|
||||||
else if (hostageCount > 1)
|
|
||||||
{
|
|
||||||
hostageString = "hostages ";
|
hostageString = "hostages ";
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = $"{messengerName} offers ";
|
var message = $"{messengerName} offers ";
|
||||||
if (offer.GoldOffered > 0)
|
if (offer.GoldOffered > 0) {
|
||||||
{
|
|
||||||
message += $"{offer.GoldOffered} gold ";
|
message += $"{offer.GoldOffered} gold ";
|
||||||
|
|
||||||
if (hostageCount > 0)
|
if (hostageCount > 0) { message += $"and {hostageString} "; }
|
||||||
{
|
} else {
|
||||||
message += $"and {hostageString} ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message += hostageString;
|
message += hostageString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,97 +51,93 @@ namespace eagle
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvailableCommand AvailableCommand
|
public AvailableCommand AvailableCommand {
|
||||||
{
|
|
||||||
get => _availableCommand;
|
get => _availableCommand;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableCommand = value;
|
_availableCommand = value;
|
||||||
if (value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
PopupInfos = new List<PopupInfo>();
|
PopupInfos = new List<PopupInfo>();
|
||||||
}
|
} else {
|
||||||
else
|
PopupInfos = _availableCommand.ResolveRansomOfferCommand.Offers
|
||||||
{
|
.Select(off => new PopupInfo {
|
||||||
PopupInfos = _availableCommand.ResolveRansomOfferCommand.Offers.Select(off => new PopupInfo
|
titleText = "RansomOffered",
|
||||||
{
|
mainText = MainText(off),
|
||||||
titleText = "RansomOffered",
|
affectedProvinceIds = new List<ProvinceId>()
|
||||||
mainText = MainText(off),
|
})
|
||||||
affectedProvinceIds = new List<ProvinceId>()
|
.ToList();
|
||||||
}).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedCommand selectedCommand(DiplomacyOfferStatus resolution) => new SelectedCommand
|
public SelectedCommand selectedCommand(
|
||||||
{
|
DiplomacyOfferStatus resolution) => new SelectedCommand {
|
||||||
ResolveRansomOfferCommand = new ResolveRansomOfferSelectedCommand
|
ResolveRansomOfferCommand =
|
||||||
{
|
new ResolveRansomOfferSelectedCommand {
|
||||||
Resolution = resolution,
|
Resolution = resolution,
|
||||||
OfferingFactionId = AvailableCommand.ResolveRansomOfferCommand.Offers[DisplayedIndex].OfferingFactionId,
|
OfferingFactionId = AvailableCommand.ResolveRansomOfferCommand
|
||||||
RansomOffer = AvailableCommand.ResolveRansomOfferCommand.Offers[DisplayedIndex]
|
.Offers[DisplayedIndex]
|
||||||
}
|
.OfferingFactionId,
|
||||||
|
RansomOffer =
|
||||||
|
AvailableCommand.ResolveRansomOfferCommand.Offers[DisplayedIndex]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void AcceptButtonClicked()
|
public void AcceptButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RejectButtonClicked()
|
public void RejectButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImprisonButtonClicked()
|
public void ImprisonButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void SetUpPanel()
|
override protected void SetUpPanel() {
|
||||||
{
|
|
||||||
base.SetUpPanel();
|
base.SetUpPanel();
|
||||||
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
|
|
||||||
if (_availableCommand?.ResolveRansomOfferCommand?.Offers.Count > DisplayedIndex)
|
if (_availableCommand?.ResolveRansomOfferCommand?.Offers.Count > DisplayedIndex) {
|
||||||
{
|
|
||||||
var offer = _availableCommand.ResolveRansomOfferCommand.Offers[DisplayedIndex];
|
var offer = _availableCommand.ResolveRansomOfferCommand.Offers[DisplayedIndex];
|
||||||
heroDetailsController.SetHero(Model.Heroes[offer.PrisonerToBeRansomed.PrisonerHeroId], Model);
|
heroDetailsController.SetHero(
|
||||||
|
Model.Heroes[offer.PrisonerToBeRansomed.PrisonerHeroId],
|
||||||
|
Model);
|
||||||
var offeringFaction = Model.ActiveFactions[offer.OfferingFactionId];
|
var offeringFaction = Model.ActiveFactions[offer.OfferingFactionId];
|
||||||
|
|
||||||
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
||||||
FactionHeadshot.texture = fetcher.GetImage(Model.Heroes[offeringFaction.FactionHeadId].ImagePath);
|
FactionHeadshot.texture =
|
||||||
|
fetcher.GetImage(Model.Heroes[offeringFaction.FactionHeadId].ImagePath);
|
||||||
|
|
||||||
mapController.OverrideTargetedProvinces = Model.Provinces.Values
|
mapController.OverrideTargetedProvinces =
|
||||||
.Where(pv => pv.RulingFactionId == offeringFaction.Id)
|
Model.Provinces.Values.Where(pv => pv.RulingFactionId == offeringFaction.Id)
|
||||||
.Select(pv => pv.Id)
|
.Select(pv => pv.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
exchangedHeroesTable.RowCount = 0;
|
exchangedHeroesTable.RowCount = 0;
|
||||||
|
|
||||||
var offeringFactionName = Model.FactionName(offer.OfferingFactionId);
|
var offeringFactionName = Model.FactionName(offer.OfferingFactionId);
|
||||||
foreach (var hostage in offer.HostagesOffered)
|
foreach (var hostage in offer.HostagesOffered) {
|
||||||
{
|
var row =
|
||||||
var row = exchangedHeroesTable.AddRowWithComponent<ExchangedHeroRowController>();
|
exchangedHeroesTable.AddRowWithComponent<ExchangedHeroRowController>();
|
||||||
row.SetHostage(Model.Heroes[hostage.HeroId], offeringFactionName);
|
row.SetHostage(Model.Heroes[hostage.HeroId], offeringFactionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var prisoner in offer.PrisonersOffered)
|
foreach (var prisoner in offer.PrisonersOffered) {
|
||||||
{
|
var row =
|
||||||
var row = exchangedHeroesTable.AddRowWithComponent<ExchangedHeroRowController>();
|
exchangedHeroesTable.AddRowWithComponent<ExchangedHeroRowController>();
|
||||||
|
|
||||||
var prisonerFactionName = "";
|
var prisonerFactionName = "";
|
||||||
if (prisoner.FactionIdForPrisoner != -1)
|
if (prisoner.FactionIdForPrisoner != -1) {
|
||||||
{
|
|
||||||
prisonerFactionName = Model.FactionName(prisoner.FactionIdForPrisoner);
|
prisonerFactionName = Model.FactionName(prisoner.FactionIdForPrisoner);
|
||||||
}
|
}
|
||||||
row.SetPrisoner(Model.Heroes[prisoner.HeroId], offeringFactionName);
|
row.SetPrisoner(Model.Heroes[prisoner.HeroId], offeringFactionName);
|
||||||
|
|||||||
+35
-44
@@ -5,12 +5,10 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class ResolveTreatyCommandSelector : PopupPanelController
|
public class ResolveTreatyCommandSelector : PopupPanelController {
|
||||||
{
|
|
||||||
public Action<SelectedCommand> submissionAction;
|
public Action<SelectedCommand> submissionAction;
|
||||||
|
|
||||||
public GameModel Model { get; set; }
|
public GameModel Model { get; set; }
|
||||||
@@ -21,87 +19,80 @@ namespace eagle
|
|||||||
public HeroDetailsController heroDetailsController;
|
public HeroDetailsController heroDetailsController;
|
||||||
private AvailableCommand _availableCommand = null;
|
private AvailableCommand _availableCommand = null;
|
||||||
|
|
||||||
private string MainText(TreatyOffer offer)
|
private string MainText(TreatyOffer offer) {
|
||||||
{
|
|
||||||
var originatingFactionId = offer.OriginatingFactionId;
|
var originatingFactionId = offer.OriginatingFactionId;
|
||||||
var messengerHeroId = offer.MessengerHeroId;
|
var messengerHeroId = offer.MessengerHeroId;
|
||||||
var messengerName = Model.Heroes[messengerHeroId].Name;
|
var messengerName = Model.Heroes[messengerHeroId].Name;
|
||||||
return $"{messengerName} brings a treaty proposal from {Model.FactionName(originatingFactionId)}.";
|
return $"{messengerName} brings a treaty proposal from {Model.FactionName(originatingFactionId)}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvailableCommand AvailableCommand
|
public AvailableCommand AvailableCommand {
|
||||||
{
|
|
||||||
get => _availableCommand;
|
get => _availableCommand;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableCommand = value;
|
_availableCommand = value;
|
||||||
if (value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
PopupInfos = new List<PopupInfo>();
|
PopupInfos = new List<PopupInfo>();
|
||||||
}
|
} else {
|
||||||
else
|
PopupInfos = _availableCommand.ResolveTreatyOfferCommand.Offers
|
||||||
{
|
.Select(off => new PopupInfo {
|
||||||
PopupInfos = _availableCommand.ResolveTreatyOfferCommand.Offers.Select(off => new PopupInfo
|
titleText = "Treaty Proposed",
|
||||||
{
|
mainText = MainText(off),
|
||||||
titleText = "Treaty Proposed",
|
affectedProvinceIds = new List<ProvinceId>()
|
||||||
mainText = MainText(off),
|
})
|
||||||
affectedProvinceIds = new List<ProvinceId>()
|
.ToList();
|
||||||
}).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedCommand selectedCommand(DiplomacyOfferStatus resolution) => new SelectedCommand
|
public SelectedCommand selectedCommand(DiplomacyOfferStatus resolution) =>
|
||||||
{
|
new SelectedCommand {
|
||||||
ResolveTreatyOfferCommand = new ResolveTreatyOfferSelectedCommand
|
ResolveTreatyOfferCommand =
|
||||||
{
|
new ResolveTreatyOfferSelectedCommand {
|
||||||
Resolution = resolution,
|
Resolution = resolution,
|
||||||
OriginatingFactionId = AvailableCommand.ResolveTreatyOfferCommand.Offers[DisplayedIndex].OriginatingFactionId
|
OriginatingFactionId = AvailableCommand.ResolveTreatyOfferCommand
|
||||||
}
|
.Offers[DisplayedIndex]
|
||||||
};
|
.OriginatingFactionId
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public void AcceptButtonClicked()
|
public void AcceptButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Accepted));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RejectButtonClicked()
|
public void RejectButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Rejected));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImprisonButtonClicked()
|
public void ImprisonButtonClicked() {
|
||||||
{
|
|
||||||
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
submissionAction(selectedCommand(DiplomacyOfferStatus.Imprisoned));
|
||||||
AvailableCommand = null;
|
AvailableCommand = null;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void SetUpPanel()
|
override protected void SetUpPanel() {
|
||||||
{
|
|
||||||
base.SetUpPanel();
|
base.SetUpPanel();
|
||||||
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
|
|
||||||
if (_availableCommand?.ResolveTreatyOfferCommand?.Offers.Count > DisplayedIndex)
|
if (_availableCommand?.ResolveTreatyOfferCommand?.Offers.Count > DisplayedIndex) {
|
||||||
{
|
|
||||||
var offer = _availableCommand.ResolveTreatyOfferCommand.Offers[DisplayedIndex];
|
var offer = _availableCommand.ResolveTreatyOfferCommand.Offers[DisplayedIndex];
|
||||||
heroDetailsController.SetHero(Model.Heroes[offer.MessengerHeroId], Model);
|
heroDetailsController.SetHero(Model.Heroes[offer.MessengerHeroId], Model);
|
||||||
var offeringFaction = Model.ActiveFactions[offer.OriginatingFactionId];
|
var offeringFaction = Model.ActiveFactions[offer.OriginatingFactionId];
|
||||||
|
|
||||||
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
||||||
FactionHeadshot.texture = fetcher.GetImage(Model.Heroes[offeringFaction.FactionHeadId].ImagePath);
|
FactionHeadshot.texture =
|
||||||
|
fetcher.GetImage(Model.Heroes[offeringFaction.FactionHeadId].ImagePath);
|
||||||
|
|
||||||
mapController.OverrideTargetedProvinces = Model.Provinces.Values
|
mapController.OverrideTargetedProvinces =
|
||||||
.Where(pv => pv.RulingFactionId == offeringFaction.Id)
|
Model.Provinces.Values.Where(pv => pv.RulingFactionId == offeringFaction.Id)
|
||||||
.Select(pv => pv.Id)
|
.Select(pv => pv.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-28
@@ -5,12 +5,10 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class ResolveTributeCommandSelector : CommandSelector
|
public class ResolveTributeCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public TMP_Text factionDescription;
|
public TMP_Text factionDescription;
|
||||||
public TMP_Text goldAmountLabel;
|
public TMP_Text goldAmountLabel;
|
||||||
public TMP_Text foodAmountLabel;
|
public TMP_Text foodAmountLabel;
|
||||||
@@ -19,50 +17,49 @@ namespace eagle
|
|||||||
public Toggle payToggle;
|
public Toggle payToggle;
|
||||||
public Button nextFactionButton;
|
public Button nextFactionButton;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ResolveTributeCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.ResolveTributeCommand;
|
||||||
public override string HeaderString => "Tribute Demanded";
|
public override string HeaderString => "Tribute Demanded";
|
||||||
public override string CommitButtonString => payToggle.isOn ? "Commit Pay Tribute" : "Commit Refuse to Pay";
|
public override string CommitButtonString =>
|
||||||
|
payToggle.isOn ? "Commit Pay Tribute" : "Commit Refuse to Pay";
|
||||||
public override bool EnableCommitButton => !payToggle.isOn || SufficientResources;
|
public override bool EnableCommitButton => !payToggle.isOn || SufficientResources;
|
||||||
public override string DisabledCommitButtonReason => "You don't have enough resources to pay";
|
public override string DisabledCommitButtonReason =>
|
||||||
|
"You don't have enough resources to pay";
|
||||||
|
|
||||||
private List<TributeAndFaction> _demands;
|
private List<TributeAndFaction> _demands;
|
||||||
private TributeAndFaction SelectedDemand => _demands[_demandIndex];
|
private TributeAndFaction SelectedDemand => _demands[_demandIndex];
|
||||||
private bool SufficientResources => ResolveTributeAvailableCommand.AvailableGold >= SelectedDemand.TributeDemanded.Gold
|
private bool SufficientResources =>
|
||||||
&& ResolveTributeAvailableCommand.AvailableFood >= SelectedDemand.TributeDemanded.Food;
|
ResolveTributeAvailableCommand.AvailableGold >=
|
||||||
|
SelectedDemand.TributeDemanded.Gold &&
|
||||||
|
ResolveTributeAvailableCommand.AvailableFood >= SelectedDemand.TributeDemanded.Food;
|
||||||
|
|
||||||
private int _demandIndex;
|
private int _demandIndex;
|
||||||
|
|
||||||
private ResolveTributeAvailableCommand ResolveTributeAvailableCommand => _availableCommand.ResolveTributeCommand;
|
private ResolveTributeAvailableCommand ResolveTributeAvailableCommand =>
|
||||||
|
_availableCommand.ResolveTributeCommand;
|
||||||
private ProvinceId ActingProvinceId => ResolveTributeAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ResolveTributeAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
ResolveTributeCommand =
|
||||||
ResolveTributeCommand = new ResolveTributeSelectedCommand
|
new ResolveTributeSelectedCommand {
|
||||||
{
|
DemandingFactionId = SelectedDemand.DemandingFactionId,
|
||||||
DemandingFactionId = SelectedDemand.DemandingFactionId,
|
Paid = payToggle.isOn
|
||||||
Paid = payToggle.isOn
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void NextButtonClicked()
|
public void NextButtonClicked() {
|
||||||
{
|
|
||||||
_demandIndex += 1;
|
_demandIndex += 1;
|
||||||
if (_demandIndex >= _demands.Count)
|
if (_demandIndex >= _demands.Count) { _demandIndex = 0; }
|
||||||
{
|
|
||||||
_demandIndex = 0;
|
|
||||||
}
|
|
||||||
DisplayDemand();
|
DisplayDemand();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
_demands = new List<TributeAndFaction>(ResolveTributeAvailableCommand.Demands);
|
_demands = new List<TributeAndFaction>(ResolveTributeAvailableCommand.Demands);
|
||||||
_demandIndex = 0;
|
_demandIndex = 0;
|
||||||
DisplayDemand();
|
DisplayDemand();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayDemand()
|
private void DisplayDemand() {
|
||||||
{
|
|
||||||
nextFactionButton.gameObject.SetActive(_demands.Count > 1);
|
nextFactionButton.gameObject.SetActive(_demands.Count > 1);
|
||||||
|
|
||||||
var demandingFaction = _model.MaybeDestroyedFaction(SelectedDemand.DemandingFactionId);
|
var demandingFaction = _model.MaybeDestroyedFaction(SelectedDemand.DemandingFactionId);
|
||||||
@@ -72,7 +69,8 @@ namespace eagle
|
|||||||
goldAmountLabel.text = SelectedDemand.TributeDemanded.Gold.ToString();
|
goldAmountLabel.text = SelectedDemand.TributeDemanded.Gold.ToString();
|
||||||
foodAmountLabel.text = SelectedDemand.TributeDemanded.Food.ToString();
|
foodAmountLabel.text = SelectedDemand.TributeDemanded.Food.ToString();
|
||||||
|
|
||||||
var armiesForFaction = _model.Provinces[ActingProvinceId].KnownIncomingArmies.Where(ai => ai.FactionId == SelectedDemand.DemandingFactionId);
|
var armiesForFaction = _model.Provinces[ActingProvinceId].KnownIncomingArmies.Where(
|
||||||
|
ai => ai.FactionId == SelectedDemand.DemandingFactionId);
|
||||||
incomingHeroCount.text = SelectedDemand.HeroCount.ToString();
|
incomingHeroCount.text = SelectedDemand.HeroCount.ToString();
|
||||||
incomingTroopsCount.text = SelectedDemand.TroopCount.ToString();
|
incomingTroopsCount.text = SelectedDemand.TroopCount.ToString();
|
||||||
|
|
||||||
|
|||||||
+7
-12
@@ -1,26 +1,21 @@
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class RestCommandSelector : CommandSelector
|
public class RestCommandSelector : CommandSelector {
|
||||||
{
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.RestCommand;
|
AvailableCommand.SealedValueOneofCase.RestCommand;
|
||||||
public override string HeaderString => "Rest";
|
public override string HeaderString => "Rest";
|
||||||
public override string CommitButtonString => "Commit Rest";
|
public override string CommitButtonString => "Commit Rest";
|
||||||
|
|
||||||
private RestAvailableCommand RestAvailableCommand => _availableCommand.RestCommand;
|
private RestAvailableCommand RestAvailableCommand => _availableCommand.RestCommand;
|
||||||
private ProvinceId ActingProvinceId => RestAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => RestAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command =>
|
||||||
{
|
new SelectedCommand { RestSelectedCommand = new RestSelectedCommand() };
|
||||||
RestSelectedCommand = new RestSelectedCommand()
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-12
@@ -3,26 +3,21 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class ReturnCommandSelector : CommandSelector
|
public class ReturnCommandSelector : CommandSelector {
|
||||||
{
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.ReturnCommand;
|
AvailableCommand.SealedValueOneofCase.ReturnCommand;
|
||||||
public override string HeaderString => "Return to Base";
|
public override string HeaderString => "Return to Base";
|
||||||
public override string CommitButtonString => "Commit Return";
|
public override string CommitButtonString => "Commit Return";
|
||||||
|
|
||||||
private ReturnAvailableCommand ReturnAvailableCommand => _availableCommand.ReturnCommand;
|
private ReturnAvailableCommand ReturnAvailableCommand => _availableCommand.ReturnCommand;
|
||||||
private ProvinceId ActingProvinceId => ReturnAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => ReturnAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command =>
|
||||||
{
|
new SelectedCommand { ReturnSelectedCommand = new ReturnSelectedCommand() };
|
||||||
ReturnSelectedCommand = new ReturnSelectedCommand()
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-46
@@ -7,15 +7,15 @@ using EagleGUIUtils;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
|
|
||||||
public class SendSuppliesCommandSelector : CommandSelector
|
public class SendSuppliesCommandSelector : CommandSelector {
|
||||||
{
|
private ProvinceId SelectedDestinationProvinceId =>
|
||||||
private ProvinceId SelectedDestinationProvinceId => SendSuppliesAvailableCommand.AvailableDestinationProvinceIds[ToDropdown.value];
|
SendSuppliesAvailableCommand.AvailableDestinationProvinceIds[ToDropdown.value];
|
||||||
private ProvinceView SelectedDestinationProvince => _model.Provinces[SelectedDestinationProvinceId];
|
private ProvinceView SelectedDestinationProvince =>
|
||||||
|
_model.Provinces[SelectedDestinationProvinceId];
|
||||||
private HeroId SelectedActorId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedActorId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
public TMP_Dropdown FromDropdown;
|
public TMP_Dropdown FromDropdown;
|
||||||
@@ -28,31 +28,36 @@ namespace eagle
|
|||||||
public TMP_Text FoodLeft;
|
public TMP_Text FoodLeft;
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.SendSuppliesCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.SendSuppliesCommand;
|
||||||
public override string HeaderString => "Send Supplies";
|
public override string HeaderString => "Send Supplies";
|
||||||
public override string CommitButtonString => "Commit Send";
|
public override string CommitButtonString => "Commit Send";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedActorId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedActorId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => SendSuppliesAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
SendSuppliesAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
public override bool WarnOnCommitButton => !SelectedDestinationProvince.RulingFactionId.HasValue || SelectedDestinationProvince.RulingFactionId.Value != _model.PlayerId;
|
public override bool WarnOnCommitButton =>
|
||||||
public override string CommitWarningText => $"You do not currently occupy {SelectedDestinationProvince.Name}. Are you sure you wish to send supplies there?";
|
!SelectedDestinationProvince.RulingFactionId.HasValue ||
|
||||||
|
SelectedDestinationProvince.RulingFactionId.Value != _model.PlayerId;
|
||||||
|
public override string CommitWarningText =>
|
||||||
|
$"You do not currently occupy {SelectedDestinationProvince.Name}. Are you sure you wish to send supplies there?";
|
||||||
|
|
||||||
private SendSuppliesAvailableCommand SendSuppliesAvailableCommand => _availableCommand.SendSuppliesCommand;
|
private SendSuppliesAvailableCommand SendSuppliesAvailableCommand =>
|
||||||
|
_availableCommand.SendSuppliesCommand;
|
||||||
private ProvinceId ActingProvinceId => SendSuppliesAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => SendSuppliesAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => SelectedDestinationProvinceId;
|
get => SelectedDestinationProvinceId;
|
||||||
|
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
int index =
|
||||||
{
|
SendSuppliesAvailableCommand.AvailableDestinationProvinceIds.IndexOf(
|
||||||
int index = SendSuppliesAvailableCommand.AvailableDestinationProvinceIds.IndexOf(value.Value);
|
value.Value);
|
||||||
if (index != -1)
|
if (index != -1) ToDropdown.value = index;
|
||||||
ToDropdown.value = index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,20 +65,22 @@ namespace eagle
|
|||||||
public override bool EnableCommitButton => FoodSlider.value > 0 || GoldSlider.value > 0;
|
public override bool EnableCommitButton => FoodSlider.value > 0 || GoldSlider.value > 0;
|
||||||
public override string DisabledCommitButtonReason => "Must send some food or gold";
|
public override string DisabledCommitButtonReason => "Must send some food or gold";
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
FromDropdown.ClearOptions();
|
FromDropdown.ClearOptions();
|
||||||
FromDropdown.AddOptions(new List<String> { _model.Provinces[ActingProvinceId].Name });
|
FromDropdown.AddOptions(new List<String> { _model.Provinces[ActingProvinceId].Name });
|
||||||
|
|
||||||
ToDropdown.ClearOptions();
|
ToDropdown.ClearOptions();
|
||||||
ToDropdown.AddOptions(
|
ToDropdown.AddOptions(SendSuppliesAvailableCommand.AvailableDestinationProvinceIds
|
||||||
SendSuppliesAvailableCommand.AvailableDestinationProvinceIds
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
_model.Provinces[id],
|
||||||
.ToList()
|
_model.PlayerId.Value))
|
||||||
);
|
.ToList());
|
||||||
|
|
||||||
ToDropdown.value = 0;
|
ToDropdown.value = 0;
|
||||||
var firstOwned = SendSuppliesAvailableCommand.AvailableDestinationProvinceIds.ToList().FindIndex(pid => _model.Provinces[pid].RulingFactionId.HasValue && _model.Provinces[pid].RulingFactionId.Value == _model.PlayerId);
|
var firstOwned =
|
||||||
|
SendSuppliesAvailableCommand.AvailableDestinationProvinceIds.ToList().FindIndex(
|
||||||
|
pid => _model.Provinces[pid].RulingFactionId.HasValue &&
|
||||||
|
_model.Provinces[pid].RulingFactionId.Value == _model.PlayerId);
|
||||||
ToDropdown.value = firstOwned < 0 ? 0 : firstOwned;
|
ToDropdown.value = firstOwned < 0 ? 0 : firstOwned;
|
||||||
|
|
||||||
FoodSlider.value = 0;
|
FoodSlider.value = 0;
|
||||||
@@ -88,31 +95,27 @@ namespace eagle
|
|||||||
GoldTaken.text = "0";
|
GoldTaken.text = "0";
|
||||||
GoldLeft.text = SendSuppliesAvailableCommand.GoldAvailable.ToString();
|
GoldLeft.text = SendSuppliesAvailableCommand.GoldAvailable.ToString();
|
||||||
|
|
||||||
heroDropdownController.AvailableHeroes = SendSuppliesAvailableCommand
|
heroDropdownController.AvailableHeroes =
|
||||||
.AvailableHeroIds
|
SendSuppliesAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id])
|
||||||
.Select(id => _model.Heroes[id])
|
.ToList();
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
SendSuppliesCommand =
|
||||||
SendSuppliesCommand = new SendSuppliesSelectedCommand
|
new SendSuppliesSelectedCommand {
|
||||||
{
|
Food = (int)FoodSlider.value,
|
||||||
Food = (int)FoodSlider.value,
|
Gold = (int)GoldSlider.value,
|
||||||
Gold = (int)GoldSlider.value,
|
ActingHeroId = SelectedActorId,
|
||||||
ActingHeroId = SelectedActorId,
|
DestinationProvinceId = SelectedDestinationProvinceId,
|
||||||
DestinationProvinceId = SelectedDestinationProvinceId,
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void GoldSliderChanged(float newValue)
|
public void GoldSliderChanged(float newValue) {
|
||||||
{
|
|
||||||
GoldTaken.text = newValue.ToString();
|
GoldTaken.text = newValue.ToString();
|
||||||
GoldLeft.text = (SendSuppliesAvailableCommand.GoldAvailable - newValue).ToString();
|
GoldLeft.text = (SendSuppliesAvailableCommand.GoldAvailable - newValue).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FoodSliderChanged(float newValue)
|
public void FoodSliderChanged(float newValue) {
|
||||||
{
|
|
||||||
FoodTaken.text = newValue.ToString();
|
FoodTaken.text = newValue.ToString();
|
||||||
FoodLeft.text = (SendSuppliesAvailableCommand.FoodAvailable - newValue).ToString();
|
FoodLeft.text = (SendSuppliesAvailableCommand.FoodAvailable - newValue).ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-42
@@ -6,77 +6,71 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class StartEpidemicCommandSelector : CommandSelector
|
public class StartEpidemicCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public TMP_Dropdown targetDropdown;
|
public TMP_Dropdown targetDropdown;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.StartEpidemicCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.StartEpidemicCommand;
|
||||||
public override string HeaderString => "Start Plague";
|
public override string HeaderString => "Start Plague";
|
||||||
public override string CommitButtonString => $"Commit Plague";
|
public override string CommitButtonString => $"Commit Plague";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => StartEpidemicAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
StartEpidemicAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private StartEpidemicAvailableCommand StartEpidemicAvailableCommand => _availableCommand.StartEpidemicCommand;
|
private StartEpidemicAvailableCommand StartEpidemicAvailableCommand =>
|
||||||
|
_availableCommand.StartEpidemicCommand;
|
||||||
private ProvinceId ActingProvinceId => StartEpidemicAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => StartEpidemicAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
private ProvinceId SelectedTargetProvinceId => StartEpidemicAvailableCommand.Options[targetDropdown.value].TargetProvinceId;
|
private ProvinceId SelectedTargetProvinceId =>
|
||||||
|
StartEpidemicAvailableCommand.Options[targetDropdown.value].TargetProvinceId;
|
||||||
|
|
||||||
protected override ProvinceId? TargetedProvince
|
protected override ProvinceId? TargetedProvince {
|
||||||
{
|
|
||||||
get => SelectedTargetProvinceId;
|
get => SelectedTargetProvinceId;
|
||||||
set
|
set {
|
||||||
{
|
if (value.HasValue) {
|
||||||
if (value.HasValue)
|
int index = StartEpidemicAvailableCommand.Options.ToList().FindIndex(
|
||||||
{
|
seo => seo.TargetProvinceId == value.Value);
|
||||||
int index = StartEpidemicAvailableCommand.Options.ToList().FindIndex(seo => seo.TargetProvinceId == value.Value);
|
if (index != -1) targetDropdown.value = index;
|
||||||
if (index != -1)
|
|
||||||
targetDropdown.value = index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command =>
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
new SelectedCommand
|
StartEpidemicSelectedCommand =
|
||||||
{
|
new StartEpidemicSelectedCommand {
|
||||||
StartEpidemicSelectedCommand = new StartEpidemicSelectedCommand
|
SelectedProvinceId = SelectedTargetProvinceId,
|
||||||
{
|
ActingHeroId = SelectedHeroId
|
||||||
SelectedProvinceId = SelectedTargetProvinceId,
|
}
|
||||||
ActingHeroId = SelectedHeroId
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
protected override void SetUpUI() {
|
||||||
protected override void SetUpUI()
|
heroDropdownController.AvailableHeroes =
|
||||||
{
|
StartEpidemicAvailableCommand.AvailableHeroIds.Select(hid => _model.Heroes[hid])
|
||||||
heroDropdownController.AvailableHeroes = StartEpidemicAvailableCommand
|
.ToList();
|
||||||
.AvailableHeroIds
|
|
||||||
.Select(hid => _model.Heroes[hid])
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
targetDropdown.ClearOptions();
|
targetDropdown.ClearOptions();
|
||||||
var destinationProvinceNames = StartEpidemicAvailableCommand.Options
|
var destinationProvinceNames =
|
||||||
.Select(opt => opt.TargetProvinceId)
|
StartEpidemicAvailableCommand.Options.Select(opt => opt.TargetProvinceId)
|
||||||
.Select(id => GUIUtils.DarkColoredProvinceName(_model.Provinces[id], _model.PlayerId.Value))
|
.Select(id => GUIUtils.DarkColoredProvinceName(
|
||||||
.ToList();
|
_model.Provinces[id],
|
||||||
|
_model.PlayerId.Value))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
targetDropdown.AddOptions(destinationProvinceNames);
|
targetDropdown.AddOptions(destinationProvinceNames);
|
||||||
targetDropdown.value = 0;
|
targetDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+39
-31
@@ -3,38 +3,44 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class SuppressBeastsCommandSelector : CommandSelector
|
public class SuppressBeastsCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public BattalionDropdownController battalionDropdownController;
|
public BattalionDropdownController battalionDropdownController;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.SuppressBrigandsCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
public override string HeaderString => $"Suppress {DisplayNames.Capitalized(DisplayNames.BeastTypeName(BeastType))}";
|
AvailableCommand.SealedValueOneofCase.SuppressBrigandsCommand;
|
||||||
|
public override string HeaderString =>
|
||||||
|
$"Suppress {DisplayNames.Capitalized(DisplayNames.BeastTypeName(BeastType))}";
|
||||||
public override string CommitButtonString => "Commit Suppression";
|
public override string CommitButtonString => "Commit Suppression";
|
||||||
public override bool WarnOnCommitButton => !SelectedBattalionId.HasValue;
|
public override bool WarnOnCommitButton => !SelectedBattalionId.HasValue;
|
||||||
public override string CommitWarningText => "You aren't sending a battalion. Your hero may be killed.";
|
public override string CommitWarningText =>
|
||||||
|
"You aren't sending a battalion. Your hero may be killed.";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => SuppressBrigandsAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
SuppressBrigandsAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
public override List<BattalionId> TargetedBattalionIds => SelectedBattalionId.HasValue ? new List<BattalionId> { SelectedBattalionId.Value } : new List<BattalionId>();
|
public override List<BattalionId> TargetedBattalionIds =>
|
||||||
public override bool BattalionIsTargetable(BattalionId bid) => SuppressBrigandsAvailableCommand.AvailableBattalionIds.Contains(bid);
|
SelectedBattalionId.HasValue ? new List<BattalionId> { SelectedBattalionId.Value }
|
||||||
public override void AddTargetedBattalion(BattalionId bid) => battalionDropdownController.SelectedBattalionId = bid;
|
: new List<BattalionId>();
|
||||||
|
public override bool BattalionIsTargetable(BattalionId bid) =>
|
||||||
|
SuppressBrigandsAvailableCommand.AvailableBattalionIds.Contains(bid);
|
||||||
|
public override void AddTargetedBattalion(BattalionId bid) =>
|
||||||
|
battalionDropdownController.SelectedBattalionId = bid;
|
||||||
|
|
||||||
private SuppressBrigandsAvailableCommand SuppressBrigandsAvailableCommand => _availableCommand.SuppressBrigandsCommand;
|
private SuppressBrigandsAvailableCommand SuppressBrigandsAvailableCommand =>
|
||||||
|
_availableCommand.SuppressBrigandsCommand;
|
||||||
private ProvinceId ActingProvinceId => SuppressBrigandsAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => SuppressBrigandsAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
private Net.Eagle0.Eagle.Common.BeastType BeastType
|
private Net.Eagle0.Eagle.Common.BeastType BeastType {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
if (Province == null) return Net.Eagle0.Eagle.Common.BeastType.Unknown;
|
if (Province == null) return Net.Eagle0.Eagle.Common.BeastType.Unknown;
|
||||||
var beastEvents = Province.KnownEvents.Where(ev => ev.BeastsEvent != null);
|
var beastEvents = Province.KnownEvents.Where(ev => ev.BeastsEvent != null);
|
||||||
|
|
||||||
@@ -46,25 +52,27 @@ namespace eagle
|
|||||||
|
|
||||||
private ProvinceView Province => _model == null ? null : _model.Provinces[ActingProvinceId];
|
private ProvinceView Province => _model == null ? null : _model.Provinces[ActingProvinceId];
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes =
|
||||||
heroDropdownController.AvailableHeroes = SuppressBrigandsAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
SuppressBrigandsAvailableCommand.AvailableHeroIds
|
||||||
battalionDropdownController.AvailableBattalions = SuppressBrigandsAvailableCommand.AvailableBattalionIds
|
.Select(id => _model.Heroes[id])
|
||||||
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
.ToList();
|
||||||
.OrderBy(batt => batt.Type)
|
battalionDropdownController.AvailableBattalions =
|
||||||
.ToList();
|
SuppressBrigandsAvailableCommand.AvailableBattalionIds
|
||||||
|
.Select(id => Province.FullInfo.Battalions.First(b => b.Id == id))
|
||||||
|
.OrderBy(batt => batt.Type)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
private BattalionId? SelectedBattalionId => battalionDropdownController.SelectedBattalionId;
|
private BattalionId? SelectedBattalionId => battalionDropdownController.SelectedBattalionId;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
SuppressBrigandsCommand =
|
||||||
SuppressBrigandsCommand = new SuppressBrigandsSelectedCommand()
|
new SuppressBrigandsSelectedCommand() {
|
||||||
{
|
HeroId = SelectedHeroId,
|
||||||
HeroId = SelectedHeroId,
|
BattalionId = SelectedBattalionId
|
||||||
BattalionId = SelectedBattalionId
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+19
-21
@@ -3,49 +3,47 @@ using System.Linq;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class SwearBrotherhoodCommandSelector : CommandSelector
|
public class SwearBrotherhoodCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
public HeroDetailsController heroDetails;
|
public HeroDetailsController heroDetails;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.SwearBrotherhoodCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.SwearBrotherhoodCommand;
|
||||||
public override string HeaderString => "Swear Brotherhood with Hero";
|
public override string HeaderString => "Swear Brotherhood with Hero";
|
||||||
public override string CommitButtonString => "Commit Oath";
|
public override string CommitButtonString => "Commit Oath";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => SwearBrotherhoodAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
SwearBrotherhoodAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private SwearBrotherhoodAvailableCommand SwearBrotherhoodAvailableCommand => _availableCommand.SwearBrotherhoodCommand;
|
private SwearBrotherhoodAvailableCommand SwearBrotherhoodAvailableCommand =>
|
||||||
|
_availableCommand.SwearBrotherhoodCommand;
|
||||||
private ProvinceId ActingProvinceId => SwearBrotherhoodAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => SwearBrotherhoodAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
heroDropdownController.AvailableHeroes =
|
||||||
heroDropdownController.AvailableHeroes = SwearBrotherhoodAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
SwearBrotherhoodAvailableCommand.AvailableHeroIds
|
||||||
|
.Select(id => _model.Heroes[id])
|
||||||
|
.ToList();
|
||||||
|
|
||||||
heroDropdownController.SelectedHeroIdUpdated = () => HeroDropdownChanged();
|
heroDropdownController.SelectedHeroIdUpdated = () => HeroDropdownChanged();
|
||||||
|
|
||||||
HeroDropdownChanged();
|
HeroDropdownChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeroDropdownChanged()
|
void HeroDropdownChanged() { heroDetails.SetHero(_model.Heroes[SelectedHeroId], _model); }
|
||||||
{
|
|
||||||
heroDetails.SetHero(_model.Heroes[SelectedHeroId], _model);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
SwearBrotherhoodCommand =
|
||||||
SwearBrotherhoodCommand = new SwearBrotherhoodSelectedCommand
|
new SwearBrotherhoodSelectedCommand { NewBrotherHeroId = SelectedHeroId }
|
||||||
{
|
|
||||||
NewBrotherHeroId = SelectedHeroId
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-21
@@ -4,12 +4,10 @@ using Net.Eagle0.Eagle.Common;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class TradeCommandSelector : CommandSelector
|
public class TradeCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public TMP_Text buyPrice;
|
public TMP_Text buyPrice;
|
||||||
public TMP_Text sellPrice;
|
public TMP_Text sellPrice;
|
||||||
public Slider slider;
|
public Slider slider;
|
||||||
@@ -17,18 +15,20 @@ namespace eagle
|
|||||||
public TMP_Text foodText;
|
public TMP_Text foodText;
|
||||||
public TMP_Text description;
|
public TMP_Text description;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.TradeCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.TradeCommand;
|
||||||
public override string HeaderString => "Trade";
|
public override string HeaderString => "Trade";
|
||||||
public override string CommitButtonString => IsBuy ? "Commit Buy" : "Commit Sell";
|
public override string CommitButtonString => IsBuy ? "Commit Buy" : "Commit Sell";
|
||||||
|
|
||||||
private TradeAvailableCommand TradeCommand => _availableCommand.TradeCommand;
|
private TradeAvailableCommand TradeCommand => _availableCommand.TradeCommand;
|
||||||
private ProvinceId ActingProvinceId => TradeCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => TradeCommand.ActingProvinceId;
|
||||||
|
|
||||||
private int MaxFood => TradeCommand.FoodAvailable + (int)Math.Floor(TradeCommand.GoldAvailable / TradeCommand.FoodBuyPrice);
|
private int MaxFood =>
|
||||||
|
TradeCommand.FoodAvailable +
|
||||||
|
(int)Math.Floor(TradeCommand.GoldAvailable / TradeCommand.FoodBuyPrice);
|
||||||
private int FoodAmount => (int)slider.value;
|
private int FoodAmount => (int)slider.value;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
|
||||||
slider.minValue = 0;
|
slider.minValue = 0;
|
||||||
slider.maxValue = MaxFood;
|
slider.maxValue = MaxFood;
|
||||||
slider.value = TradeCommand.FoodAvailable;
|
slider.value = TradeCommand.FoodAvailable;
|
||||||
@@ -44,26 +44,25 @@ namespace eagle
|
|||||||
|
|
||||||
private bool IsBuy => FoodAmount > TradeCommand.FoodAvailable;
|
private bool IsBuy => FoodAmount > TradeCommand.FoodAvailable;
|
||||||
private int NetFood => FoodAmount - TradeCommand.FoodAvailable;
|
private int NetFood => FoodAmount - TradeCommand.FoodAvailable;
|
||||||
private int NetGold => IsBuy ? -(int)Math.Ceiling(NetFood * TradeCommand.FoodBuyPrice) : -(int)Math.Ceiling(NetFood * TradeCommand.FoodSellPrice);
|
private int NetGold => IsBuy ? -(int)Math.Ceiling(NetFood * TradeCommand.FoodBuyPrice)
|
||||||
|
: -(int)Math.Ceiling(NetFood * TradeCommand.FoodSellPrice);
|
||||||
private int GoldAmount => TradeCommand.GoldAvailable + NetGold;
|
private int GoldAmount => TradeCommand.GoldAvailable + NetGold;
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
TradeCommand =
|
||||||
TradeCommand = new TradeSelectedCommand
|
new TradeSelectedCommand {
|
||||||
{
|
Amount = Math.Abs(FoodAmount - TradeCommand.FoodAvailable),
|
||||||
Amount = Math.Abs(FoodAmount - TradeCommand.FoodAvailable),
|
TradeType = IsBuy ? TradeSelectedCommand.Types.TradeType.BuyFood
|
||||||
TradeType = IsBuy
|
: TradeSelectedCommand.Types.TradeType.SellFood
|
||||||
? TradeSelectedCommand.Types.TradeType.BuyFood
|
}
|
||||||
: TradeSelectedCommand.Types.TradeType.SellFood
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void SetTextFields()
|
public void SetTextFields() {
|
||||||
{
|
|
||||||
goldText.text = GoldAmount.ToString();
|
goldText.text = GoldAmount.ToString();
|
||||||
foodText.text = FoodAmount.ToString();
|
foodText.text = FoodAmount.ToString();
|
||||||
|
|
||||||
description.text = IsBuy ? $"Buying {NetFood} food for {-NetGold} gold" : $"Selling {-NetFood} food for {NetGold} gold";
|
description.text = IsBuy ? $"Buying {NetFood} food for {-NetGold} gold"
|
||||||
|
: $"Selling {-NetFood} food for {NetGold} gold";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-16
@@ -2,42 +2,39 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = System.Int32;
|
using HeroId = System.Int32;
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class TrainCommandSelector : CommandSelector
|
public class TrainCommandSelector : CommandSelector {
|
||||||
{
|
|
||||||
public HeroDropdownController heroDropdownController;
|
public HeroDropdownController heroDropdownController;
|
||||||
|
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.TrainCommand;
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
|
AvailableCommand.SealedValueOneofCase.TrainCommand;
|
||||||
public override string HeaderString => "Train";
|
public override string HeaderString => "Train";
|
||||||
public override string CommitButtonString => "Commit Train";
|
public override string CommitButtonString => "Commit Train";
|
||||||
|
|
||||||
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
public override List<HeroId> TargetedHeroIds => new List<HeroId> { SelectedHeroId };
|
||||||
public override bool HeroIsTargetable(HeroId heroId) => TrainAvailableCommand.AvailableHeroIds.Contains(heroId);
|
public override bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public override void AddTargetedHero(HeroId heroId) => heroDropdownController.SelectedHeroId = heroId;
|
TrainAvailableCommand.AvailableHeroIds.Contains(heroId);
|
||||||
|
public override void AddTargetedHero(HeroId heroId) =>
|
||||||
|
heroDropdownController.SelectedHeroId = heroId;
|
||||||
|
|
||||||
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
private HeroId SelectedHeroId => heroDropdownController.SelectedHeroId;
|
||||||
|
|
||||||
private TrainAvailableCommand TrainAvailableCommand => _availableCommand.TrainCommand;
|
private TrainAvailableCommand TrainAvailableCommand => _availableCommand.TrainCommand;
|
||||||
private ProvinceId ActingProvinceId => TrainAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => TrainAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {
|
||||||
{
|
var heroes =
|
||||||
var heroes = TrainAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
TrainAvailableCommand.AvailableHeroIds.Select(id => _model.Heroes[id]).ToList();
|
||||||
heroDropdownController.AvailableHeroes = heroes;
|
heroDropdownController.AvailableHeroes = heroes;
|
||||||
|
|
||||||
heroDropdownController.SelectedHeroId = TrainAvailableCommand.RecommendedHeroId;
|
heroDropdownController.SelectedHeroId = TrainAvailableCommand.RecommendedHeroId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command => new SelectedCommand {
|
||||||
{
|
TrainCommand = new TrainSelectedCommand { ActingHeroId = SelectedHeroId }
|
||||||
TrainCommand = new TrainSelectedCommand
|
|
||||||
{
|
|
||||||
ActingHeroId = SelectedHeroId
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-12
@@ -1,26 +1,21 @@
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class TravelCommandSelector : CommandSelector
|
public class TravelCommandSelector : CommandSelector {
|
||||||
{
|
public override AvailableCommand.SealedValueOneofCase CommandType =>
|
||||||
public override AvailableCommand.SealedValueOneofCase CommandType => AvailableCommand.SealedValueOneofCase.TravelCommand;
|
AvailableCommand.SealedValueOneofCase.TravelCommand;
|
||||||
public override string HeaderString => "Travel";
|
public override string HeaderString => "Travel";
|
||||||
public override string CommitButtonString => "Commit Travel";
|
public override string CommitButtonString => "Commit Travel";
|
||||||
|
|
||||||
private TravelAvailableCommand TravelAvailableCommand => _availableCommand.TravelCommand;
|
private TravelAvailableCommand TravelAvailableCommand => _availableCommand.TravelCommand;
|
||||||
private ProvinceId ActingProvinceId => TravelAvailableCommand.ActingProvinceId;
|
private ProvinceId ActingProvinceId => TravelAvailableCommand.ActingProvinceId;
|
||||||
|
|
||||||
protected override void SetUpUI()
|
protected override void SetUpUI() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override SelectedCommand Command => new SelectedCommand
|
public override SelectedCommand Command =>
|
||||||
{
|
new SelectedCommand { TravelCommand = new TravelSelectedCommand() };
|
||||||
TravelCommand = new TravelSelectedCommand()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+27
-23
@@ -7,53 +7,57 @@ using System;
|
|||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
|
|
||||||
public class BattalionDropdownController : MonoBehaviour
|
public class BattalionDropdownController : MonoBehaviour {
|
||||||
{
|
|
||||||
private List<BattalionView> _availableBattalions;
|
private List<BattalionView> _availableBattalions;
|
||||||
public List<BattalionView> AvailableBattalions
|
public List<BattalionView> AvailableBattalions {
|
||||||
{
|
|
||||||
get => _availableBattalions;
|
get => _availableBattalions;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableBattalions = new List<BattalionView>(value);
|
_availableBattalions = new List<BattalionView>(value);
|
||||||
|
|
||||||
var dropdown = GetComponent<TMP_Dropdown>();
|
var dropdown = GetComponent<TMP_Dropdown>();
|
||||||
|
|
||||||
dropdown.ClearOptions();
|
dropdown.ClearOptions();
|
||||||
dropdown.AddOptions(new List<TMP_Dropdown.OptionData> { new TMP_Dropdown.OptionData { text = "None" } });
|
dropdown.AddOptions(new List<TMP_Dropdown.OptionData> {
|
||||||
|
new TMP_Dropdown.OptionData { text = "None" }
|
||||||
|
});
|
||||||
dropdown.AddOptions(AvailableBattalions.Select(BattalionOption).ToList());
|
dropdown.AddOptions(AvailableBattalions.Select(BattalionOption).ToList());
|
||||||
dropdown.value = Math.Min(1, AvailableBattalions.Count);
|
dropdown.value = Math.Min(1, AvailableBattalions.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattalionId? SelectedBattalionId
|
public BattalionId? SelectedBattalionId {
|
||||||
{
|
get => GetComponent<TMP_Dropdown>().value == 0
|
||||||
get => GetComponent<TMP_Dropdown>().value == 0 ? null : (BattalionId?)(AvailableBattalions[GetComponent<TMP_Dropdown>().value - 1].Id);
|
? null
|
||||||
set => GetComponent<TMP_Dropdown>().value = AvailableBattalions.FindIndex(h => h.Id == value) + 1;
|
: (BattalionId?)(
|
||||||
|
AvailableBattalions[GetComponent<TMP_Dropdown>().value - 1]
|
||||||
|
.Id);
|
||||||
|
set => GetComponent<TMP_Dropdown>().value =
|
||||||
|
AvailableBattalions.FindIndex(h => h.Id == value) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnityEvent SelectedBattalionIdUpdated;
|
public UnityEvent SelectedBattalionIdUpdated;
|
||||||
|
|
||||||
public void DropdownUpdated(int newValue)
|
public void DropdownUpdated(int newValue) {
|
||||||
{
|
gameObject.GetComponentInParent<EagleGameController>()
|
||||||
gameObject.GetComponentInParent<EagleGameController>().GetComponentInChildren<HeroesAndBattalionsPanelController>().UpdateBattalionSelections();
|
.GetComponentInChildren<HeroesAndBattalionsPanelController>()
|
||||||
|
.UpdateBattalionSelections();
|
||||||
|
|
||||||
if (SelectedBattalionIdUpdated != null) SelectedBattalionIdUpdated.Invoke();
|
if (SelectedBattalionIdUpdated != null) SelectedBattalionIdUpdated.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TMP_Dropdown.OptionData BattalionOption(BattalionView bv)
|
private TMP_Dropdown.OptionData BattalionOption(BattalionView bv) {
|
||||||
{
|
var texture =
|
||||||
var texture = gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(bv.Type);
|
gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(bv.Type);
|
||||||
return new TMP_Dropdown.OptionData
|
return new TMP_Dropdown.OptionData {
|
||||||
{
|
image = Sprite.Create(
|
||||||
image = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)),
|
texture,
|
||||||
|
new Rect(0, 0, texture.width, texture.height),
|
||||||
|
new Vector2(0.5f, 0.5f)),
|
||||||
text = $"{bv.Name} ({bv.Size})"
|
text = $"{bv.Name} ({bv.Size})"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+113
-147
@@ -8,14 +8,12 @@ using System;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using BattalionId = Int32;
|
using BattalionId = Int32;
|
||||||
using static Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types;
|
using static Net.Eagle0.Eagle.Api.Command.Util.SuitableBattalions.Types;
|
||||||
|
|
||||||
public class EventBasedUnitSelector : MonoBehaviour
|
public class EventBasedUnitSelector : MonoBehaviour {
|
||||||
{
|
|
||||||
public GameObject availableHeroesContent;
|
public GameObject availableHeroesContent;
|
||||||
public GameObject availableBattalionsContent;
|
public GameObject availableBattalionsContent;
|
||||||
public GameObject selectedUnitsContent;
|
public GameObject selectedUnitsContent;
|
||||||
@@ -31,30 +29,27 @@ namespace eagle
|
|||||||
|
|
||||||
public int BattalionCount => SelectedActingUnits.Where(u => u.BattalionId.HasValue).Count();
|
public int BattalionCount => SelectedActingUnits.Where(u => u.BattalionId.HasValue).Count();
|
||||||
|
|
||||||
private EagleCommonTextures textures => gameObject.GetComponentInParent<EagleCommonTextures>();
|
private EagleCommonTextures textures =>
|
||||||
|
gameObject.GetComponentInParent<EagleCommonTextures>();
|
||||||
|
|
||||||
public struct MaybeHeroAndBattalion
|
public struct MaybeHeroAndBattalion {
|
||||||
{
|
|
||||||
public HeroId? heroId;
|
public HeroId? heroId;
|
||||||
public BattalionView battalion;
|
public BattalionView battalion;
|
||||||
|
|
||||||
public BattalionId? BattalionId => battalion == null ? (BattalionId?)null : battalion.Id;
|
public BattalionId? BattalionId =>
|
||||||
|
battalion == null ? (BattalionId?)null : battalion.Id;
|
||||||
}
|
}
|
||||||
public List<MaybeHeroAndBattalion> SelectedIds = new List<MaybeHeroAndBattalion>();
|
public List<MaybeHeroAndBattalion> SelectedIds = new List<MaybeHeroAndBattalion>();
|
||||||
|
|
||||||
private List<HeroId> _allHeroIds;
|
private List<HeroId> _allHeroIds;
|
||||||
private List<BattalionView> _orderedBattalions;
|
private List<BattalionView> _orderedBattalions;
|
||||||
|
|
||||||
public List<CombatUnit> SelectedActingUnits
|
public List<CombatUnit> SelectedActingUnits {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
var cus = new List<CombatUnit>();
|
var cus = new List<CombatUnit>();
|
||||||
if (SelectedIds.Exists(sid => !sid.heroId.HasValue)) return cus;
|
if (SelectedIds.Exists(sid => !sid.heroId.HasValue)) return cus;
|
||||||
for (int i = 0; i < SelectedIds.Count; i++)
|
for (int i = 0; i < SelectedIds.Count; i++) {
|
||||||
{
|
cus.Add(new CombatUnit {
|
||||||
cus.Add(new CombatUnit
|
|
||||||
{
|
|
||||||
HeroId = SelectedIds[i].heroId.Value,
|
HeroId = SelectedIds[i].heroId.Value,
|
||||||
BattalionId = SelectedIds[i].BattalionId,
|
BattalionId = SelectedIds[i].BattalionId,
|
||||||
FactionId = _model.PlayerId.Value
|
FactionId = _model.PlayerId.Value
|
||||||
@@ -63,47 +58,52 @@ namespace eagle
|
|||||||
return cus;
|
return cus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public bool UnitsAreValid => SelectedIds.Count > 0
|
public bool UnitsAreValid => SelectedIds.Count > 0 &&
|
||||||
&& SelectedIds.TrueForAll(sid => sid.heroId.HasValue);
|
SelectedIds.TrueForAll(sid => sid.heroId.HasValue);
|
||||||
public string InvalidUnitsReason => SelectedIds.Count < 1 ? "No units were selected" : "Each battalion must have a hero";
|
public string InvalidUnitsReason => SelectedIds.Count < 1
|
||||||
|
? "No units were selected"
|
||||||
|
: "Each battalion must have a hero";
|
||||||
|
|
||||||
public List<HeroId> HeroIdsLeadingInappropriateUnits => SelectedActingUnits.Where(u => u.BattalionId.HasValue && SuitableBattalions[u.HeroId].Find(bws => bws.BattalionId == u.BattalionId.Value).Level == SuitabilityLevel.Restrictive)
|
public List<HeroId> HeroIdsLeadingInappropriateUnits =>
|
||||||
.Select(u => u.HeroId)
|
SelectedActingUnits
|
||||||
.ToList();
|
.Where(u => u.BattalionId.HasValue &&
|
||||||
|
SuitableBattalions[u.HeroId]
|
||||||
|
.Find(bws => bws.BattalionId ==
|
||||||
|
u.BattalionId.Value)
|
||||||
|
.Level == SuitabilityLevel.Restrictive)
|
||||||
|
.Select(u => u.HeroId)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
public bool HeroIsTargetable(HeroId heroId) => AvailableHeroIds.Contains(heroId) || SelectedActingUnits.Select(u => u.HeroId).Contains(heroId);
|
public bool HeroIsTargetable(HeroId heroId) =>
|
||||||
public void AddTargetedHero(HeroId heroId)
|
AvailableHeroIds.Contains(heroId) ||
|
||||||
{
|
SelectedActingUnits.Select(u => u.HeroId).Contains(heroId);
|
||||||
|
public void AddTargetedHero(HeroId heroId) {
|
||||||
var index = AvailableHeroIds.IndexOf(heroId);
|
var index = AvailableHeroIds.IndexOf(heroId);
|
||||||
|
|
||||||
if (index != -1)
|
if (index != -1) { availableHeroButtonClicked(index); }
|
||||||
{
|
|
||||||
availableHeroButtonClicked(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveTargetedHero(HeroId heroId) => selectedHeroClicked(SelectedIds.FindIndex(cu => cu.heroId == heroId));
|
public void RemoveTargetedHero(HeroId heroId) =>
|
||||||
|
selectedHeroClicked(SelectedIds.FindIndex(cu => cu.heroId == heroId));
|
||||||
|
|
||||||
public bool BattalionIsTargetable(BattalionId bid) => AvailableBattalions.Where(batt => batt.Id == bid).Count() > 0 || SelectedActingUnits.Select(u => u.BattalionId).Contains(bid);
|
public bool BattalionIsTargetable(BattalionId bid) =>
|
||||||
public void AddTargetedBattalion(BattalionId bid)
|
AvailableBattalions.Where(batt => batt.Id == bid).Count() > 0 ||
|
||||||
{
|
SelectedActingUnits.Select(u => u.BattalionId).Contains(bid);
|
||||||
|
public void AddTargetedBattalion(BattalionId bid) {
|
||||||
var index = AvailableBattalions.FindIndex(batt => batt.Id == bid);
|
var index = AvailableBattalions.FindIndex(batt => batt.Id == bid);
|
||||||
|
|
||||||
if (index != -1)
|
if (index != -1) { availableBattalionButtonClicked(index); }
|
||||||
{
|
|
||||||
availableBattalionButtonClicked(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveTargetedBattalion(BattalionId bid) => selectedBattalionClicked(SelectedIds.FindIndex(cu => cu.BattalionId == bid));
|
public void RemoveTargetedBattalion(BattalionId bid) =>
|
||||||
|
selectedBattalionClicked(SelectedIds.FindIndex(cu => cu.BattalionId == bid));
|
||||||
|
|
||||||
public void SetUpUnits(
|
public void SetUpUnits(
|
||||||
GameModel model,
|
GameModel model,
|
||||||
List<HeroId> availableHeroIds,
|
List<HeroId> availableHeroIds,
|
||||||
List<BattalionView> orderedBattalions,
|
List<BattalionView> orderedBattalions,
|
||||||
Dictionary<HeroId, List<BattalionIdWithSuitability>> suitableBattalions,
|
Dictionary<HeroId, List<BattalionIdWithSuitability>> suitableBattalions,
|
||||||
List<CombatUnit> recommendedUnits)
|
List<CombatUnit> recommendedUnits) {
|
||||||
{
|
|
||||||
_model = model;
|
_model = model;
|
||||||
_allHeroIds = availableHeroIds;
|
_allHeroIds = availableHeroIds;
|
||||||
_orderedBattalions = orderedBattalions;
|
_orderedBattalions = orderedBattalions;
|
||||||
@@ -125,9 +125,12 @@ namespace eagle
|
|||||||
Dictionary<HeroId, List<BattalionIdWithSuitability>> SuitableBattalions;
|
Dictionary<HeroId, List<BattalionIdWithSuitability>> SuitableBattalions;
|
||||||
List<CombatUnit> RecommendedUnits;
|
List<CombatUnit> RecommendedUnits;
|
||||||
|
|
||||||
private GameObject instantiateInTable(GameObject prefab, Transform tableContent)
|
private GameObject instantiateInTable(GameObject prefab, Transform tableContent) {
|
||||||
{
|
var newRow = Instantiate(
|
||||||
var newRow = Instantiate(prefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0), tableContent);
|
prefab,
|
||||||
|
new Vector3(0, 0, 0),
|
||||||
|
new Quaternion(0, 0, 0, 0),
|
||||||
|
tableContent);
|
||||||
|
|
||||||
// FIXME: I don't know why this reset of the z-position is necessary
|
// FIXME: I don't know why this reset of the z-position is necessary
|
||||||
var position = newRow.GetComponent<RectTransform>().anchoredPosition3D;
|
var position = newRow.GetComponent<RectTransform>().anchoredPosition3D;
|
||||||
@@ -137,97 +140,82 @@ namespace eagle
|
|||||||
return newRow;
|
return newRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpTables()
|
private void SetUpTables() {
|
||||||
{
|
|
||||||
AvailableHeroIds.OrderBy(hid => _allHeroIds.IndexOf(hid));
|
AvailableHeroIds.OrderBy(hid => _allHeroIds.IndexOf(hid));
|
||||||
AvailableBattalions.OrderBy(b => _orderedBattalions.IndexOf(b));
|
AvailableBattalions.OrderBy(b => _orderedBattalions.IndexOf(b));
|
||||||
var oddColor = availableHeroRow.GetComponent<UnityEngine.UI.Image>().color;
|
var oddColor = availableHeroRow.GetComponent<UnityEngine.UI.Image>().color;
|
||||||
oddColor.a = 0;
|
oddColor.a = 0;
|
||||||
|
|
||||||
foreach (Transform row in availableHeroesContent.transform)
|
foreach (Transform row in availableHeroesContent.transform) { Destroy(row.gameObject); }
|
||||||
{
|
|
||||||
Destroy(row.gameObject);
|
|
||||||
}
|
|
||||||
var parentTransform = availableHeroesContent.transform;
|
var parentTransform = availableHeroesContent.transform;
|
||||||
for (int i = 0; i < AvailableHeroIds.Count; i++)
|
for (int i = 0; i < AvailableHeroIds.Count; i++) {
|
||||||
{
|
|
||||||
var hid = AvailableHeroIds[i];
|
var hid = AvailableHeroIds[i];
|
||||||
var hero = _model.Heroes[hid];
|
var hero = _model.Heroes[hid];
|
||||||
|
|
||||||
var newRow = instantiateInTable(availableHeroRow, parentTransform).GetComponent<UnitSelectorHeroRowController>();
|
var newRow = instantiateInTable(availableHeroRow, parentTransform)
|
||||||
|
.GetComponent<UnitSelectorHeroRowController>();
|
||||||
newRow.Hero = hero;
|
newRow.Hero = hero;
|
||||||
|
|
||||||
var index = i;
|
var index = i;
|
||||||
newRow.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(() => availableHeroButtonClicked(index));
|
newRow.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
() => availableHeroButtonClicked(index));
|
||||||
newRow.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
newRow.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
|
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1) { newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor; }
|
||||||
{
|
|
||||||
newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Transform row in selectedUnitsContent.transform)
|
foreach (Transform row in selectedUnitsContent.transform) { Destroy(row.gameObject); }
|
||||||
{
|
|
||||||
Destroy(row.gameObject);
|
|
||||||
}
|
|
||||||
parentTransform = selectedUnitsContent.transform;
|
parentTransform = selectedUnitsContent.transform;
|
||||||
|
|
||||||
var idsCount = SelectedIds.Count;
|
var idsCount = SelectedIds.Count;
|
||||||
for (int i = 0; i < idsCount; i++)
|
for (int i = 0; i < idsCount; i++) {
|
||||||
{
|
var newRow = instantiateInTable(selectedUnitRow, parentTransform)
|
||||||
var newRow = instantiateInTable(selectedUnitRow, parentTransform).GetComponent<SelectedUnitRowController>();
|
.GetComponent<SelectedUnitRowController>();
|
||||||
var buttons = newRow.GetComponentsInChildren<Button>();
|
var buttons = newRow.GetComponentsInChildren<Button>();
|
||||||
|
|
||||||
var heroId = SelectedIds[i].heroId;
|
var heroId = SelectedIds[i].heroId;
|
||||||
var battalion = SelectedIds[i].battalion;
|
var battalion = SelectedIds[i].battalion;
|
||||||
var appropriate = heroId.HasValue &&
|
var appropriate = heroId.HasValue &&
|
||||||
(battalion == null || SuitableBattalions[heroId.Value].Find(bws => bws.BattalionId == battalion.Id).Level != SuitabilityLevel.Restrictive);
|
(battalion == null ||
|
||||||
|
SuitableBattalions[heroId.Value]
|
||||||
|
.Find(bws => bws.BattalionId == battalion.Id)
|
||||||
|
.Level != SuitabilityLevel.Restrictive);
|
||||||
|
|
||||||
var index = i;
|
var index = i;
|
||||||
|
|
||||||
if (heroId is HeroId hid)
|
if (heroId is HeroId hid) {
|
||||||
{
|
|
||||||
var hero = _model.Heroes[hid];
|
var hero = _model.Heroes[hid];
|
||||||
newRow.Hero = hero;
|
newRow.Hero = hero;
|
||||||
newRow.Appropriate = appropriate;
|
newRow.Appropriate = appropriate;
|
||||||
newRow.HeroClickDetector = () => selectedHeroClicked(index);
|
newRow.HeroClickDetector = () => selectedHeroClicked(index);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
newRow.Hero = null;
|
newRow.Hero = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
newRow.Battalion = battalion;
|
newRow.Battalion = battalion;
|
||||||
newRow.BattalionClickDetector = () => selectedBattalionClicked(index);
|
newRow.BattalionClickDetector = () => selectedBattalionClicked(index);
|
||||||
|
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1) { newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor; }
|
||||||
{
|
|
||||||
newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Transform row in availableBattalionsContent.transform)
|
foreach (Transform row in availableBattalionsContent.transform) {
|
||||||
{
|
|
||||||
Destroy(row.gameObject);
|
Destroy(row.gameObject);
|
||||||
}
|
}
|
||||||
parentTransform = availableBattalionsContent.transform;
|
parentTransform = availableBattalionsContent.transform;
|
||||||
for (int i = 0; i < AvailableBattalions.Count; i++)
|
for (int i = 0; i < AvailableBattalions.Count; i++) {
|
||||||
{
|
|
||||||
var battalion = AvailableBattalions[i];
|
var battalion = AvailableBattalions[i];
|
||||||
|
|
||||||
var newRow = instantiateInTable(availableBattalionsRow.gameObject, parentTransform).GetComponent<BattalionRowController>();
|
var newRow = instantiateInTable(availableBattalionsRow.gameObject, parentTransform)
|
||||||
|
.GetComponent<BattalionRowController>();
|
||||||
newRow.Battalion = battalion;
|
newRow.Battalion = battalion;
|
||||||
|
|
||||||
var index = i;
|
var index = i;
|
||||||
|
|
||||||
newRow.GetComponent<TableRowClickDetector>().onClick.AddListener(() => availableBattalionButtonClicked(index));
|
newRow.GetComponent<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
() => availableBattalionButtonClicked(index));
|
||||||
newRow.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
newRow.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
|
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1) { newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor; }
|
||||||
{
|
|
||||||
newRow.GetComponent<UnityEngine.UI.Image>().color = oddColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
heroesAndBattalionsPanelController.UpdateTables();
|
heroesAndBattalionsPanelController.UpdateTables();
|
||||||
@@ -235,20 +223,12 @@ namespace eagle
|
|||||||
selectionChanged.Invoke();
|
selectionChanged.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void availableHeroButtonClicked(int index)
|
public void availableHeroButtonClicked(int index) {
|
||||||
{
|
|
||||||
var hid = AvailableHeroIds[index];
|
var hid = AvailableHeroIds[index];
|
||||||
var chosenIndex = SelectedIds.FindIndex(sid => !sid.heroId.HasValue);
|
var chosenIndex = SelectedIds.FindIndex(sid => !sid.heroId.HasValue);
|
||||||
if (chosenIndex == -1)
|
if (chosenIndex == -1) {
|
||||||
{
|
SelectedIds.Add(new MaybeHeroAndBattalion { heroId = hid, battalion = null });
|
||||||
SelectedIds.Add(new MaybeHeroAndBattalion
|
} else {
|
||||||
{
|
|
||||||
heroId = hid,
|
|
||||||
battalion = null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var sid = SelectedIds[chosenIndex];
|
var sid = SelectedIds[chosenIndex];
|
||||||
sid.heroId = hid;
|
sid.heroId = hid;
|
||||||
SelectedIds[chosenIndex] = sid;
|
SelectedIds[chosenIndex] = sid;
|
||||||
@@ -259,20 +239,12 @@ namespace eagle
|
|||||||
SetUpTables();
|
SetUpTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void availableBattalionButtonClicked(int index)
|
public void availableBattalionButtonClicked(int index) {
|
||||||
{
|
|
||||||
var batt = AvailableBattalions[index];
|
var batt = AvailableBattalions[index];
|
||||||
var chosenIndex = SelectedIds.FindIndex(sid => sid.battalion == null);
|
var chosenIndex = SelectedIds.FindIndex(sid => sid.battalion == null);
|
||||||
if (chosenIndex == -1)
|
if (chosenIndex == -1) {
|
||||||
{
|
SelectedIds.Add(new MaybeHeroAndBattalion { heroId = null, battalion = batt });
|
||||||
SelectedIds.Add(new MaybeHeroAndBattalion
|
} else {
|
||||||
{
|
|
||||||
heroId = null,
|
|
||||||
battalion = batt
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var sid = SelectedIds[chosenIndex];
|
var sid = SelectedIds[chosenIndex];
|
||||||
sid.battalion = batt;
|
sid.battalion = batt;
|
||||||
SelectedIds[chosenIndex] = sid;
|
SelectedIds[chosenIndex] = sid;
|
||||||
@@ -283,19 +255,15 @@ namespace eagle
|
|||||||
SetUpTables();
|
SetUpTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectedHeroClicked(int index)
|
public void selectedHeroClicked(int index) {
|
||||||
{
|
|
||||||
var heroId = SelectedIds[index].heroId;
|
var heroId = SelectedIds[index].heroId;
|
||||||
if (heroId.HasValue)
|
if (heroId.HasValue) {
|
||||||
{
|
|
||||||
AvailableHeroIds.Add(heroId.Value);
|
AvailableHeroIds.Add(heroId.Value);
|
||||||
|
|
||||||
if (SelectedIds[index].battalion != null)
|
if (SelectedIds[index].battalion != null) {
|
||||||
{
|
SelectedIds[index] =
|
||||||
SelectedIds[index] = new MaybeHeroAndBattalion { battalion = SelectedIds[index].battalion };
|
new MaybeHeroAndBattalion { battalion = SelectedIds[index].battalion };
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SelectedIds.RemoveAt(index);
|
SelectedIds.RemoveAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,19 +272,15 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectedBattalionClicked(int index)
|
public void selectedBattalionClicked(int index) {
|
||||||
{
|
|
||||||
var battalion = SelectedIds[index].battalion;
|
var battalion = SelectedIds[index].battalion;
|
||||||
if (battalion != null)
|
if (battalion != null) {
|
||||||
{
|
|
||||||
AvailableBattalions.Add(battalion);
|
AvailableBattalions.Add(battalion);
|
||||||
|
|
||||||
if (SelectedIds[index].heroId.HasValue)
|
if (SelectedIds[index].heroId.HasValue) {
|
||||||
{
|
SelectedIds[index] =
|
||||||
SelectedIds[index] = new MaybeHeroAndBattalion { heroId = SelectedIds[index].heroId };
|
new MaybeHeroAndBattalion { heroId = SelectedIds[index].heroId };
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SelectedIds.RemoveAt(index);
|
SelectedIds.RemoveAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,24 +289,29 @@ namespace eagle
|
|||||||
SetUpTables();
|
SetUpTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recommendedConfigClicked()
|
public void recommendedConfigClicked() {
|
||||||
{
|
SelectedIds.Select(sid => sid.heroId)
|
||||||
SelectedIds.Select(sid => sid.heroId).Where(hid => hid.HasValue).ToList().ForEach(hid => AvailableHeroIds.Add(hid.Value));
|
.Where(hid => hid.HasValue)
|
||||||
SelectedIds.Select(sid => sid.battalion).Where(bid => bid != null).ToList().ForEach(batt => AvailableBattalions.Add(batt));
|
.ToList()
|
||||||
|
.ForEach(hid => AvailableHeroIds.Add(hid.Value));
|
||||||
|
SelectedIds.Select(sid => sid.battalion)
|
||||||
|
.Where(bid => bid != null)
|
||||||
|
.ToList()
|
||||||
|
.ForEach(batt => AvailableBattalions.Add(batt));
|
||||||
SelectedIds.Clear();
|
SelectedIds.Clear();
|
||||||
|
|
||||||
foreach (var cu in RecommendedUnits)
|
foreach (var cu in RecommendedUnits) {
|
||||||
{
|
var recommendedBattalion =
|
||||||
var recommendedBattalion = cu.BattalionId.HasValue ? _orderedBattalions.First(batt => batt.Id == cu.BattalionId) : null;
|
cu.BattalionId.HasValue
|
||||||
SelectedIds.Add(new MaybeHeroAndBattalion
|
? _orderedBattalions.First(batt => batt.Id == cu.BattalionId)
|
||||||
{
|
: null;
|
||||||
|
SelectedIds.Add(new MaybeHeroAndBattalion {
|
||||||
heroId = cu.HeroId,
|
heroId = cu.HeroId,
|
||||||
battalion = recommendedBattalion
|
battalion = recommendedBattalion
|
||||||
});
|
});
|
||||||
AvailableHeroIds.Remove(cu.HeroId);
|
AvailableHeroIds.Remove(cu.HeroId);
|
||||||
|
|
||||||
if (recommendedBattalion != null)
|
if (recommendedBattalion != null) {
|
||||||
{
|
|
||||||
AvailableBattalions.Remove(recommendedBattalion);
|
AvailableBattalions.Remove(recommendedBattalion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,9 +322,6 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+28
-36
@@ -7,12 +7,10 @@ using System;
|
|||||||
using EagleGUIUtils;
|
using EagleGUIUtils;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
|
|
||||||
public class HeroDropdownController : MonoBehaviour
|
public class HeroDropdownController : MonoBehaviour {
|
||||||
{
|
|
||||||
private TMP_Dropdown Dropdown => gameObject.GetComponent<TMP_Dropdown>();
|
private TMP_Dropdown Dropdown => gameObject.GetComponent<TMP_Dropdown>();
|
||||||
public RawImage HeadshotImage;
|
public RawImage HeadshotImage;
|
||||||
public bool showCondition = true;
|
public bool showCondition = true;
|
||||||
@@ -22,24 +20,19 @@ namespace eagle
|
|||||||
public string ConditionName = "VIG";
|
public string ConditionName = "VIG";
|
||||||
|
|
||||||
private List<HeroView> _availableHeroes;
|
private List<HeroView> _availableHeroes;
|
||||||
public List<HeroView> AvailableHeroes
|
public List<HeroView> AvailableHeroes {
|
||||||
{
|
|
||||||
get => _availableHeroes;
|
get => _availableHeroes;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableHeroes = new List<HeroView>(value);
|
_availableHeroes = new List<HeroView>(value);
|
||||||
Dropdown.ClearOptions();
|
Dropdown.ClearOptions();
|
||||||
Dropdown.AddOptions(
|
Dropdown.AddOptions(_availableHeroes.Select(HeroOption).ToList());
|
||||||
_availableHeroes.Select(HeroOption).ToList());
|
|
||||||
SetHeadshot();
|
SetHeadshot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeroId SelectedHeroId
|
public HeroId SelectedHeroId {
|
||||||
{
|
|
||||||
get => AvailableHeroes[Dropdown.value].Id;
|
get => AvailableHeroes[Dropdown.value].Id;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
Dropdown.value = AvailableHeroes.FindIndex(h => h.Id == value);
|
Dropdown.value = AvailableHeroes.FindIndex(h => h.Id == value);
|
||||||
DropdownUpdated(Dropdown.value);
|
DropdownUpdated(Dropdown.value);
|
||||||
}
|
}
|
||||||
@@ -47,30 +40,23 @@ namespace eagle
|
|||||||
|
|
||||||
public Action SelectedHeroIdUpdated;
|
public Action SelectedHeroIdUpdated;
|
||||||
|
|
||||||
void Start()
|
void Start() { Dropdown.onValueChanged.AddListener(DropdownUpdated); }
|
||||||
{
|
|
||||||
Dropdown.onValueChanged.AddListener(DropdownUpdated);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetHeadshot()
|
private void SetHeadshot() {
|
||||||
{
|
|
||||||
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
var fetcher = GetComponentInParent<AWSResourceFetcher>();
|
||||||
if (fetcher != null)
|
if (fetcher != null) {
|
||||||
{
|
|
||||||
var imagePath = AvailableHeroes[Dropdown.value].ImagePath;
|
var imagePath = AvailableHeroes[Dropdown.value].ImagePath;
|
||||||
if (!string.IsNullOrEmpty(imagePath))
|
if (!string.IsNullOrEmpty(imagePath)) {
|
||||||
{
|
|
||||||
HeadshotImage.texture = fetcher.GetImage(imagePath);
|
HeadshotImage.texture = fetcher.GetImage(imagePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropdownUpdated(int newValue)
|
void DropdownUpdated(int newValue) {
|
||||||
{
|
|
||||||
var egc = gameObject.GetComponentInParent<EagleGameController>();
|
var egc = gameObject.GetComponentInParent<EagleGameController>();
|
||||||
if (egc != null)
|
if (egc != null) {
|
||||||
{
|
egc.GetComponentInChildren<HeroesAndBattalionsPanelController>()
|
||||||
egc.GetComponentInChildren<HeroesAndBattalionsPanelController>().UpdateHeroSelections();
|
.UpdateHeroSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHeadshot();
|
SetHeadshot();
|
||||||
@@ -78,17 +64,23 @@ namespace eagle
|
|||||||
if (SelectedHeroIdUpdated != null) SelectedHeroIdUpdated.Invoke();
|
if (SelectedHeroIdUpdated != null) SelectedHeroIdUpdated.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TMP_Dropdown.OptionData HeroOption(HeroView hv)
|
private TMP_Dropdown.OptionData HeroOption(HeroView hv) {
|
||||||
{
|
|
||||||
var texture = textures.Profession(hv.Profession);
|
var texture = textures.Profession(hv.Profession);
|
||||||
var text = showCondition ? $"{hv.Name} ({GUIUtils.ConditionString(ConditionAccessor(hv), ConditionName)})" : hv.Name;
|
var text =
|
||||||
return new TMP_Dropdown.OptionData
|
showCondition
|
||||||
{
|
? $"{hv.Name} ({GUIUtils.ConditionString(ConditionAccessor(hv), ConditionName)})"
|
||||||
image = texture == null ? null : Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)),
|
: hv.Name;
|
||||||
|
return new TMP_Dropdown.OptionData {
|
||||||
|
image = texture == null ? null
|
||||||
|
: Sprite.Create(
|
||||||
|
texture,
|
||||||
|
new Rect(0, 0, texture.width, texture.height),
|
||||||
|
new Vector2(0.5f, 0.5f)),
|
||||||
text = text
|
text = text
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private EagleCommonTextures textures => gameObject.GetComponentInParent<EagleCommonTextures>();
|
private EagleCommonTextures textures =>
|
||||||
|
gameObject.GetComponentInParent<EagleCommonTextures>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-16
@@ -1,29 +1,20 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class CommandWarningPanelController : PopupPanelController
|
public class CommandWarningPanelController : PopupPanelController {
|
||||||
{
|
public void SetWarning(string title, string text) {
|
||||||
public void SetWarning(string title, string text)
|
PopupInfos = new List<PopupInfo> { new PopupInfo {
|
||||||
{
|
|
||||||
PopupInfos = new List<PopupInfo>
|
|
||||||
{
|
|
||||||
new PopupInfo
|
|
||||||
{
|
|
||||||
titleText = title,
|
titleText = title,
|
||||||
mainText = text,
|
mainText = text,
|
||||||
affectedProvinceIds = new List<ProvinceId>()
|
affectedProvinceIds = new List<ProvinceId>()
|
||||||
}
|
} };
|
||||||
};
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearWarning()
|
public void ClearWarning() {
|
||||||
{
|
if (PopupInfos.Count > 0) {
|
||||||
if (PopupInfos.Count > 0)
|
|
||||||
{
|
|
||||||
PopupInfos.Clear();
|
PopupInfos.Clear();
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,85 +5,76 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using Net.Eagle0.Eagle.Api.Command.Util;
|
using Net.Eagle0.Eagle.Api.Command.Util;
|
||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class DisplayNames {
|
||||||
public class DisplayNames
|
public static readonly Dictionary<Profession, string> ProfessionNames =
|
||||||
{
|
new Dictionary<Profession, string> {
|
||||||
public static readonly Dictionary<Profession, string> ProfessionNames = new Dictionary<Profession, string>
|
{ Profession.NoProfession, "None" },
|
||||||
{
|
{ Profession.Engineer, "Engineer" },
|
||||||
{ Profession.NoProfession, "None" },
|
{ Profession.Mage, "Mage" },
|
||||||
{ Profession.Engineer, "Engineer" },
|
{ Profession.Necromancer, "Necromancer" },
|
||||||
{ Profession.Mage, "Mage" },
|
{ Profession.Paladin, "Paladin" },
|
||||||
{ Profession.Necromancer, "Necromancer" },
|
{ Profession.Ranger, "Ranger" },
|
||||||
{ Profession.Paladin, "Paladin" },
|
{ Profession.Champion, "Champion" }
|
||||||
{ Profession.Ranger, "Ranger" },
|
};
|
||||||
{ Profession.Champion, "Champion" }
|
|
||||||
};
|
|
||||||
|
|
||||||
public static readonly Dictionary<Profession, string> ShortProfessionNames = new Dictionary<Profession, string>
|
public static readonly Dictionary<Profession, string> ShortProfessionNames =
|
||||||
{
|
new Dictionary<Profession, string> {
|
||||||
{ Profession.NoProfession, "None" },
|
{ Profession.NoProfession, "None" },
|
||||||
{ Profession.Engineer, "Engr" },
|
{ Profession.Engineer, "Engr" },
|
||||||
{ Profession.Mage, "Mage" },
|
{ Profession.Mage, "Mage" },
|
||||||
{ Profession.Necromancer, "Necr" },
|
{ Profession.Necromancer, "Necr" },
|
||||||
{ Profession.Paladin, "Pldn" },
|
{ Profession.Paladin, "Pldn" },
|
||||||
{ Profession.Ranger, "Rngr" },
|
{ Profession.Ranger, "Rngr" },
|
||||||
{ Profession.Champion, "Chmp" }
|
{ Profession.Champion, "Chmp" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<BattalionTypeId, string> LongBattalionTypeNames = new Dictionary<BattalionTypeId, string>
|
public static readonly Dictionary<BattalionTypeId, string> LongBattalionTypeNames =
|
||||||
{
|
new Dictionary<BattalionTypeId, string> {
|
||||||
{ BattalionTypeId.LightInfantry, "Light Infantry" },
|
{ BattalionTypeId.LightInfantry, "Light Infantry" },
|
||||||
{ BattalionTypeId.HeavyInfantry, "Heavy Infantry" },
|
{ BattalionTypeId.HeavyInfantry, "Heavy Infantry" },
|
||||||
{ BattalionTypeId.LightCavalry, "Light Cavalry" },
|
{ BattalionTypeId.LightCavalry, "Light Cavalry" },
|
||||||
{ BattalionTypeId.HeavyCavalry, "Heavy Cavalry" },
|
{ BattalionTypeId.HeavyCavalry, "Heavy Cavalry" },
|
||||||
{ BattalionTypeId.Longbowmen, "Longbowmen" }
|
{ BattalionTypeId.Longbowmen, "Longbowmen" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<BattalionTypeId, string> ShortBattalionTypeNames = new Dictionary<BattalionTypeId, string>
|
public static readonly Dictionary<BattalionTypeId, string> ShortBattalionTypeNames =
|
||||||
{
|
new Dictionary<BattalionTypeId, string> {
|
||||||
{ BattalionTypeId.LightInfantry, "L Infantry" },
|
{ BattalionTypeId.LightInfantry, "L Infantry" },
|
||||||
{ BattalionTypeId.HeavyInfantry, "H Infantry" },
|
{ BattalionTypeId.HeavyInfantry, "H Infantry" },
|
||||||
{ BattalionTypeId.LightCavalry, "L Cavalry" },
|
{ BattalionTypeId.LightCavalry, "L Cavalry" },
|
||||||
{ BattalionTypeId.HeavyCavalry, "H Cavalry" },
|
{ BattalionTypeId.HeavyCavalry, "H Cavalry" },
|
||||||
{ BattalionTypeId.Longbowmen, "Longbowmen" }
|
{ BattalionTypeId.Longbowmen, "Longbowmen" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<ProvinceOrderType, string> ProvinceOrderTypeNames = new Dictionary<ProvinceOrderType, string>
|
public static readonly Dictionary<ProvinceOrderType, string> ProvinceOrderTypeNames =
|
||||||
{
|
new Dictionary<ProvinceOrderType, string> {
|
||||||
{ ProvinceOrderType.Develop, "Develop" },
|
{ ProvinceOrderType.Develop, "Develop" },
|
||||||
{ ProvinceOrderType.Expand, "Expand" },
|
{ ProvinceOrderType.Expand, "Expand" },
|
||||||
{ ProvinceOrderType.Mobilize, "Mobilize" },
|
{ ProvinceOrderType.Mobilize, "Mobilize" },
|
||||||
{ ProvinceOrderType.Entrust, "Entrust" }
|
{ ProvinceOrderType.Entrust, "Entrust" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<CapturedHeroOption, string> CapturedHeroOptionNames = new Dictionary<CapturedHeroOption, string>
|
public static readonly Dictionary<CapturedHeroOption, string> CapturedHeroOptionNames =
|
||||||
{
|
new Dictionary<CapturedHeroOption, string> {
|
||||||
{ CapturedHeroOption.RecruitCapturedHeroOption, "Recruit" },
|
{ CapturedHeroOption.RecruitCapturedHeroOption, "Recruit" },
|
||||||
{ CapturedHeroOption.ImprisonCapturedHeroOption, "Imprison" },
|
{ CapturedHeroOption.ImprisonCapturedHeroOption, "Imprison" },
|
||||||
{ CapturedHeroOption.ExileCapturedHeroOption, "Exile" },
|
{ CapturedHeroOption.ExileCapturedHeroOption, "Exile" },
|
||||||
{ CapturedHeroOption.ExecuteCapturedHeroOption, "Execute" },
|
{ CapturedHeroOption.ExecuteCapturedHeroOption, "Execute" },
|
||||||
{ CapturedHeroOption.ReturnCapturedHeroOption, "Return" }
|
{ CapturedHeroOption.ReturnCapturedHeroOption, "Return" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string PrisonerManagementTypeName(PrisonerManagementOption option)
|
public static string PrisonerManagementTypeName(PrisonerManagementOption option) {
|
||||||
{
|
switch (option.SealedValueCase) {
|
||||||
switch (option.SealedValueCase)
|
|
||||||
{
|
|
||||||
case PrisonerManagementOption.SealedValueOneofCase.Execute: return "Execute";
|
case PrisonerManagementOption.SealedValueOneofCase.Execute: return "Execute";
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string QuestStringFromName(string name, Quest quest, GameModel model)
|
public static string QuestStringFromName(string name, Quest quest, GameModel model) {
|
||||||
{
|
if (quest == null) { return $"There is nothing you can do for {name} right now."; }
|
||||||
if (quest == null)
|
|
||||||
{
|
|
||||||
return $"There is nothing you can do for {name} right now.";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (quest.DetailsCase)
|
switch (quest.DetailsCase) {
|
||||||
{
|
|
||||||
case Quest.DetailsOneofCase.DefeatFactionQuest:
|
case Quest.DetailsOneofCase.DefeatFactionQuest:
|
||||||
return $"{name} hates {model.FactionName(quest.DefeatFactionQuest.TargetFactionId)} and will be pleased if you defeat them in battle.";
|
return $"{name} hates {model.FactionName(quest.DefeatFactionQuest.TargetFactionId)} and will be pleased if you defeat them in battle.";
|
||||||
|
|
||||||
@@ -122,17 +113,10 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ShortQuestString(Quest quest, GameModel model) {
|
||||||
|
if (quest == null) { return $"There is nothing you can do"; }
|
||||||
|
|
||||||
|
switch (quest.DetailsCase) {
|
||||||
public static string ShortQuestString(Quest quest, GameModel model)
|
|
||||||
{
|
|
||||||
if (quest == null)
|
|
||||||
{
|
|
||||||
return $"There is nothing you can do";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (quest.DetailsCase)
|
|
||||||
{
|
|
||||||
case Quest.DetailsOneofCase.DefeatFactionQuest:
|
case Quest.DetailsOneofCase.DefeatFactionQuest:
|
||||||
return $"Defeat {model.FactionName(quest.DefeatFactionQuest.TargetFactionId)}";
|
return $"Defeat {model.FactionName(quest.DefeatFactionQuest.TargetFactionId)}";
|
||||||
|
|
||||||
@@ -166,25 +150,20 @@ namespace eagle
|
|||||||
case Quest.DetailsOneofCase.TreatyCountQuest:
|
case Quest.DetailsOneofCase.TreatyCountQuest:
|
||||||
return $"Have treaties with {quest.TreatyCountQuest.TreatyCount} factions";
|
return $"Have treaties with {quest.TreatyCountQuest.TreatyCount} factions";
|
||||||
|
|
||||||
default:
|
default: return $"Crosby hasn't gotten to it yet";
|
||||||
return $"Crosby hasn't gotten to it yet";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string QuestString(ExpandedUnaffiliatedHero euh, GameModel model)
|
public static string QuestString(ExpandedUnaffiliatedHero euh, GameModel model) {
|
||||||
{
|
|
||||||
return QuestStringFromName(euh.Hero.Name, euh.Quest, model);
|
return QuestStringFromName(euh.Hero.Name, euh.Quest, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string RecruitmentStatusString(string name, RecruitmentInfo recruitmentInfo)
|
public static string RecruitmentStatusString(string name, RecruitmentInfo recruitmentInfo) {
|
||||||
{
|
switch (recruitmentInfo.Status) {
|
||||||
switch (recruitmentInfo.Status)
|
|
||||||
{
|
|
||||||
case RecruitmentStatus.LowPrestige:
|
case RecruitmentStatus.LowPrestige:
|
||||||
return $"You need more prestige before you can seek {name}'s favor.";
|
return $"You need more prestige before you can seek {name}'s favor.";
|
||||||
|
|
||||||
case RecruitmentStatus.WouldJoin:
|
case RecruitmentStatus.WouldJoin: return $"{name} would already gladly join you.";
|
||||||
return $"{name} would already gladly join you.";
|
|
||||||
|
|
||||||
case RecruitmentStatus.NotDivined:
|
case RecruitmentStatus.NotDivined:
|
||||||
return $"You need to divine to learn {name}'s wishes.";
|
return $"You need to divine to learn {name}'s wishes.";
|
||||||
@@ -201,140 +180,96 @@ namespace eagle
|
|||||||
case RecruitmentStatus.Traveler:
|
case RecruitmentStatus.Traveler:
|
||||||
return $"{name} is unlikely to stay here long enough to impress with a quest.";
|
return $"{name} is unlikely to stay here long enough to impress with a quest.";
|
||||||
|
|
||||||
case RecruitmentStatus.Sworn:
|
case RecruitmentStatus.Sworn: return $"{name} is dedicated to another faction.";
|
||||||
return $"{name} is dedicated to another faction.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"Unknown!";
|
return $"Unknown!";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ShortRecruitmentStatusString(RecruitmentInfo recruitmentInfo)
|
public static string ShortRecruitmentStatusString(RecruitmentInfo recruitmentInfo) {
|
||||||
{
|
switch (recruitmentInfo.Status) {
|
||||||
switch (recruitmentInfo.Status)
|
case RecruitmentStatus.LowPrestige: return $"Not enough prestige";
|
||||||
{
|
|
||||||
case RecruitmentStatus.LowPrestige:
|
|
||||||
return $"Not enough prestige";
|
|
||||||
|
|
||||||
case RecruitmentStatus.WouldJoin:
|
case RecruitmentStatus.WouldJoin: return $"Ready to join";
|
||||||
return $"Ready to join";
|
|
||||||
|
|
||||||
case RecruitmentStatus.NotDivined:
|
case RecruitmentStatus.NotDivined: return $"Not divined";
|
||||||
return $"Not divined";
|
|
||||||
|
|
||||||
case RecruitmentStatus.Outlaw:
|
case RecruitmentStatus.Outlaw: return $"Outlaw";
|
||||||
return $"Outlaw";
|
|
||||||
|
|
||||||
case RecruitmentStatus.Exile:
|
case RecruitmentStatus.Exile: return $"Exile";
|
||||||
return $"Exile";
|
|
||||||
|
|
||||||
case RecruitmentStatus.Prisoner:
|
case RecruitmentStatus.Prisoner: return $"Prisoner";
|
||||||
return $"Prisoner";
|
|
||||||
|
|
||||||
case RecruitmentStatus.Traveler:
|
case RecruitmentStatus.Traveler: return $"Traveler";
|
||||||
return $"Traveler";
|
|
||||||
|
|
||||||
case RecruitmentStatus.Sworn:
|
case RecruitmentStatus.Sworn: return $"Dedicated to another faction";
|
||||||
return $"Dedicated to another faction";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"Unknown!";
|
return $"Unknown!";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string QuestTypeString(Quest quest)
|
public static string QuestTypeString(Quest quest) {
|
||||||
{
|
switch (quest.DetailsCase) {
|
||||||
switch (quest.DetailsCase)
|
case Quest.DetailsOneofCase.DefeatFactionQuest: return "Attack Faction";
|
||||||
{
|
case Quest.DetailsOneofCase.DismissSpecificVassalQuest: return "Dismiss Vassal";
|
||||||
case Quest.DetailsOneofCase.DefeatFactionQuest:
|
case Quest.DetailsOneofCase.ImproveAgricultureQuest: return "Improve Agriculture";
|
||||||
return "Attack Faction";
|
case Quest.DetailsOneofCase.ImproveEconomyQuest: return "Improve Economy";
|
||||||
case Quest.DetailsOneofCase.DismissSpecificVassalQuest:
|
|
||||||
return "Dismiss Vassal";
|
|
||||||
case Quest.DetailsOneofCase.ImproveAgricultureQuest:
|
|
||||||
return "Improve Agriculture";
|
|
||||||
case Quest.DetailsOneofCase.ImproveEconomyQuest:
|
|
||||||
return "Improve Economy";
|
|
||||||
case Quest.DetailsOneofCase.ImproveInfrastructureQuest:
|
case Quest.DetailsOneofCase.ImproveInfrastructureQuest:
|
||||||
return "Improve Infrastructure";
|
return "Improve Infrastructure";
|
||||||
case Quest.DetailsOneofCase.UpgradeBattalionQuest:
|
case Quest.DetailsOneofCase.UpgradeBattalionQuest: return "Great Battalion";
|
||||||
return "Great Battalion";
|
case Quest.DetailsOneofCase.GrandArmyQuest: return "Grand Army";
|
||||||
case Quest.DetailsOneofCase.GrandArmyQuest:
|
case Quest.DetailsOneofCase.SpecificExpansionQuest: return "Expand to Province";
|
||||||
return "Grand Army";
|
case Quest.DetailsOneofCase.WealthQuest: return "Accumulate Wealth";
|
||||||
case Quest.DetailsOneofCase.SpecificExpansionQuest:
|
case Quest.DetailsOneofCase.TreatyWithFactionQuest: return "Treaty with Faction";
|
||||||
return "Expand to Province";
|
case Quest.DetailsOneofCase.TreatyCountQuest: return "Treaty Count";
|
||||||
case Quest.DetailsOneofCase.WealthQuest:
|
|
||||||
return "Accumulate Wealth";
|
|
||||||
case Quest.DetailsOneofCase.TreatyWithFactionQuest:
|
|
||||||
return "Treaty with Faction";
|
|
||||||
case Quest.DetailsOneofCase.TreatyCountQuest:
|
|
||||||
return "Treaty Count";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentException($"unknown quest {quest}");
|
throw new ArgumentException($"unknown quest {quest}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MonthString(int month)
|
public static string MonthString(int month) {
|
||||||
{
|
|
||||||
return new DateTime(777, month, 1).ToString("MMMM", CultureInfo.InvariantCulture);
|
return new DateTime(777, month, 1).ToString("MMMM", CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MonthString(Date date)
|
public static string MonthString(Date date) {
|
||||||
{
|
return new DateTime(date.Year, date.Month, 1)
|
||||||
return new DateTime(date.Year, date.Month, 1).ToString("MMMM", CultureInfo.InvariantCulture);
|
.ToString("MMMM", CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DateString(Date date)
|
public static string DateString(Date date) { return $"{MonthString(date)} {date.Year}"; }
|
||||||
{
|
|
||||||
return $"{MonthString(date)} {date.Year}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string UnaffiliatedHeroStatus(UnaffiliatedHero.Types.Type status)
|
public static string UnaffiliatedHeroStatus(UnaffiliatedHero.Types.Type status) {
|
||||||
{
|
switch (status) {
|
||||||
switch (status)
|
case UnaffiliatedHero.Types.Type.Prisoner: return "Prisoner";
|
||||||
{
|
|
||||||
|
|
||||||
case UnaffiliatedHero.Types.Type.Prisoner:
|
case UnaffiliatedHero.Types.Type.Traveler: return "Traveler";
|
||||||
return "Prisoner";
|
|
||||||
|
|
||||||
case UnaffiliatedHero.Types.Type.Traveler:
|
case UnaffiliatedHero.Types.Type.Resident: return "Resident";
|
||||||
return "Traveler";
|
|
||||||
|
|
||||||
case UnaffiliatedHero.Types.Type.Resident:
|
case UnaffiliatedHero.Types.Type.Outlaw: return "Outlaw";
|
||||||
return "Resident";
|
|
||||||
|
|
||||||
case UnaffiliatedHero.Types.Type.Outlaw:
|
|
||||||
return "Outlaw";
|
|
||||||
|
|
||||||
case UnaffiliatedHero.Types.Type.Unknown:
|
case UnaffiliatedHero.Types.Type.Unknown:
|
||||||
default:
|
default: throw new ArgumentOutOfRangeException("Unknown free hero status");
|
||||||
throw new ArgumentOutOfRangeException("Unknown free hero status");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ControlWeatherTypeName(ControlWeatherType type)
|
public static string ControlWeatherTypeName(ControlWeatherType type) {
|
||||||
{
|
switch (type) {
|
||||||
switch (type)
|
case ControlWeatherType.ControlWeatherStartBlizzard: return "Start Blizzard";
|
||||||
{
|
|
||||||
case ControlWeatherType.ControlWeatherStartBlizzard:
|
|
||||||
return "Start Blizzard";
|
|
||||||
|
|
||||||
case ControlWeatherType.ControlWeatherEndBlizzard:
|
case ControlWeatherType.ControlWeatherEndBlizzard: return "End Blizzard";
|
||||||
return "End Blizzard";
|
|
||||||
|
|
||||||
case ControlWeatherType.ControlWeatherStartDrought:
|
case ControlWeatherType.ControlWeatherStartDrought: return "Start Drought";
|
||||||
return "Start Drought";
|
|
||||||
|
|
||||||
case ControlWeatherType.ControlWeatherEndDrought:
|
case ControlWeatherType.ControlWeatherEndDrought: return "End Drought";
|
||||||
return "End Drought";
|
|
||||||
|
|
||||||
case ControlWeatherType.ControlWeatherUnknown:
|
case ControlWeatherType.ControlWeatherUnknown:
|
||||||
default:
|
default: throw new ArgumentOutOfRangeException("Unknown control weather type");
|
||||||
throw new ArgumentOutOfRangeException("Unknown control weather type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BeastTypeName(BeastType beastType)
|
public static string BeastTypeName(BeastType beastType) {
|
||||||
{
|
return beastType switch {
|
||||||
return beastType switch
|
|
||||||
{
|
|
||||||
BeastType.Brigands => "brigands",
|
BeastType.Brigands => "brigands",
|
||||||
BeastType.Wolves => "wolves",
|
BeastType.Wolves => "wolves",
|
||||||
BeastType.Tigers => "tigers",
|
BeastType.Tigers => "tigers",
|
||||||
@@ -363,30 +298,22 @@ namespace eagle
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Capitalized(string str)
|
public static string Capitalized(string str) {
|
||||||
{
|
|
||||||
if (String.IsNullOrEmpty(str)) return str;
|
if (String.IsNullOrEmpty(str)) return str;
|
||||||
else if (str.Length == 1) return str.ToUpper();
|
else if (str.Length == 1)
|
||||||
else return char.ToUpper(str[0]) + str.Substring(1);
|
return str.ToUpper();
|
||||||
|
else
|
||||||
|
return char.ToUpper(str[0]) + str.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ListString(IList<String> strings)
|
public static string ListString(IList<String> strings) {
|
||||||
{
|
if (strings.Count == 1) {
|
||||||
if (strings.Count == 1)
|
|
||||||
{
|
|
||||||
return strings[0];
|
return strings[0];
|
||||||
}
|
} else if (strings.Count == 2) {
|
||||||
else if (strings.Count == 2)
|
|
||||||
{
|
|
||||||
return $"{strings[0]} and {strings[1]}";
|
return $"{strings[0]} and {strings[1]}";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
string str = "";
|
string str = "";
|
||||||
for (int i = 0; i < strings.Count - 1; i++)
|
for (int i = 0; i < strings.Count - 1; i++) { str += strings[i] + ", "; }
|
||||||
{
|
|
||||||
str += strings[i] + ", ";
|
|
||||||
}
|
|
||||||
str += "and " + strings[strings.Count - 1];
|
str += "and " + strings[strings.Count - 1];
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
|||||||
+45
-80
@@ -8,12 +8,10 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class DominionPanelController : MonoBehaviour
|
public class DominionPanelController : MonoBehaviour {
|
||||||
{
|
|
||||||
public TMP_Text label;
|
public TMP_Text label;
|
||||||
public EventBasedTable table;
|
public EventBasedTable table;
|
||||||
|
|
||||||
@@ -21,8 +19,7 @@ namespace eagle
|
|||||||
public MapController mapController;
|
public MapController mapController;
|
||||||
public Toggle onToggle;
|
public Toggle onToggle;
|
||||||
|
|
||||||
enum SortKey
|
enum SortKey {
|
||||||
{
|
|
||||||
None = 0,
|
None = 0,
|
||||||
Support = 1,
|
Support = 1,
|
||||||
Commanders = 2,
|
Commanders = 2,
|
||||||
@@ -37,91 +34,74 @@ namespace eagle
|
|||||||
Castles = 11,
|
Castles = 11,
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<SortKey, Func<ProvinceView, int>> sortFuncs = new Dictionary<SortKey, Func<ProvinceView, int>>
|
Dictionary<SortKey, Func<ProvinceView, int>> sortFuncs =
|
||||||
{
|
new Dictionary<SortKey, Func<ProvinceView, int>> {
|
||||||
{ SortKey.Support, p => p.FullInfo.Support.Stat },
|
{ SortKey.Support, p => p.FullInfo.Support.Stat },
|
||||||
{ SortKey.Commanders, p => p.FullInfo.RulingFactionHeroIds.Count },
|
{ SortKey.Commanders, p => p.FullInfo.RulingFactionHeroIds.Count },
|
||||||
{ SortKey.Battalions, p => p.FullInfo.Battalions.Count },
|
{ SortKey.Battalions, p => p.FullInfo.Battalions.Count },
|
||||||
{ SortKey.Troops, p => p.FullInfo.Battalions.Sum(b => b.Size) },
|
{ SortKey.Troops, p => p.FullInfo.Battalions.Sum(b => b.Size) },
|
||||||
{ SortKey.Economy, p => p.FullInfo.Economy },
|
{ SortKey.Economy, p => p.FullInfo.Economy },
|
||||||
{ SortKey.Agriculture, p => p.FullInfo.Agriculture },
|
{ SortKey.Agriculture, p => p.FullInfo.Agriculture },
|
||||||
{ SortKey.Infrastructure, p => p.FullInfo.Infrastructure },
|
{ SortKey.Infrastructure, p => p.FullInfo.Infrastructure },
|
||||||
{ SortKey.Gold, p => p.FullInfo.Gold },
|
{ SortKey.Gold, p => p.FullInfo.Gold },
|
||||||
{ SortKey.Food, p => p.FullInfo.Food },
|
{ SortKey.Food, p => p.FullInfo.Food },
|
||||||
{ SortKey.FreeHeroes, p => p.FullInfo.UnaffiliatedHeroes.Count },
|
{ SortKey.FreeHeroes, p => p.FullInfo.UnaffiliatedHeroes.Count },
|
||||||
{ SortKey.Castles, p => p.FullInfo.CastleCount },
|
{ SortKey.Castles, p => p.FullInfo.CastleCount },
|
||||||
};
|
};
|
||||||
|
|
||||||
private SortKey currentSortKey = SortKey.None;
|
private SortKey currentSortKey = SortKey.None;
|
||||||
private bool ascending = false;
|
private bool ascending = false;
|
||||||
|
|
||||||
private GameModel _model;
|
private GameModel _model;
|
||||||
public GameModel Model
|
public GameModel Model {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_model = value;
|
_model = value;
|
||||||
SetUpTable();
|
SetUpTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForceUpdate()
|
public void ForceUpdate() { SetUpTable(); }
|
||||||
{
|
|
||||||
SetUpTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ProvinceView> SortedProvinces()
|
private List<ProvinceView> SortedProvinces() {
|
||||||
{
|
|
||||||
var unsorted = _model.Provinces.Values.Where(p => p.RulingFactionId == _model.PlayerId);
|
var unsorted = _model.Provinces.Values.Where(p => p.RulingFactionId == _model.PlayerId);
|
||||||
|
|
||||||
if (currentSortKey == SortKey.None)
|
if (currentSortKey == SortKey.None) { return unsorted.OrderBy(p => p.Name).ToList(); }
|
||||||
{
|
|
||||||
return unsorted.OrderBy(p => p.Name).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
var sortFunc = sortFuncs[currentSortKey];
|
var sortFunc = sortFuncs[currentSortKey];
|
||||||
|
|
||||||
if (ascending)
|
if (ascending) {
|
||||||
{
|
|
||||||
return unsorted.OrderBy(sortFunc).ToList();
|
return unsorted.OrderBy(sortFunc).ToList();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return unsorted.OrderByDescending(sortFunc).ToList();
|
return unsorted.OrderByDescending(sortFunc).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUpTable()
|
void SetUpTable() {
|
||||||
{
|
|
||||||
var provinces = SortedProvinces();
|
var provinces = SortedProvinces();
|
||||||
|
|
||||||
table.RowCount = provinces.Count;
|
table.RowCount = provinces.Count;
|
||||||
|
|
||||||
for (int i = 0; i < provinces.Count; i++)
|
for (int i = 0; i < provinces.Count; i++) {
|
||||||
{
|
|
||||||
var province = provinces[i];
|
var province = provinces[i];
|
||||||
var hasCommands = _model.AvailableCommandsForProvince(province.Id).Any();
|
var hasCommands = _model.AvailableCommandsForProvince(province.Id).Any();
|
||||||
table.ComponentAt<DominionTableRowController>(i).Set(province.Id, _model, mapController.SelectedProvinceId == province.Id, hasCommands);
|
table.ComponentAt<DominionTableRowController>(i).Set(
|
||||||
|
province.Id,
|
||||||
|
_model,
|
||||||
|
mapController.SelectedProvinceId == province.Id,
|
||||||
|
hasCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sort(int key)
|
public void Sort(int key) {
|
||||||
{
|
|
||||||
SortKey newKey = (SortKey)key;
|
SortKey newKey = (SortKey)key;
|
||||||
|
|
||||||
if (newKey == currentSortKey)
|
if (newKey == currentSortKey) {
|
||||||
{
|
if (!ascending) {
|
||||||
if (!ascending)
|
|
||||||
{
|
|
||||||
ascending = true;
|
ascending = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSortKey = SortKey.None;
|
currentSortKey = SortKey.None;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSortKey = newKey;
|
currentSortKey = newKey;
|
||||||
ascending = false;
|
ascending = false;
|
||||||
}
|
}
|
||||||
@@ -130,46 +110,31 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
currentSortKey = SortKey.None;
|
currentSortKey = SortKey.None;
|
||||||
ascending = true;
|
ascending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void ProvinceHovered(ProvinceId? pid) {
|
||||||
|
for (int i = 0; i < table.RowCount; i++) {
|
||||||
public void ProvinceHovered(ProvinceId? pid)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < table.RowCount; i++)
|
|
||||||
{
|
|
||||||
table.ComponentAt<DominionTableRowController>(i).ShadeOff();
|
table.ComponentAt<DominionTableRowController>(i).ShadeOff();
|
||||||
}
|
}
|
||||||
if (pid is ProvinceId provinceId)
|
if (pid is ProvinceId provinceId) {
|
||||||
{
|
|
||||||
var index = SortedProvinces().FindIndex(p => p.Id == provinceId);
|
var index = SortedProvinces().FindIndex(p => p.Id == provinceId);
|
||||||
if (index != -1)
|
if (index != -1) { table.ComponentAt<DominionTableRowController>(index).ShadeOn(); }
|
||||||
{
|
|
||||||
table.ComponentAt<DominionTableRowController>(index).ShadeOn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RowClicked(int provinceId)
|
public void RowClicked(int provinceId) { mapController.SelectedProvinceId = provinceId; }
|
||||||
{
|
|
||||||
mapController.SelectedProvinceId = provinceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RowHovered(int provinceId)
|
public void RowHovered(int provinceId) {
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId> { provinceId };
|
mapController.OverrideTargetedProvinces = new List<ProvinceId> { provinceId };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RowUnhovered()
|
public void RowUnhovered() {
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-11
@@ -4,28 +4,33 @@ using System.Threading.Tasks;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using Net.Eagle0.Shardok.Common;
|
using Net.Eagle0.Shardok.Common;
|
||||||
|
|
||||||
namespace eagle0
|
namespace eagle0 {
|
||||||
{
|
|
||||||
using PlayerId = Int32;
|
using PlayerId = Int32;
|
||||||
using GameId = Int64;
|
using GameId = Int64;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using static Net.Eagle0.Eagle.Api.ShardokPlacementCommands.Types;
|
using static Net.Eagle0.Eagle.Api.ShardokPlacementCommands.Types;
|
||||||
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
||||||
|
|
||||||
public interface EagleClientInterface
|
public interface EagleClientInterface {
|
||||||
{
|
|
||||||
PlayerId? PlayerId { get; }
|
PlayerId? PlayerId { get; }
|
||||||
GameId GameId { get; }
|
GameId GameId { get; }
|
||||||
|
|
||||||
Task<Boolean> RegisterForUpdates(
|
Task<Boolean> RegisterForUpdates(
|
||||||
Action<UpdateStreamResponse, Grpc.Core.StatusCode> repeatedCallback,
|
Action<UpdateStreamResponse, Grpc.Core.StatusCode> repeatedCallback,
|
||||||
int knownHistoryCount,
|
int knownHistoryCount,
|
||||||
List<ShardokViewStatus> shardokViewStatuses); // calls back with null if interrupted
|
List<ShardokViewStatus>
|
||||||
|
shardokViewStatuses); // calls back with null if interrupted
|
||||||
void UnregisterForUpdates();
|
void UnregisterForUpdates();
|
||||||
Task<PostCommandResponse> PostCommand(long token, ProvinceId provinceId, SelectedCommand command);
|
Task<PostCommandResponse>
|
||||||
Task<PostCommandResponse> PostShardokCommand(string gameId, Int32 playerId, Int64 token, Int32 index);
|
PostCommand(long token, ProvinceId provinceId, SelectedCommand command);
|
||||||
Task<PostCommandResponse> PostShardokPlacementCommands(string gameId, Int32 playerId, List<ShardokPlacementCommand> placementCommands, Int64 token);
|
Task<PostCommandResponse>
|
||||||
|
PostShardokCommand(string gameId, Int32 playerId, Int64 token, Int32 index);
|
||||||
|
Task<PostCommandResponse> PostShardokPlacementCommands(
|
||||||
|
string gameId,
|
||||||
|
Int32 playerId,
|
||||||
|
List<ShardokPlacementCommand> placementCommands,
|
||||||
|
Int64 token);
|
||||||
Task<HexMap> GetHexMapAsync(string mapName);
|
Task<HexMap> GetHexMapAsync(string mapName);
|
||||||
HexMap GetHexMap(string mapName); // FIXME: get rid of synchronous version
|
HexMap GetHexMap(string mapName); // FIXME: get rid of synchronous version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-19
@@ -3,8 +3,7 @@ using System.Linq;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class EagleCommonTextures : MonoBehaviour
|
public class EagleCommonTextures : MonoBehaviour {
|
||||||
{
|
|
||||||
public List<Texture2D> battalionTextures;
|
public List<Texture2D> battalionTextures;
|
||||||
public List<Texture2D> professionTextures;
|
public List<Texture2D> professionTextures;
|
||||||
public Texture2D training;
|
public Texture2D training;
|
||||||
@@ -12,31 +11,27 @@ public class EagleCommonTextures : MonoBehaviour
|
|||||||
|
|
||||||
public Texture2D noProfessionTexture;
|
public Texture2D noProfessionTexture;
|
||||||
|
|
||||||
public Texture2D BattalionType(BattalionTypeId type)
|
public Texture2D BattalionType(BattalionTypeId type) { return battalionTextures[(int)type]; }
|
||||||
{
|
|
||||||
|
public Texture2D BattalionType(
|
||||||
|
Net.Eagle0.Shardok.Api.BattalionView.Types.BattalionTypeId type) {
|
||||||
return battalionTextures[(int)type];
|
return battalionTextures[(int)type];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture2D BattalionType(Net.Eagle0.Shardok.Api.BattalionView.Types.BattalionTypeId type)
|
public Texture2D Profession(Profession profession) {
|
||||||
{
|
if (profession == Net.Eagle0.Eagle.Common.Profession.NoProfession)
|
||||||
return battalionTextures[(int)type];
|
return professionTextures.Last();
|
||||||
}
|
|
||||||
|
|
||||||
public Texture2D Profession(Profession profession)
|
|
||||||
{
|
|
||||||
if (profession == Net.Eagle0.Eagle.Common.Profession.NoProfession) return professionTextures.Last();
|
|
||||||
return professionTextures[(int)profession];
|
return professionTextures[(int)profession];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture2D Profession(Net.Eagle0.Shardok.Api.HeroView.Types.ProfessionSpecificInfo.Types.Profession profession)
|
public Texture2D Profession(Net.Eagle0.Shardok.Api.HeroView.Types.ProfessionSpecificInfo.Types
|
||||||
{
|
.Profession profession) {
|
||||||
if (profession == Net.Eagle0.Shardok.Api.HeroView.Types.ProfessionSpecificInfo.Types.Profession.NoProfession) return professionTextures.Last();
|
if (profession == Net.Eagle0.Shardok.Api.HeroView.Types.ProfessionSpecificInfo.Types
|
||||||
|
.Profession.NoProfession)
|
||||||
|
return professionTextures.Last();
|
||||||
return professionTextures[(int)profession];
|
return professionTextures[(int)profession];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+146
-223
@@ -11,16 +11,14 @@ using eagle0;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using GameId = Int64;
|
using GameId = Int64;
|
||||||
using FactionId = Int32;
|
using FactionId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using CommandType = AvailableCommand.SealedValueOneofCase;
|
using CommandType = AvailableCommand.SealedValueOneofCase;
|
||||||
|
|
||||||
public class EagleGameController : MonoBehaviour
|
public class EagleGameController : MonoBehaviour {
|
||||||
{
|
|
||||||
public Camera mainCamera;
|
public Camera mainCamera;
|
||||||
public TextMeshProUGUI roundStatusLabel;
|
public TextMeshProUGUI roundStatusLabel;
|
||||||
|
|
||||||
@@ -66,22 +64,20 @@ namespace eagle
|
|||||||
public Canvas ShardokCanvas;
|
public Canvas ShardokCanvas;
|
||||||
|
|
||||||
private KeyValuePair<ProvinceId, OneProvinceAvailableCommands> NextActiveProvinceKeyPair =>
|
private KeyValuePair<ProvinceId, OneProvinceAvailableCommands> NextActiveProvinceKeyPair =>
|
||||||
Model.AvailableCommandsByProvince.First(kvp => kvp.Key == Model.SuggestedProvinceId);
|
Model.AvailableCommandsByProvince.First(
|
||||||
|
kvp => kvp.Key == Model.SuggestedProvinceId);
|
||||||
|
|
||||||
struct GameInfo
|
struct GameInfo {
|
||||||
{
|
|
||||||
public FactionId playerId { get; }
|
public FactionId playerId { get; }
|
||||||
public GameId gameId { get; }
|
public GameId gameId { get; }
|
||||||
|
|
||||||
public GameInfo(FactionId playerId, GameId gameId)
|
public GameInfo(FactionId playerId, GameId gameId) {
|
||||||
{
|
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
gameIdButton.GetComponentInChildren<Text>().text = "";
|
gameIdButton.GetComponentInChildren<Text>().text = "";
|
||||||
mapController.TargetedProvincesChangedCallback = MapControllerChangedTarget;
|
mapController.TargetedProvincesChangedCallback = MapControllerChangedTarget;
|
||||||
mapController.HoveredProvinceChangedCallback = MapControllerChangedHover;
|
mapController.HoveredProvinceChangedCallback = MapControllerChangedHover;
|
||||||
@@ -90,103 +86,78 @@ namespace eagle
|
|||||||
dominionPanelController.gameObject.SetActive(false);
|
dominionPanelController.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapControllerChangedTarget(List<ProvinceId> newTarget)
|
void MapControllerChangedTarget(List<ProvinceId> newTarget) {
|
||||||
{
|
if (commandPanelController.Selector != null) {
|
||||||
if (commandPanelController.Selector != null)
|
|
||||||
{
|
|
||||||
commandPanelController.Selector.TargetedProvinces = newTarget;
|
commandPanelController.Selector.TargetedProvinces = newTarget;
|
||||||
focusInfoPanelController.UpdateTables();
|
focusInfoPanelController.UpdateTables();
|
||||||
heroesAndBattalionsPanelController.UpdateTables();
|
heroesAndBattalionsPanelController.UpdateTables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapControllerChangedHover(ProvinceId? newHover)
|
void MapControllerChangedHover(ProvinceId? newHover) {
|
||||||
{
|
|
||||||
dominionPanelController.ProvinceHovered(newHover);
|
dominionPanelController.ProvinceHovered(newHover);
|
||||||
focusInfoPanelController.ProvinceHovered(newHover);
|
focusInfoPanelController.ProvinceHovered(newHover);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
if (newModel != null) { SwapModel(); }
|
||||||
if (newModel != null)
|
|
||||||
{
|
|
||||||
SwapModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Model != null)
|
if (Model != null) {
|
||||||
{
|
if (commandPanelController.Selector == null) {
|
||||||
if (commandPanelController.Selector == null)
|
if (Model.AvailableCommandsByProvince.Count > 0 &&
|
||||||
{
|
Model.AvailableCommandsByProvince.ContainsKey(0)) {
|
||||||
if (Model.AvailableCommandsByProvince.Count > 0 && Model.AvailableCommandsByProvince.ContainsKey(0))
|
|
||||||
{
|
|
||||||
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
||||||
}
|
} else {
|
||||||
else
|
mapController.ProvincesWithCommands =
|
||||||
{
|
Model.AvailableCommandsByProvince.Keys.ToList();
|
||||||
mapController.ProvincesWithCommands = Model.AvailableCommandsByProvince.Keys.ToList();
|
|
||||||
}
|
}
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
}
|
} else {
|
||||||
else
|
mapController.TargetedProvinces =
|
||||||
{
|
commandPanelController.Selector.TargetedProvinces;
|
||||||
mapController.TargetedProvinces = commandPanelController.Selector.TargetedProvinces;
|
|
||||||
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetButtonUp("Cancel"))
|
if (Input.GetButtonUp("Cancel")) {
|
||||||
{
|
|
||||||
HandleQuit();
|
HandleQuit();
|
||||||
}
|
} else if (Input.GetButtonUp("Windowed Mode")) {
|
||||||
else if (Input.GetButtonUp("Windowed Mode"))
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// do nothing
|
// do nothing
|
||||||
#else
|
#else
|
||||||
Screen.fullScreen = !Screen.fullScreen;
|
Screen.fullScreen = !Screen.fullScreen;
|
||||||
#endif
|
#endif
|
||||||
}
|
} else if (Input.GetButtonUp("Toggle Dominion Table")) {
|
||||||
else if (Input.GetButtonUp("Toggle Dominion Table"))
|
|
||||||
{
|
|
||||||
dominionViewToggle.isOn = !dominionViewToggle.isOn;
|
dominionViewToggle.isOn = !dominionViewToggle.isOn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationPause(bool pause)
|
void OnApplicationPause(bool pause) {
|
||||||
{
|
|
||||||
#if !UNITY_EDITOR
|
#if !UNITY_EDITOR
|
||||||
if (ModelUpdater == null)
|
if (ModelUpdater == null) { return; }
|
||||||
{
|
if (pause) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pause)
|
|
||||||
{
|
|
||||||
ModelUpdater.StopListeningForUpdates();
|
ModelUpdater.StopListeningForUpdates();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ModelUpdater.StartListeningForUpdates();
|
ModelUpdater.StartListeningForUpdates();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationQuit()
|
void OnApplicationQuit() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnApplicationFocus(bool focus)
|
void OnApplicationFocus(bool focus) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
void OnPlayModeStateChanged(PlayModeStateChange state)
|
void OnPlayModeStateChanged(PlayModeStateChange state) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public void SetUpGame(long gameId, int? playerId, EagleConnection eagleConnection)
|
public void SetUpGame(long gameId, int? playerId, EagleConnection eagleConnection) {
|
||||||
{
|
var oneGameClient = new RemoteEagleClient(
|
||||||
var oneGameClient = new RemoteEagleClient(gameId, eagleConnection.EagleGrpcClient, eagleConnection.Credentials, playerId, EagleConnection.EagleCancellationToken);
|
gameId,
|
||||||
|
eagleConnection.EagleGrpcClient,
|
||||||
|
eagleConnection.Credentials,
|
||||||
|
playerId,
|
||||||
|
EagleConnection.EagleCancellationToken);
|
||||||
ModelUpdater = new GameModelUpdater(oneGameClient, eagleConnection.PlayerName);
|
ModelUpdater = new GameModelUpdater(oneGameClient, eagleConnection.PlayerName);
|
||||||
|
|
||||||
EagleConnection = eagleConnection;
|
EagleConnection = eagleConnection;
|
||||||
@@ -194,7 +165,8 @@ namespace eagle
|
|||||||
|
|
||||||
ModelUpdater.UpdateAction = ModelUpdated;
|
ModelUpdater.UpdateAction = ModelUpdated;
|
||||||
|
|
||||||
ModelUpdater.NoteRecipient = (title, text, pids, image1, image2) => notificationPanel.AddNote(title, text, pids, image1, image2);
|
ModelUpdater.NoteRecipient = (title, text, pids, image1, image2) =>
|
||||||
|
notificationPanel.AddNote(title, text, pids, image1, image2);
|
||||||
ModelUpdater.FetchHeadshot = (imagePath) => awsResourceFetcher.GetImage(imagePath);
|
ModelUpdater.FetchHeadshot = (imagePath) => awsResourceFetcher.GetImage(imagePath);
|
||||||
|
|
||||||
commitCommandButton.gameObject.SetActive(false);
|
commitCommandButton.gameObject.SetActive(false);
|
||||||
@@ -209,44 +181,38 @@ namespace eagle
|
|||||||
|
|
||||||
ModelUpdater.errorPanel = errorPanel;
|
ModelUpdater.errorPanel = errorPanel;
|
||||||
|
|
||||||
MainQueue.Q.EnqueueForNextUpdate(() =>
|
MainQueue.Q.EnqueueForNextUpdate(() => { ModelUpdater.StartListeningForUpdates(); });
|
||||||
{
|
|
||||||
ModelUpdater.StartListeningForUpdates();
|
|
||||||
});
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
EditorApplication.playModeStateChanged += (state) => OnPlayModeStateChanged(state);
|
EditorApplication.playModeStateChanged += (state) => OnPlayModeStateChanged(state);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectRecommendedCommand(ProvinceId provinceId)
|
private void SelectRecommendedCommand(ProvinceId provinceId) {
|
||||||
{
|
|
||||||
OneProvinceAvailableCommands opac;
|
OneProvinceAvailableCommands opac;
|
||||||
if (Model.AvailableCommandsByProvince.TryGetValue(provinceId, out opac))
|
if (Model.AvailableCommandsByProvince.TryGetValue(provinceId, out opac)) {
|
||||||
{
|
SelectButtonIndex(opac.SuggestedCommandIndex); // probably wrong
|
||||||
SelectButtonIndex(opac.SuggestedCommandIndex); // probably wrong
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectNextActiveProvince()
|
public void SelectNextActiveProvince() {
|
||||||
{
|
|
||||||
mapController.SelectedProvinceId = NextActiveProvinceKeyPair.Key;
|
mapController.SelectedProvinceId = NextActiveProvinceKeyPair.Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectButtonIndex(int buttonIndex)
|
public void SelectButtonIndex(int buttonIndex) {
|
||||||
{
|
var selector =
|
||||||
var selector = Model.AvailableCommandsForProvince(SelectedProvince.Value)
|
Model.AvailableCommandsForProvince(SelectedProvince.Value)
|
||||||
.SelectMany(cmd => commandPanelController.AppropriateSelectors(cmd))
|
.SelectMany(cmd => commandPanelController.AppropriateSelectors(cmd))
|
||||||
.ElementAt(buttonIndex);
|
.ElementAt(buttonIndex);
|
||||||
|
|
||||||
var newType = selector.CommandType;
|
var newType = selector.CommandType;
|
||||||
var cmd = Model.AvailableCommandsForProvince(SelectedProvince.Value).Find(c => c.SealedValueCase == newType);
|
var cmd = Model.AvailableCommandsForProvince(SelectedProvince.Value)
|
||||||
var commandIndex = Model.AvailableCommandsForProvince(SelectedProvince.Value).IndexOf(cmd);
|
.Find(c => c.SealedValueCase == newType);
|
||||||
|
var commandIndex =
|
||||||
|
Model.AvailableCommandsForProvince(SelectedProvince.Value).IndexOf(cmd);
|
||||||
|
|
||||||
commandPanelController.SetAvailableCommandAndSelector(cmd, selector);
|
commandPanelController.SetAvailableCommandAndSelector(cmd, selector);
|
||||||
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
||||||
@@ -254,38 +220,32 @@ namespace eagle
|
|||||||
heroesAndBattalionsPanelController.UpdateTables();
|
heroesAndBattalionsPanelController.UpdateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateButtons()
|
private void UpdateButtons() {
|
||||||
{
|
if (SelectedProvince.HasValue) {
|
||||||
if (SelectedProvince.HasValue)
|
commandButtonController.SetButtonContents(
|
||||||
{
|
Model.AvailableCommandsForProvince(SelectedProvince.Value)
|
||||||
commandButtonController.SetButtonContents(Model
|
.SelectMany(
|
||||||
.AvailableCommandsForProvince(SelectedProvince.Value)
|
cmd => commandPanelController.ButtonContentsForCommand(cmd))
|
||||||
.SelectMany(cmd => commandPanelController.ButtonContentsForCommand(cmd))
|
.ToArray());
|
||||||
.ToArray());
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
commandButtonController.ClearButtonContents();
|
commandButtonController.ClearButtonContents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetNextActiveProvinceButton()
|
private void SetNextActiveProvinceButton() {
|
||||||
{
|
nextActiveProvinceButton.gameObject.SetActive(
|
||||||
nextActiveProvinceButton.gameObject.SetActive(commandPanelController.Selector == null && Model != null && Model.AvailableCommandsByProvince.Count > 0);
|
commandPanelController.Selector == null && Model != null &&
|
||||||
|
Model.AvailableCommandsByProvince.Count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProvinceWasSelected(ProvinceId? pid)
|
public void ProvinceWasSelected(ProvinceId? pid) {
|
||||||
{
|
if (pid.HasValue) {
|
||||||
if (pid.HasValue)
|
|
||||||
{
|
|
||||||
SelectRecommendedCommand(pid.Value);
|
SelectRecommendedCommand(pid.Value);
|
||||||
var currentProvince = Model.Provinces[pid.Value];
|
var currentProvince = Model.Provinces[pid.Value];
|
||||||
provinceInfoPanelController.Province = currentProvince;
|
provinceInfoPanelController.Province = currentProvince;
|
||||||
focusInfoPanelController.CurrentProvince = currentProvince;
|
focusInfoPanelController.CurrentProvince = currentProvince;
|
||||||
heroesAndBattalionsPanelController.CurrentProvince = currentProvince;
|
heroesAndBattalionsPanelController.CurrentProvince = currentProvince;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
provinceInfoPanelController.Province = null;
|
provinceInfoPanelController.Province = null;
|
||||||
focusInfoPanelController.CurrentProvince = null;
|
focusInfoPanelController.CurrentProvince = null;
|
||||||
heroesAndBattalionsPanelController.CurrentProvince = null;
|
heroesAndBattalionsPanelController.CurrentProvince = null;
|
||||||
@@ -296,33 +256,28 @@ namespace eagle
|
|||||||
dominionPanelController.ForceUpdate();
|
dominionPanelController.ForceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrefetchHeadshotForHeroes(List<HeroView> heroViews)
|
private void PrefetchHeadshotForHeroes(List<HeroView> heroViews) {
|
||||||
{
|
|
||||||
awsResourceFetcher.Prefetch(heroViews.Select(h => h.ImagePath));
|
awsResourceFetcher.Prefetch(heroViews.Select(h => h.ImagePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrefetchHeadshots(GameModel model)
|
private void PrefetchHeadshots(GameModel model) {
|
||||||
{
|
var heroList = model.ActiveFactions.Values
|
||||||
var heroList = model.ActiveFactions.Values.Select(faction => model.Heroes[faction.FactionHeadId]).ToList();
|
.Select(faction => model.Heroes[faction.FactionHeadId])
|
||||||
|
.ToList();
|
||||||
|
|
||||||
foreach (ProvinceView province in model.Provinces.Values)
|
foreach (ProvinceView province in model.Provinces.Values) {
|
||||||
{
|
if (province.FullInfo is FullProvinceInfo fpi) {
|
||||||
if (province.FullInfo is FullProvinceInfo fpi)
|
|
||||||
{
|
|
||||||
heroList.AddRange(fpi.RulingFactionHeroIds.Select(hid => model.Heroes[hid]));
|
heroList.AddRange(fpi.RulingFactionHeroIds.Select(hid => model.Heroes[hid]));
|
||||||
heroList.AddRange(fpi.UnaffiliatedHeroes.Select(uh => uh.HeroId).Select(hid => model.Heroes[hid]));
|
heroList.AddRange(fpi.UnaffiliatedHeroes.Select(uh => uh.HeroId)
|
||||||
|
.Select(hid => model.Heroes[hid]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefetchHeadshotForHeroes(heroList);
|
PrefetchHeadshotForHeroes(heroList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapModel()
|
void SwapModel() {
|
||||||
{
|
if (newModel == Model) { return; }
|
||||||
if (newModel == Model)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefetchHeadshots(newModel);
|
PrefetchHeadshots(newModel);
|
||||||
|
|
||||||
@@ -332,74 +287,61 @@ namespace eagle
|
|||||||
commandPanelController.Model = newModel;
|
commandPanelController.Model = newModel;
|
||||||
dominionPanelController.Model = newModel;
|
dominionPanelController.Model = newModel;
|
||||||
|
|
||||||
if (newModel == null)
|
if (newModel == null) { return; }
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var oldModel = Model;
|
var oldModel = Model;
|
||||||
Model = newModel;
|
Model = newModel;
|
||||||
|
|
||||||
mapController.Model = Model;
|
mapController.Model = Model;
|
||||||
if ((oldModel == null || oldModel.CommandToken != newModel.CommandToken) && Model.AvailableCommandsByProvince.Count > 0)
|
if ((oldModel == null || oldModel.CommandToken != newModel.CommandToken) &&
|
||||||
{
|
Model.AvailableCommandsByProvince.Count > 0) {
|
||||||
if (oldModel != null && oldModel.AvailableCommandsByProvince.Count > 0)
|
if (oldModel != null && oldModel.AvailableCommandsByProvince.Count > 0) {
|
||||||
{
|
string str = "We got replacement commands, but we already had commands. " +
|
||||||
string str = "We got replacement commands, but we already had commands. " + oldModel.CommandToken + " " + newModel.CommandToken;
|
oldModel.CommandToken + " " + newModel.CommandToken;
|
||||||
|
|
||||||
var oldProvinces = oldModel.AvailableCommandsByProvince.Keys.ToHashSet();
|
var oldProvinces = oldModel.AvailableCommandsByProvince.Keys.ToHashSet();
|
||||||
var newProvinces = newModel.AvailableCommandsByProvince.Keys.ToHashSet();
|
var newProvinces = newModel.AvailableCommandsByProvince.Keys.ToHashSet();
|
||||||
|
|
||||||
if (oldProvinces != newProvinces)
|
if (oldProvinces != newProvinces) {
|
||||||
{
|
|
||||||
var oldNotNew = oldProvinces.Except(newProvinces);
|
var oldNotNew = oldProvinces.Except(newProvinces);
|
||||||
if (oldNotNew.Any())
|
if (oldNotNew.Any()) {
|
||||||
{
|
|
||||||
str += $"\nWe used to have commands for province {oldNotNew} but now we don't";
|
str += $"\nWe used to have commands for province {oldNotNew} but now we don't";
|
||||||
}
|
}
|
||||||
|
|
||||||
var newNotOld = newProvinces.Except(oldProvinces);
|
var newNotOld = newProvinces.Except(oldProvinces);
|
||||||
if (newNotOld.Any())
|
if (newNotOld.Any()) {
|
||||||
{
|
|
||||||
str += $"\nWe now have commands for provinces {newNotOld} where we didn't before";
|
str += $"\nWe now have commands for provinces {newNotOld} where we didn't before";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var kv in oldModel.AvailableCommandsByProvince)
|
foreach (var kv in oldModel.AvailableCommandsByProvince) {
|
||||||
{
|
if (newModel.AvailableCommandsByProvince.ContainsKey(kv.Key)) {
|
||||||
if (newModel.AvailableCommandsByProvince.ContainsKey(kv.Key))
|
|
||||||
{
|
|
||||||
|
|
||||||
var oldCommands = kv.Value;
|
var oldCommands = kv.Value;
|
||||||
var newCommands = newModel.AvailableCommandsByProvince[kv.Key];
|
var newCommands = newModel.AvailableCommandsByProvince[kv.Key];
|
||||||
if (oldCommands.Commands.Count != newCommands.Commands.Count)
|
if (oldCommands.Commands.Count != newCommands.Commands.Count) {
|
||||||
{
|
|
||||||
str += $"\nWe had {oldCommands.Commands.Count} but now we have {newCommands.Commands.Count}";
|
str += $"\nWe had {oldCommands.Commands.Count} but now we have {newCommands.Commands.Count}";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var cmd in oldCommands.Commands)
|
foreach (var cmd in oldCommands.Commands) {
|
||||||
{
|
if (!newCommands.Commands.Contains(cmd)) {
|
||||||
if (!newCommands.Commands.Contains(cmd))
|
|
||||||
{
|
|
||||||
str += $"\nWe had {cmd} but now we don't";
|
str += $"\nWe had {cmd} but now we don't";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var cmd in newCommands.Commands)
|
foreach (var cmd in newCommands.Commands) {
|
||||||
{
|
if (!oldCommands.Commands.Contains(cmd)) {
|
||||||
if (!oldCommands.Commands.Contains(cmd))
|
|
||||||
{
|
|
||||||
str += $"\nWe have {cmd}, we didn't before";
|
str += $"\nWe have {cmd}, we didn't before";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
throw new InvalidOperationException(str);
|
throw new InvalidOperationException(str);
|
||||||
}
|
}
|
||||||
switch (Model.AvailableCommandsByProvince.First().Value.Commands.First().SealedValueCase)
|
switch (Model.AvailableCommandsByProvince.First()
|
||||||
{
|
.Value.Commands.First()
|
||||||
|
.SealedValueCase) {
|
||||||
case AvailableCommand.SealedValueOneofCase.ResolveTreatyOfferCommand:
|
case AvailableCommand.SealedValueOneofCase.ResolveTreatyOfferCommand:
|
||||||
resolveTreatyCommandSelector.Model = Model;
|
resolveTreatyCommandSelector.Model = Model;
|
||||||
resolveTreatyCommandSelector.AvailableCommand = Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
resolveTreatyCommandSelector.AvailableCommand =
|
||||||
|
Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
mapController.SelectedProvinceId = null;
|
mapController.SelectedProvinceId = null;
|
||||||
@@ -407,7 +349,8 @@ namespace eagle
|
|||||||
|
|
||||||
case AvailableCommand.SealedValueOneofCase.ResolveInvitationCommand:
|
case AvailableCommand.SealedValueOneofCase.ResolveInvitationCommand:
|
||||||
resolveInvitationCommandSelector.Model = Model;
|
resolveInvitationCommandSelector.Model = Model;
|
||||||
resolveInvitationCommandSelector.AvailableCommand = Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
resolveInvitationCommandSelector.AvailableCommand =
|
||||||
|
Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
mapController.SelectedProvinceId = null;
|
mapController.SelectedProvinceId = null;
|
||||||
@@ -415,7 +358,8 @@ namespace eagle
|
|||||||
|
|
||||||
case AvailableCommand.SealedValueOneofCase.ResolveRansomOfferCommand:
|
case AvailableCommand.SealedValueOneofCase.ResolveRansomOfferCommand:
|
||||||
resolveRansomOfferCommandSelector.Model = Model;
|
resolveRansomOfferCommandSelector.Model = Model;
|
||||||
resolveRansomOfferCommandSelector.AvailableCommand = Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
resolveRansomOfferCommandSelector.AvailableCommand =
|
||||||
|
Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
mapController.SelectedProvinceId = null;
|
mapController.SelectedProvinceId = null;
|
||||||
@@ -423,7 +367,8 @@ namespace eagle
|
|||||||
|
|
||||||
case AvailableCommand.SealedValueOneofCase.PleaseRecruitMeCommand:
|
case AvailableCommand.SealedValueOneofCase.PleaseRecruitMeCommand:
|
||||||
pleaseRecruitMeCommandSelector.Model = Model;
|
pleaseRecruitMeCommandSelector.Model = Model;
|
||||||
pleaseRecruitMeCommandSelector.AvailableCommand = Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
pleaseRecruitMeCommandSelector.AvailableCommand =
|
||||||
|
Model.AvailableCommandsByProvince.First().Value.Commands.First();
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
mapController.SelectedProvinceId = null;
|
mapController.SelectedProvinceId = null;
|
||||||
@@ -437,29 +382,26 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldModel != null &&
|
if (oldModel != null && oldModel.AvailableCommandsByProvince.Any() &&
|
||||||
oldModel.AvailableCommandsByProvince.Any() &&
|
|
||||||
newModel.AvailableCommandsByProvince.Any() &&
|
newModel.AvailableCommandsByProvince.Any() &&
|
||||||
oldModel.AvailableCommandsByProvince == newModel.AvailableCommandsByProvince)
|
oldModel.AvailableCommandsByProvince == newModel.AvailableCommandsByProvince) {
|
||||||
{
|
// We got the same set of commands. This shouldn't happen; let's throw an exception
|
||||||
// We got the same set of commands. This shouldn't happen; let's throw an exception indicating the command we got.
|
// indicating the command we got.
|
||||||
//string str = "We got exactly the same set of commands! This could cause a bad reset. Last ActionResultView was ";
|
// string str = "We got exactly the same set of commands! This could cause a bad
|
||||||
//str += newModel.lastActionResultView.ToString();
|
// reset. Last ActionResultView was "; str +=
|
||||||
|
// newModel.lastActionResultView.ToString();
|
||||||
|
|
||||||
//throw new InvalidOperationException(str);
|
// throw new InvalidOperationException(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
focusInfoPanelController.UpdateTables();
|
focusInfoPanelController.UpdateTables();
|
||||||
heroesAndBattalionsPanelController.UpdateTables();
|
heroesAndBattalionsPanelController.UpdateTables();
|
||||||
|
|
||||||
Canvas.ForceUpdateCanvases();
|
Canvas.ForceUpdateCanvases();
|
||||||
var date = Model.CurrentDate;
|
var date = Model.CurrentDate;
|
||||||
if (date != null)
|
if (date != null) {
|
||||||
{
|
|
||||||
string factionLabel = "Observer";
|
string factionLabel = "Observer";
|
||||||
if (Model.PlayerId.HasValue)
|
if (Model.PlayerId.HasValue) {
|
||||||
{
|
|
||||||
var faction = Model.MaybeDestroyedFaction(Model.PlayerId.Value);
|
var faction = Model.MaybeDestroyedFaction(Model.PlayerId.Value);
|
||||||
factionLabel = $"{faction.Name} ({faction.Prestige})";
|
factionLabel = $"{faction.Name} ({faction.Prestige})";
|
||||||
}
|
}
|
||||||
@@ -467,58 +409,43 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToBattleButton.gameObject.SetActive(Model.ShardokGameModels.Count > 0);
|
goToBattleButton.gameObject.SetActive(Model.ShardokGameModels.Count > 0);
|
||||||
foreach (var shardokGameModel in Model.ShardokGameModels.Values)
|
foreach (var shardokGameModel in Model.ShardokGameModels.Values) {
|
||||||
{
|
if (shardokGameModel.PlayerId != -1) {
|
||||||
if (shardokGameModel.PlayerId != -1)
|
|
||||||
{
|
|
||||||
goToBattleButtonText.text = "Battle!";
|
goToBattleButtonText.text = "Battle!";
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
goToBattleButtonText.text = "Observe Battle";
|
goToBattleButtonText.text = "Observe Battle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < Model.ShardokBattles.Count; i++)
|
for (int i = 0; i < Model.ShardokBattles.Count; i++) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
newModel = null;
|
newModel = null;
|
||||||
SetNextActiveProvinceButton();
|
SetNextActiveProvinceButton();
|
||||||
|
|
||||||
if (Model.AvailableCommandsByProvince.Count > 0 && Model.AvailableCommandsByProvince.ContainsKey(0))
|
if (Model.AvailableCommandsByProvince.Count > 0 &&
|
||||||
{
|
Model.AvailableCommandsByProvince.ContainsKey(0)) {
|
||||||
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
mapController.ProvincesWithCommands = new List<ProvinceId>();
|
||||||
}
|
} else {
|
||||||
else
|
mapController.ProvincesWithCommands =
|
||||||
{
|
Model.AvailableCommandsByProvince.Keys.ToList();
|
||||||
mapController.ProvincesWithCommands = Model.AvailableCommandsByProvince.Keys.ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelUpdated(GameModel nm)
|
void ModelUpdated(GameModel nm) {
|
||||||
{
|
MainQueue.Q.Enqueue(() => { newModel = nm; });
|
||||||
MainQueue.Q.Enqueue(() =>
|
|
||||||
{
|
|
||||||
newModel = nm;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PostCommittedCommand(ProvinceId provinceId, SelectedCommand selectedCommand)
|
private void PostCommittedCommand(ProvinceId provinceId, SelectedCommand selectedCommand) {
|
||||||
{
|
ModelUpdater.PostCommand(provinceId: provinceId, command: selectedCommand)
|
||||||
ModelUpdater.PostCommand(provinceId: provinceId, command: selectedCommand).ContinueWith(response =>
|
.ContinueWith(response => {
|
||||||
{
|
if (response.IsFaulted) { errorPanel.Add(response.Exception); }
|
||||||
if (response.IsFaulted)
|
});
|
||||||
{
|
|
||||||
errorPanel.Add(response.Exception);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoCommitCommand()
|
private void DoCommitCommand() {
|
||||||
{
|
PostCommittedCommand(
|
||||||
PostCommittedCommand(provinceId: mapController.SelectedProvinceId.GetValueOrDefault(), commandPanelController.SelectedCommand);
|
provinceId: mapController.SelectedProvinceId.GetValueOrDefault(),
|
||||||
|
commandPanelController.SelectedCommand);
|
||||||
commitCommandButton.gameObject.SetActive(false);
|
commitCommandButton.gameObject.SetActive(false);
|
||||||
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
commandPanelController.SetAvailableCommandAndSelector(null, null);
|
||||||
mapController.TargetedProvinces = new List<ProvinceId>();
|
mapController.TargetedProvinces = new List<ProvinceId>();
|
||||||
@@ -527,17 +454,16 @@ namespace eagle
|
|||||||
heroesAndBattalionsPanelController.UpdateTables();
|
heroesAndBattalionsPanelController.UpdateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CommitCommandButtonClicked()
|
public void CommitCommandButtonClicked() {
|
||||||
{
|
|
||||||
commandWarningPanelController.ClearWarning();
|
commandWarningPanelController.ClearWarning();
|
||||||
DoCommitCommand();
|
DoCommitCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToBattle()
|
public void GoToBattle() {
|
||||||
{
|
|
||||||
var myBattles = Model.ShardokGameModels.Values.Where(sgm => sgm.PlayerId != -1);
|
var myBattles = Model.ShardokGameModels.Values.Where(sgm => sgm.PlayerId != -1);
|
||||||
|
|
||||||
var selectedModel = (myBattles.Count() > 0) ? myBattles.First(b => b.PlayerId != -1) : Model.ShardokGameModels.Values.First();
|
var selectedModel = (myBattles.Count() > 0) ? myBattles.First(b => b.PlayerId != -1)
|
||||||
|
: Model.ShardokGameModels.Values.First();
|
||||||
|
|
||||||
goToBattleButton.gameObject.SetActive(false);
|
goToBattleButton.gameObject.SetActive(false);
|
||||||
|
|
||||||
@@ -548,13 +474,11 @@ namespace eagle
|
|||||||
this.gameObject.SetActive(false);
|
this.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DominionViewToggleClicked(bool value)
|
public void DominionViewToggleClicked(bool value) {
|
||||||
{
|
|
||||||
dominionPanelController.gameObject.SetActive(value);
|
dominionPanelController.gameObject.SetActive(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleQuit()
|
void HandleQuit() {
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// UnityEditor.EditorApplication.isPlaying = false;
|
// UnityEditor.EditorApplication.isPlaying = false;
|
||||||
#else
|
#else
|
||||||
@@ -563,8 +487,7 @@ namespace eagle
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GameIdButtonClicked()
|
public void GameIdButtonClicked() {
|
||||||
{
|
|
||||||
var textField = gameIdButton.GetComponentInChildren<Text>();
|
var textField = gameIdButton.GetComponentInChildren<Text>();
|
||||||
textField.text = textField.text == "" ? ModelUpdater.GameId.ToString("X") : "";
|
textField.text = textField.text == "" ? ModelUpdater.GameId.ToString("X") : "";
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+94
-146
@@ -8,20 +8,15 @@ using ProvinceId = System.Int32;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class FocusInfoPanelController : MonoBehaviour {
|
||||||
public class FocusInfoPanelController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public GameObject panel;
|
public GameObject panel;
|
||||||
|
|
||||||
private ProvinceView _currentProvince;
|
private ProvinceView _currentProvince;
|
||||||
public ProvinceView CurrentProvince
|
public ProvinceView CurrentProvince {
|
||||||
{
|
|
||||||
get => _currentProvince;
|
get => _currentProvince;
|
||||||
set
|
set {
|
||||||
{
|
if (_currentProvince != value) {
|
||||||
if (_currentProvince != value)
|
|
||||||
{
|
|
||||||
_currentProvince = value;
|
_currentProvince = value;
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
@@ -29,10 +24,9 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GameModel _model;
|
private GameModel _model;
|
||||||
public GameModel Model
|
public GameModel Model { private
|
||||||
{
|
get => _model;
|
||||||
private get => _model; set
|
set {
|
||||||
{
|
|
||||||
_model = value;
|
_model = value;
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
panel.SetActive(value != null);
|
panel.SetActive(value != null);
|
||||||
@@ -47,12 +41,11 @@ namespace eagle
|
|||||||
public CommandPanelController commandPanelController;
|
public CommandPanelController commandPanelController;
|
||||||
public MapController mapController;
|
public MapController mapController;
|
||||||
|
|
||||||
private CommandSelector CommandSelector => commandPanelController == null ? null : commandPanelController.Selector;
|
private CommandSelector CommandSelector =>
|
||||||
|
commandPanelController == null ? null : commandPanelController.Selector;
|
||||||
|
|
||||||
public void UpdateTables()
|
public void UpdateTables() {
|
||||||
{
|
if (Model == null) {
|
||||||
if (Model == null)
|
|
||||||
{
|
|
||||||
panel.SetActive(false);
|
panel.SetActive(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,76 +55,60 @@ namespace eagle
|
|||||||
setUpFactions();
|
setUpFactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUnaffiliatedHeroRowSelections(UnaffiliatedHeroRowController row, UnaffiliatedHeroBasics uh)
|
private void SetUnaffiliatedHeroRowSelections(
|
||||||
{
|
UnaffiliatedHeroRowController row,
|
||||||
if (CommandSelector == null)
|
UnaffiliatedHeroBasics uh) {
|
||||||
{
|
if (CommandSelector == null) {
|
||||||
row.Selected = false;
|
row.Selected = false;
|
||||||
row.Selectable = false;
|
row.Selectable = false;
|
||||||
row.RightSelectable = false;
|
row.RightSelectable = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row.Selected = commandPanelController.Selector.TargetedHeroIds.Contains(uh.HeroId);
|
row.Selected = commandPanelController.Selector.TargetedHeroIds.Contains(uh.HeroId);
|
||||||
row.Selectable = commandPanelController.Selector.HeroIsTargetable(uh.HeroId);
|
row.Selectable = commandPanelController.Selector.HeroIsTargetable(uh.HeroId);
|
||||||
row.RightSelectable = false;
|
row.RightSelectable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUnaffiliatedHeroSelections()
|
public void UpdateUnaffiliatedHeroSelections() {
|
||||||
{
|
UnaffiliatedHeroes.Each(
|
||||||
UnaffiliatedHeroes.Each((uh, i) =>
|
(uh, i) => SetUnaffiliatedHeroRowSelections(
|
||||||
SetUnaffiliatedHeroRowSelections(unaffiliatedHeroesTable.ComponentAt<UnaffiliatedHeroRowController>(i), uh)
|
unaffiliatedHeroesTable.ComponentAt<UnaffiliatedHeroRowController>(i),
|
||||||
);
|
uh));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnaffiliatedHeroRowClicked(int index)
|
public void UnaffiliatedHeroRowClicked(int index) {
|
||||||
{
|
|
||||||
var heroId = UnaffiliatedHeroes.ElementAt(index).HeroId;
|
var heroId = UnaffiliatedHeroes.ElementAt(index).HeroId;
|
||||||
if (CommandSelector != null)
|
if (CommandSelector != null) { CommandSelector.AddTargetedHero(heroId); }
|
||||||
{
|
|
||||||
CommandSelector.AddTargetedHero(heroId);
|
|
||||||
}
|
|
||||||
UpdateUnaffiliatedHeroSelections();
|
UpdateUnaffiliatedHeroSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpUnaffiliatedHeroesTable()
|
private void setUpUnaffiliatedHeroesTable() {
|
||||||
{
|
|
||||||
unaffiliatedHeroesTable.RowCount = UnaffiliatedHeroCount;
|
unaffiliatedHeroesTable.RowCount = UnaffiliatedHeroCount;
|
||||||
|
|
||||||
UnaffiliatedHeroes.Each((uh, i) =>
|
UnaffiliatedHeroes.Each((uh, i) => {
|
||||||
{
|
|
||||||
var newRow = unaffiliatedHeroesTable.ComponentAt<UnaffiliatedHeroRowController>(i);
|
var newRow = unaffiliatedHeroesTable.ComponentAt<UnaffiliatedHeroRowController>(i);
|
||||||
newRow.SetUnaffiliatedHero(uh, Model);
|
newRow.SetUnaffiliatedHero(uh, Model);
|
||||||
SetUnaffiliatedHeroRowSelections(newRow, uh);
|
SetUnaffiliatedHeroRowSelections(newRow, uh);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpIncomingArmiesTable()
|
private void setUpIncomingArmiesTable() {
|
||||||
{
|
|
||||||
movingArmiesTable.RowCount = MovingArmiesCount;
|
movingArmiesTable.RowCount = MovingArmiesCount;
|
||||||
|
|
||||||
MovingArmies.Each((army, i) =>
|
MovingArmies.Each((army, i) => {
|
||||||
{
|
|
||||||
var newRow = movingArmiesTable.ComponentAt<MovingArmyTableRow>(i);
|
var newRow = movingArmiesTable.ComponentAt<MovingArmyTableRow>(i);
|
||||||
if (army.FactionId == Model.PlayerId)
|
if (army.FactionId == Model.PlayerId) {
|
||||||
{
|
|
||||||
newRow.Faction = null;
|
newRow.Faction = null;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
newRow.Faction = Model.FactionName(army.FactionId);
|
newRow.Faction = Model.FactionName(army.FactionId);
|
||||||
}
|
}
|
||||||
newRow.HeroCount = army.HeroCount;
|
newRow.HeroCount = army.HeroCount;
|
||||||
newRow.TroopCount = army.TroopCount;
|
newRow.TroopCount = army.TroopCount;
|
||||||
newRow.Origin = Model.Provinces[army.OriginProvinceId].Name;
|
newRow.Origin = Model.Provinces[army.OriginProvinceId].Name;
|
||||||
newRow.Destination = Model.Provinces[army.DestinationProvinceId].Name;
|
newRow.Destination = Model.Provinces[army.DestinationProvinceId].Name;
|
||||||
if (CurrentProvince != null && army.DestinationProvinceId == CurrentProvince.Id)
|
if (CurrentProvince != null && army.DestinationProvinceId == CurrentProvince.Id) {
|
||||||
{
|
|
||||||
newRow.DestinationColor = Color.blue;
|
newRow.DestinationColor = Color.blue;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
newRow.DestinationColor = Color.black;
|
newRow.DestinationColor = Color.black;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,186 +120,157 @@ namespace eagle
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int provinceCount(FactionView faction)
|
private int provinceCount(FactionView faction) {
|
||||||
{
|
|
||||||
return Model.Provinces.Values.Count(pv => pv.RulingFactionId == faction.Id);
|
return Model.Provinces.Values.Count(pv => pv.RulingFactionId == faction.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Treaty existingTreaty(FactionView faction)
|
private Treaty existingTreaty(FactionView faction) {
|
||||||
{
|
if (Model.PlayerId is FactionId myFid) {
|
||||||
if (Model.PlayerId is FactionId myFid)
|
return Model.MaybeDestroyedFaction(myFid).Treaties.FirstOrDefault(
|
||||||
{
|
t => t.TargetFactionId == faction.Id);
|
||||||
return Model.MaybeDestroyedFaction(myFid).Treaties.FirstOrDefault(t => t.TargetFactionId == faction.Id);
|
} else
|
||||||
}
|
return null;
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUpFactionRow(FactionView faction, FactionTableRow row)
|
private void SetUpFactionRow(FactionView faction, FactionTableRow row) {
|
||||||
{
|
|
||||||
row.Faction = faction.Name;
|
row.Faction = faction.Name;
|
||||||
row.FactionId = faction.Id;
|
row.FactionId = faction.Id;
|
||||||
row.FactionColor = PlayerColors.LightPlayerColor(faction.Id);
|
row.FactionColor = PlayerColors.LightPlayerColor(faction.Id);
|
||||||
row.ProvinceCount = Model.Provinces.Values.Count(pv => pv.RulingFactionId == faction.Id);
|
row.ProvinceCount =
|
||||||
|
Model.Provinces.Values.Count(pv => pv.RulingFactionId == faction.Id);
|
||||||
|
|
||||||
Treaty treaty = existingTreaty(faction);
|
Treaty treaty = existingTreaty(faction);
|
||||||
|
|
||||||
if (treaty == null)
|
if (treaty == null) {
|
||||||
{
|
|
||||||
row.TreatyStatus = null;
|
row.TreatyStatus = null;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row.TreatyStatus = $"Treaty until {DisplayNames.DateString(treaty.EndDate)}";
|
row.TreatyStatus = $"Treaty until {DisplayNames.DateString(treaty.EndDate)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandSelector != null)
|
if (CommandSelector != null) {
|
||||||
{
|
|
||||||
row.Selectable = CommandSelector.FactionIsTargetable(faction.Id);
|
row.Selectable = CommandSelector.FactionIsTargetable(faction.Id);
|
||||||
row.Selected = CommandSelector.TargetedFactionIds.Contains(faction.Id);
|
row.Selected = CommandSelector.TargetedFactionIds.Contains(faction.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpFactions()
|
private void setUpFactions() {
|
||||||
{
|
|
||||||
var displayedFactions = DisplayedFactions.ToList();
|
var displayedFactions = DisplayedFactions.ToList();
|
||||||
|
|
||||||
leftFactionsTable.RowCount = (displayedFactions.Count + 1) / 2;
|
leftFactionsTable.RowCount = (displayedFactions.Count + 1) / 2;
|
||||||
rightFactionsTable.RowCount = (displayedFactions.Count) / 2;
|
rightFactionsTable.RowCount = (displayedFactions.Count) / 2;
|
||||||
|
|
||||||
for (int i = 0; i < (displayedFactions.Count + 1) / 2; i++)
|
for (int i = 0; i < (displayedFactions.Count + 1) / 2; i++) {
|
||||||
{
|
|
||||||
var newLeftRow = leftFactionsTable.ComponentAt<FactionTableRow>(i);
|
var newLeftRow = leftFactionsTable.ComponentAt<FactionTableRow>(i);
|
||||||
SetUpFactionRow(displayedFactions.ElementAt(2 * i), newLeftRow);
|
SetUpFactionRow(displayedFactions.ElementAt(2 * i), newLeftRow);
|
||||||
|
|
||||||
if (2 * i + 1 < displayedFactions.Count)
|
if (2 * i + 1 < displayedFactions.Count) {
|
||||||
{
|
|
||||||
var newRightRow = rightFactionsTable.ComponentAt<FactionTableRow>(i);
|
var newRightRow = rightFactionsTable.ComponentAt<FactionTableRow>(i);
|
||||||
SetUpFactionRow(displayedFactions.ElementAt(2 * i + 1), newRightRow);
|
SetUpFactionRow(displayedFactions.ElementAt(2 * i + 1), newRightRow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FactionRowHovered(FactionId fid)
|
public void FactionRowHovered(FactionId fid) {
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = Model.ProvincesForFaction(fid).ToList();
|
mapController.OverrideTargetedProvinces = Model.ProvincesForFaction(fid).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FactionRowUnhovered()
|
public void FactionRowUnhovered() {
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MovingArmyRowHovered(MovingArmyTableRow row)
|
public void MovingArmyRowHovered(MovingArmyTableRow row) {
|
||||||
{
|
for (int i = 0; i < movingArmiesTable.RowCount; i++) {
|
||||||
for (int i = 0; i < movingArmiesTable.RowCount; i++)
|
if (movingArmiesTable.ComponentAt<MovingArmyTableRow>(i) == row) {
|
||||||
{
|
|
||||||
if (movingArmiesTable.ComponentAt<MovingArmyTableRow>(i) == row)
|
|
||||||
{
|
|
||||||
var army = MovingArmies.ElementAt(i);
|
var army = MovingArmies.ElementAt(i);
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId> { army.OriginProvinceId, army.DestinationProvinceId };
|
mapController.OverrideTargetedProvinces = new List<ProvinceId> {
|
||||||
|
army.OriginProvinceId,
|
||||||
|
army.DestinationProvinceId
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MovingArmyRowUnhovered()
|
public void MovingArmyRowUnhovered() {
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProvinceHovered(ProvinceId? pid)
|
public void ProvinceHovered(ProvinceId? pid) {
|
||||||
{
|
|
||||||
// Highlight moving armies table
|
// Highlight moving armies table
|
||||||
MovingArmies.Each((army, i) =>
|
MovingArmies.Each((army, i) => {
|
||||||
{
|
|
||||||
var row = movingArmiesTable.ComponentAt<MovingArmyTableRow>(i);
|
var row = movingArmiesTable.ComponentAt<MovingArmyTableRow>(i);
|
||||||
if (army.DestinationProvinceId == pid || army.OriginProvinceId == pid)
|
if (army.DestinationProvinceId == pid || army.OriginProvinceId == pid) {
|
||||||
{
|
|
||||||
row.ShadeOn();
|
row.ShadeOn();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row.ShadeOff();
|
row.ShadeOff();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Highlight faction table
|
// Highlight faction table
|
||||||
FactionId? fid = null;
|
FactionId? fid = null;
|
||||||
if (pid is ProvinceId hoverPid)
|
if (pid is ProvinceId hoverPid) { fid = Model.Provinces[hoverPid].RulingFactionId; }
|
||||||
{
|
|
||||||
fid = Model.Provinces[hoverPid].RulingFactionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < leftFactionsTable.RowCount; i++)
|
for (int i = 0; i < leftFactionsTable.RowCount; i++) {
|
||||||
{
|
|
||||||
leftFactionsTable.ComponentAt<FactionTableRow>(i).ShadeOff();
|
leftFactionsTable.ComponentAt<FactionTableRow>(i).ShadeOff();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < rightFactionsTable.RowCount; i++)
|
for (int i = 0; i < rightFactionsTable.RowCount; i++) {
|
||||||
{
|
|
||||||
rightFactionsTable.ComponentAt<FactionTableRow>(i).ShadeOff();
|
rightFactionsTable.ComponentAt<FactionTableRow>(i).ShadeOff();
|
||||||
}
|
}
|
||||||
if (fid is FactionId factionId)
|
if (fid is FactionId factionId) {
|
||||||
{
|
|
||||||
var index = DisplayedFactions.FindIndex(f => f.Id == factionId);
|
var index = DisplayedFactions.FindIndex(f => f.Id == factionId);
|
||||||
if (index != -1)
|
if (index != -1) {
|
||||||
{
|
if (index % 2 == 0) {
|
||||||
if (index % 2 == 0)
|
|
||||||
{
|
|
||||||
leftFactionsTable.ComponentAt<FactionTableRow>(index / 2).ShadeOn();
|
leftFactionsTable.ComponentAt<FactionTableRow>(index / 2).ShadeOn();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rightFactionsTable.ComponentAt<FactionTableRow>(index / 2).ShadeOn();
|
rightFactionsTable.ComponentAt<FactionTableRow>(index / 2).ShadeOn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FactionLeftRowClicked(int index)
|
public void FactionLeftRowClicked(int index) {
|
||||||
{
|
|
||||||
var factionId = DisplayedFactions.ElementAt(2 * index).Id;
|
var factionId = DisplayedFactions.ElementAt(2 * index).Id;
|
||||||
if (CommandSelector != null && CommandSelector.FactionIsTargetable(factionId))
|
if (CommandSelector != null && CommandSelector.FactionIsTargetable(factionId)) {
|
||||||
{
|
|
||||||
CommandSelector.AddTargetedFaction(factionId);
|
CommandSelector.AddTargetedFaction(factionId);
|
||||||
}
|
}
|
||||||
setUpFactions();
|
setUpFactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FactionRightRowClicked(int index)
|
public void FactionRightRowClicked(int index) {
|
||||||
{
|
|
||||||
var factionId = DisplayedFactions.ElementAt(2 * index + 1).Id;
|
var factionId = DisplayedFactions.ElementAt(2 * index + 1).Id;
|
||||||
if (CommandSelector != null && CommandSelector.FactionIsTargetable(factionId))
|
if (CommandSelector != null && CommandSelector.FactionIsTargetable(factionId)) {
|
||||||
{
|
|
||||||
CommandSelector.AddTargetedFaction(factionId);
|
CommandSelector.AddTargetedFaction(factionId);
|
||||||
}
|
}
|
||||||
setUpFactions();
|
setUpFactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start() { panel.SetActive(Model != null); }
|
||||||
{
|
|
||||||
panel.SetActive(Model != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool HasProvinceInfo => (CurrentProvince != null && CurrentProvince.FullInfo != null);
|
private bool HasProvinceInfo =>
|
||||||
|
(CurrentProvince != null && CurrentProvince.FullInfo != null);
|
||||||
|
|
||||||
private int UnaffiliatedHeroCount => HasProvinceInfo ? CurrentProvince.FullInfo.UnaffiliatedHeroes.Count : 0;
|
private int UnaffiliatedHeroCount =>
|
||||||
private IEnumerable<UnaffiliatedHeroBasics> UnaffiliatedHeroes => HasProvinceInfo
|
HasProvinceInfo ? CurrentProvince.FullInfo.UnaffiliatedHeroes.Count : 0;
|
||||||
? CurrentProvince.FullInfo.UnaffiliatedHeroes.OrderByDescending(uh => Model.Heroes[uh.HeroId].SortKey).ToList()
|
private IEnumerable<UnaffiliatedHeroBasics> UnaffiliatedHeroes =>
|
||||||
: new List<UnaffiliatedHeroBasics>();
|
HasProvinceInfo ? CurrentProvince.FullInfo.UnaffiliatedHeroes
|
||||||
|
.OrderByDescending(uh => Model.Heroes[uh.HeroId].SortKey)
|
||||||
|
.ToList()
|
||||||
|
: new List<UnaffiliatedHeroBasics>();
|
||||||
|
|
||||||
private int MovingArmiesCount => MovingArmies.Count();
|
private int MovingArmiesCount => MovingArmies.Count();
|
||||||
public IEnumerable<IncomingArmyView> MovingArmies => Model.Provinces.Values
|
public IEnumerable<IncomingArmyView> MovingArmies =>
|
||||||
.SelectMany(p => p.KnownIncomingArmies)
|
Model.Provinces.Values.SelectMany(p => p.KnownIncomingArmies)
|
||||||
.OrderBy(a => a.FactionId == Model.PlayerId)
|
.OrderBy(a => a.FactionId == Model.PlayerId)
|
||||||
.ThenBy(a => CurrentProvince != null && a.DestinationProvinceId != CurrentProvince.Id)
|
.ThenBy(a => CurrentProvince != null &&
|
||||||
.ThenByDescending(a => a.HeroCount);
|
a.DestinationProvinceId != CurrentProvince.Id)
|
||||||
|
.ThenByDescending(a => a.HeroCount);
|
||||||
|
|
||||||
private int FactionsCount => Model.ActiveFactions.Count;
|
private int FactionsCount => Model.ActiveFactions.Count;
|
||||||
private IEnumerable<FactionView> ActiveFactions => Model.ActiveFactions.Values;
|
private IEnumerable<FactionView> ActiveFactions => Model.ActiveFactions.Values;
|
||||||
private List<FactionView> DisplayedFactions => Model.ActiveFactions.Values
|
private List<FactionView> DisplayedFactions =>
|
||||||
.OrderBy(fac => existingTreaty(fac) != null)
|
Model.ActiveFactions.Values.OrderBy(fac => existingTreaty(fac) != null)
|
||||||
.ThenBy(fac => existingTreaty(fac)?.EndDate.Year ?? 0)
|
.ThenBy(fac => existingTreaty(fac)?.EndDate.Year ?? 0)
|
||||||
.ThenBy(fac => existingTreaty(fac)?.EndDate.Month ?? 0)
|
.ThenBy(fac => existingTreaty(fac)?.EndDate.Month ?? 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+21
-32
@@ -5,12 +5,10 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using FactionId = System.Int32;
|
using FactionId = System.Int32;
|
||||||
|
|
||||||
public class HeroDetailsController : MonoBehaviour
|
public class HeroDetailsController : MonoBehaviour {
|
||||||
{
|
|
||||||
public RawImage HeadshotImage;
|
public RawImage HeadshotImage;
|
||||||
public RawImage ProfessionImage;
|
public RawImage ProfessionImage;
|
||||||
public TMP_Text HeroNameText;
|
public TMP_Text HeroNameText;
|
||||||
@@ -30,30 +28,29 @@ namespace eagle
|
|||||||
|
|
||||||
private string professionName;
|
private string professionName;
|
||||||
|
|
||||||
public string StatView(int value)
|
public string StatView(int value) {
|
||||||
{
|
|
||||||
if (value == 0) return "??";
|
if (value == 0) return "??";
|
||||||
return value.ToString();
|
return value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string StatView(double value)
|
public string StatView(double value) { return StatView((int)value); }
|
||||||
{
|
|
||||||
return StatView((int)value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetHeroBasics(HeroView value)
|
private void SetHeroBasics(HeroView value) {
|
||||||
{
|
if (value.ImagePath is String imagePath && !string.IsNullOrEmpty(imagePath)) {
|
||||||
if (value.ImagePath is String imagePath && !string.IsNullOrEmpty(imagePath))
|
HeadshotImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<AWSResourceFetcher>().GetImage(
|
||||||
HeadshotImage.texture = gameObject.GetComponentInParent<AWSResourceFetcher>().GetImage(value.ImagePath);
|
value.ImagePath);
|
||||||
}
|
}
|
||||||
ProfessionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(value.Profession);
|
ProfessionImage.texture =
|
||||||
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
|
value.Profession);
|
||||||
ProfessionImage.gameObject.SetActive(ProfessionImage.texture != null);
|
ProfessionImage.gameObject.SetActive(ProfessionImage.texture != null);
|
||||||
|
|
||||||
HeroNameText.text = value.Name;
|
HeroNameText.text = value.Name;
|
||||||
StrengthText.text = StatView(value.Strength);
|
StrengthText.text = StatView(value.Strength);
|
||||||
AgilityText.text = StatView(value.Agility);
|
AgilityText.text = StatView(value.Agility);
|
||||||
VigorText.text = $"{GUIUtils.ConditionString(value.Vigor)}/{StatView(value.Constitution)}";
|
VigorText.text =
|
||||||
|
$"{GUIUtils.ConditionString(value.Vigor)}/{StatView(value.Constitution)}";
|
||||||
CharismaText.text = StatView(value.Charisma);
|
CharismaText.text = StatView(value.Charisma);
|
||||||
WisdomText.text = StatView(value.Wisdom);
|
WisdomText.text = StatView(value.Wisdom);
|
||||||
|
|
||||||
@@ -63,8 +60,7 @@ namespace eagle
|
|||||||
professionName = DisplayNames.ProfessionNames[value.Profession];
|
professionName = DisplayNames.ProfessionNames[value.Profession];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetOrdinaryHero(HeroView value)
|
private void SetOrdinaryHero(HeroView value) {
|
||||||
{
|
|
||||||
SetHeroBasics(value);
|
SetHeroBasics(value);
|
||||||
|
|
||||||
vipImageContainer.gameObject.SetActive(false);
|
vipImageContainer.gameObject.SetActive(false);
|
||||||
@@ -72,29 +68,22 @@ namespace eagle
|
|||||||
factionColorImage.color = Color.clear;
|
factionColorImage.color = Color.clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetFactionLeader(HeroView value, Color factionColor)
|
private void SetFactionLeader(HeroView value, Color factionColor) {
|
||||||
{
|
|
||||||
SetOrdinaryHero(value);
|
SetOrdinaryHero(value);
|
||||||
vipImageContainer.gameObject.SetActive(true);
|
vipImageContainer.gameObject.SetActive(true);
|
||||||
|
|
||||||
factionColorImage.color = factionColor;
|
factionColorImage.color = factionColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHero(HeroView hero, GameModel model)
|
public void SetHero(HeroView hero, GameModel model) {
|
||||||
{
|
if (hero.FactionId is FactionId fid &&
|
||||||
if (hero.FactionId is FactionId fid && model.ActiveFactions[fid].Leaders.Contains(hero.Id))
|
model.ActiveFactions[fid].Leaders.Contains(hero.Id)) {
|
||||||
{
|
|
||||||
SetFactionLeader(hero, PlayerColors.LightPlayerColor(fid));
|
SetFactionLeader(hero, PlayerColors.LightPlayerColor(fid));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SetOrdinaryHero(hero);
|
SetOrdinaryHero(hero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProfessionImageHover()
|
public void ProfessionImageHover() { tooltip.text = professionName; }
|
||||||
{
|
|
||||||
tooltip.text = professionName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+54
-84
@@ -4,20 +4,15 @@ using System.Linq;
|
|||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using common;
|
using common;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class HeroesAndBattalionsPanelController : MonoBehaviour {
|
||||||
public class HeroesAndBattalionsPanelController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public GameObject panel;
|
public GameObject panel;
|
||||||
|
|
||||||
private ProvinceView _currentProvince;
|
private ProvinceView _currentProvince;
|
||||||
public ProvinceView CurrentProvince
|
public ProvinceView CurrentProvince {
|
||||||
{
|
|
||||||
get => _currentProvince;
|
get => _currentProvince;
|
||||||
set
|
set {
|
||||||
{
|
if (_currentProvince != value) {
|
||||||
if (_currentProvince != value)
|
|
||||||
{
|
|
||||||
_currentProvince = value;
|
_currentProvince = value;
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
}
|
}
|
||||||
@@ -25,10 +20,9 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GameModel _model;
|
private GameModel _model;
|
||||||
public GameModel Model
|
public GameModel Model { private
|
||||||
{
|
get => _model;
|
||||||
private get => _model; set
|
set {
|
||||||
{
|
|
||||||
_model = value;
|
_model = value;
|
||||||
UpdateTables();
|
UpdateTables();
|
||||||
panel.SetActive(value != null);
|
panel.SetActive(value != null);
|
||||||
@@ -41,12 +35,11 @@ namespace eagle
|
|||||||
|
|
||||||
public CommandPanelController commandPanelController;
|
public CommandPanelController commandPanelController;
|
||||||
|
|
||||||
private CommandSelector CommandSelector => commandPanelController == null ? null : commandPanelController.Selector;
|
private CommandSelector CommandSelector =>
|
||||||
|
commandPanelController == null ? null : commandPanelController.Selector;
|
||||||
|
|
||||||
public void UpdateTables()
|
public void UpdateTables() {
|
||||||
{
|
if (Model == null) {
|
||||||
if (Model == null)
|
|
||||||
{
|
|
||||||
panel.SetActive(false);
|
panel.SetActive(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,131 +48,108 @@ namespace eagle
|
|||||||
setUpBattalionsTable();
|
setUpBattalionsTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetHeroRowSelections(HeroRowController row, HeroView hero)
|
private void SetHeroRowSelections(HeroRowController row, HeroView hero) {
|
||||||
{
|
if (CommandSelector == null) {
|
||||||
if (CommandSelector == null)
|
|
||||||
{
|
|
||||||
row.Selected = false;
|
row.Selected = false;
|
||||||
row.Selectable = false;
|
row.Selectable = false;
|
||||||
row.RightSelectable = false;
|
row.RightSelectable = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row.Selected = CommandSelector.TargetedHeroIds.Contains(hero.Id);
|
row.Selected = CommandSelector.TargetedHeroIds.Contains(hero.Id);
|
||||||
row.Selectable = CommandSelector.HeroIsTargetable(hero.Id);
|
row.Selectable = CommandSelector.HeroIsTargetable(hero.Id);
|
||||||
row.RightSelectable = CommandSelector.TargetedHeroIds.Contains(hero.Id);
|
row.RightSelectable = CommandSelector.TargetedHeroIds.Contains(hero.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetBattalionRowSelections(BattalionRowController row, BattalionView batt)
|
private void SetBattalionRowSelections(BattalionRowController row, BattalionView batt) {
|
||||||
{
|
if (CommandSelector == null) {
|
||||||
if (CommandSelector == null)
|
|
||||||
{
|
|
||||||
row.Selected = false;
|
row.Selected = false;
|
||||||
row.Selectable = false;
|
row.Selectable = false;
|
||||||
row.RightSelectable = false;
|
row.RightSelectable = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row.Selected = CommandSelector.TargetedBattalionIds.Contains(batt.Id);
|
row.Selected = CommandSelector.TargetedBattalionIds.Contains(batt.Id);
|
||||||
row.Selectable = CommandSelector.BattalionIsTargetable(batt.Id);
|
row.Selectable = CommandSelector.BattalionIsTargetable(batt.Id);
|
||||||
row.RightSelectable = CommandSelector.TargetedBattalionIds.Contains(batt.Id);
|
row.RightSelectable = CommandSelector.TargetedBattalionIds.Contains(batt.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateHeroSelections()
|
public void UpdateHeroSelections() {
|
||||||
{
|
Heroes.Each(
|
||||||
Heroes.Each((hero, i) =>
|
(hero, i) => SetHeroRowSelections(
|
||||||
SetHeroRowSelections(heroesTable.ComponentAt<HeroRowController>(i), hero)
|
heroesTable.ComponentAt<HeroRowController>(i),
|
||||||
);
|
hero));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBattalionSelections()
|
public void UpdateBattalionSelections() {
|
||||||
{
|
Battalions.Each(
|
||||||
Battalions.Each((batt, i) =>
|
(batt, i) => SetBattalionRowSelections(
|
||||||
SetBattalionRowSelections(battalionsTable.ComponentAt<BattalionRowController>(i), batt)
|
battalionsTable.ComponentAt<BattalionRowController>(i),
|
||||||
);
|
batt));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HeroRowClicked(int index)
|
public void HeroRowClicked(int index) {
|
||||||
{
|
|
||||||
var heroId = Heroes.ElementAt(index).Id;
|
var heroId = Heroes.ElementAt(index).Id;
|
||||||
if (CommandSelector != null && CommandSelector.HeroIsTargetable(heroId))
|
if (CommandSelector != null && CommandSelector.HeroIsTargetable(heroId)) {
|
||||||
{
|
|
||||||
CommandSelector.AddTargetedHero(heroId);
|
CommandSelector.AddTargetedHero(heroId);
|
||||||
}
|
}
|
||||||
UpdateHeroSelections();
|
UpdateHeroSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HeroRowRightClicked(int index)
|
public void HeroRowRightClicked(int index) {
|
||||||
{
|
|
||||||
var heroId = Heroes.ElementAt(index).Id;
|
var heroId = Heroes.ElementAt(index).Id;
|
||||||
if (CommandSelector != null)
|
if (CommandSelector != null) { CommandSelector.RemoveTargetedHero(heroId); }
|
||||||
{
|
|
||||||
CommandSelector.RemoveTargetedHero(heroId);
|
|
||||||
}
|
|
||||||
UpdateHeroSelections();
|
UpdateHeroSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BattalionRowClicked(int index)
|
public void BattalionRowClicked(int index) {
|
||||||
{
|
|
||||||
var battalionId = Battalions.ElementAt(index).Id;
|
var battalionId = Battalions.ElementAt(index).Id;
|
||||||
if (CommandSelector != null && CommandSelector.BattalionIsTargetable(battalionId))
|
if (CommandSelector != null && CommandSelector.BattalionIsTargetable(battalionId)) {
|
||||||
{
|
|
||||||
CommandSelector.AddTargetedBattalion(battalionId);
|
CommandSelector.AddTargetedBattalion(battalionId);
|
||||||
}
|
}
|
||||||
UpdateBattalionSelections();
|
UpdateBattalionSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BattalionRowRightClicked(int index)
|
public void BattalionRowRightClicked(int index) {
|
||||||
{
|
|
||||||
var battalionId = Battalions.ElementAt(index).Id;
|
var battalionId = Battalions.ElementAt(index).Id;
|
||||||
if (CommandSelector != null)
|
if (CommandSelector != null) { CommandSelector.RemoveTargetedBattalion(battalionId); }
|
||||||
{
|
|
||||||
CommandSelector.RemoveTargetedBattalion(battalionId);
|
|
||||||
}
|
|
||||||
UpdateBattalionSelections();
|
UpdateBattalionSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpHeroesTable()
|
private void setUpHeroesTable() {
|
||||||
{
|
|
||||||
heroesTable.RowCount = HeroCount;
|
heroesTable.RowCount = HeroCount;
|
||||||
|
|
||||||
Heroes.Each((hero, i) =>
|
Heroes.Each((hero, i) => {
|
||||||
{
|
|
||||||
var row = heroesTable.ComponentAt<HeroRowController>(i);
|
var row = heroesTable.ComponentAt<HeroRowController>(i);
|
||||||
row.Hero = hero;
|
row.Hero = hero;
|
||||||
SetHeroRowSelections(row, hero);
|
SetHeroRowSelections(row, hero);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpBattalionsTable()
|
private void setUpBattalionsTable() {
|
||||||
{
|
|
||||||
battalionsTable.RowCount = BattalionCount;
|
battalionsTable.RowCount = BattalionCount;
|
||||||
|
|
||||||
Battalions.Each((battalion, i) =>
|
Battalions.Each((battalion, i) => {
|
||||||
{
|
|
||||||
var newRow = battalionsTable.ComponentAt<BattalionRowController>(i);
|
var newRow = battalionsTable.ComponentAt<BattalionRowController>(i);
|
||||||
newRow.Battalion = battalion;
|
newRow.Battalion = battalion;
|
||||||
SetBattalionRowSelections(newRow, battalion);
|
SetBattalionRowSelections(newRow, battalion);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start() { panel.SetActive(Model != null); }
|
||||||
{
|
|
||||||
panel.SetActive(Model != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool HasProvinceInfo => (CurrentProvince != null && CurrentProvince.FullInfo != null);
|
private bool HasProvinceInfo =>
|
||||||
|
(CurrentProvince != null && CurrentProvince.FullInfo != null);
|
||||||
|
|
||||||
private int HeroCount => HasProvinceInfo ? CurrentProvince.FullInfo.RulingFactionHeroIds.Count : 0;
|
private int HeroCount =>
|
||||||
private IEnumerable<HeroView> Heroes => HasProvinceInfo
|
HasProvinceInfo ? CurrentProvince.FullInfo.RulingFactionHeroIds.Count : 0;
|
||||||
? CurrentProvince.FullInfo.RulingFactionHeroIds.Select(id => Model.Heroes[id])
|
private IEnumerable<HeroView> Heroes =>
|
||||||
: new List<HeroView>();
|
HasProvinceInfo ? CurrentProvince.FullInfo.RulingFactionHeroIds.Select(
|
||||||
|
id => Model.Heroes[id])
|
||||||
|
: new List<HeroView>();
|
||||||
|
|
||||||
private int BattalionCount => HasProvinceInfo ? CurrentProvince.FullInfo.Battalions.Count : 0;
|
private int BattalionCount =>
|
||||||
private IEnumerable<BattalionView> Battalions => HasProvinceInfo
|
HasProvinceInfo ? CurrentProvince.FullInfo.Battalions.Count : 0;
|
||||||
? ProvinceUtils.OrderedBattalions(CurrentProvince)
|
private IEnumerable<BattalionView> Battalions =>
|
||||||
: new List<BattalionView>();
|
HasProvinceInfo ? ProvinceUtils.OrderedBattalions(CurrentProvince)
|
||||||
|
: new List<BattalionView>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,7 @@ using UnityEngine.UI;
|
|||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
using FactionId = System.Int32;
|
using FactionId = System.Int32;
|
||||||
|
|
||||||
public class MapController : MonoBehaviour
|
public class MapController : MonoBehaviour {
|
||||||
{
|
|
||||||
public eagle.EagleGameController eagleGameController;
|
public eagle.EagleGameController eagleGameController;
|
||||||
|
|
||||||
public RawImage mapBWImage;
|
public RawImage mapBWImage;
|
||||||
@@ -21,16 +20,13 @@ public class MapController : MonoBehaviour
|
|||||||
|
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
private void SetDefaultProvinceColor(ProvinceId provinceId)
|
private void SetDefaultProvinceColor(ProvinceId provinceId) {
|
||||||
{
|
|
||||||
SetProvinceColor(provinceId, colorForProvince(Model.Provinces[provinceId]));
|
SetProvinceColor(provinceId, colorForProvince(Model.Provinces[provinceId]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetProvinceColor(ProvinceId provinceId, Color color)
|
private void SetProvinceColor(ProvinceId provinceId, Color color) {
|
||||||
{
|
|
||||||
var image = ImageForProvince(provinceId);
|
var image = ImageForProvince(provinceId);
|
||||||
if (image.texture == null)
|
if (image.texture == null) {
|
||||||
{
|
|
||||||
Texture2D texture = new Texture2D(1, 1);
|
Texture2D texture = new Texture2D(1, 1);
|
||||||
texture.wrapMode = TextureWrapMode.Repeat;
|
texture.wrapMode = TextureWrapMode.Repeat;
|
||||||
image.texture = texture;
|
image.texture = texture;
|
||||||
@@ -42,13 +38,10 @@ public class MapController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ProvinceId? _selectedProvinceId;
|
private ProvinceId? _selectedProvinceId;
|
||||||
public ProvinceId? SelectedProvinceId
|
public ProvinceId? SelectedProvinceId {
|
||||||
{
|
|
||||||
get => _selectedProvinceId;
|
get => _selectedProvinceId;
|
||||||
set
|
set {
|
||||||
{
|
if (_selectedProvinceId is ProvinceId provinceId) {
|
||||||
if (_selectedProvinceId is ProvinceId provinceId)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(provinceId);
|
SetDefaultProvinceColor(provinceId);
|
||||||
}
|
}
|
||||||
_selectedProvinceId = value;
|
_selectedProvinceId = value;
|
||||||
@@ -57,21 +50,12 @@ public class MapController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<ProvinceId> _targetedProvinces = new List<ProvinceId>();
|
private List<ProvinceId> _targetedProvinces = new List<ProvinceId>();
|
||||||
public List<ProvinceId> TargetedProvinces
|
public List<ProvinceId> TargetedProvinces {
|
||||||
{
|
|
||||||
get => _targetedProvinces;
|
get => _targetedProvinces;
|
||||||
set
|
set {
|
||||||
{
|
if (value == null) { value = new List<ProvinceId>(); }
|
||||||
if (value == null)
|
if (!Enumerable.SequenceEqual(_targetedProvinces, value)) {
|
||||||
{
|
foreach (ProvinceId pid in _targetedProvinces) { SetDefaultProvinceColor(pid); }
|
||||||
value = new List<ProvinceId>();
|
|
||||||
}
|
|
||||||
if (!Enumerable.SequenceEqual(_targetedProvinces, value))
|
|
||||||
{
|
|
||||||
foreach (ProvinceId pid in _targetedProvinces)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
_targetedProvinces = new List<ProvinceId>(value);
|
_targetedProvinces = new List<ProvinceId>(value);
|
||||||
}
|
}
|
||||||
@@ -79,19 +63,12 @@ public class MapController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<ProvinceId> _overrideTargetedProvinces = new List<ProvinceId>();
|
private List<ProvinceId> _overrideTargetedProvinces = new List<ProvinceId>();
|
||||||
public IList<ProvinceId> OverrideTargetedProvinces
|
public IList<ProvinceId> OverrideTargetedProvinces {
|
||||||
{
|
|
||||||
get => _overrideTargetedProvinces;
|
get => _overrideTargetedProvinces;
|
||||||
set
|
set {
|
||||||
{
|
if (value == null) { value = new List<ProvinceId>(); }
|
||||||
if (value == null)
|
if (!Enumerable.SequenceEqual(_overrideTargetedProvinces, value)) {
|
||||||
{
|
foreach (ProvinceId pid in _overrideTargetedProvinces) {
|
||||||
value = new List<ProvinceId>();
|
|
||||||
}
|
|
||||||
if (!Enumerable.SequenceEqual(_overrideTargetedProvinces, value))
|
|
||||||
{
|
|
||||||
foreach (ProvinceId pid in _overrideTargetedProvinces)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(pid);
|
SetDefaultProvinceColor(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,37 +80,25 @@ public class MapController : MonoBehaviour
|
|||||||
public Action<List<ProvinceId>> TargetedProvincesChangedCallback;
|
public Action<List<ProvinceId>> TargetedProvincesChangedCallback;
|
||||||
public Action<ProvinceId?> HoveredProvinceChangedCallback;
|
public Action<ProvinceId?> HoveredProvinceChangedCallback;
|
||||||
private List<ProvinceId> _provincesWithCommands = new List<ProvinceId>();
|
private List<ProvinceId> _provincesWithCommands = new List<ProvinceId>();
|
||||||
public List<ProvinceId> ProvincesWithCommands
|
public List<ProvinceId> ProvincesWithCommands {
|
||||||
{
|
|
||||||
get => _provincesWithCommands;
|
get => _provincesWithCommands;
|
||||||
set
|
set {
|
||||||
{
|
if (!value.SequenceEqual(_provincesWithCommands)) {
|
||||||
if (!value.SequenceEqual(_provincesWithCommands))
|
foreach (var pid in _provincesWithCommands) { SetDefaultProvinceColor(pid); }
|
||||||
{
|
|
||||||
foreach (var pid in _provincesWithCommands)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(pid);
|
|
||||||
}
|
|
||||||
_provincesWithCommands = value;
|
_provincesWithCommands = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameModel _model;
|
private GameModel _model;
|
||||||
public GameModel Model
|
public GameModel Model {
|
||||||
{
|
|
||||||
get => _model;
|
get => _model;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_model = value;
|
_model = value;
|
||||||
|
|
||||||
foreach (var kv in _model.Provinces)
|
foreach (var kv in _model.Provinces) { SetDefaultProvinceColor(kv.Value.Id); }
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(kv.Value.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var province in _model.Provinces.Values)
|
foreach (var province in _model.Provinces.Values) {
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(province.Id);
|
SetDefaultProvinceColor(province.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,19 +120,17 @@ public class MapController : MonoBehaviour
|
|||||||
private byte[] mapIdBytes;
|
private byte[] mapIdBytes;
|
||||||
ProvinceId? previouslyHoveredProvinceId;
|
ProvinceId? previouslyHoveredProvinceId;
|
||||||
|
|
||||||
private Color colorForProvince(ProvinceView province)
|
private Color colorForProvince(ProvinceView province) {
|
||||||
{
|
|
||||||
var color = PlayerColors.LightPlayerColor(province.RulingFactionId.GetValueOrDefault(0));
|
var color = PlayerColors.LightPlayerColor(province.RulingFactionId.GetValueOrDefault(0));
|
||||||
if (province.RulingFactionId.HasValue && province.FullInfo != null && province.FullInfo.Support != null && province.FullInfo.Support.Stat < 40)
|
if (province.RulingFactionId.HasValue && province.FullInfo != null &&
|
||||||
{
|
province.FullInfo.Support != null && province.FullInfo.Support.Stat < 40) {
|
||||||
color = PlayerColors.MutedPlayerColor(province.RulingFactionId.GetValueOrDefault(0));
|
color = PlayerColors.MutedPlayerColor(province.RulingFactionId.GetValueOrDefault(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
mapIdBytes = rawGray.bytes;
|
mapIdBytes = rawGray.bytes;
|
||||||
imageWidth = mapBWImage.texture.width;
|
imageWidth = mapBWImage.texture.width;
|
||||||
imageHeight = mapBWImage.texture.height;
|
imageHeight = mapBWImage.texture.height;
|
||||||
@@ -175,134 +138,93 @@ public class MapController : MonoBehaviour
|
|||||||
previouslyHoveredProvinceId = null;
|
previouslyHoveredProvinceId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int? ProvinceFromPoint(Vector2 point)
|
int? ProvinceFromPoint(Vector2 point) {
|
||||||
{
|
|
||||||
var mousePosition = new Vector2(point.x, Screen.height - point.y);
|
var mousePosition = new Vector2(point.x, Screen.height - point.y);
|
||||||
var mapRect = gameObject.GetComponentInParent<PanelPositions>().MapRect;
|
var mapRect = gameObject.GetComponentInParent<PanelPositions>().MapRect;
|
||||||
|
|
||||||
var relativeX = (int)((mousePosition.x - mapRect.x) * imageWidth / mapRect.width);
|
var relativeX = (int)((mousePosition.x - mapRect.x) * imageWidth / mapRect.width);
|
||||||
var relativeY = (int)(imageHeight - (mousePosition.y - mapRect.y) * imageHeight / mapRect.height);
|
var relativeY =
|
||||||
|
(int)(imageHeight - (mousePosition.y - mapRect.y) * imageHeight / mapRect.height);
|
||||||
|
|
||||||
if (relativeX < 0 || relativeX >= imageWidth || relativeY < 0 || relativeY >= imageHeight)
|
if (relativeX < 0 || relativeX >= imageWidth || relativeY < 0 || relativeY >= imageHeight) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var provinceId = mapIdBytes[relativeY * imageWidth + relativeX];
|
var provinceId = mapIdBytes[relativeY * imageWidth + relativeX];
|
||||||
if (provinceId == 0 || provinceId == 0xFF)
|
if (provinceId == 0 || provinceId == 0xFF) { return null; }
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return provinceId;
|
return provinceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
if (Model == null || Model.Provinces == null || Model.Provinces.Count == 0) { return; }
|
||||||
if (Model == null || Model.Provinces == null || Model.Provinces.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var maybeHoveredProvinceId = ProvinceFromPoint(Input.mousePosition);
|
var maybeHoveredProvinceId = ProvinceFromPoint(Input.mousePosition);
|
||||||
if (maybeHoveredProvinceId != previouslyHoveredProvinceId)
|
if (maybeHoveredProvinceId != previouslyHoveredProvinceId) {
|
||||||
{
|
|
||||||
previouslyHoveredProvinceId = maybeHoveredProvinceId;
|
previouslyHoveredProvinceId = maybeHoveredProvinceId;
|
||||||
HoveredProvinceChangedCallback.Invoke(maybeHoveredProvinceId);
|
HoveredProvinceChangedCallback.Invoke(maybeHoveredProvinceId);
|
||||||
if (maybeHoveredProvinceId is ProvinceId hoveredProvinceId)
|
if (maybeHoveredProvinceId is ProvinceId hoveredProvinceId) {
|
||||||
{
|
|
||||||
SetUpCenterText(hoveredProvinceId, HOVER_COLOR);
|
SetUpCenterText(hoveredProvinceId, HOVER_COLOR);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SetUpCenterText(SelectedProvinceId, Color.black);
|
SetUpCenterText(SelectedProvinceId, Color.black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OverrideTargetedProvinces.Any())
|
if (OverrideTargetedProvinces.Any()) {
|
||||||
{
|
if (SelectedProvinceId is ProvinceId sPid) { SetDefaultProvinceColor(sPid); }
|
||||||
if (SelectedProvinceId is ProvinceId sPid)
|
foreach (ProvinceId tPid in TargetedProvinces) { SetDefaultProvinceColor(tPid); }
|
||||||
{
|
foreach (var commandProvince in ProvincesWithCommands) {
|
||||||
SetDefaultProvinceColor(sPid);
|
|
||||||
}
|
|
||||||
foreach (ProvinceId tPid in TargetedProvinces)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(tPid);
|
|
||||||
}
|
|
||||||
foreach (var commandProvince in ProvincesWithCommands)
|
|
||||||
{
|
|
||||||
SetDefaultProvinceColor(commandProvince);
|
SetDefaultProvinceColor(commandProvince);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pid in OverrideTargetedProvinces)
|
foreach (var pid in OverrideTargetedProvinces) {
|
||||||
{
|
|
||||||
flashProvince(pid, TARGET_COLOR, 0.25f);
|
flashProvince(pid, TARGET_COLOR, 0.25f);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (SelectedProvinceId is ProvinceId sPid) {
|
||||||
{
|
|
||||||
if (SelectedProvinceId is ProvinceId sPid)
|
|
||||||
{
|
|
||||||
flashProvince(sPid, SELECTION_COLOR, 1.0f);
|
flashProvince(sPid, SELECTION_COLOR, 1.0f);
|
||||||
}
|
}
|
||||||
foreach (ProvinceId tPid in TargetedProvinces)
|
foreach (ProvinceId tPid in TargetedProvinces) {
|
||||||
{
|
|
||||||
flashProvince(tPid, TARGET_COLOR, 0.25f);
|
flashProvince(tPid, TARGET_COLOR, 0.25f);
|
||||||
}
|
}
|
||||||
foreach (var commandProvince in ProvincesWithCommands)
|
foreach (var commandProvince in ProvincesWithCommands) {
|
||||||
{
|
|
||||||
flashProvince(commandProvince, COMMAND_AVAILABLE_COLOR, 0.5f);
|
flashProvince(commandProvince, COMMAND_AVAILABLE_COLOR, 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flashProvince(ProvinceId provinceId, Color flashColor, float duration)
|
private void flashProvince(ProvinceId provinceId, Color flashColor, float duration) {
|
||||||
{
|
SetProvinceColor(
|
||||||
SetProvinceColor(provinceId,
|
provinceId,
|
||||||
Color.Lerp(
|
Color.Lerp(
|
||||||
colorForProvince(Model.Provinces[provinceId]),
|
colorForProvince(Model.Provinces[provinceId]),
|
||||||
flashColor,
|
flashColor,
|
||||||
Mathf.PingPong(Time.time, duration)
|
Mathf.PingPong(Time.time, duration)));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLeftClick(Vector2 position)
|
public void OnLeftClick(Vector2 position) { SelectedProvinceId = ProvinceFromPoint(position); }
|
||||||
{
|
|
||||||
SelectedProvinceId = ProvinceFromPoint(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnRightClick(Vector2 position)
|
public void OnRightClick(Vector2 position) {
|
||||||
{
|
if (ProvinceFromPoint(position) is ProvinceId pid) {
|
||||||
if (ProvinceFromPoint(position) is ProvinceId pid)
|
|
||||||
{
|
|
||||||
TargetedProvinces = new List<ProvinceId> { pid };
|
TargetedProvinces = new List<ProvinceId> { pid };
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
TargetedProvinces.Clear();
|
TargetedProvinces.Clear();
|
||||||
}
|
}
|
||||||
TargetedProvincesChangedCallback.Invoke(TargetedProvinces);
|
TargetedProvincesChangedCallback.Invoke(TargetedProvinces);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUpCenterText(ProvinceId? maybeProvinceId, Color color)
|
void SetUpCenterText(ProvinceId? maybeProvinceId, Color color) {
|
||||||
{
|
|
||||||
provinceNameText.color = color;
|
provinceNameText.color = color;
|
||||||
provinceOwnerText.color = color;
|
provinceOwnerText.color = color;
|
||||||
if (maybeProvinceId is ProvinceId pid)
|
if (maybeProvinceId is ProvinceId pid) {
|
||||||
{
|
|
||||||
var province = Model.Provinces[pid];
|
var province = Model.Provinces[pid];
|
||||||
provinceNameText.text = province.Name;
|
provinceNameText.text = province.Name;
|
||||||
|
|
||||||
if (province.RulingFactionId is FactionId fid)
|
if (province.RulingFactionId is FactionId fid) {
|
||||||
{
|
|
||||||
provinceOwnerText.text = Model.FactionName(fid);
|
provinceOwnerText.text = Model.FactionName(fid);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
provinceOwnerText.text = "";
|
provinceOwnerText.text = "";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
provinceNameText.text = "";
|
provinceNameText.text = "";
|
||||||
provinceOwnerText.text = "";
|
provinceOwnerText.text = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,21 @@ using TMPro;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class NotificationPanel : PopupPanelController
|
public class NotificationPanel : PopupPanelController {
|
||||||
{
|
|
||||||
public Button DismissAllButton;
|
public Button DismissAllButton;
|
||||||
public TMP_Text DismissOneButtonText;
|
public TMP_Text DismissOneButtonText;
|
||||||
|
|
||||||
private class Note
|
private class Note {
|
||||||
{
|
|
||||||
public string Title { get; }
|
public string Title { get; }
|
||||||
public string Text { get; private set; }
|
public string Text { get; private set; }
|
||||||
public string FirstImagePath { get; private set; }
|
public string FirstImagePath { get; private set; }
|
||||||
public string SecondImagePath { get; private set; }
|
public string SecondImagePath { get; private set; }
|
||||||
public List<ProvinceId> ProvinceIds { get; private set; }
|
public List<ProvinceId> ProvinceIds { get; private set; }
|
||||||
|
|
||||||
public Note(string title, string text, List<ProvinceId> provinceIds)
|
public Note(string title, string text, List<ProvinceId> provinceIds) {
|
||||||
{
|
|
||||||
Title = title;
|
Title = title;
|
||||||
Text = text;
|
Text = text;
|
||||||
ProvinceIds = provinceIds;
|
ProvinceIds = provinceIds;
|
||||||
@@ -29,8 +25,12 @@ namespace eagle
|
|||||||
SecondImagePath = null;
|
SecondImagePath = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Note(string title, string text, List<ProvinceId> provinceIds, string firstImagePath, string secondImagePath)
|
public Note(
|
||||||
{
|
string title,
|
||||||
|
string text,
|
||||||
|
List<ProvinceId> provinceIds,
|
||||||
|
string firstImagePath,
|
||||||
|
string secondImagePath) {
|
||||||
Title = title;
|
Title = title;
|
||||||
Text = text;
|
Text = text;
|
||||||
ProvinceIds = provinceIds;
|
ProvinceIds = provinceIds;
|
||||||
@@ -38,8 +38,7 @@ namespace eagle
|
|||||||
SecondImagePath = secondImagePath;
|
SecondImagePath = secondImagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Append(string text, List<ProvinceId> provinceIds)
|
public void Append(string text, List<ProvinceId> provinceIds) {
|
||||||
{
|
|
||||||
Text += "\n" + text;
|
Text += "\n" + text;
|
||||||
ProvinceIds.AddRange(provinceIds);
|
ProvinceIds.AddRange(provinceIds);
|
||||||
}
|
}
|
||||||
@@ -47,66 +46,58 @@ namespace eagle
|
|||||||
|
|
||||||
private Queue<Note> notes = new Queue<Note>();
|
private Queue<Note> notes = new Queue<Note>();
|
||||||
|
|
||||||
private void SetPopupInfos()
|
private void SetPopupInfos() {
|
||||||
{
|
PopupInfos = notes.Select(note => new PopupInfo {
|
||||||
PopupInfos = notes.Select(note => new PopupInfo
|
titleText = note.Title,
|
||||||
{
|
mainText = note.Text,
|
||||||
titleText = note.Title,
|
affectedProvinceIds = note.ProvinceIds,
|
||||||
mainText = note.Text,
|
firstHeroPath = note.FirstImagePath,
|
||||||
affectedProvinceIds = note.ProvinceIds,
|
secondHeroPath = note.SecondImagePath
|
||||||
firstHeroPath = note.FirstImagePath,
|
})
|
||||||
secondHeroPath = note.SecondImagePath
|
.ToList();
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
|
|
||||||
if (PopupInfos.Count == 1)
|
if (PopupInfos.Count == 1) {
|
||||||
{
|
|
||||||
DismissAllButton.gameObject.SetActive(false);
|
DismissAllButton.gameObject.SetActive(false);
|
||||||
DismissOneButtonText.text = "Done";
|
DismissOneButtonText.text = "Done";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
DismissAllButton.gameObject.SetActive(true);
|
DismissAllButton.gameObject.SetActive(true);
|
||||||
DismissOneButtonText.text = "Dismiss";
|
DismissOneButtonText.text = "Dismiss";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNote(string title, string text, List<ProvinceId> provinceIds)
|
public void AddNote(string title, string text, List<ProvinceId> provinceIds) {
|
||||||
{
|
MainQueue.Q.Enqueue(() => {
|
||||||
MainQueue.Q.Enqueue(() =>
|
|
||||||
{
|
|
||||||
var existingNote = notes.FirstOrDefault(n => n.Title == title);
|
var existingNote = notes.FirstOrDefault(n => n.Title == title);
|
||||||
|
|
||||||
if (existingNote == null)
|
if (existingNote == null) {
|
||||||
{
|
|
||||||
notes.Enqueue(new Note(title, text, provinceIds));
|
notes.Enqueue(new Note(title, text, provinceIds));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
existingNote.Append(text, provinceIds);
|
existingNote.Append(text, provinceIds);
|
||||||
}
|
}
|
||||||
SetPopupInfos();
|
SetPopupInfos();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNote(string title, string text, List<ProvinceId> provinceIds, string firstImagePath, string secondImagePath)
|
public void AddNote(
|
||||||
{
|
string title,
|
||||||
MainQueue.Q.Enqueue(() =>
|
string text,
|
||||||
{
|
List<ProvinceId> provinceIds,
|
||||||
|
string firstImagePath,
|
||||||
|
string secondImagePath) {
|
||||||
|
MainQueue.Q.Enqueue(() => {
|
||||||
notes.Enqueue(new Note(title, text, provinceIds, firstImagePath, secondImagePath));
|
notes.Enqueue(new Note(title, text, provinceIds, firstImagePath, secondImagePath));
|
||||||
SetPopupInfos();
|
SetPopupInfos();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DismissButtonClicked()
|
public void DismissButtonClicked() {
|
||||||
{
|
|
||||||
notes.Dequeue();
|
notes.Dequeue();
|
||||||
SetPopupInfos();
|
SetPopupInfos();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DismissAllClicked()
|
public void DismissAllClicked() {
|
||||||
{
|
|
||||||
notes.Clear();
|
notes.Clear();
|
||||||
SetPopupInfos();
|
SetPopupInfos();
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-29
@@ -5,10 +5,8 @@ using UnityEngine;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using static Net.Eagle0.Eagle.Api.OrganizeTroopsAvailableCommand.Types;
|
using static Net.Eagle0.Eagle.Api.OrganizeTroopsAvailableCommand.Types;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class OrganizeExtrasTable : MonoBehaviour {
|
||||||
public class OrganizeExtrasTable : MonoBehaviour
|
|
||||||
{
|
|
||||||
public RawImage unavailableImage;
|
public RawImage unavailableImage;
|
||||||
public GameObject minimumAgricultureRow;
|
public GameObject minimumAgricultureRow;
|
||||||
public GameObject minimumEconomyRow;
|
public GameObject minimumEconomyRow;
|
||||||
@@ -16,49 +14,34 @@ namespace eagle
|
|||||||
public TMP_Text minimumEconomy;
|
public TMP_Text minimumEconomy;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void
|
||||||
|
Set(bool allowed, BattalionTypeStatus battalionTypeStatus, int agriculture, int economy) {
|
||||||
public void Set(bool allowed, BattalionTypeStatus battalionTypeStatus, int agriculture, int economy)
|
|
||||||
{
|
|
||||||
var parent = gameObject.transform.parent;
|
var parent = gameObject.transform.parent;
|
||||||
parent.GetComponentInChildren<Button>().interactable = allowed;
|
parent.GetComponentInChildren<Button>().interactable = allowed;
|
||||||
unavailableImage.gameObject.SetActive(!allowed);
|
unavailableImage.gameObject.SetActive(!allowed);
|
||||||
|
|
||||||
var color = parent.GetComponentInChildren<RawImage>().color;
|
var color = parent.GetComponentInChildren<RawImage>().color;
|
||||||
if (allowed)
|
if (allowed) {
|
||||||
{
|
|
||||||
color.a = 255;
|
color.a = 255;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
color.a = 70;
|
color.a = 70;
|
||||||
|
|
||||||
if (agriculture < battalionTypeStatus.MinimumAgriculture)
|
if (agriculture < battalionTypeStatus.MinimumAgriculture) {
|
||||||
{
|
|
||||||
minimumAgriculture.text = battalionTypeStatus.MinimumAgriculture.ToString();
|
minimumAgriculture.text = battalionTypeStatus.MinimumAgriculture.ToString();
|
||||||
minimumAgricultureRow.gameObject.SetActive(true);
|
minimumAgricultureRow.gameObject.SetActive(true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
minimumAgricultureRow.gameObject.SetActive(false);
|
minimumAgricultureRow.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (economy < battalionTypeStatus.MinimumEconomy)
|
if (economy < battalionTypeStatus.MinimumEconomy) {
|
||||||
{
|
|
||||||
minimumEconomy.text = battalionTypeStatus.MinimumEconomy.ToString();
|
minimumEconomy.text = battalionTypeStatus.MinimumEconomy.ToString();
|
||||||
minimumEconomyRow.gameObject.SetActive(true);
|
minimumEconomyRow.gameObject.SetActive(true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
minimumEconomyRow.gameObject.SetActive(false);
|
minimumEconomyRow.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PanelPositions : MonoBehaviour
|
public class PanelPositions : MonoBehaviour {
|
||||||
{
|
|
||||||
public Canvas canvas;
|
public Canvas canvas;
|
||||||
public RectTransform mapPanelTransform;
|
public RectTransform mapPanelTransform;
|
||||||
|
|
||||||
public Rect MapRect
|
public Rect MapRect {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
Vector3[] corners = new Vector3[4];
|
Vector3[] corners = new Vector3[4];
|
||||||
mapPanelTransform.GetWorldCorners(corners);
|
mapPanelTransform.GetWorldCorners(corners);
|
||||||
Vector3 topLeft = new Vector3(corners[1].x, canvas.pixelRect.height - corners[1].y, corners[1].z);
|
Vector3 topLeft =
|
||||||
|
new Vector3(corners[1].x, canvas.pixelRect.height - corners[1].y, corners[1].z);
|
||||||
|
|
||||||
Vector2 scaledSize = new Vector2(canvas.scaleFactor * mapPanelTransform.rect.size.x, canvas.scaleFactor * mapPanelTransform.rect.size.y);
|
Vector2 scaledSize = new Vector2(
|
||||||
|
canvas.scaleFactor * mapPanelTransform.rect.size.x,
|
||||||
|
canvas.scaleFactor* mapPanelTransform.rect.size.y);
|
||||||
return new Rect(topLeft, scaledSize);
|
return new Rect(topLeft, scaledSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-19
@@ -1,19 +1,15 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class PopupCanvasController : MonoBehaviour {
|
||||||
public class PopupCanvasController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public GameObject modalBlocker;
|
public GameObject modalBlocker;
|
||||||
public GameObject panel;
|
public GameObject panel;
|
||||||
|
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
|
||||||
bool enable = false;
|
bool enable = false;
|
||||||
|
|
||||||
foreach (var controller in panel.GetComponentsInChildren<PopupPanelController>())
|
foreach (var controller in panel.GetComponentsInChildren<PopupPanelController>()) {
|
||||||
{
|
|
||||||
bool hasInfo = controller.HasInfo;
|
bool hasInfo = controller.HasInfo;
|
||||||
enable = enable || hasInfo;
|
enable = enable || hasInfo;
|
||||||
controller.gameObject.SetActive(hasInfo);
|
controller.gameObject.SetActive(hasInfo);
|
||||||
@@ -22,19 +18,18 @@ namespace eagle
|
|||||||
panel.SetActive(enable);
|
panel.SetActive(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetChildActive(bool val)
|
public void SetChildActive(bool val) {
|
||||||
{
|
// if (val)
|
||||||
//if (val)
|
|
||||||
//{
|
//{
|
||||||
// gameObject.SetActive(true);
|
// gameObject.SetActive(true);
|
||||||
//}
|
// }
|
||||||
//else
|
// else
|
||||||
//{
|
//{
|
||||||
// MainQueue.Q.EnqueueForNextUpdate(() =>
|
// MainQueue.Q.EnqueueForNextUpdate(() =>
|
||||||
// {
|
// {
|
||||||
// gameObject.SetActive(HasActiveChild);
|
// gameObject.SetActive(HasActiveChild);
|
||||||
// });
|
// });
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+24
-52
@@ -4,12 +4,10 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = System.Int32;
|
using ProvinceId = System.Int32;
|
||||||
|
|
||||||
public class PopupPanelController : MonoBehaviour
|
public class PopupPanelController : MonoBehaviour {
|
||||||
{
|
|
||||||
public PopupCanvasController canvas;
|
public PopupCanvasController canvas;
|
||||||
public MapController mapController;
|
public MapController mapController;
|
||||||
public TextMeshProUGUI textField;
|
public TextMeshProUGUI textField;
|
||||||
@@ -20,8 +18,7 @@ namespace eagle
|
|||||||
public Button acceptButton;
|
public Button acceptButton;
|
||||||
public Button rejectButton;
|
public Button rejectButton;
|
||||||
|
|
||||||
public struct PopupInfo
|
public struct PopupInfo {
|
||||||
{
|
|
||||||
public string titleText;
|
public string titleText;
|
||||||
public string mainText;
|
public string mainText;
|
||||||
public string firstHeroPath;
|
public string firstHeroPath;
|
||||||
@@ -30,11 +27,9 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<PopupInfo> _popupInfos = new List<PopupInfo>();
|
List<PopupInfo> _popupInfos = new List<PopupInfo>();
|
||||||
protected List<PopupInfo> PopupInfos
|
protected List<PopupInfo> PopupInfos {
|
||||||
{
|
|
||||||
get => _popupInfos;
|
get => _popupInfos;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_popupInfos = value;
|
_popupInfos = value;
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
@@ -44,59 +39,40 @@ namespace eagle
|
|||||||
|
|
||||||
protected int DisplayedIndex { get; private set; }
|
protected int DisplayedIndex { get; private set; }
|
||||||
|
|
||||||
void Start()
|
void Start() { SetUpPanel(); }
|
||||||
{
|
|
||||||
SetUpPanel();
|
void OnDisable() {
|
||||||
|
if (_popupInfos.Count == 0) { canvas.SetChildActive(false); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable()
|
virtual protected void SetUpPanel() {
|
||||||
{
|
if (_popupInfos.Count == 0) {
|
||||||
if (_popupInfos.Count == 0)
|
|
||||||
{
|
|
||||||
canvas.SetChildActive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual protected void SetUpPanel()
|
|
||||||
{
|
|
||||||
if (_popupInfos.Count == 0)
|
|
||||||
{
|
|
||||||
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
mapController.OverrideTargetedProvinces = new List<ProvinceId>();
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
} else {
|
||||||
else
|
if (DisplayedIndex >= _popupInfos.Count) { DisplayedIndex = 0; }
|
||||||
{
|
|
||||||
if (DisplayedIndex >= _popupInfos.Count)
|
|
||||||
{
|
|
||||||
DisplayedIndex = 0;
|
|
||||||
}
|
|
||||||
if (nextButton) nextButton.gameObject.SetActive(PopupInfos.Count > 1);
|
if (nextButton) nextButton.gameObject.SetActive(PopupInfos.Count > 1);
|
||||||
|
|
||||||
title.text = PopupInfos[DisplayedIndex].titleText;
|
title.text = PopupInfos[DisplayedIndex].titleText;
|
||||||
textField.text = PopupInfos[DisplayedIndex].mainText;
|
textField.text = PopupInfos[DisplayedIndex].mainText;
|
||||||
mapController.OverrideTargetedProvinces = PopupInfos[DisplayedIndex].affectedProvinceIds;
|
mapController.OverrideTargetedProvinces =
|
||||||
|
PopupInfos[DisplayedIndex].affectedProvinceIds;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(PopupInfos[DisplayedIndex].firstHeroPath))
|
if (string.IsNullOrEmpty(PopupInfos[DisplayedIndex].firstHeroPath)) {
|
||||||
{
|
if (firstImage != null) {
|
||||||
if (firstImage != null)
|
|
||||||
{
|
|
||||||
firstImage.gameObject.SetActive(false);
|
firstImage.gameObject.SetActive(false);
|
||||||
secondImage.gameObject.SetActive(false);
|
secondImage.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
var fetcher = GetComponentInParent<AWSResourceFetcher>(includeInactive: true);
|
var fetcher = GetComponentInParent<AWSResourceFetcher>(includeInactive: true);
|
||||||
firstImage.texture = fetcher.GetImage(PopupInfos[DisplayedIndex].firstHeroPath);
|
firstImage.texture = fetcher.GetImage(PopupInfos[DisplayedIndex].firstHeroPath);
|
||||||
firstImage.gameObject.SetActive(true);
|
firstImage.gameObject.SetActive(true);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(PopupInfos[DisplayedIndex].secondHeroPath))
|
if (string.IsNullOrEmpty(PopupInfos[DisplayedIndex].secondHeroPath)) {
|
||||||
{
|
|
||||||
secondImage.gameObject.SetActive(false);
|
secondImage.gameObject.SetActive(false);
|
||||||
}
|
} else {
|
||||||
else
|
secondImage.texture =
|
||||||
{
|
fetcher.GetImage(PopupInfos[DisplayedIndex].secondHeroPath);
|
||||||
secondImage.texture = fetcher.GetImage(PopupInfos[DisplayedIndex].secondHeroPath);
|
|
||||||
secondImage.gameObject.SetActive(true);
|
secondImage.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,13 +84,9 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NextButtonClicked()
|
public void NextButtonClicked() {
|
||||||
{
|
|
||||||
DisplayedIndex++;
|
DisplayedIndex++;
|
||||||
if (DisplayedIndex >= PopupInfos.Count)
|
if (DisplayedIndex >= PopupInfos.Count) { DisplayedIndex = 0; }
|
||||||
{
|
|
||||||
DisplayedIndex = 0;
|
|
||||||
}
|
|
||||||
SetUpPanel();
|
SetUpPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+83
-109
@@ -9,19 +9,15 @@ using UnityEngine.UI;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using HeroId = Int32;
|
using HeroId = Int32;
|
||||||
using FactionId = Int32;
|
using FactionId = Int32;
|
||||||
|
|
||||||
public class ProvinceInfoPanelController : MonoBehaviour
|
public class ProvinceInfoPanelController : MonoBehaviour {
|
||||||
{
|
|
||||||
private GameModel _model;
|
private GameModel _model;
|
||||||
public GameModel Model
|
public GameModel Model { private
|
||||||
{
|
get => _model;
|
||||||
private get => _model;
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_model = value;
|
_model = value;
|
||||||
panel.SetActive(_model != null && _provinceView != null);
|
panel.SetActive(_model != null && _provinceView != null);
|
||||||
}
|
}
|
||||||
@@ -58,95 +54,88 @@ namespace eagle
|
|||||||
|
|
||||||
private ProvinceView _provinceView;
|
private ProvinceView _provinceView;
|
||||||
|
|
||||||
private void SetHeadshotToHeroId(HeroId hid)
|
private void SetHeadshotToHeroId(HeroId hid) {
|
||||||
{
|
|
||||||
var rulingHero = _model.Heroes[hid];
|
var rulingHero = _model.Heroes[hid];
|
||||||
|
|
||||||
if (rulingHero.ImagePath is String path)
|
if (rulingHero.ImagePath is String path) {
|
||||||
{
|
Texture2D headshotTexture =
|
||||||
Texture2D headshotTexture = GetComponentInParent<AWSResourceFetcher>().GetImage(path);
|
GetComponentInParent<AWSResourceFetcher>().GetImage(path);
|
||||||
HeadshotImage.texture = headshotTexture;
|
HeadshotImage.texture = headshotTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateHeadshot()
|
private void PopulateHeadshot() {
|
||||||
{
|
|
||||||
HeadshotImage.texture = null;
|
HeadshotImage.texture = null;
|
||||||
Color c = HeadshotImage.color;
|
Color c = HeadshotImage.color;
|
||||||
c.a = 1.0f;
|
c.a = 1.0f;
|
||||||
if (_provinceView?.FullInfo?.RulingHeroId is HeroId rulingHid)
|
if (_provinceView?.FullInfo?.RulingHeroId is HeroId rulingHid) {
|
||||||
{
|
|
||||||
SetHeadshotToHeroId(rulingHid);
|
SetHeadshotToHeroId(rulingHid);
|
||||||
var rulingHero = _model.Heroes[rulingHid];
|
var rulingHero = _model.Heroes[rulingHid];
|
||||||
}
|
} else if (_provinceView?.RulingFactionId is FactionId fid) {
|
||||||
else if (_provinceView?.RulingFactionId is FactionId fid)
|
|
||||||
{
|
|
||||||
SetHeadshotToHeroId(_model.ActiveFactions[fid].FactionHeadId);
|
SetHeadshotToHeroId(_model.ActiveFactions[fid].FactionHeadId);
|
||||||
|
|
||||||
c.a = 0.5f;
|
c.a = 0.5f;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
HeadshotImage.texture = null;
|
HeadshotImage.texture = null;
|
||||||
}
|
}
|
||||||
HeadshotImage.color = c;
|
HeadshotImage.color = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateDetails()
|
private void PopulateDetails() {
|
||||||
{
|
|
||||||
bool ownProvince = _provinceView.RulingFactionId == Model.PlayerId;
|
bool ownProvince = _provinceView.RulingFactionId == Model.PlayerId;
|
||||||
var underAttack = ownProvince && Province.KnownIncomingArmies.Any(x => x.FactionId != Model.PlayerId && x.HeroCount > 0);
|
var underAttack =
|
||||||
|
ownProvince && Province.KnownIncomingArmies.Any(
|
||||||
|
x => x.FactionId != Model.PlayerId && x.HeroCount > 0);
|
||||||
AsOfField.gameObject.SetActive(false);
|
AsOfField.gameObject.SetActive(false);
|
||||||
ProvinceEventsField.gameObject.SetActive(false);
|
ProvinceEventsField.gameObject.SetActive(false);
|
||||||
|
|
||||||
if (ownProvince)
|
if (ownProvince) {
|
||||||
{
|
panel.GetComponent<Image>().color =
|
||||||
panel.GetComponent<Image>().color = underAttack ? GUIUtils.UnderAttackPanelColor : GUIUtils.PanelColor;
|
underAttack ? GUIUtils.UnderAttackPanelColor : GUIUtils.PanelColor;
|
||||||
UnderAttackField.gameObject.SetActive(underAttack);
|
UnderAttackField.gameObject.SetActive(underAttack);
|
||||||
}
|
} else if (Province.AsOf != null) {
|
||||||
else if (Province.AsOf != null)
|
|
||||||
{
|
|
||||||
AsOfField.text = $"As of {DisplayNames.DateString(Province.AsOf)}";
|
AsOfField.text = $"As of {DisplayNames.DateString(Province.AsOf)}";
|
||||||
AsOfField.gameObject.SetActive(true);
|
AsOfField.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool overFoodCap = Province.FullInfo.Food > Province.FullInfo.FoodCap;
|
bool overFoodCap = Province.FullInfo.Food > Province.FullInfo.FoodCap;
|
||||||
bool overGoldCap = Province.FullInfo.Gold > Province.FullInfo.GoldCap;
|
bool overGoldCap = Province.FullInfo.Gold > Province.FullInfo.GoldCap;
|
||||||
GoldField.text = $"{GUIUtils.PossiblyColoredString(overGoldCap, Color.red, Province.FullInfo.Gold.ToString())} / {Province.FullInfo.GoldCap}";
|
GoldField.text =
|
||||||
FoodField.text = $"{GUIUtils.PossiblyColoredString(overFoodCap, Color.red, Province.FullInfo.Food.ToString())} / {Province.FullInfo.FoodCap}";
|
$"{GUIUtils.PossiblyColoredString(overGoldCap, Color.red, Province.FullInfo.Gold.ToString())} / {Province.FullInfo.GoldCap}";
|
||||||
|
FoodField.text =
|
||||||
|
$"{GUIUtils.PossiblyColoredString(overFoodCap, Color.red, Province.FullInfo.Food.ToString())} / {Province.FullInfo.FoodCap}";
|
||||||
ConsumedField.text = $"{Province.FullInfo.FoodConsumption}";
|
ConsumedField.text = $"{Province.FullInfo.FoodConsumption}";
|
||||||
|
|
||||||
EconomyField.text = $"{Province.FullInfo.Economy}";
|
EconomyField.text = $"{Province.FullInfo.Economy}";
|
||||||
if (Province.FullInfo.EconomyDevastation > 0)
|
if (Province.FullInfo.EconomyDevastation > 0) {
|
||||||
{
|
var devastatedEconomy =
|
||||||
var devastatedEconomy = $"{Math.Max(0.0, Province.FullInfo.Economy - Province.FullInfo.EconomyDevastation)}";
|
$"{Math.Max(0.0, Province.FullInfo.Economy - Province.FullInfo.EconomyDevastation)}";
|
||||||
EconomyField.text += $" ({GUIUtils.ColoredString(Color.red, devastatedEconomy)})";
|
EconomyField.text += $" ({GUIUtils.ColoredString(Color.red, devastatedEconomy)})";
|
||||||
}
|
}
|
||||||
|
|
||||||
AgricultureField.text = $"{Province.FullInfo.Agriculture}";
|
AgricultureField.text = $"{Province.FullInfo.Agriculture}";
|
||||||
if (Province.FullInfo.AgricultureDevastation > 0)
|
if (Province.FullInfo.AgricultureDevastation > 0) {
|
||||||
{
|
var devastatedAgriculture =
|
||||||
var devastatedAgriculture = $"{Math.Max(0.0, Province.FullInfo.Agriculture - Province.FullInfo.AgricultureDevastation)}";
|
$"{Math.Max(0.0, Province.FullInfo.Agriculture - Province.FullInfo.AgricultureDevastation)}";
|
||||||
AgricultureField.text += $" ({GUIUtils.ColoredString(Color.red, devastatedAgriculture)})";
|
AgricultureField.text +=
|
||||||
|
$" ({GUIUtils.ColoredString(Color.red, devastatedAgriculture)})";
|
||||||
}
|
}
|
||||||
|
|
||||||
InfrastructureField.text = $"{Province.FullInfo.Infrastructure}";
|
InfrastructureField.text = $"{Province.FullInfo.Infrastructure}";
|
||||||
if (Province.FullInfo.InfrastructureDevastation > 0)
|
if (Province.FullInfo.InfrastructureDevastation > 0) {
|
||||||
{
|
var devastatedInfrastructure =
|
||||||
var devastatedInfrastructure = $"{Math.Max(0.0, Province.FullInfo.Infrastructure - Province.FullInfo.InfrastructureDevastation)}";
|
$"{Math.Max(0.0, Province.FullInfo.Infrastructure - Province.FullInfo.InfrastructureDevastation)}";
|
||||||
InfrastructureField.text += $" ({GUIUtils.ColoredString(Color.red, devastatedInfrastructure)})";
|
InfrastructureField.text +=
|
||||||
|
$" ({GUIUtils.ColoredString(Color.red, devastatedInfrastructure)})";
|
||||||
}
|
}
|
||||||
|
|
||||||
SupportField.text = $"{GUIUtils.ConditionString(Province.FullInfo.Support)}";
|
SupportField.text = $"{GUIUtils.ConditionString(Province.FullInfo.Support)}";
|
||||||
|
|
||||||
var heroCount = Province.FullInfo.RulingFactionHeroIds.Count;
|
var heroCount = Province.FullInfo.RulingFactionHeroIds.Count;
|
||||||
var heroCountString = $"{heroCount}";
|
var heroCountString = $"{heroCount}";
|
||||||
if (Province.FullInfo.HeroCap >= Province.FullInfo.RulingFactionHeroIds.Count)
|
if (Province.FullInfo.HeroCap >= Province.FullInfo.RulingFactionHeroIds.Count) {
|
||||||
{
|
|
||||||
CommandersField.text = heroCountString;
|
CommandersField.text = heroCountString;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CommandersField.text = $"{GUIUtils.ColoredString(Color.red, heroCountString)}";
|
CommandersField.text = $"{GUIUtils.ColoredString(Color.red, heroCountString)}";
|
||||||
}
|
}
|
||||||
FreeHeroesField.text = $"{Province.FullInfo?.UnaffiliatedHeroes.Count ?? 0}";
|
FreeHeroesField.text = $"{Province.FullInfo?.UnaffiliatedHeroes.Count ?? 0}";
|
||||||
@@ -156,19 +145,17 @@ namespace eagle
|
|||||||
CastleCountField.text = $"{Province.FullInfo.CastleCount}";
|
CastleCountField.text = $"{Province.FullInfo.CastleCount}";
|
||||||
|
|
||||||
var eventTexts = new List<String>();
|
var eventTexts = new List<String>();
|
||||||
foreach (var ae in Province.KnownEvents)
|
foreach (var ae in Province.KnownEvents) {
|
||||||
{
|
|
||||||
ProvinceEventsField.gameObject.SetActive(true);
|
ProvinceEventsField.gameObject.SetActive(true);
|
||||||
|
|
||||||
switch (ae.SealedValueCase)
|
switch (ae.SealedValueCase) {
|
||||||
{
|
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.BeastsEvent: {
|
||||||
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.BeastsEvent:
|
var beastType = DisplayNames.BeastTypeName(ae.BeastsEvent.BeastType);
|
||||||
{
|
eventTexts.Add($"{ae.BeastsEvent.Count} {beastType} are disrupting trade!");
|
||||||
var beastType = DisplayNames.BeastTypeName(ae.BeastsEvent.BeastType);
|
break;
|
||||||
eventTexts.Add($"{ae.BeastsEvent.Count} {beastType} are disrupting trade!");
|
}
|
||||||
break;
|
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase
|
||||||
}
|
.ImminentRiotEvent:
|
||||||
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.ImminentRiotEvent:
|
|
||||||
eventTexts.Add("The people are angry! A riot is imminent!");
|
eventTexts.Add("The people are angry! A riot is imminent!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -191,23 +178,19 @@ namespace eagle
|
|||||||
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.EpidemicEvent:
|
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.EpidemicEvent:
|
||||||
eventTexts.Add("A terrible plague!");
|
eventTexts.Add("A terrible plague!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProvinceEventsField.text = String.Join(" ", eventTexts);
|
ProvinceEventsField.text = String.Join(" ", eventTexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProvinceView Province
|
public ProvinceView Province {
|
||||||
{
|
|
||||||
get => _provinceView;
|
get => _provinceView;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
DiplomacyInfoField.gameObject.SetActive(false);
|
DiplomacyInfoField.gameObject.SetActive(false);
|
||||||
ProvinceDetailsContainer.SetActive(false);
|
ProvinceDetailsContainer.SetActive(false);
|
||||||
|
|
||||||
_provinceView = value;
|
_provinceView = value;
|
||||||
if (_provinceView != null)
|
if (_provinceView != null) {
|
||||||
{
|
|
||||||
panel.SetActive(true);
|
panel.SetActive(true);
|
||||||
|
|
||||||
var ownProvince = Province.RulingFactionId == Model.PlayerId;
|
var ownProvince = Province.RulingFactionId == Model.PlayerId;
|
||||||
@@ -215,58 +198,56 @@ namespace eagle
|
|||||||
|
|
||||||
PopulateHeadshot();
|
PopulateHeadshot();
|
||||||
|
|
||||||
if (hasFullInfo)
|
if (hasFullInfo) {
|
||||||
{
|
|
||||||
PopulateDetails();
|
PopulateDetails();
|
||||||
|
|
||||||
ProvinceDetailsContainer.SetActive(true);
|
ProvinceDetailsContainer.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Province.RulingFactionId.HasValue)
|
if (Province.RulingFactionId.HasValue) {
|
||||||
{
|
|
||||||
var faction = Model.MaybeDestroyedFaction(Province.RulingFactionId.Value);
|
var faction = Model.MaybeDestroyedFaction(Province.RulingFactionId.Value);
|
||||||
var rulingHeroName = hasFullInfo ? Model.Heroes[Province.FullInfo.RulingHeroId.Value].Name : "UNKNOWN";
|
var rulingHeroName =
|
||||||
|
hasFullInfo
|
||||||
|
? Model.Heroes[Province.FullInfo.RulingHeroId.Value].Name
|
||||||
|
: "UNKNOWN";
|
||||||
|
|
||||||
var rulerLabel = $"{rulingHeroName} ({faction.Name}" + (ownProvince ? $" {faction.Prestige})" : ")");
|
var rulerLabel = $"{rulingHeroName} ({faction.Name}" +
|
||||||
if (hasFullInfo && Province.FullInfo.ProvinceOrders != Net.Eagle0.Eagle.Common.ProvinceOrderType.UnknownOrders)
|
(ownProvince ? $" {faction.Prestige})" : ")");
|
||||||
{
|
if (hasFullInfo &&
|
||||||
rulerLabel += $" – {DisplayNames.ProvinceOrderTypeNames[Province.FullInfo.ProvinceOrders]}";
|
Province.FullInfo.ProvinceOrders !=
|
||||||
|
Net.Eagle0.Eagle.Common.ProvinceOrderType.UnknownOrders) {
|
||||||
|
rulerLabel +=
|
||||||
|
$" – {DisplayNames.ProvinceOrderTypeNames[Province.FullInfo.ProvinceOrders]}";
|
||||||
}
|
}
|
||||||
ProvinceNameField.text = Province.Name;
|
ProvinceNameField.text = Province.Name;
|
||||||
ProvinceLeaderField.text = rulerLabel;
|
ProvinceLeaderField.text = rulerLabel;
|
||||||
|
|
||||||
if (!hasFullInfo)
|
if (!hasFullInfo) {
|
||||||
{
|
if (Model.PlayerId.HasValue) {
|
||||||
if (Model.PlayerId.HasValue)
|
|
||||||
{
|
|
||||||
DiplomacyInfoField.text = "";
|
DiplomacyInfoField.text = "";
|
||||||
foreach (var treaty in faction.Treaties)
|
foreach (var treaty in faction.Treaties) {
|
||||||
{
|
if (treaty.TargetFactionId == Model.PlayerId) {
|
||||||
if (treaty.TargetFactionId == Model.PlayerId)
|
DiplomacyInfoField.text +=
|
||||||
{
|
$"We have a treaty with them until {DisplayNames.DateString(treaty.EndDate)}.\n";
|
||||||
DiplomacyInfoField.text += $"We have a treaty with them until {DisplayNames.DateString(treaty.EndDate)}.\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var offer in Model.MaybeDestroyedFaction(Model.PlayerId.Value).OutgoingOffers)
|
foreach (var offer in Model
|
||||||
{
|
.MaybeDestroyedFaction(Model.PlayerId.Value)
|
||||||
if (offer.TargetFactionId == faction.Id)
|
.OutgoingOffers) {
|
||||||
{
|
if (offer.TargetFactionId == faction.Id) {
|
||||||
DiplomacyInfoField.text += $"We have a treaty offer en route to them.";
|
DiplomacyInfoField.text +=
|
||||||
|
$"We have a treaty offer en route to them.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DiplomacyInfoField.gameObject.SetActive(true);
|
DiplomacyInfoField.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ProvinceNameField.text = Province.Name;
|
ProvinceNameField.text = Province.Name;
|
||||||
ProvinceLeaderField.text = "Free Province";
|
ProvinceLeaderField.text = "Free Province";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
panel.SetActive(false);
|
panel.SetActive(false);
|
||||||
ProvinceDetailsContainer.SetActive(false);
|
ProvinceDetailsContainer.SetActive(false);
|
||||||
}
|
}
|
||||||
@@ -274,20 +255,13 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() { panel.SetActive(false); }
|
||||||
{
|
|
||||||
panel.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
if (Model == null) {
|
||||||
if (Model == null)
|
|
||||||
{
|
|
||||||
panel.SetActive(false);
|
panel.SetActive(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
panel.SetActive(true);
|
panel.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,12 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public static class ProvinceUtils {
|
||||||
public static class ProvinceUtils
|
public static List<BattalionView> OrderedBattalions(ProvinceView province) {
|
||||||
{
|
if (province == null || province.FullInfo == null) { return new List<BattalionView>(); }
|
||||||
public static List<BattalionView> OrderedBattalions(ProvinceView province)
|
return province.FullInfo.Battalions.OrderBy(b => b, BattalionUtils.BattalionComparer)
|
||||||
{
|
.ToList();
|
||||||
if (province == null || province.FullInfo == null)
|
|
||||||
{
|
|
||||||
return new List<BattalionView>();
|
|
||||||
}
|
|
||||||
return province.FullInfo.Battalions
|
|
||||||
.OrderBy(b => b, BattalionUtils.BattalionComparer)
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+74
-103
@@ -7,19 +7,16 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using Net.Eagle0.Shardok.Common;
|
using Net.Eagle0.Shardok.Common;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
|
|
||||||
namespace eagle0
|
namespace eagle0 {
|
||||||
{
|
|
||||||
using static Net.Eagle0.Eagle.Api.ShardokPlacementCommands.Types;
|
using static Net.Eagle0.Eagle.Api.ShardokPlacementCommands.Types;
|
||||||
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
using static Net.Eagle0.Eagle.Api.UpdateStreamRequest.Types;
|
||||||
using GameId = Int64;
|
using GameId = Int64;
|
||||||
using PlayerId = Int32;
|
using PlayerId = Int32;
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class RemoteEagleClient : EagleClientInterface
|
public class RemoteEagleClient : EagleClientInterface {
|
||||||
{
|
|
||||||
private readonly double TIMEOUT_SECONDS = 55.0;
|
private readonly double TIMEOUT_SECONDS = 55.0;
|
||||||
private DateTime? GetDeadlineFromNow()
|
private DateTime? GetDeadlineFromNow() {
|
||||||
{
|
|
||||||
return DateTime.UtcNow.AddSeconds(TIMEOUT_SECONDS);
|
return DateTime.UtcNow.AddSeconds(TIMEOUT_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +29,12 @@ namespace eagle0
|
|||||||
|
|
||||||
private Logger logger = Logger.connectionLogger;
|
private Logger logger = Logger.connectionLogger;
|
||||||
|
|
||||||
public RemoteEagleClient(GameId gameId, Eagle.EagleClient client, Metadata creds, PlayerId? playerId, CancellationToken token)
|
public RemoteEagleClient(
|
||||||
{
|
GameId gameId,
|
||||||
|
Eagle.EagleClient client,
|
||||||
|
Metadata creds,
|
||||||
|
PlayerId? playerId,
|
||||||
|
CancellationToken token) {
|
||||||
grpcClient = client;
|
grpcClient = client;
|
||||||
GameId = gameId;
|
GameId = gameId;
|
||||||
PlayerId = playerId;
|
PlayerId = playerId;
|
||||||
@@ -41,50 +42,47 @@ namespace eagle0
|
|||||||
cancellationToken = token;
|
cancellationToken = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PostCommandResponse> PostCommand(long token, ProvinceId provinceId, SelectedCommand command)
|
public async Task<PostCommandResponse>
|
||||||
{
|
PostCommand(long token, ProvinceId provinceId, SelectedCommand command) {
|
||||||
var request = new PostCommandRequest
|
var request = new PostCommandRequest {
|
||||||
{
|
|
||||||
GameId = GameId,
|
GameId = GameId,
|
||||||
Token = token,
|
Token = token,
|
||||||
|
|
||||||
Command = new UniversalCommand
|
Command =
|
||||||
{
|
new UniversalCommand {
|
||||||
EagleCommand = new EagleCommand
|
EagleCommand =
|
||||||
{
|
new EagleCommand { ProvinceId = provinceId, Command = command }
|
||||||
ProvinceId = provinceId,
|
}
|
||||||
Command = command
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return await grpcClient.PostCommandAsync(request);
|
return await grpcClient.PostCommandAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PostCommandResponse> PostShardokCommand(string gameId, Int32 playerId, Int64 token, Int32 index)
|
public async Task<PostCommandResponse>
|
||||||
{
|
PostShardokCommand(string gameId, Int32 playerId, Int64 token, Int32 index) {
|
||||||
var request = new PostCommandRequest
|
var request = new PostCommandRequest {
|
||||||
{
|
|
||||||
GameId = GameId,
|
GameId = GameId,
|
||||||
Token = token,
|
Token = token,
|
||||||
|
|
||||||
Command = new UniversalCommand
|
Command =
|
||||||
{
|
new UniversalCommand {
|
||||||
ShardokCommand = new ShardokCommand
|
ShardokCommand =
|
||||||
{
|
new ShardokCommand {
|
||||||
GameId = gameId,
|
GameId = gameId,
|
||||||
PlayerId = playerId,
|
PlayerId = playerId,
|
||||||
Token = token,
|
Token = token,
|
||||||
Index = index
|
Index = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return await grpcClient.PostCommandAsync(request);
|
return await grpcClient.PostCommandAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PostCommandResponse> PostShardokPlacementCommands(string gameId, Int32 playerId, List<ShardokPlacementCommand> placementCommands, Int64 token)
|
public async Task<PostCommandResponse> PostShardokPlacementCommands(
|
||||||
{
|
string gameId,
|
||||||
var sc = new ShardokPlacementCommands
|
Int32 playerId,
|
||||||
{
|
List<ShardokPlacementCommand> placementCommands,
|
||||||
|
Int64 token) {
|
||||||
|
var sc = new ShardokPlacementCommands {
|
||||||
GameId = gameId,
|
GameId = gameId,
|
||||||
PlayerId = playerId,
|
PlayerId = playerId,
|
||||||
Token = token
|
Token = token
|
||||||
@@ -92,52 +90,39 @@ namespace eagle0
|
|||||||
|
|
||||||
sc.PlacementCommands.AddRange(placementCommands);
|
sc.PlacementCommands.AddRange(placementCommands);
|
||||||
|
|
||||||
var request = new PostCommandRequest
|
var request = new PostCommandRequest {
|
||||||
{
|
|
||||||
GameId = GameId,
|
GameId = GameId,
|
||||||
Token = token,
|
Token = token,
|
||||||
|
|
||||||
Command = new UniversalCommand
|
Command = new UniversalCommand { ShardokPlacementCommands = sc }
|
||||||
{
|
|
||||||
ShardokPlacementCommands = sc
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return await grpcClient.PostCommandAsync(request);
|
return await grpcClient.PostCommandAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action<UpdateStreamResponse, StatusCode> repeatedCallback = null;
|
private Action<UpdateStreamResponse, StatusCode> repeatedCallback = null;
|
||||||
|
|
||||||
private async Task<bool> handleStreamingCall()
|
private async Task<bool> handleStreamingCall() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
AsyncServerStreamingCall<UpdateStreamResponse> sc = null;
|
AsyncServerStreamingCall<UpdateStreamResponse> sc = null;
|
||||||
lock (this)
|
lock (this) { sc = streamingCall; }
|
||||||
{
|
while (sc != null && await sc.ResponseStream.MoveNext(cancellationToken)) {
|
||||||
sc = streamingCall;
|
lock (this) {
|
||||||
}
|
if (repeatedCallback != null) {
|
||||||
while (sc != null && await sc.ResponseStream.MoveNext(cancellationToken))
|
|
||||||
{
|
|
||||||
lock (this)
|
|
||||||
{
|
|
||||||
if (repeatedCallback != null)
|
|
||||||
{
|
|
||||||
var current = sc.ResponseStream.Current;
|
var current = sc.ResponseStream.Current;
|
||||||
logger.LogLine($" Got an update of type {current.ResponseDetailsCase}");
|
logger.LogLine(
|
||||||
|
$" Got an update of type {current.ResponseDetailsCase}");
|
||||||
|
|
||||||
if (current.ResponseDetailsCase == UpdateStreamResponse.ResponseDetailsOneofCase.ErrorResponse)
|
if (current.ResponseDetailsCase ==
|
||||||
{
|
UpdateStreamResponse.ResponseDetailsOneofCase.ErrorResponse) {
|
||||||
logger.LogLine("It's an error response!");
|
logger.LogLine("It's an error response!");
|
||||||
MainQueue.Q.Enqueue(() => repeatedCallback.Invoke(null, StatusCode.Cancelled));
|
MainQueue.Q.Enqueue(
|
||||||
}
|
() => repeatedCallback.Invoke(null, StatusCode.Cancelled));
|
||||||
else
|
} else {
|
||||||
{
|
MainQueue.Q.Enqueue(
|
||||||
MainQueue.Q.Enqueue(() => repeatedCallback.Invoke(current, StatusCode.OK));
|
() => repeatedCallback.Invoke(current, StatusCode.OK));
|
||||||
}
|
}
|
||||||
sc = streamingCall;
|
sc = streamingCall;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.LogLine("calling streamingCall.Dispose()");
|
logger.LogLine("calling streamingCall.Dispose()");
|
||||||
streamingCall.Dispose();
|
streamingCall.Dispose();
|
||||||
streamingCall = null;
|
streamingCall = null;
|
||||||
@@ -147,33 +132,24 @@ namespace eagle0
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.LogLine("How did we get here? This is not my beautiful wife!");
|
logger.LogLine("How did we get here? This is not my beautiful wife!");
|
||||||
}
|
} catch (RpcException e) {
|
||||||
catch (RpcException e)
|
lock (this) {
|
||||||
{
|
switch (e.StatusCode) {
|
||||||
lock (this)
|
|
||||||
{
|
|
||||||
switch (e.StatusCode)
|
|
||||||
{
|
|
||||||
case StatusCode.Cancelled:
|
case StatusCode.Cancelled:
|
||||||
case StatusCode.Internal:
|
case StatusCode.Internal: logger.LogLine($"Got exception {e}"); break;
|
||||||
logger.LogLine($"Got exception {e}");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case StatusCode.DeadlineExceeded:
|
case StatusCode.DeadlineExceeded:
|
||||||
logger.LogLine("Got DeadlineExceeded");
|
logger.LogLine("Got DeadlineExceeded");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StatusCode.Unavailable:
|
case StatusCode.Unavailable: logger.LogLine("Got Unavailable"); break;
|
||||||
logger.LogLine("Got Unavailable");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.LogLine($"Something went very wrong, caught exception {e}");
|
logger.LogLine($"Something went very wrong, caught exception {e}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repeatedCallback != null)
|
if (repeatedCallback != null) {
|
||||||
{
|
|
||||||
MainQueue.Q.Enqueue(() => repeatedCallback.Invoke(null, e.StatusCode));
|
MainQueue.Q.Enqueue(() => repeatedCallback.Invoke(null, e.StatusCode));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -183,12 +159,13 @@ namespace eagle0
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> RegisterForUpdates(Action<UpdateStreamResponse, StatusCode> rc, int lastUnfilteredResultCount, List<ShardokViewStatus> shardokViewStatuses)
|
public async Task<bool> RegisterForUpdates(
|
||||||
{
|
Action<UpdateStreamResponse, StatusCode> rc,
|
||||||
|
int lastUnfilteredResultCount,
|
||||||
|
List<ShardokViewStatus> shardokViewStatuses) {
|
||||||
logger.LogLine("Calling StreamUpdates...");
|
logger.LogLine("Calling StreamUpdates...");
|
||||||
|
|
||||||
var request = new UpdateStreamRequest
|
var request = new UpdateStreamRequest {
|
||||||
{
|
|
||||||
GameId = GameId,
|
GameId = GameId,
|
||||||
UnfilteredResultCount = lastUnfilteredResultCount
|
UnfilteredResultCount = lastUnfilteredResultCount
|
||||||
};
|
};
|
||||||
@@ -196,13 +173,11 @@ namespace eagle0
|
|||||||
request.ShardokViewStatuses.AddRange(shardokViewStatuses);
|
request.ShardokViewStatuses.AddRange(shardokViewStatuses);
|
||||||
|
|
||||||
using (var call = grpcClient.StreamUpdates(
|
using (var call = grpcClient.StreamUpdates(
|
||||||
request: request,
|
request: request,
|
||||||
headers: Credentials,
|
headers: Credentials,
|
||||||
deadline: GetDeadlineFromNow(),
|
deadline: GetDeadlineFromNow(),
|
||||||
cancellationToken: cancellationToken))
|
cancellationToken: cancellationToken)) {
|
||||||
{
|
lock (this) {
|
||||||
lock (this)
|
|
||||||
{
|
|
||||||
repeatedCallback = rc;
|
repeatedCallback = rc;
|
||||||
streamingCall = call;
|
streamingCall = call;
|
||||||
}
|
}
|
||||||
@@ -211,23 +186,19 @@ namespace eagle0
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnregisterForUpdates()
|
public void UnregisterForUpdates() {
|
||||||
{
|
lock (this) {
|
||||||
lock (this)
|
|
||||||
{
|
|
||||||
repeatedCallback = null;
|
repeatedCallback = null;
|
||||||
streamingCall.Dispose();
|
streamingCall.Dispose();
|
||||||
streamingCall = null;
|
streamingCall = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HexMap GetHexMap(string mapName)
|
public HexMap GetHexMap(string mapName) {
|
||||||
{
|
|
||||||
return grpcClient.GetHexMap(new HexMapRequest { MapName = mapName }).Map;
|
return grpcClient.GetHexMap(new HexMapRequest { MapName = mapName }).Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<HexMap> GetHexMapAsync(string mapName)
|
public async Task<HexMap> GetHexMapAsync(string mapName) {
|
||||||
{
|
|
||||||
return (await grpcClient.GetHexMapAsync(new HexMapRequest { MapName = mapName })).Map;
|
return (await grpcClient.GetHexMapAsync(new HexMapRequest { MapName = mapName })).Map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-60
@@ -5,10 +5,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class ArmTroopsRowController : TableRowController {
|
||||||
public class ArmTroopsRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage battalionImage;
|
public RawImage battalionImage;
|
||||||
public TMP_Text oldArmamentLabel;
|
public TMP_Text oldArmamentLabel;
|
||||||
public TMP_Text newArmamentLabel;
|
public TMP_Text newArmamentLabel;
|
||||||
@@ -26,74 +24,32 @@ namespace eagle
|
|||||||
public Action ResetButtonClickedCallback;
|
public Action ResetButtonClickedCallback;
|
||||||
public Action MaxButtonClickedCallback;
|
public Action MaxButtonClickedCallback;
|
||||||
|
|
||||||
public Texture BattalionImage
|
public Texture BattalionImage { set => battalionImage.texture = value; }
|
||||||
{
|
|
||||||
set => battalionImage.texture = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double CostPerPoint
|
public double CostPerPoint { set => costPerPointLabel.text = value.ToString("0.##"); }
|
||||||
{
|
|
||||||
set => costPerPointLabel.text = value.ToString("0.##");
|
|
||||||
}
|
|
||||||
|
|
||||||
public double OldArmament
|
public double OldArmament { set => oldArmamentLabel.text = Math.Floor(value).ToString(); }
|
||||||
{
|
|
||||||
set => oldArmamentLabel.text = Math.Floor(value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double NewArmament
|
public double NewArmament { set => newArmamentLabel.text = Math.Floor(value).ToString(); }
|
||||||
{
|
|
||||||
set => newArmamentLabel.text = Math.Floor(value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Size
|
public int Size { set => sizeLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => sizeLabel.text = value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
public string Name { set => nameLabel.text = value; }
|
||||||
{
|
|
||||||
set => nameLabel.text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowPlus
|
public bool AllowPlus { set => plusButton.interactable = value; }
|
||||||
{
|
|
||||||
set => plusButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowMinus
|
public bool AllowMinus { set => minusButton.interactable = value; }
|
||||||
{
|
|
||||||
set => minusButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowReset
|
public bool AllowReset { set => resetButton.interactable = value; }
|
||||||
{
|
|
||||||
set => resetButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowMax
|
public bool AllowMax { set => maxButton.interactable = value; }
|
||||||
{
|
|
||||||
set => maxButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PlusButtonClicked()
|
public void PlusButtonClicked() { PlusButtonClickedCallback(); }
|
||||||
{
|
|
||||||
PlusButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MinusButtonClicked()
|
public void MinusButtonClicked() { MinusButtonClickedCallback(); }
|
||||||
{
|
|
||||||
MinusButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetButtonClicked()
|
public void ResetButtonClicked() { ResetButtonClickedCallback(); }
|
||||||
{
|
|
||||||
ResetButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MaxButtonClicked()
|
public void MaxButtonClicked() { MaxButtonClickedCallback(); }
|
||||||
{
|
|
||||||
MaxButtonClickedCallback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-16
@@ -3,28 +3,18 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class AvailableHeroTableRow : TableRowController {
|
||||||
public class AvailableHeroTableRow : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public TMP_Text heroName;
|
public TMP_Text heroName;
|
||||||
|
|
||||||
public Texture ProfessionImage
|
public Texture ProfessionImage {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
professionImage.texture = value;
|
professionImage.texture = value;
|
||||||
if (value == null)
|
if (value == null) { professionImage.color = Color.clear; }
|
||||||
{
|
|
||||||
professionImage.color = Color.clear;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string HeroName
|
public string HeroName { set => heroName.text = value; }
|
||||||
{
|
|
||||||
set => heroName.text = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-14
@@ -2,10 +2,8 @@
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public abstract class BattalionDisplayInfo {
|
||||||
public abstract class BattalionDisplayInfo
|
|
||||||
{
|
|
||||||
public Texture Image { get; }
|
public Texture Image { get; }
|
||||||
public double Cost { get; }
|
public double Cost { get; }
|
||||||
public int Capacity { get; }
|
public int Capacity { get; }
|
||||||
@@ -19,26 +17,19 @@ namespace eagle
|
|||||||
|
|
||||||
public bool Open { get; set; }
|
public bool Open { get; set; }
|
||||||
|
|
||||||
public BattalionDisplayInfo(Texture image, double cost, int capacity)
|
public BattalionDisplayInfo(Texture image, double cost, int capacity) {
|
||||||
{
|
|
||||||
Image = image;
|
Image = image;
|
||||||
Cost = cost;
|
Cost = cost;
|
||||||
Capacity = capacity;
|
Capacity = capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct BattalionComponent
|
public struct BattalionComponent {
|
||||||
{
|
|
||||||
public int count;
|
public int count;
|
||||||
public double armament;
|
public double armament;
|
||||||
public double training;
|
public double training;
|
||||||
|
|
||||||
public enum ComponentSource
|
public enum ComponentSource { originalTroops, mergedTroops, newTroops }
|
||||||
{
|
|
||||||
originalTroops,
|
|
||||||
mergedTroops,
|
|
||||||
newTroops
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentSource? source;
|
public ComponentSource? source;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-13
@@ -3,25 +3,20 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class BattalionRowController : TableRowController {
|
||||||
public class BattalionRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage battalionImage;
|
public RawImage battalionImage;
|
||||||
public TMP_Text sizeLabel;
|
public TMP_Text sizeLabel;
|
||||||
public TMP_Text trainingLabel;
|
public TMP_Text trainingLabel;
|
||||||
public TMP_Text armamentLabel;
|
public TMP_Text armamentLabel;
|
||||||
public TMP_Text battalionNameLabel;
|
public TMP_Text battalionNameLabel;
|
||||||
|
|
||||||
public BattalionView Battalion
|
public BattalionView Battalion {
|
||||||
{
|
set {
|
||||||
set
|
battalionImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(
|
||||||
battalionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(value.Type);
|
value.Type);
|
||||||
if (battalionImage.texture == null)
|
if (battalionImage.texture == null) { battalionImage.color = Color.clear; }
|
||||||
{
|
|
||||||
battalionImage.color = Color.clear;
|
|
||||||
}
|
|
||||||
sizeLabel.text = value.Size.ToString();
|
sizeLabel.text = value.Size.ToString();
|
||||||
trainingLabel.text = ((int)value.Training).ToString();
|
trainingLabel.text = ((int)value.Training).ToString();
|
||||||
armamentLabel.text = ((int)value.Armament).ToString();
|
armamentLabel.text = ((int)value.Armament).ToString();
|
||||||
|
|||||||
+8
-17
@@ -4,10 +4,8 @@ using Net.Eagle0.Eagle.Api;
|
|||||||
using Net.Eagle0.Eagle.Common;
|
using Net.Eagle0.Eagle.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class CombatUnitRowController : TableRowController {
|
||||||
public class CombatUnitRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public TMP_Text heroNameLabel;
|
public TMP_Text heroNameLabel;
|
||||||
public RawImage battalionImage;
|
public RawImage battalionImage;
|
||||||
@@ -15,29 +13,22 @@ namespace eagle
|
|||||||
public TMP_Text trainingLabel;
|
public TMP_Text trainingLabel;
|
||||||
public TMP_Text armamentLabel;
|
public TMP_Text armamentLabel;
|
||||||
|
|
||||||
public HeroView Hero
|
public HeroView Hero {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
professionImage.texture = CommonTextures.Profession(value.Profession);
|
professionImage.texture = CommonTextures.Profession(value.Profession);
|
||||||
professionImage.color = professionImage.texture == null ? Color.clear : Color.white;
|
professionImage.color = professionImage.texture == null ? Color.clear : Color.white;
|
||||||
heroNameLabel.text = value.Name;
|
heroNameLabel.text = value.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattalionView Battalion
|
public BattalionView Battalion {
|
||||||
{
|
set {
|
||||||
set
|
if (value == null) {
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
battalionImage.texture = null;
|
battalionImage.texture = null;
|
||||||
sizeLabel.text = "0";
|
sizeLabel.text = "0";
|
||||||
trainingLabel.text = null;
|
trainingLabel.text = null;
|
||||||
armamentLabel.text = null;
|
armamentLabel.text = null;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
battalionImage.texture = CommonTextures.BattalionType(value.Type);
|
battalionImage.texture = CommonTextures.BattalionType(value.Type);
|
||||||
sizeLabel.text = value.Size.ToString();
|
sizeLabel.text = value.Size.ToString();
|
||||||
trainingLabel.text = ((int)value.Training).ToString();
|
trainingLabel.text = ((int)value.Training).ToString();
|
||||||
|
|||||||
+45
-49
@@ -5,10 +5,8 @@ using Net.Eagle0.Common;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class CustomUnitRowController : TableRowController {
|
||||||
public class CustomUnitRowController : TableRowController
|
|
||||||
{
|
|
||||||
public TMP_Dropdown professionDropdown;
|
public TMP_Dropdown professionDropdown;
|
||||||
public TMP_InputField heroName;
|
public TMP_InputField heroName;
|
||||||
public TMP_InputField strength;
|
public TMP_InputField strength;
|
||||||
@@ -29,53 +27,46 @@ namespace eagle
|
|||||||
public Toggle canStartFire;
|
public Toggle canStartFire;
|
||||||
public Button deleteButton;
|
public Button deleteButton;
|
||||||
|
|
||||||
public CommonProfession SelectedProfession
|
public CommonProfession SelectedProfession {
|
||||||
{
|
get => professionDropdown.value == 0 ? CommonProfession.NoProfession
|
||||||
get => professionDropdown.value == 0 ? CommonProfession.NoProfession : (CommonProfession)(professionDropdown.value);
|
: (CommonProfession)(professionDropdown.value);
|
||||||
set => professionDropdown.value = (int)value;
|
set => professionDropdown.value = (int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommonBattalionTypeId SelectedBattalionTypeId
|
public CommonBattalionTypeId SelectedBattalionTypeId {
|
||||||
{
|
|
||||||
get => (CommonBattalionTypeId)battalionTypeDropdown.value;
|
get => (CommonBattalionTypeId)battalionTypeDropdown.value;
|
||||||
set => battalionTypeDropdown.value = (int)value;
|
set => battalionTypeDropdown.value = (int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteButtonClicked()
|
public void DeleteButtonClicked() {
|
||||||
{
|
|
||||||
GetComponentInParent<EventBasedTable>().RemoveRow(this);
|
GetComponentInParent<EventBasedTable>().RemoveRow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<int> _availableStartingPositions;
|
private List<int> _availableStartingPositions;
|
||||||
public List<int> AvailableStartingPositions
|
public List<int> AvailableStartingPositions {
|
||||||
{
|
|
||||||
get => _availableStartingPositions;
|
get => _availableStartingPositions;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_availableStartingPositions = value;
|
_availableStartingPositions = value;
|
||||||
if (_availableStartingPositions.Count == 0)
|
if (_availableStartingPositions.Count == 0) {
|
||||||
{
|
startingPosition.options = new List<TMP_Dropdown.OptionData> {
|
||||||
startingPosition.options = new List<TMP_Dropdown.OptionData> { new TMP_Dropdown.OptionData("DEF") };
|
new TMP_Dropdown.OptionData("DEF")
|
||||||
}
|
};
|
||||||
else
|
} else {
|
||||||
{
|
startingPosition.options =
|
||||||
startingPosition.options = _availableStartingPositions.Select(i => new TMP_Dropdown.OptionData(i.ToString())).ToList();
|
_availableStartingPositions
|
||||||
|
.Select(i => new TMP_Dropdown.OptionData(i.ToString()))
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
startingPosition.value = 0;
|
startingPosition.value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommonUnit Unit
|
public CommonUnit Unit {
|
||||||
{
|
get {
|
||||||
get
|
var hero = new CommonHero {
|
||||||
{
|
|
||||||
var hero = new CommonHero
|
|
||||||
{
|
|
||||||
Name = heroName.text,
|
Name = heroName.text,
|
||||||
Profession = SelectedProfession,
|
Profession = SelectedProfession,
|
||||||
Strength = int.Parse(strength.text),
|
Strength = int.Parse(strength.text),
|
||||||
@@ -88,30 +79,33 @@ namespace eagle
|
|||||||
IsVip = isVip.isOn
|
IsVip = isVip.isOn
|
||||||
};
|
};
|
||||||
|
|
||||||
var battalion = SelectedBattalionTypeId == CommonBattalionTypeId.Undead ? null : new CommonBattalion
|
var battalion = SelectedBattalionTypeId == CommonBattalionTypeId.Undead
|
||||||
{
|
? null
|
||||||
Type = SelectedBattalionTypeId,
|
: new CommonBattalion {
|
||||||
Size = int.Parse(sizeLabel.text),
|
Type = SelectedBattalionTypeId,
|
||||||
Training = double.Parse(trainingLabel.text),
|
Size = int.Parse(sizeLabel.text),
|
||||||
Armament = double.Parse(armamentLabel.text)
|
Training = double.Parse(trainingLabel.text),
|
||||||
};
|
Armament = double.Parse(armamentLabel.text)
|
||||||
|
};
|
||||||
|
|
||||||
return new CommonUnit
|
return new CommonUnit {
|
||||||
{
|
|
||||||
Hero = hero,
|
Hero = hero,
|
||||||
Battalion = battalion,
|
Battalion = battalion,
|
||||||
StartingPositionIndex = _availableStartingPositions != null && _availableStartingPositions.Count > 0
|
StartingPositionIndex =
|
||||||
? (int?)_availableStartingPositions[startingPosition.value]
|
_availableStartingPositions != null &&
|
||||||
: (int?)null,
|
_availableStartingPositions.Count >
|
||||||
|
0?(int?)_availableStartingPositions[startingPosition.value] :
|
||||||
|
(int?)null,
|
||||||
CanFlee = canFlee.isOn,
|
CanFlee = canFlee.isOn,
|
||||||
CanArchery = canArchery.isOn,
|
CanArchery = canArchery.isOn,
|
||||||
CanStartFire = canStartFire.isOn
|
CanStartFire = canStartFire.isOn
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
heroName.text = value.Hero.Name;
|
heroName.text = value.Hero.Name;
|
||||||
professionDropdown.value = value.Hero.Profession == CommonProfession.NoProfession ? 0 : (int)value.Hero.Profession;
|
professionDropdown.value = value.Hero.Profession == CommonProfession.NoProfession
|
||||||
|
? 0
|
||||||
|
: (int)value.Hero.Profession;
|
||||||
strength.text = value.Hero.Strength.ToString();
|
strength.text = value.Hero.Strength.ToString();
|
||||||
agility.text = value.Hero.Agility.ToString();
|
agility.text = value.Hero.Agility.ToString();
|
||||||
constitution.text = value.Hero.Constitution.ToString();
|
constitution.text = value.Hero.Constitution.ToString();
|
||||||
@@ -125,9 +119,11 @@ namespace eagle
|
|||||||
trainingLabel.text = value.Battalion.Training.ToString();
|
trainingLabel.text = value.Battalion.Training.ToString();
|
||||||
armamentLabel.text = value.Battalion.Armament.ToString();
|
armamentLabel.text = value.Battalion.Armament.ToString();
|
||||||
|
|
||||||
startingPosition.value = (value.StartingPositionIndex.HasValue && _availableStartingPositions != null)
|
startingPosition.value = (value.StartingPositionIndex.HasValue &&
|
||||||
? _availableStartingPositions.IndexOf(value.StartingPositionIndex.Value)
|
_availableStartingPositions != null)
|
||||||
: 0;
|
? _availableStartingPositions.IndexOf(
|
||||||
|
value.StartingPositionIndex.Value)
|
||||||
|
: 0;
|
||||||
canFlee.isOn = value.CanFlee;
|
canFlee.isOn = value.CanFlee;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-45
@@ -8,12 +8,13 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using ProvinceId = Int32;
|
using ProvinceId = Int32;
|
||||||
|
|
||||||
public class DominionTableRowController : TableRowController, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
public class DominionTableRowController : TableRowController,
|
||||||
{
|
IPointerEnterHandler,
|
||||||
|
IPointerExitHandler,
|
||||||
|
IPointerClickHandler {
|
||||||
public TMP_Text provinceName;
|
public TMP_Text provinceName;
|
||||||
public TMP_Text ruler;
|
public TMP_Text ruler;
|
||||||
public TMP_Text support;
|
public TMP_Text support;
|
||||||
@@ -36,38 +37,28 @@ namespace eagle
|
|||||||
|
|
||||||
private ProvinceId ProvinceId;
|
private ProvinceId ProvinceId;
|
||||||
|
|
||||||
private void SetDevastatedValue(TMP_Text textField, double baseValue, double devastation)
|
private void SetDevastatedValue(TMP_Text textField, double baseValue, double devastation) {
|
||||||
{
|
if (devastation == 0.0) {
|
||||||
if (devastation == 0.0)
|
|
||||||
{
|
|
||||||
textField.color = Color.black;
|
textField.color = Color.black;
|
||||||
textField.text = baseValue.ToString();
|
textField.text = baseValue.ToString();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
textField.color = Color.red;
|
textField.color = Color.red;
|
||||||
var devastatedValue = Math.Max(0.0, baseValue - devastation);
|
var devastatedValue = Math.Max(0.0, baseValue - devastation);
|
||||||
textField.text = devastatedValue.ToString();
|
textField.text = devastatedValue.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(ProvinceId provinceId, GameModel model, bool isSelected, bool hasCommands)
|
public void Set(ProvinceId provinceId, GameModel model, bool isSelected, bool hasCommands) {
|
||||||
{
|
|
||||||
ProvinceId = provinceId;
|
ProvinceId = provinceId;
|
||||||
|
|
||||||
var province = model.Provinces[provinceId];
|
var province = model.Provinces[provinceId];
|
||||||
|
|
||||||
provinceName.text = province.Name;
|
provinceName.text = province.Name;
|
||||||
if (isSelected)
|
if (isSelected) {
|
||||||
{
|
|
||||||
provinceName.color = Color.magenta;
|
provinceName.color = Color.magenta;
|
||||||
}
|
} else if (hasCommands) {
|
||||||
else if (hasCommands)
|
|
||||||
{
|
|
||||||
provinceName.color = Color.blue;
|
provinceName.color = Color.blue;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
provinceName.color = Color.black;
|
provinceName.color = Color.black;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +68,18 @@ namespace eagle
|
|||||||
battalionCount.text = province.FullInfo.Battalions.Count.ToString();
|
battalionCount.text = province.FullInfo.Battalions.Count.ToString();
|
||||||
troopCount.text = province.FullInfo.Battalions.Sum(x => x.Size).ToString();
|
troopCount.text = province.FullInfo.Battalions.Sum(x => x.Size).ToString();
|
||||||
|
|
||||||
SetDevastatedValue(economy, province.FullInfo.Economy, province.FullInfo.EconomyDevastation);
|
SetDevastatedValue(
|
||||||
SetDevastatedValue(agriculture, province.FullInfo.Agriculture, province.FullInfo.AgricultureDevastation);
|
economy,
|
||||||
SetDevastatedValue(infrastructure, province.FullInfo.Infrastructure, province.FullInfo.InfrastructureDevastation);
|
province.FullInfo.Economy,
|
||||||
|
province.FullInfo.EconomyDevastation);
|
||||||
|
SetDevastatedValue(
|
||||||
|
agriculture,
|
||||||
|
province.FullInfo.Agriculture,
|
||||||
|
province.FullInfo.AgricultureDevastation);
|
||||||
|
SetDevastatedValue(
|
||||||
|
infrastructure,
|
||||||
|
province.FullInfo.Infrastructure,
|
||||||
|
province.FullInfo.InfrastructureDevastation);
|
||||||
|
|
||||||
gold.text = province.FullInfo.Gold.ToString();
|
gold.text = province.FullInfo.Gold.ToString();
|
||||||
food.text = province.FullInfo.Food.ToString();
|
food.text = province.FullInfo.Food.ToString();
|
||||||
@@ -93,10 +93,8 @@ namespace eagle
|
|||||||
festival.gameObject.SetActive(false);
|
festival.gameObject.SetActive(false);
|
||||||
flood.gameObject.SetActive(false);
|
flood.gameObject.SetActive(false);
|
||||||
|
|
||||||
foreach (var pe in province.KnownEvents)
|
foreach (var pe in province.KnownEvents) {
|
||||||
{
|
switch (pe.SealedValueCase) {
|
||||||
switch (pe.SealedValueCase)
|
|
||||||
{
|
|
||||||
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.BeastsEvent:
|
case Net.Eagle0.Eagle.Common.ProvinceEvent.SealedValueOneofCase.BeastsEvent:
|
||||||
beasts.gameObject.SetActive(true);
|
beasts.gameObject.SetActive(true);
|
||||||
break;
|
break;
|
||||||
@@ -125,35 +123,24 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void Clicked() {}
|
||||||
|
|
||||||
public void Clicked()
|
public void OnPointerEnter(PointerEventData eventData) {
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerEnter(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
ShadeOn();
|
ShadeOn();
|
||||||
GetComponentInParent<DominionPanelController>().RowHovered(ProvinceId);
|
GetComponentInParent<DominionPanelController>().RowHovered(ProvinceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerExit(PointerEventData eventData)
|
public void OnPointerExit(PointerEventData eventData) {
|
||||||
{
|
|
||||||
ShadeOff();
|
ShadeOff();
|
||||||
GetComponentInParent<DominionPanelController>().RowUnhovered();
|
GetComponentInParent<DominionPanelController>().RowUnhovered();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerClick(PointerEventData eventData)
|
public void OnPointerClick(PointerEventData eventData) {
|
||||||
{
|
|
||||||
GetComponentInParent<DominionPanelController>().RowClicked(ProvinceId);
|
GetComponentInParent<DominionPanelController>().RowClicked(ProvinceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-21
@@ -5,10 +5,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class ExchangedHeroRowController : TableRowController {
|
||||||
public class ExchangedHeroRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public TMP_Text heroNameLabel;
|
public TMP_Text heroNameLabel;
|
||||||
public TMP_Text strLabel;
|
public TMP_Text strLabel;
|
||||||
@@ -23,33 +21,28 @@ namespace eagle
|
|||||||
public RawImage prisonerImage;
|
public RawImage prisonerImage;
|
||||||
public TMP_Text lastFactionLabel;
|
public TMP_Text lastFactionLabel;
|
||||||
|
|
||||||
public void SetHostage(HeroView hero, string factionName)
|
public void SetHostage(HeroView hero, string factionName) {
|
||||||
{
|
|
||||||
SetHero(hero, factionName);
|
SetHero(hero, factionName);
|
||||||
prisonerImage.gameObject.SetActive(false);
|
prisonerImage.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrisoner(HeroView hero, string factionName)
|
public void SetPrisoner(HeroView hero, string factionName) {
|
||||||
{
|
|
||||||
SetHero(hero, factionName);
|
SetHero(hero, factionName);
|
||||||
prisonerImage.gameObject.SetActive(true);
|
prisonerImage.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHero(HeroView hero, string factionName)
|
public void SetHero(HeroView hero, string factionName) {
|
||||||
{
|
professionImage.texture =
|
||||||
professionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(hero.Profession);
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
if (professionImage.texture == null)
|
hero.Profession);
|
||||||
{
|
if (professionImage.texture == null) {
|
||||||
professionImage.color = Color.clear;
|
professionImage.color = Color.clear;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
professionImage.color = Color.white;
|
professionImage.color = Color.white;
|
||||||
}
|
}
|
||||||
heroNameLabel.text = hero.Name;
|
heroNameLabel.text = hero.Name;
|
||||||
|
|
||||||
if (hero.Strength > 0)
|
if (hero.Strength > 0) {
|
||||||
{
|
|
||||||
strLabel.text = hero.Strength.ToString();
|
strLabel.text = hero.Strength.ToString();
|
||||||
agiLabel.text = hero.Agility.ToString();
|
agiLabel.text = hero.Agility.ToString();
|
||||||
wisLabel.text = hero.Wisdom.ToString();
|
wisLabel.text = hero.Wisdom.ToString();
|
||||||
@@ -58,9 +51,7 @@ namespace eagle
|
|||||||
|
|
||||||
archeryImage.gameObject.SetActive(hero.ArcheryCapable);
|
archeryImage.gameObject.SetActive(hero.ArcheryCapable);
|
||||||
fireImage.gameObject.SetActive(hero.StartFireCapable);
|
fireImage.gameObject.SetActive(hero.StartFireCapable);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strLabel.text = "";
|
strLabel.text = "";
|
||||||
agiLabel.text = "";
|
agiLabel.text = "";
|
||||||
wisLabel.text = "";
|
wisLabel.text = "";
|
||||||
|
|||||||
+2
-6
@@ -3,8 +3,7 @@ using System.Collections.Generic;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ExtraTroopsRowController : TableRowController
|
public class ExtraTroopsRowController : TableRowController {
|
||||||
{
|
|
||||||
public TMP_Text sizeField;
|
public TMP_Text sizeField;
|
||||||
public TMP_Text trainingField;
|
public TMP_Text trainingField;
|
||||||
public TMP_Text armamentField;
|
public TMP_Text armamentField;
|
||||||
@@ -14,8 +13,5 @@ public class ExtraTroopsRowController : TableRowController
|
|||||||
public double Armament { set => armamentField.text = ((int)value).ToString(); }
|
public double Armament { set => armamentField.text = ((int)value).ToString(); }
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-27
@@ -3,12 +3,10 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
|
||||||
using FactionId = System.Int32;
|
using FactionId = System.Int32;
|
||||||
|
|
||||||
public class FactionTableRow : TableRowController, IPointerEnterHandler, IPointerExitHandler
|
public class FactionTableRow : TableRowController, IPointerEnterHandler, IPointerExitHandler {
|
||||||
{
|
|
||||||
public TMP_Text factionLabel;
|
public TMP_Text factionLabel;
|
||||||
public TMP_Text provinceCountLabel;
|
public TMP_Text provinceCountLabel;
|
||||||
public TMP_Text treatyStatusLabel;
|
public TMP_Text treatyStatusLabel;
|
||||||
@@ -18,43 +16,29 @@ namespace eagle
|
|||||||
|
|
||||||
public FactionId FactionId;
|
public FactionId FactionId;
|
||||||
|
|
||||||
public string Faction
|
public string Faction { set => factionLabel.text = value; }
|
||||||
{
|
|
||||||
set => factionLabel.text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color FactionColor
|
public Color FactionColor {
|
||||||
{
|
|
||||||
get => _factionColor;
|
get => _factionColor;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_factionColor = value;
|
_factionColor = value;
|
||||||
colorBox.color = value;
|
colorBox.color = value;
|
||||||
provinceCountLabel.outlineColor = value;
|
provinceCountLabel.outlineColor = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ProvinceCount
|
public int ProvinceCount { set => provinceCountLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => provinceCountLabel.text = value.ToString();
|
public string TreatyStatus {
|
||||||
|
set { treatyStatusLabel.text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TreatyStatus
|
public void OnPointerEnter(PointerEventData eventData) {
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
treatyStatusLabel.text = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerEnter(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
ShadeOn();
|
ShadeOn();
|
||||||
GetComponentInParent<FocusInfoPanelController>().FactionRowHovered(FactionId);
|
GetComponentInParent<FocusInfoPanelController>().FactionRowHovered(FactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerExit(PointerEventData eventData)
|
public void OnPointerExit(PointerEventData eventData) {
|
||||||
{
|
|
||||||
ShadeOff();
|
ShadeOff();
|
||||||
GetComponentInParent<FocusInfoPanelController>().FactionRowUnhovered();
|
GetComponentInParent<FocusInfoPanelController>().FactionRowUnhovered();
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-21
@@ -4,10 +4,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class HeroRowController : TableRowController {
|
||||||
public class HeroRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public TMP_Text heroNameLabel;
|
public TMP_Text heroNameLabel;
|
||||||
public TMP_Text strengthLabel;
|
public TMP_Text strengthLabel;
|
||||||
@@ -25,24 +23,20 @@ namespace eagle
|
|||||||
public RawImage archeryImage;
|
public RawImage archeryImage;
|
||||||
public RawImage fireImage;
|
public RawImage fireImage;
|
||||||
|
|
||||||
public HeroView Hero
|
public HeroView Hero {
|
||||||
{
|
set {
|
||||||
set
|
professionImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
professionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(value.Profession);
|
value.Profession);
|
||||||
if (professionImage.texture == null)
|
if (professionImage.texture == null) {
|
||||||
{
|
|
||||||
professionImage.color = Color.clear;
|
professionImage.color = Color.clear;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
professionImage.color = Color.white;
|
professionImage.color = Color.white;
|
||||||
}
|
}
|
||||||
heroNameLabel.text = value.Name;
|
heroNameLabel.text = value.Name;
|
||||||
|
|
||||||
// not ideal -- this is just so we don't show 0s for scouted heroes
|
// not ideal -- this is just so we don't show 0s for scouted heroes
|
||||||
if (value.Strength != 0)
|
if (value.Strength != 0) {
|
||||||
{
|
|
||||||
strengthLabel.text = value.Strength.ToString();
|
strengthLabel.text = value.Strength.ToString();
|
||||||
strengthXpLabel.text = $"({value.StrengthXp})";
|
strengthXpLabel.text = $"({value.StrengthXp})";
|
||||||
agilityLabel.text = value.Agility.ToString();
|
agilityLabel.text = value.Agility.ToString();
|
||||||
@@ -51,15 +45,17 @@ namespace eagle
|
|||||||
wisdomXpLabel.text = $"({value.WisdomXp})";
|
wisdomXpLabel.text = $"({value.WisdomXp})";
|
||||||
charismaLabel.text = value.Charisma.ToString();
|
charismaLabel.text = value.Charisma.ToString();
|
||||||
charismaXpLabel.text = $"({value.CharismaXp})";
|
charismaXpLabel.text = $"({value.CharismaXp})";
|
||||||
vigorLabel.text = value.Vigor == null ? null : GUIUtils.ConditionString(value.Vigor) + "/" + (value.Constitution.ToString());
|
vigorLabel.text = value.Vigor == null
|
||||||
|
? null
|
||||||
|
: GUIUtils.ConditionString(value.Vigor) + "/" +
|
||||||
|
(value.Constitution.ToString());
|
||||||
constitutionXpLabel.text = $"({value.ConstitutionXp})";
|
constitutionXpLabel.text = $"({value.ConstitutionXp})";
|
||||||
loyaltyLabel.text = value.Loyalty == null ? "—" : GUIUtils.ConditionString(value.Loyalty);
|
loyaltyLabel.text =
|
||||||
|
value.Loyalty == null ? "—" : GUIUtils.ConditionString(value.Loyalty);
|
||||||
|
|
||||||
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
||||||
fireImage.gameObject.SetActive(value.StartFireCapable);
|
fireImage.gameObject.SetActive(value.StartFireCapable);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strengthLabel.text = "?";
|
strengthLabel.text = "?";
|
||||||
strengthXpLabel.text = "?";
|
strengthXpLabel.text = "?";
|
||||||
agilityLabel.text = "?";
|
agilityLabel.text = "?";
|
||||||
|
|||||||
+6
-20
@@ -1,33 +1,19 @@
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class IncomingArmyTableRow : TableRowController {
|
||||||
public class IncomingArmyTableRow : TableRowController
|
|
||||||
{
|
|
||||||
public TMP_Text factionLabel;
|
public TMP_Text factionLabel;
|
||||||
public TMP_Text heroCountLabel;
|
public TMP_Text heroCountLabel;
|
||||||
public TMP_Text troopCountLabel;
|
public TMP_Text troopCountLabel;
|
||||||
public TMP_Text originLabel;
|
public TMP_Text originLabel;
|
||||||
|
|
||||||
public string Faction
|
public string Faction { set => factionLabel.text = value; }
|
||||||
{
|
|
||||||
set => factionLabel.text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int HeroCount
|
public int HeroCount { set => heroCountLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => heroCountLabel.text = value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int TroopCount
|
public int TroopCount { set => troopCountLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => troopCountLabel.text = value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Origin
|
public string Origin { set => originLabel.text = value; }
|
||||||
{
|
|
||||||
set => originLabel.text = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+19
-40
@@ -2,10 +2,10 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class MovingArmyTableRow : TableRowController,
|
||||||
public class MovingArmyTableRow : TableRowController, IPointerEnterHandler, IPointerExitHandler
|
IPointerEnterHandler,
|
||||||
{
|
IPointerExitHandler {
|
||||||
public GameObject factionRow;
|
public GameObject factionRow;
|
||||||
public TMP_Text factionLabel;
|
public TMP_Text factionLabel;
|
||||||
public GameObject heroesTroopsRow;
|
public GameObject heroesTroopsRow;
|
||||||
@@ -17,20 +17,16 @@ namespace eagle
|
|||||||
public TMP_Text originLabel;
|
public TMP_Text originLabel;
|
||||||
public TMP_Text destinationLabel;
|
public TMP_Text destinationLabel;
|
||||||
|
|
||||||
public string Faction
|
public string Faction {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
factionLabel.text = value;
|
factionLabel.text = value;
|
||||||
factionRow.SetActive(!string.IsNullOrEmpty(value));
|
factionRow.SetActive(!string.IsNullOrEmpty(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _heroCount;
|
private int _heroCount;
|
||||||
public int HeroCount
|
public int HeroCount {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_heroCount = value;
|
_heroCount = value;
|
||||||
heroCountLabel.text = _heroCount.ToString();
|
heroCountLabel.text = _heroCount.ToString();
|
||||||
heroesTroopsRow.SetActive(_heroCount != 0 || _troopCount != 0);
|
heroesTroopsRow.SetActive(_heroCount != 0 || _troopCount != 0);
|
||||||
@@ -38,10 +34,8 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int _troopCount;
|
private int _troopCount;
|
||||||
public int TroopCount
|
public int TroopCount {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_troopCount = value;
|
_troopCount = value;
|
||||||
troopCountLabel.text = value.ToString();
|
troopCountLabel.text = value.ToString();
|
||||||
heroesTroopsRow.SetActive(_heroCount != 0 || _troopCount != 0);
|
heroesTroopsRow.SetActive(_heroCount != 0 || _troopCount != 0);
|
||||||
@@ -49,10 +43,8 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int _food = 0;
|
private int _food = 0;
|
||||||
public int Food
|
public int Food {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_food = value;
|
_food = value;
|
||||||
foodLabel.text = _food.ToString();
|
foodLabel.text = _food.ToString();
|
||||||
suppliesRow.SetActive(_food != 0 || _gold != 0);
|
suppliesRow.SetActive(_food != 0 || _gold != 0);
|
||||||
@@ -60,39 +52,26 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int _gold = 0;
|
private int _gold = 0;
|
||||||
public int Gold
|
public int Gold {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_gold = value;
|
_gold = value;
|
||||||
goldLabel.text = _gold.ToString();
|
goldLabel.text = _gold.ToString();
|
||||||
suppliesRow.SetActive(_food != 0 || _gold != 0);
|
suppliesRow.SetActive(_food != 0 || _gold != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Origin
|
public string Origin { set => originLabel.text = value; }
|
||||||
{
|
|
||||||
set => originLabel.text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Destination
|
public string Destination { set => destinationLabel.text = value; }
|
||||||
{
|
|
||||||
set => destinationLabel.text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color DestinationColor
|
public Color DestinationColor { set => destinationLabel.color = value; }
|
||||||
{
|
|
||||||
set => destinationLabel.color = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerEnter(PointerEventData eventData)
|
public void OnPointerEnter(PointerEventData eventData) {
|
||||||
{
|
|
||||||
GetComponentInParent<FocusInfoPanelController>().MovingArmyRowHovered(this);
|
GetComponentInParent<FocusInfoPanelController>().MovingArmyRowHovered(this);
|
||||||
ShadeOn();
|
ShadeOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerExit(PointerEventData eventData)
|
public void OnPointerExit(PointerEventData eventData) {
|
||||||
{
|
|
||||||
GetComponentInParent<FocusInfoPanelController>().FactionRowUnhovered();
|
GetComponentInParent<FocusInfoPanelController>().FactionRowUnhovered();
|
||||||
ShadeOff();
|
ShadeOff();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-21
@@ -3,10 +3,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class OrganizeTroopsComponentRow : MonoBehaviour {
|
||||||
public class OrganizeTroopsComponentRow : MonoBehaviour
|
|
||||||
{
|
|
||||||
public TMP_Text sizeField;
|
public TMP_Text sizeField;
|
||||||
public TMP_Text armamentField;
|
public TMP_Text armamentField;
|
||||||
public TMP_Text trainingField;
|
public TMP_Text trainingField;
|
||||||
@@ -15,28 +13,21 @@ namespace eagle
|
|||||||
public Image armamentBackground;
|
public Image armamentBackground;
|
||||||
public Image trainingBackground;
|
public Image trainingBackground;
|
||||||
|
|
||||||
public BattalionComponent BattalionComponent
|
public BattalionComponent BattalionComponent {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
armamentField.text = Math.Floor(value.armament).ToString();
|
armamentField.text = Math.Floor(value.armament).ToString();
|
||||||
trainingField.text = Math.Floor(value.training).ToString();
|
trainingField.text = Math.Floor(value.training).ToString();
|
||||||
sizeField.text = value.count.ToString();
|
sizeField.text = value.count.ToString();
|
||||||
|
|
||||||
Color color = Color.black;
|
Color color = Color.black;
|
||||||
switch (value.source)
|
switch (value.source) {
|
||||||
{
|
|
||||||
case BattalionComponent.ComponentSource.originalTroops:
|
case BattalionComponent.ComponentSource.originalTroops:
|
||||||
color = Color.black;
|
color = Color.black;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BattalionComponent.ComponentSource.mergedTroops:
|
case BattalionComponent.ComponentSource.mergedTroops: color = Color.blue; break;
|
||||||
color = Color.blue;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BattalionComponent.ComponentSource.newTroops:
|
case BattalionComponent.ComponentSource.newTroops: color = Color.green; break;
|
||||||
color = Color.green;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
color.a = 0.25f;
|
color.a = 0.25f;
|
||||||
@@ -47,10 +38,6 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-40
@@ -3,10 +3,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class OrganizeTroopsResultRow : MonoBehaviour {
|
||||||
public class OrganizeTroopsResultRow : MonoBehaviour
|
|
||||||
{
|
|
||||||
public RawImage battalionImage;
|
public RawImage battalionImage;
|
||||||
public TMP_Text priceLabel;
|
public TMP_Text priceLabel;
|
||||||
public TMP_Text newTrainingLabel;
|
public TMP_Text newTrainingLabel;
|
||||||
@@ -16,50 +14,25 @@ namespace eagle
|
|||||||
public TMP_Text totalCostLabel;
|
public TMP_Text totalCostLabel;
|
||||||
public TMP_Text battalionNameLabel;
|
public TMP_Text battalionNameLabel;
|
||||||
|
|
||||||
private void Start()
|
private void Start() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Texture BattalionImage
|
public Texture BattalionImage { set => battalionImage.texture = value; }
|
||||||
{
|
|
||||||
set => battalionImage.texture = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Price
|
public double Price { set => priceLabel.text = value.ToString("0.##"); }
|
||||||
{
|
|
||||||
set => priceLabel.text = value.ToString("0.##");
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Training
|
public double Training { set => newTrainingLabel.text = Math.Floor(value).ToString(); }
|
||||||
{
|
|
||||||
set => newTrainingLabel.text = Math.Floor(value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Armament
|
public double Armament { set => newArmamentLabel.text = Math.Floor(value).ToString(); }
|
||||||
{
|
|
||||||
set => newArmamentLabel.text = Math.Floor(value).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Size
|
public int Size { set => newSizeLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => newSizeLabel.text = value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Capacity
|
public int Capacity { set => sizeCapLabel.text = value.ToString(); }
|
||||||
{
|
|
||||||
set => sizeCapLabel.text = value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
public string Name {
|
||||||
{
|
set {
|
||||||
set
|
if (string.IsNullOrEmpty(value)) {
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
battalionNameLabel.gameObject.SetActive(false);
|
battalionNameLabel.gameObject.SetActive(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
battalionNameLabel.gameObject.SetActive(true);
|
battalionNameLabel.gameObject.SetActive(true);
|
||||||
battalionNameLabel.text = value;
|
battalionNameLabel.text = value;
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-67
@@ -4,15 +4,14 @@ using System.Linq;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class OrganizeTroopsTableRow : TableRowController {
|
||||||
public class OrganizeTroopsTableRow : TableRowController
|
|
||||||
{
|
|
||||||
public LayoutElement layoutElement;
|
public LayoutElement layoutElement;
|
||||||
public OrganizeTroopsResultRow resultRow;
|
public OrganizeTroopsResultRow resultRow;
|
||||||
public OrganizeTroopsComponentRow componentRowPrefab;
|
public OrganizeTroopsComponentRow componentRowPrefab;
|
||||||
public Transform componentsLayoutTransform;
|
public Transform componentsLayoutTransform;
|
||||||
private List<OrganizeTroopsComponentRow> existingComponents = new List<OrganizeTroopsComponentRow>();
|
private List<OrganizeTroopsComponentRow> existingComponents =
|
||||||
|
new List<OrganizeTroopsComponentRow>();
|
||||||
|
|
||||||
public Toggle disclosureTriangle;
|
public Toggle disclosureTriangle;
|
||||||
|
|
||||||
@@ -29,28 +28,23 @@ namespace eagle
|
|||||||
private BattalionDisplayInfo _displayInfo;
|
private BattalionDisplayInfo _displayInfo;
|
||||||
|
|
||||||
private bool _canAugment = true;
|
private bool _canAugment = true;
|
||||||
public Boolean CanAugment
|
public Boolean CanAugment {
|
||||||
{
|
|
||||||
get => _canAugment;
|
get => _canAugment;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_canAugment = value;
|
_canAugment = value;
|
||||||
SetButtons();
|
SetButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetButtons()
|
private void SetButtons() {
|
||||||
{
|
|
||||||
AllowPlus = BattalionInfo.Count < BattalionInfo.Capacity && CanAugment;
|
AllowPlus = BattalionInfo.Count < BattalionInfo.Capacity && CanAugment;
|
||||||
AllowMax = BattalionInfo.Count < BattalionInfo.Capacity && CanAugment;
|
AllowMax = BattalionInfo.Count < BattalionInfo.Capacity && CanAugment;
|
||||||
AllowMinus = BattalionInfo.Count > 0;
|
AllowMinus = BattalionInfo.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattalionDisplayInfo BattalionInfo
|
public BattalionDisplayInfo BattalionInfo {
|
||||||
{
|
|
||||||
get => _displayInfo;
|
get => _displayInfo;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_displayInfo = value;
|
_displayInfo = value;
|
||||||
|
|
||||||
resultRow.BattalionImage = value.Image;
|
resultRow.BattalionImage = value.Image;
|
||||||
@@ -71,84 +65,58 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<BattalionComponent> _components = new List<BattalionComponent>();
|
private List<BattalionComponent> _components = new List<BattalionComponent>();
|
||||||
public List<BattalionComponent> Components
|
public List<BattalionComponent> Components { get => _components; }
|
||||||
{
|
|
||||||
get => _components;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawComponents()
|
private void DrawComponents() {
|
||||||
{
|
|
||||||
existingComponents.ForEach(t => Destroy(t.gameObject));
|
existingComponents.ForEach(t => Destroy(t.gameObject));
|
||||||
existingComponents.Clear();
|
existingComponents.Clear();
|
||||||
|
|
||||||
var resultHeight = resultRow.GetComponent<LayoutElement>().minHeight;
|
var resultHeight = resultRow.GetComponent<LayoutElement>().minHeight;
|
||||||
|
|
||||||
if (disclosureTriangle.isOn)
|
if (disclosureTriangle.isOn) {
|
||||||
{
|
|
||||||
existingComponents = Components
|
existingComponents = Components
|
||||||
.Select(comp =>
|
.Select(comp => {
|
||||||
{
|
var cr = Instantiate(
|
||||||
var cr = Instantiate(componentRowPrefab, componentsLayoutTransform);
|
componentRowPrefab,
|
||||||
cr.BattalionComponent = comp;
|
componentsLayoutTransform);
|
||||||
return cr;
|
cr.BattalionComponent = comp;
|
||||||
})
|
return cr;
|
||||||
.ToList();
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
layoutElement.minHeight = resultHeight + existingComponents.Select(c => c.gameObject.GetComponent<LayoutElement>().minHeight).Sum();
|
layoutElement.minHeight =
|
||||||
}
|
resultHeight +
|
||||||
else
|
existingComponents
|
||||||
{
|
.Select(c => c.gameObject.GetComponent<LayoutElement>().minHeight)
|
||||||
|
.Sum();
|
||||||
|
} else {
|
||||||
layoutElement.minHeight = resultHeight;
|
layoutElement.minHeight = resultHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
private void Start()
|
private void Start() {
|
||||||
{
|
|
||||||
disclosureTriangle.isOn = BattalionInfo != null && BattalionInfo.Open;
|
disclosureTriangle.isOn = BattalionInfo != null && BattalionInfo.Open;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisclosureTriangleToggled(bool newValue) {
|
||||||
public void DisclosureTriangleToggled(bool newValue)
|
|
||||||
{
|
|
||||||
BattalionInfo.Open = newValue;
|
BattalionInfo.Open = newValue;
|
||||||
|
|
||||||
DrawComponents();
|
DrawComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AllowPlus
|
public bool AllowPlus { set => plusButton.interactable = value; }
|
||||||
{
|
|
||||||
set => plusButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowMinus
|
public bool AllowMinus { set => minusButton.interactable = value; }
|
||||||
{
|
|
||||||
set => minusButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowMax
|
public bool AllowMax { set => maxButton.interactable = value; }
|
||||||
{
|
|
||||||
set => maxButton.interactable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PlusButtonClicked()
|
public void PlusButtonClicked() { PlusButtonClickedCallback(); }
|
||||||
{
|
|
||||||
PlusButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MinusButtonClicked()
|
public void MinusButtonClicked() { MinusButtonClickedCallback(); }
|
||||||
{
|
|
||||||
MinusButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MaxButtonClicked()
|
public void MaxButtonClicked() { MaxButtonClickedCallback(); }
|
||||||
{
|
|
||||||
MaxButtonClickedCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DismissButtonClicked()
|
public void DismissButtonClicked() { DismissButtonClickedCallback(); }
|
||||||
{
|
|
||||||
DismissButtonClickedCallback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+37
-52
@@ -6,10 +6,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class SelectedUnitRowController : TableRowController {
|
||||||
public class SelectedUnitRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public RawImage archeryImage;
|
public RawImage archeryImage;
|
||||||
public RawImage fireImage;
|
public RawImage fireImage;
|
||||||
@@ -23,22 +21,18 @@ namespace eagle
|
|||||||
public RawImage armamentImage;
|
public RawImage armamentImage;
|
||||||
public TMP_Text battalionNameLabel;
|
public TMP_Text battalionNameLabel;
|
||||||
|
|
||||||
public HeroView Hero
|
public HeroView Hero {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
|
|
||||||
archeryImage.gameObject.SetActive(false);
|
archeryImage.gameObject.SetActive(false);
|
||||||
fireImage.gameObject.SetActive(false);
|
fireImage.gameObject.SetActive(false);
|
||||||
|
|
||||||
if (value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
heroNameLabel.text = "None";
|
heroNameLabel.text = "None";
|
||||||
heroNameLabel.color = Color.red;
|
heroNameLabel.color = Color.red;
|
||||||
}
|
} else {
|
||||||
else
|
professionImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
professionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(value.Profession);
|
value.Profession);
|
||||||
heroNameLabel.text = value.Name;
|
heroNameLabel.text = value.Name;
|
||||||
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
||||||
fireImage.gameObject.SetActive(value.StartFireCapable);
|
fireImage.gameObject.SetActive(value.StartFireCapable);
|
||||||
@@ -47,10 +41,8 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnityEngine.Events.UnityAction HeroClickDetector
|
public UnityEngine.Events.UnityAction HeroClickDetector {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
heroNameLabel.GetComponent<TableRowClickDetector>().onClick.AddListener(value);
|
heroNameLabel.GetComponent<TableRowClickDetector>().onClick.AddListener(value);
|
||||||
heroNameLabel.GetComponent<TableRowClickDetector>().selectable = true;
|
heroNameLabel.GetComponent<TableRowClickDetector>().selectable = true;
|
||||||
professionImage.GetComponent<TableRowClickDetector>().onClick.AddListener(value);
|
professionImage.GetComponent<TableRowClickDetector>().onClick.AddListener(value);
|
||||||
@@ -62,27 +54,19 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Appropriate
|
public bool Appropriate {
|
||||||
{
|
set {
|
||||||
set
|
if (value) {
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
heroNameLabel.color = Color.black;
|
heroNameLabel.color = Color.black;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
heroNameLabel.color = Color.red;
|
heroNameLabel.color = Color.red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattalionView Battalion
|
public BattalionView Battalion {
|
||||||
{
|
set {
|
||||||
set
|
if (value == null) {
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
battalionImage.color = Color.clear;
|
battalionImage.color = Color.clear;
|
||||||
trainImage.color = Color.clear;
|
trainImage.color = Color.clear;
|
||||||
armamentImage.color = Color.clear;
|
armamentImage.color = Color.clear;
|
||||||
@@ -90,14 +74,11 @@ namespace eagle
|
|||||||
trainingLabel.text = "";
|
trainingLabel.text = "";
|
||||||
armamentLabel.text = "";
|
armamentLabel.text = "";
|
||||||
battalionNameLabel.text = "";
|
battalionNameLabel.text = "";
|
||||||
}
|
} else {
|
||||||
else
|
battalionImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(
|
||||||
battalionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().BattalionType(value.Type);
|
value.Type);
|
||||||
if (battalionImage.texture == null)
|
if (battalionImage.texture == null) { battalionImage.color = Color.clear; }
|
||||||
{
|
|
||||||
battalionImage.color = Color.clear;
|
|
||||||
}
|
|
||||||
sizeLabel.text = value.Size.ToString();
|
sizeLabel.text = value.Size.ToString();
|
||||||
trainingLabel.text = ((int)value.Training).ToString();
|
trainingLabel.text = ((int)value.Training).ToString();
|
||||||
armamentLabel.text = ((int)value.Armament).ToString();
|
armamentLabel.text = ((int)value.Armament).ToString();
|
||||||
@@ -106,21 +87,25 @@ namespace eagle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnityEngine.Events.UnityAction BattalionClickDetector
|
public UnityEngine.Events.UnityAction BattalionClickDetector {
|
||||||
{
|
set {
|
||||||
set
|
battalionImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
{
|
value);
|
||||||
battalionImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
|
||||||
battalionImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
battalionImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
sizeLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
sizeLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
value);
|
||||||
sizeLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
sizeLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
trainingLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
trainingLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
value);
|
||||||
trainingLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
trainingLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
armamentLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
armamentLabel.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
value);
|
||||||
armamentLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
armamentLabel.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
trainImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
trainImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
value);
|
||||||
trainImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
trainImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
armamentImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(value);
|
armamentImage.GetComponentInChildren<TableRowClickDetector>().onClick.AddListener(
|
||||||
|
value);
|
||||||
armamentImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
armamentImage.GetComponentInChildren<TableRowClickDetector>().selectable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-41
@@ -2,79 +2,63 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class TableRowController : MonoBehaviour
|
public class TableRowController : MonoBehaviour {
|
||||||
{
|
|
||||||
public TableRowClickDetector ClickDetector => GetComponent<TableRowClickDetector>();
|
public TableRowClickDetector ClickDetector => GetComponent<TableRowClickDetector>();
|
||||||
|
|
||||||
public EagleCommonTextures CommonTextures => gameObject.GetComponentInParent<EagleCommonTextures>();
|
public EagleCommonTextures CommonTextures =>
|
||||||
|
gameObject.GetComponentInParent<EagleCommonTextures>();
|
||||||
|
|
||||||
private bool _selected = false;
|
private bool _selected = false;
|
||||||
public bool Selected
|
public bool Selected {
|
||||||
{
|
|
||||||
get => _selected;
|
get => _selected;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_selected = value;
|
_selected = value;
|
||||||
ColorRow();
|
ColorRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color _backgroundColor = Color.white;
|
private Color _backgroundColor = Color.white;
|
||||||
virtual public Color BackgroundColor
|
virtual public Color BackgroundColor {
|
||||||
{
|
|
||||||
get => _backgroundColor;
|
get => _backgroundColor;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
_backgroundColor = value;
|
_backgroundColor = value;
|
||||||
ColorRow();
|
ColorRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Selectable
|
public bool Selectable {
|
||||||
{
|
|
||||||
get => ClickDetector != null && ClickDetector.selectable;
|
get => ClickDetector != null && ClickDetector.selectable;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
if (ClickDetector != null) ClickDetector.selectable = value;
|
if (ClickDetector != null) ClickDetector.selectable = value;
|
||||||
if (!value) Selected = false;
|
if (!value) Selected = false;
|
||||||
ColorRow();
|
ColorRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RightSelectable
|
public bool RightSelectable {
|
||||||
{
|
|
||||||
get => ClickDetector != null && ClickDetector.rightSelectable;
|
get => ClickDetector != null && ClickDetector.rightSelectable;
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
if (ClickDetector != null) ClickDetector.rightSelectable = value;
|
if (ClickDetector != null) ClickDetector.rightSelectable = value;
|
||||||
ColorRow();
|
ColorRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color _textColor = Color.black;
|
private Color _textColor = Color.black;
|
||||||
public Color TextColor
|
public Color TextColor {
|
||||||
{
|
set {
|
||||||
set
|
|
||||||
{
|
|
||||||
_textColor = value;
|
_textColor = value;
|
||||||
foreach (var text in gameObject.GetComponentsInChildren<TMP_Text>())
|
foreach (var text in gameObject.GetComponentsInChildren<TMP_Text>()) {
|
||||||
{
|
|
||||||
text.color = _textColor;
|
text.color = _textColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ColorRow()
|
public void ColorRow() {
|
||||||
{
|
if (ClickDetector != null) {
|
||||||
if (ClickDetector != null)
|
|
||||||
{
|
|
||||||
var newColor = Color.black;
|
var newColor = Color.black;
|
||||||
if (Selected)
|
if (Selected) {
|
||||||
{
|
|
||||||
newColor = Color.blue;
|
newColor = Color.blue;
|
||||||
}
|
} else if (!Selectable && !RightSelectable) {
|
||||||
else if (!Selectable && !RightSelectable)
|
|
||||||
{
|
|
||||||
newColor = Color.gray;
|
newColor = Color.gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,14 +67,13 @@ public class TableRowController : MonoBehaviour
|
|||||||
gameObject.GetComponent<Image>().color = BackgroundColor;
|
gameObject.GetComponent<Image>().color = BackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShadeOn()
|
public void ShadeOn() {
|
||||||
{
|
var shadedBackground = new Color(
|
||||||
var shadedBackground = new Color(BackgroundColor.r - 0.25f, BackgroundColor.g - 0.25f, BackgroundColor.b + 0.25f);
|
BackgroundColor.r - 0.25f,
|
||||||
|
BackgroundColor.g - 0.25f,
|
||||||
|
BackgroundColor.b + 0.25f);
|
||||||
gameObject.GetComponent<Image>().color = shadedBackground;
|
gameObject.GetComponent<Image>().color = shadedBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShadeOff()
|
public void ShadeOff() { gameObject.GetComponent<Image>().color = BackgroundColor; }
|
||||||
{
|
|
||||||
gameObject.GetComponent<Image>().color = BackgroundColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-22
@@ -4,10 +4,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class UnaffiliatedHeroRowController : TableRowController {
|
||||||
public class UnaffiliatedHeroRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public TMP_Text heroNameLabel;
|
public TMP_Text heroNameLabel;
|
||||||
public TMP_Text questLabel;
|
public TMP_Text questLabel;
|
||||||
@@ -20,35 +18,31 @@ namespace eagle
|
|||||||
public RawImage archeryImage;
|
public RawImage archeryImage;
|
||||||
public RawImage fireImage;
|
public RawImage fireImage;
|
||||||
|
|
||||||
public void SetUnaffiliatedHero(UnaffiliatedHeroBasics uh, GameModel model)
|
public void SetUnaffiliatedHero(UnaffiliatedHeroBasics uh, GameModel model) {
|
||||||
{
|
professionImage.texture =
|
||||||
professionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(uh.Profession);
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
if (professionImage.texture == null)
|
uh.Profession);
|
||||||
{
|
if (professionImage.texture == null) {
|
||||||
professionImage.color = Color.clear;
|
professionImage.color = Color.clear;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
professionImage.color = Color.white;
|
professionImage.color = Color.white;
|
||||||
}
|
}
|
||||||
heroNameLabel.text = uh.Name;
|
heroNameLabel.text = uh.Name;
|
||||||
|
|
||||||
switch (uh.RecruitmentInfo.Status)
|
switch (uh.RecruitmentInfo.Status) {
|
||||||
{
|
|
||||||
case Net.Eagle0.Eagle.Common.RecruitmentStatus.HasQuest:
|
case Net.Eagle0.Eagle.Common.RecruitmentStatus.HasQuest:
|
||||||
questLabel.text = DisplayNames.ShortQuestString(uh.RecruitmentInfo.Quest, model);
|
questLabel.text =
|
||||||
|
DisplayNames.ShortQuestString(uh.RecruitmentInfo.Quest, model);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
questLabel.text = DisplayNames.ShortRecruitmentStatusString(uh.RecruitmentInfo);
|
questLabel.text = DisplayNames.ShortRecruitmentStatusString(uh.RecruitmentInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Heroes.ContainsKey(uh.HeroId))
|
if (model.Heroes.ContainsKey(uh.HeroId)) {
|
||||||
{
|
|
||||||
var hero = model.Heroes[uh.HeroId];
|
var hero = model.Heroes[uh.HeroId];
|
||||||
|
|
||||||
if (hero.Strength > 0)
|
if (hero.Strength > 0) {
|
||||||
{
|
|
||||||
strLabel.text = hero.Strength.ToString();
|
strLabel.text = hero.Strength.ToString();
|
||||||
agiLabel.text = hero.Agility.ToString();
|
agiLabel.text = hero.Agility.ToString();
|
||||||
wisLabel.text = hero.Wisdom.ToString();
|
wisLabel.text = hero.Wisdom.ToString();
|
||||||
@@ -57,9 +51,7 @@ namespace eagle
|
|||||||
|
|
||||||
archeryImage.gameObject.SetActive(hero.ArcheryCapable);
|
archeryImage.gameObject.SetActive(hero.ArcheryCapable);
|
||||||
fireImage.gameObject.SetActive(hero.StartFireCapable);
|
fireImage.gameObject.SetActive(hero.StartFireCapable);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strLabel.text = "";
|
strLabel.text = "";
|
||||||
agiLabel.text = "";
|
agiLabel.text = "";
|
||||||
wisLabel.text = "";
|
wisLabel.text = "";
|
||||||
|
|||||||
+7
-9
@@ -4,20 +4,18 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace eagle
|
namespace eagle {
|
||||||
{
|
public class UnitSelectorHeroRowController : TableRowController {
|
||||||
public class UnitSelectorHeroRowController : TableRowController
|
|
||||||
{
|
|
||||||
public RawImage professionImage;
|
public RawImage professionImage;
|
||||||
public RawImage archeryImage;
|
public RawImage archeryImage;
|
||||||
public RawImage fireImage;
|
public RawImage fireImage;
|
||||||
public TMP_Text heroNameLabel;
|
public TMP_Text heroNameLabel;
|
||||||
|
|
||||||
public HeroView Hero
|
public HeroView Hero {
|
||||||
{
|
set {
|
||||||
set
|
professionImage.texture =
|
||||||
{
|
gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
|
||||||
professionImage.texture = gameObject.GetComponentInParent<EagleCommonTextures>().Profession(value.Profession);
|
value.Profession);
|
||||||
heroNameLabel.text = value.Name;
|
heroNameLabel.text = value.Name;
|
||||||
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
archeryImage.gameObject.SetActive(value.ArcheryCapable);
|
||||||
fireImage.gameObject.SetActive(value.StartFireCapable);
|
fireImage.gameObject.SetActive(value.StartFireCapable);
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class TextureList : MonoBehaviour
|
public class TextureList : MonoBehaviour {
|
||||||
{
|
|
||||||
public List<Texture> textures;
|
public List<Texture> textures;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using Grpc.Core.Interceptors;
|
using Grpc.Core.Interceptors;
|
||||||
//using Grpc.Core.Logging;
|
// using Grpc.Core.Logging;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Net.Eagle0.Eagle.Api;
|
using Net.Eagle0.Eagle.Api;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -14,50 +14,52 @@ using Grpc.Net.Client;
|
|||||||
using Grpc.Net.Client.Web;
|
using Grpc.Net.Client.Web;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
||||||
public class EagleConnection : IDisposable
|
public class EagleConnection : IDisposable {
|
||||||
{
|
|
||||||
private static bool loggerSet = false;
|
private static bool loggerSet = false;
|
||||||
|
|
||||||
public readonly string PlayerName;
|
public readonly string PlayerName;
|
||||||
public readonly string Url;
|
public readonly string Url;
|
||||||
public readonly Metadata Credentials;
|
public readonly Metadata Credentials;
|
||||||
|
|
||||||
public static CancellationToken EagleCancellationToken => ConnectionKiller.EagleCancellationToken;
|
public static CancellationToken EagleCancellationToken =>
|
||||||
public static CancellationToken ShardokCancellationToken => ConnectionKiller.ShardokCancellationToken;
|
ConnectionKiller.EagleCancellationToken;
|
||||||
|
public static CancellationToken ShardokCancellationToken =>
|
||||||
|
ConnectionKiller.ShardokCancellationToken;
|
||||||
|
|
||||||
public Eagle.EagleClient EagleGrpcClient { get; private set; }
|
public Eagle.EagleClient EagleGrpcClient { get; private set; }
|
||||||
public ShardokInternalInterface.ShardokInternalInterfaceClient ShardokInternalInterfaceGrpcClient { get; private set; }
|
public ShardokInternalInterface
|
||||||
|
.ShardokInternalInterfaceClient ShardokInternalInterfaceGrpcClient {
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly SslCredentials sslCreds = new SslCredentials();
|
private readonly SslCredentials sslCreds = new SslCredentials();
|
||||||
private Action<GamesReply, StatusCode> repeatedCallback;
|
private Action<GamesReply, StatusCode> repeatedCallback;
|
||||||
private AsyncServerStreamingCall<GamesReply> streamingCall;
|
private AsyncServerStreamingCall<GamesReply> streamingCall;
|
||||||
|
|
||||||
private CallInvoker MakeInvoker(string playerName, string password, string url)
|
private CallInvoker MakeInvoker(string playerName, string password, string url) {
|
||||||
{
|
|
||||||
var authInterceptor = new AuthInterceptor(playerName, password);
|
var authInterceptor = new AuthInterceptor(playerName, password);
|
||||||
|
|
||||||
GrpcWebMode mode = GrpcWebMode.GrpcWebText;
|
GrpcWebMode mode = GrpcWebMode.GrpcWebText;
|
||||||
var channel = GrpcChannel.ForAddress("https://" + url, new GrpcChannelOptions
|
var channel = GrpcChannel.ForAddress(
|
||||||
{
|
"https://" + url,
|
||||||
HttpHandler = new GrpcWebHandler(mode, new HttpClientHandler()),
|
new GrpcChannelOptions {
|
||||||
Credentials = sslCreds,
|
HttpHandler = new GrpcWebHandler(mode, new HttpClientHandler()),
|
||||||
MaxReceiveMessageSize = null
|
Credentials = sslCreds,
|
||||||
});
|
MaxReceiveMessageSize = null
|
||||||
|
});
|
||||||
|
|
||||||
var invoker = channel.Intercept(authInterceptor);
|
var invoker = channel.Intercept(authInterceptor);
|
||||||
return invoker;
|
return invoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EagleConnection(string playerName, string password, string url)
|
public EagleConnection(string playerName, string password, string url) {
|
||||||
{
|
|
||||||
PlayerName = playerName;
|
PlayerName = playerName;
|
||||||
Url = url;
|
Url = url;
|
||||||
|
|
||||||
Credentials = new Metadata();
|
Credentials = new Metadata();
|
||||||
Credentials.Add("user", playerName);
|
Credentials.Add("user", playerName);
|
||||||
|
|
||||||
if (!loggerSet)
|
if (!loggerSet) {
|
||||||
{
|
|
||||||
loggerSet = true;
|
loggerSet = true;
|
||||||
|
|
||||||
string dir = Path.Combine(Application.persistentDataPath, "eagle0", "Resources");
|
string dir = Path.Combine(Application.persistentDataPath, "eagle0", "Resources");
|
||||||
@@ -70,23 +72,24 @@ public class EagleConnection : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
EagleGrpcClient = new Eagle.EagleClient(MakeInvoker(playerName, password, url));
|
EagleGrpcClient = new Eagle.EagleClient(MakeInvoker(playerName, password, url));
|
||||||
ShardokInternalInterfaceGrpcClient = new ShardokInternalInterface.ShardokInternalInterfaceClient(MakeInvoker(playerName, password, url));
|
ShardokInternalInterfaceGrpcClient =
|
||||||
|
new ShardokInternalInterface.ShardokInternalInterfaceClient(
|
||||||
|
MakeInvoker(playerName, password, url));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose() {
|
||||||
{
|
// GrpcEnvironment.SetLogger(null);
|
||||||
//GrpcEnvironment.SetLogger(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for bypassing the lobby screen
|
// Used for bypassing the lobby screen
|
||||||
public async Task<GameInfo> FirstRunningGame()
|
public async Task<GameInfo> FirstRunningGame() {
|
||||||
{
|
|
||||||
SslCredentials sslCreds = new SslCredentials();
|
SslCredentials sslCreds = new SslCredentials();
|
||||||
|
|
||||||
using (var call = EagleGrpcClient.EnterLobby(new GamesRequest(), cancellationToken: EagleCancellationToken))
|
using (var call = EagleGrpcClient.EnterLobby(
|
||||||
{
|
new GamesRequest(),
|
||||||
while (repeatedCallback != null && await streamingCall.ResponseStream.MoveNext(cancellationToken: EagleCancellationToken))
|
cancellationToken: EagleCancellationToken)) {
|
||||||
{
|
while (repeatedCallback != null && await streamingCall.ResponseStream.MoveNext(
|
||||||
|
cancellationToken: EagleCancellationToken)) {
|
||||||
return streamingCall.ResponseStream.Current.RunningGames[0];
|
return streamingCall.ResponseStream.Current.RunningGames[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,53 +97,44 @@ public class EagleConnection : IDisposable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> EnterLobby(Action<GamesReply, StatusCode> rc)
|
public async Task<bool> EnterLobby(Action<GamesReply, StatusCode> rc) {
|
||||||
{
|
|
||||||
SslCredentials sslCreds = new SslCredentials();
|
SslCredentials sslCreds = new SslCredentials();
|
||||||
|
|
||||||
using (var call = EagleGrpcClient.EnterLobby(new Net.Eagle0.Eagle.Api.GamesRequest(), cancellationToken: EagleCancellationToken))
|
using (var call = EagleGrpcClient.EnterLobby(
|
||||||
{
|
new Net.Eagle0.Eagle.Api.GamesRequest(),
|
||||||
|
cancellationToken: EagleCancellationToken)) {
|
||||||
repeatedCallback = rc;
|
repeatedCallback = rc;
|
||||||
streamingCall = call;
|
streamingCall = call;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
while (repeatedCallback != null &&
|
||||||
while (repeatedCallback != null && await streamingCall.ResponseStream.MoveNext(cancellationToken: EagleCancellationToken))
|
await streamingCall.ResponseStream.MoveNext(
|
||||||
{
|
cancellationToken: EagleCancellationToken)) {
|
||||||
if (repeatedCallback != null)
|
if (repeatedCallback != null) {
|
||||||
{
|
repeatedCallback.Invoke(
|
||||||
repeatedCallback.Invoke(streamingCall.ResponseStream.Current, StatusCode.OK);
|
streamingCall.ResponseStream.Current,
|
||||||
}
|
StatusCode.OK);
|
||||||
else
|
} else {
|
||||||
{
|
if (streamingCall != null) {
|
||||||
if (streamingCall != null)
|
|
||||||
{
|
|
||||||
streamingCall.Dispose();
|
streamingCall.Dispose();
|
||||||
streamingCall = null;
|
streamingCall = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (RpcException e) {
|
||||||
catch (RpcException e)
|
switch (e.StatusCode) {
|
||||||
{
|
|
||||||
switch (e.StatusCode)
|
|
||||||
{
|
|
||||||
case StatusCode.Cancelled:
|
case StatusCode.Cancelled:
|
||||||
case StatusCode.Internal:
|
case StatusCode.Internal:
|
||||||
if (repeatedCallback != null)
|
if (repeatedCallback != null) {
|
||||||
{
|
|
||||||
repeatedCallback.Invoke(null, e.StatusCode);
|
repeatedCallback.Invoke(null, e.StatusCode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (e.StatusCode == StatusCode.Internal)
|
if (e.StatusCode == StatusCode.Internal) {
|
||||||
{
|
|
||||||
Console.WriteLine("wut: {e}");
|
Console.WriteLine("wut: {e}");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Something went very wrong, caught exception {e}");
|
Console.WriteLine("Something went very wrong, caught exception {e}");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -149,11 +143,9 @@ public class EagleConnection : IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LeaveLobby()
|
public void LeaveLobby() {
|
||||||
{
|
|
||||||
repeatedCallback = null;
|
repeatedCallback = null;
|
||||||
if (streamingCall != null)
|
if (streamingCall != null) {
|
||||||
{
|
|
||||||
streamingCall.Dispose();
|
streamingCall.Dispose();
|
||||||
streamingCall = null;
|
streamingCall = null;
|
||||||
}
|
}
|
||||||
|
|||||||
+104
-143
@@ -1,16 +1,16 @@
|
|||||||
/// Credit glennpow, Zarlang
|
/// Credit glennpow, Zarlang
|
||||||
/// Sourced from - http://forum.unity3d.com/threads/free-script-particle-systems-in-ui-screen-space-overlay.406862/
|
/// Sourced from -
|
||||||
|
/// http://forum.unity3d.com/threads/free-script-particle-systems-in-ui-screen-space-overlay.406862/
|
||||||
/// Updated by Zarlang with a more robust implementation, including TextureSheet annimation support
|
/// Updated by Zarlang with a more robust implementation, including TextureSheet annimation support
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions {
|
||||||
{
|
|
||||||
#if UNITY_5_3_OR_NEWER
|
#if UNITY_5_3_OR_NEWER
|
||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
[RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))]
|
[RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))]
|
||||||
[AddComponentMenu("UI/Effects/Extensions/UIParticleSystem")]
|
[AddComponentMenu("UI/Effects/Extensions/UIParticleSystem")]
|
||||||
public class UIParticleSystem : MaskableGraphic
|
public class UIParticleSystem : MaskableGraphic {
|
||||||
{
|
[Tooltip(
|
||||||
[Tooltip("Having this enabled run the system in LateUpdate rather than in Update making it faster but less precise (more clunky)")]
|
"Having this enabled run the system in LateUpdate rather than in Update making it faster but less precise (more clunky)")]
|
||||||
public bool fixedTime = true;
|
public bool fixedTime = true;
|
||||||
|
|
||||||
[Tooltip("Enables 3d rotation for the particles")]
|
[Tooltip("Enables 3d rotation for the particles")]
|
||||||
@@ -35,67 +35,44 @@ namespace UnityEngine.UI.Extensions
|
|||||||
private ParticleSystem.MainModule mainModule;
|
private ParticleSystem.MainModule mainModule;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public override Texture mainTexture
|
public override Texture mainTexture {
|
||||||
{
|
get { return currentTexture; }
|
||||||
get
|
|
||||||
{
|
|
||||||
return currentTexture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool Initialize()
|
protected bool Initialize() {
|
||||||
{
|
|
||||||
// initialize members
|
// initialize members
|
||||||
if (_transform == null)
|
if (_transform == null) { _transform = transform; }
|
||||||
{
|
if (pSystem == null) {
|
||||||
_transform = transform;
|
|
||||||
}
|
|
||||||
if (pSystem == null)
|
|
||||||
{
|
|
||||||
pSystem = GetComponent<ParticleSystem>();
|
pSystem = GetComponent<ParticleSystem>();
|
||||||
|
|
||||||
if (pSystem == null)
|
if (pSystem == null) { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
mainModule = pSystem.main;
|
mainModule = pSystem.main;
|
||||||
if (pSystem.main.maxParticles > 14000)
|
if (pSystem.main.maxParticles > 14000) { mainModule.maxParticles = 14000; }
|
||||||
{
|
|
||||||
mainModule.maxParticles = 14000;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (pSystem.maxParticles > 14000)
|
if (pSystem.maxParticles > 14000) pSystem.maxParticles = 14000;
|
||||||
pSystem.maxParticles = 14000;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
||||||
if (pRenderer != null)
|
if (pRenderer != null) pRenderer.enabled = false;
|
||||||
pRenderer.enabled = false;
|
|
||||||
|
|
||||||
if (material == null)
|
if (material == null) {
|
||||||
{
|
|
||||||
var foundShader = Shader.Find("UI Extensions/Particles/Additive");
|
var foundShader = Shader.Find("UI Extensions/Particles/Additive");
|
||||||
if (foundShader)
|
if (foundShader) { material = new Material(foundShader); }
|
||||||
{
|
|
||||||
material = new Material(foundShader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMaterial = material;
|
currentMaterial = material;
|
||||||
if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
|
if (currentMaterial && currentMaterial.HasProperty("_MainTex")) {
|
||||||
{
|
|
||||||
currentTexture = currentMaterial.mainTexture;
|
currentTexture = currentMaterial.mainTexture;
|
||||||
if (currentTexture == null)
|
if (currentTexture == null) currentTexture = Texture2D.whiteTexture;
|
||||||
currentTexture = Texture2D.whiteTexture;
|
|
||||||
}
|
}
|
||||||
material = currentMaterial;
|
material = currentMaterial;
|
||||||
// automatically set scaling
|
// automatically set scaling
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
#else
|
#else
|
||||||
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
particles = null;
|
particles = null;
|
||||||
@@ -104,8 +81,7 @@ namespace UnityEngine.UI.Extensions
|
|||||||
if (particles == null)
|
if (particles == null)
|
||||||
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
||||||
#else
|
#else
|
||||||
if (particles == null)
|
if (particles == null) particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
||||||
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
imageUV = new Vector4(0, 0, 1, 1);
|
imageUV = new Vector4(0, 0, 1, 1);
|
||||||
@@ -114,44 +90,34 @@ namespace UnityEngine.UI.Extensions
|
|||||||
textureSheetAnimation = pSystem.textureSheetAnimation;
|
textureSheetAnimation = pSystem.textureSheetAnimation;
|
||||||
textureSheetAnimationFrames = 0;
|
textureSheetAnimationFrames = 0;
|
||||||
textureSheetAnimationFrameSize = Vector2.zero;
|
textureSheetAnimationFrameSize = Vector2.zero;
|
||||||
if (textureSheetAnimation.enabled)
|
if (textureSheetAnimation.enabled) {
|
||||||
{
|
textureSheetAnimationFrames =
|
||||||
textureSheetAnimationFrames = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
|
textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
|
||||||
textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY);
|
textureSheetAnimationFrameSize = new Vector2(
|
||||||
|
1f / textureSheetAnimation.numTilesX,
|
||||||
|
1f / textureSheetAnimation.numTilesY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake() {
|
||||||
{
|
|
||||||
base.Awake();
|
base.Awake();
|
||||||
if (!Initialize())
|
if (!Initialize()) enabled = false;
|
||||||
enabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnPopulateMesh(VertexHelper vh) {
|
||||||
protected override void OnPopulateMesh(VertexHelper vh)
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying) {
|
||||||
{
|
if (!Initialize()) { return; }
|
||||||
if (!Initialize())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// prepare vertices
|
// prepare vertices
|
||||||
vh.Clear();
|
vh.Clear();
|
||||||
|
|
||||||
if (!gameObject.activeInHierarchy)
|
if (!gameObject.activeInHierarchy) { return; }
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isInitialised && !pSystem.main.playOnAwake)
|
if (!isInitialised && !pSystem.main.playOnAwake) {
|
||||||
{
|
|
||||||
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
|
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
|
||||||
isInitialised = true;
|
isInitialised = true;
|
||||||
}
|
}
|
||||||
@@ -162,15 +128,20 @@ namespace UnityEngine.UI.Extensions
|
|||||||
// iterate through current particles
|
// iterate through current particles
|
||||||
int count = pSystem.GetParticles(particles);
|
int count = pSystem.GetParticles(particles);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i) {
|
||||||
{
|
|
||||||
ParticleSystem.Particle particle = particles[i];
|
ParticleSystem.Particle particle = particles[i];
|
||||||
|
|
||||||
// get particle properties
|
// get particle properties
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector2 position =
|
||||||
|
(mainModule.simulationSpace == ParticleSystemSimulationSpace.Local
|
||||||
|
? particle.position
|
||||||
|
: _transform.InverseTransformPoint(particle.position));
|
||||||
#else
|
#else
|
||||||
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector2 position =
|
||||||
|
(pSystem.simulationSpace == ParticleSystemSimulationSpace.Local
|
||||||
|
? particle.position
|
||||||
|
: _transform.InverseTransformPoint(particle.position));
|
||||||
#endif
|
#endif
|
||||||
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
||||||
float rotation90 = rotation + Mathf.PI / 2;
|
float rotation90 = rotation + Mathf.PI / 2;
|
||||||
@@ -182,59 +153,61 @@ namespace UnityEngine.UI.Extensions
|
|||||||
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
#else
|
#else
|
||||||
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// apply texture sheet animation
|
// apply texture sheet animation
|
||||||
Vector4 particleUV = imageUV;
|
Vector4 particleUV = imageUV;
|
||||||
if (textureSheetAnimation.enabled)
|
if (textureSheetAnimation.enabled) {
|
||||||
{
|
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
|
float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
|
||||||
|
|
||||||
if (textureSheetAnimation.frameOverTime.curveMin != null)
|
if (textureSheetAnimation.frameOverTime.curveMin != null) {
|
||||||
{
|
frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(
|
||||||
frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
1 - (particle.remainingLifetime / particle.startLifetime));
|
||||||
}
|
} else if (textureSheetAnimation.frameOverTime.curve != null) {
|
||||||
else if (textureSheetAnimation.frameOverTime.curve != null)
|
frameProgress = textureSheetAnimation.frameOverTime.curve.Evaluate(
|
||||||
{
|
1 - (particle.remainingLifetime / particle.startLifetime));
|
||||||
frameProgress = textureSheetAnimation.frameOverTime.curve.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
} else if (textureSheetAnimation.frameOverTime.constant > 0) {
|
||||||
}
|
frameProgress = textureSheetAnimation.frameOverTime.constant -
|
||||||
else if (textureSheetAnimation.frameOverTime.constant > 0)
|
(particle.remainingLifetime / particle.startLifetime);
|
||||||
{
|
|
||||||
frameProgress = textureSheetAnimation.frameOverTime.constant - (particle.remainingLifetime / particle.startLifetime);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
float frameProgress = 1 - (particle.lifetime / particle.startLifetime);
|
float frameProgress = 1 - (particle.lifetime / particle.startLifetime);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
frameProgress = Mathf.Repeat(frameProgress * textureSheetAnimation.cycleCount, 1);
|
frameProgress =
|
||||||
|
Mathf.Repeat(frameProgress * textureSheetAnimation.cycleCount, 1);
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
|
|
||||||
switch (textureSheetAnimation.animation)
|
switch (textureSheetAnimation.animation) {
|
||||||
{
|
|
||||||
|
|
||||||
case ParticleSystemAnimationType.WholeSheet:
|
case ParticleSystemAnimationType.WholeSheet:
|
||||||
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
|
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParticleSystemAnimationType.SingleRow:
|
case ParticleSystemAnimationType.SingleRow:
|
||||||
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
|
frame = Mathf.FloorToInt(
|
||||||
|
frameProgress * textureSheetAnimation.numTilesX);
|
||||||
|
|
||||||
int row = textureSheetAnimation.rowIndex;
|
int row = textureSheetAnimation.rowIndex;
|
||||||
// if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
|
// if (textureSheetAnimation.useRandomRow) { // FIXME
|
||||||
// row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
|
// - is this handled internally by rowIndex?
|
||||||
|
// row = Random.Range(0,
|
||||||
|
// textureSheetAnimation.numTilesY, using:
|
||||||
|
// particle.randomSeed);
|
||||||
// }
|
// }
|
||||||
frame += row * textureSheetAnimation.numTilesX;
|
frame += row * textureSheetAnimation.numTilesX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame %= textureSheetAnimationFrames;
|
frame %= textureSheetAnimationFrames;
|
||||||
|
|
||||||
particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
|
particleUV.x = (frame % textureSheetAnimation.numTilesX) *
|
||||||
particleUV.y = 1.0f - Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y;
|
textureSheetAnimationFrameSize.x;
|
||||||
|
particleUV.y =
|
||||||
|
1.0f - Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) *
|
||||||
|
textureSheetAnimationFrameSize.y;
|
||||||
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
|
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
|
||||||
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
|
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
|
||||||
}
|
}
|
||||||
@@ -264,8 +237,7 @@ namespace UnityEngine.UI.Extensions
|
|||||||
_quad[3].color = color;
|
_quad[3].color = color;
|
||||||
_quad[3].uv0 = temp;
|
_quad[3].uv0 = temp;
|
||||||
|
|
||||||
if (rotation == 0)
|
if (rotation == 0) {
|
||||||
{
|
|
||||||
// no rotation
|
// no rotation
|
||||||
corner1.x = position.x - size;
|
corner1.x = position.x - size;
|
||||||
corner1.y = position.y - size;
|
corner1.y = position.y - size;
|
||||||
@@ -284,16 +256,19 @@ namespace UnityEngine.UI.Extensions
|
|||||||
temp.x = corner2.x;
|
temp.x = corner2.x;
|
||||||
temp.y = corner1.y;
|
temp.y = corner1.y;
|
||||||
_quad[3].position = temp;
|
_quad[3].position = temp;
|
||||||
}
|
} else {
|
||||||
else
|
if (use3dRotation) {
|
||||||
{
|
|
||||||
if (use3dRotation)
|
|
||||||
{
|
|
||||||
// get particle properties
|
// get particle properties
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
Vector3 pos3d = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector3 pos3d =
|
||||||
|
(mainModule.simulationSpace == ParticleSystemSimulationSpace.Local
|
||||||
|
? particle.position
|
||||||
|
: _transform.InverseTransformPoint(particle.position));
|
||||||
#else
|
#else
|
||||||
Vector3 pos3d = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector3 pos3d =
|
||||||
|
(pSystem.simulationSpace == ParticleSystemSimulationSpace.Local
|
||||||
|
? particle.position
|
||||||
|
: _transform.InverseTransformPoint(particle.position));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// apply scale
|
// apply scale
|
||||||
@@ -305,8 +280,7 @@ namespace UnityEngine.UI.Extensions
|
|||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Vector3[] verts = new Vector3[4]
|
Vector3[] verts = new Vector3[4] {
|
||||||
{
|
|
||||||
new Vector3(-size, -size, 0),
|
new Vector3(-size, -size, 0),
|
||||||
new Vector3(-size, size, 0),
|
new Vector3(-size, size, 0),
|
||||||
new Vector3(size, size, 0),
|
new Vector3(size, size, 0),
|
||||||
@@ -319,12 +293,12 @@ namespace UnityEngine.UI.Extensions
|
|||||||
_quad[1].position = pos3d + particleRotation * verts[1];
|
_quad[1].position = pos3d + particleRotation * verts[1];
|
||||||
_quad[2].position = pos3d + particleRotation * verts[2];
|
_quad[2].position = pos3d + particleRotation * verts[2];
|
||||||
_quad[3].position = pos3d + particleRotation * verts[3];
|
_quad[3].position = pos3d + particleRotation * verts[3];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// apply rotation
|
// apply rotation
|
||||||
Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size;
|
Vector2 right =
|
||||||
Vector2 up = new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size;
|
new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size;
|
||||||
|
Vector2 up =
|
||||||
|
new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size;
|
||||||
|
|
||||||
_quad[0].position = position - right - up;
|
_quad[0].position = position - right - up;
|
||||||
_quad[1].position = position - right + up;
|
_quad[1].position = position - right + up;
|
||||||
@@ -337,66 +311,53 @@ namespace UnityEngine.UI.Extensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update() {
|
||||||
{
|
if (!fixedTime && Application.isPlaying) {
|
||||||
if (!fixedTime && Application.isPlaying)
|
|
||||||
{
|
|
||||||
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||||
SetAllDirty();
|
SetAllDirty();
|
||||||
|
|
||||||
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
||||||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
(material != null && currentMaterial != null &&
|
||||||
{
|
material.shader != currentMaterial.shader)) {
|
||||||
pSystem = null;
|
pSystem = null;
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LateUpdate()
|
private void LateUpdate() {
|
||||||
{
|
if (!Application.isPlaying) {
|
||||||
if (!Application.isPlaying)
|
|
||||||
{
|
|
||||||
SetAllDirty();
|
SetAllDirty();
|
||||||
}
|
} else {
|
||||||
else
|
if (fixedTime) {
|
||||||
{
|
|
||||||
if (fixedTime)
|
|
||||||
{
|
|
||||||
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||||
SetAllDirty();
|
SetAllDirty();
|
||||||
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
if ((currentMaterial != null &&
|
||||||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
currentTexture != currentMaterial.mainTexture) ||
|
||||||
{
|
(material != null && currentMaterial != null &&
|
||||||
|
material.shader != currentMaterial.shader)) {
|
||||||
pSystem = null;
|
pSystem = null;
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == currentMaterial)
|
if (material == currentMaterial) return;
|
||||||
return;
|
|
||||||
pSystem = null;
|
pSystem = null;
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDestroy()
|
protected override void OnDestroy() {
|
||||||
{
|
|
||||||
currentMaterial = null;
|
currentMaterial = null;
|
||||||
currentTexture = null;
|
currentTexture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartParticleEmission()
|
public void StartParticleEmission() { pSystem.Play(); }
|
||||||
{
|
|
||||||
pSystem.Play();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopParticleEmission()
|
public void StopParticleEmission() {
|
||||||
{
|
|
||||||
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
|
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PauseParticleEmission()
|
public void PauseParticleEmission() {
|
||||||
{
|
|
||||||
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmitting);
|
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmitting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-23
@@ -4,45 +4,35 @@ using System.Collections.Generic;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CtrPanel : MonoBehaviour
|
public class CtrPanel : MonoBehaviour {
|
||||||
{
|
|
||||||
private int page = 0;
|
private int page = 0;
|
||||||
private List<GameObject> panels = new List<GameObject>();
|
private List<GameObject> panels = new List<GameObject>();
|
||||||
private TextMeshProUGUI textTitle;
|
private TextMeshProUGUI textTitle;
|
||||||
public Transform panelTransform;
|
public Transform panelTransform;
|
||||||
private bool isReady = false;
|
private bool isReady = false;
|
||||||
|
|
||||||
private void Start()
|
private void Start() {
|
||||||
{
|
|
||||||
textTitle = transform.GetComponentInChildren<TextMeshProUGUI>();
|
textTitle = transform.GetComponentInChildren<TextMeshProUGUI>();
|
||||||
|
|
||||||
foreach (Transform t in panelTransform)
|
foreach (Transform t in panelTransform) { panels.Add(t.gameObject); }
|
||||||
{
|
|
||||||
panels.Add(t.gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
isReady = true;
|
isReady = true;
|
||||||
|
|
||||||
SetTitle();
|
SetTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
|
||||||
if (panels.Count <= 0 || !isReady) return;
|
if (panels.Count <= 0 || !isReady) return;
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
|
||||||
{
|
|
||||||
Click_Prev();
|
Click_Prev();
|
||||||
}
|
} else if (Input.GetKeyDown(KeyCode.RightArrow)) {
|
||||||
else if (Input.GetKeyDown(KeyCode.RightArrow))
|
|
||||||
{
|
|
||||||
Click_Next();
|
Click_Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//이전
|
//이전
|
||||||
public void Click_Prev()
|
public void Click_Prev() {
|
||||||
{
|
|
||||||
if (page <= 0 || !isReady) return;
|
if (page <= 0 || !isReady) return;
|
||||||
|
|
||||||
panels[page].SetActive(false);
|
panels[page].SetActive(false);
|
||||||
@@ -53,8 +43,7 @@ public class CtrPanel : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
//다음
|
//다음
|
||||||
public void Click_Next()
|
public void Click_Next() {
|
||||||
{
|
|
||||||
if (page >= panels.Count - 1) return;
|
if (page >= panels.Count - 1) return;
|
||||||
|
|
||||||
panels[page].SetActive(false);
|
panels[page].SetActive(false);
|
||||||
@@ -64,8 +53,5 @@ public class CtrPanel : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
//하단 제목 설정
|
//하단 제목 설정
|
||||||
private void SetTitle()
|
private void SetTitle() { textTitle.text = panels[page].name; }
|
||||||
{
|
|
||||||
textTitle.text = panels[page].name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,88 +3,58 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class MainQueue : MonoBehaviour
|
public class MainQueue : MonoBehaviour {
|
||||||
{
|
|
||||||
static MainQueue __singletonInstance;
|
static MainQueue __singletonInstance;
|
||||||
Queue<Action> actionQueue = new Queue<Action>();
|
Queue<Action> actionQueue = new Queue<Action>();
|
||||||
Queue<Action> nextUpdateQueue = new Queue<Action>();
|
Queue<Action> nextUpdateQueue = new Queue<Action>();
|
||||||
|
|
||||||
private MainQueue() { }
|
private MainQueue() {}
|
||||||
|
|
||||||
void Awake()
|
void Awake() {
|
||||||
{
|
if (__singletonInstance == null) { __singletonInstance = this; }
|
||||||
if (__singletonInstance == null)
|
|
||||||
{
|
|
||||||
__singletonInstance = this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update() {
|
||||||
{
|
|
||||||
Action possibleAction;
|
Action possibleAction;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
possibleAction = null;
|
possibleAction = null;
|
||||||
lock (actionQueue)
|
lock (actionQueue) {
|
||||||
{
|
if (actionQueue.Count > 0) { possibleAction = actionQueue.Dequeue(); }
|
||||||
if (actionQueue.Count > 0)
|
|
||||||
{
|
|
||||||
possibleAction = actionQueue.Dequeue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possibleAction != null)
|
if (possibleAction != null) { possibleAction.Invoke(); }
|
||||||
{
|
|
||||||
possibleAction.Invoke();
|
|
||||||
}
|
|
||||||
} while (possibleAction != null);
|
} while (possibleAction != null);
|
||||||
|
|
||||||
lock (nextUpdateQueue)
|
lock (nextUpdateQueue) {
|
||||||
{
|
foreach (Action action in nextUpdateQueue) { Enqueue(action); }
|
||||||
foreach (Action action in nextUpdateQueue)
|
|
||||||
{
|
|
||||||
Enqueue(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
nextUpdateQueue.Clear();
|
nextUpdateQueue.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Enqueue(Action newAction)
|
public int Enqueue(Action newAction) {
|
||||||
{
|
lock (actionQueue) {
|
||||||
lock (actionQueue)
|
|
||||||
{
|
|
||||||
actionQueue.Enqueue(newAction);
|
actionQueue.Enqueue(newAction);
|
||||||
|
|
||||||
return actionQueue.Count;
|
return actionQueue.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int EnqueueForNextUpdate(Action newAction)
|
public int EnqueueForNextUpdate(Action newAction) {
|
||||||
{
|
lock (nextUpdateQueue) {
|
||||||
lock (nextUpdateQueue)
|
|
||||||
{
|
|
||||||
nextUpdateQueue.Enqueue(newAction);
|
nextUpdateQueue.Enqueue(newAction);
|
||||||
|
|
||||||
return nextUpdateQueue.Count;
|
return nextUpdateQueue.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainQueue Q
|
public static MainQueue Q {
|
||||||
{
|
get {
|
||||||
get
|
if (__singletonInstance == null) { throw new Exception("No singleton found!"); }
|
||||||
{
|
|
||||||
if (__singletonInstance == null)
|
|
||||||
{
|
|
||||||
throw new Exception("No singleton found!");
|
|
||||||
}
|
|
||||||
return __singletonInstance;
|
return __singletonInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDestroy()
|
void OnDestroy() { __singletonInstance = null; }
|
||||||
{
|
|
||||||
__singletonInstance = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ using SimpleFileBrowser;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
public class MapEditorController : MonoBehaviour, IClickReceiver
|
public class MapEditorController : MonoBehaviour, IClickReceiver {
|
||||||
{
|
|
||||||
public static readonly int ATTACKER_ID_COUNT = 8;
|
public static readonly int ATTACKER_ID_COUNT = 8;
|
||||||
|
|
||||||
public HexGrid hexGrid;
|
public HexGrid hexGrid;
|
||||||
public HexGrid HexGrid { get { return hexGrid; } }
|
public HexGrid HexGrid {
|
||||||
|
get { return hexGrid; }
|
||||||
|
}
|
||||||
public MouseHandler mouseHandlerPrefab;
|
public MouseHandler mouseHandlerPrefab;
|
||||||
|
|
||||||
public Text mapInfoLabel;
|
public Text mapInfoLabel;
|
||||||
@@ -72,8 +73,7 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
|
|
||||||
public WeatherPanelController weatherPanel;
|
public WeatherPanelController weatherPanel;
|
||||||
|
|
||||||
enum SelectionMode
|
enum SelectionMode {
|
||||||
{
|
|
||||||
plains = 0,
|
plains = 0,
|
||||||
hills = 1,
|
hills = 1,
|
||||||
forest = 2,
|
forest = 2,
|
||||||
@@ -88,36 +88,33 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
fire = 11,
|
fire = 11,
|
||||||
attackerStartingPositions = 12,
|
attackerStartingPositions = 12,
|
||||||
defenderStartingPositions = 13,
|
defenderStartingPositions = 13,
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
private TerrainType terrainTypeFromSelectionMode(SelectionMode mode)
|
private TerrainType terrainTypeFromSelectionMode(SelectionMode mode) {
|
||||||
{
|
|
||||||
return (TerrainType)((int)mode + (int)TerrainType.Plains);
|
return (TerrainType)((int)mode + (int)TerrainType.Plains);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SelectionMode selectionMode;
|
private SelectionMode selectionMode;
|
||||||
public int selectedAttackerId = 0;
|
public int selectedAttackerId = 0;
|
||||||
|
|
||||||
public void SelectAttackerId(int index)
|
public void SelectAttackerId(int index) {
|
||||||
{
|
|
||||||
selectedAttackerId = index;
|
selectedAttackerId = index;
|
||||||
SelectTerrainTypeButton((int)SelectionMode.attackerStartingPositions);
|
SelectTerrainTypeButton((int)SelectionMode.attackerStartingPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUpGridFromMap()
|
void SetUpGridFromMap() {
|
||||||
{
|
|
||||||
System.Random rnd = new System.Random();
|
System.Random rnd = new System.Random();
|
||||||
Texture[] textures = new Texture[map.RowCount * map.ColumnCount];
|
Texture[] textures = new Texture[map.RowCount * map.ColumnCount];
|
||||||
randomNumberForCellIndex.Clear();
|
randomNumberForCellIndex.Clear();
|
||||||
for (int row = 0; row < map.RowCount; row++)
|
for (int row = 0; row < map.RowCount; row++) {
|
||||||
{
|
for (int column = 0; column < map.ColumnCount; column++) {
|
||||||
for (int column = 0; column < map.ColumnCount; column++)
|
|
||||||
{
|
|
||||||
int randomNumber = rnd.Next();
|
int randomNumber = rnd.Next();
|
||||||
randomNumberForCellIndex.Add(randomNumber);
|
randomNumberForCellIndex.Add(randomNumber);
|
||||||
var tileTerrain = map.Terrain[row * map.ColumnCount + column];
|
var tileTerrain = map.Terrain[row * map.ColumnCount + column];
|
||||||
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
||||||
textures[cellIndex] = imageForTerrainTracker.GetImageForTerrain(tileTerrain, randomNumber, Month);
|
textures[cellIndex] =
|
||||||
|
imageForTerrainTracker.GetImageForTerrain(tileTerrain, randomNumber, Month);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,59 +125,55 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
hexGrid.SetUp();
|
hexGrid.SetUp();
|
||||||
|
|
||||||
Coords coords = new Coords();
|
Coords coords = new Coords();
|
||||||
for (int row = 0; row < map.RowCount; row++)
|
for (int row = 0; row < map.RowCount; row++) {
|
||||||
{
|
|
||||||
coords.Row = row;
|
coords.Row = row;
|
||||||
for (int column = 0; column < map.ColumnCount; column++)
|
for (int column = 0; column < map.ColumnCount; column++) {
|
||||||
{
|
|
||||||
coords.Column = column;
|
coords.Column = column;
|
||||||
|
|
||||||
var modifier = map.Terrain[row * map.ColumnCount + column].Modifier;
|
var modifier = map.Terrain[row * map.ColumnCount + column].Modifier;
|
||||||
hexGrid.SetCellModifierImage(MapCoordsToGridIndex(coords), modifier?.Bridge == null ? null : bridgeImage);
|
hexGrid.SetCellModifierImage(
|
||||||
hexGrid.SetCellModifierEffect(MapCoordsToGridIndex(coords), modifier?.Fire == null ? null : fireEffectPrefab);
|
MapCoordsToGridIndex(coords),
|
||||||
|
modifier?.Bridge == null ? null : bridgeImage);
|
||||||
|
hexGrid.SetCellModifierEffect(
|
||||||
|
MapCoordsToGridIndex(coords),
|
||||||
|
modifier?.Fire == null ? null : fireEffectPrefab);
|
||||||
|
|
||||||
int randomNumber = rnd.Next();
|
int randomNumber = rnd.Next();
|
||||||
randomNumberForCellIndex.Add(randomNumber);
|
randomNumberForCellIndex.Add(randomNumber);
|
||||||
var tileTerrain = map.Terrain[row * map.ColumnCount + column];
|
var tileTerrain = map.Terrain[row * map.ColumnCount + column];
|
||||||
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
||||||
textures[cellIndex] = imageForTerrainTracker.GetImageForTerrain(tileTerrain, randomNumber, Month);
|
textures[cellIndex] =
|
||||||
|
imageForTerrainTracker.GetImageForTerrain(tileTerrain, randomNumber, Month);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateStartingPositions();
|
UpdateStartingPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HexMap NewHexMap()
|
private HexMap NewHexMap() {
|
||||||
{
|
|
||||||
var newMap = new HexMap();
|
var newMap = new HexMap();
|
||||||
newMap.RowCount = ROW_COUNT;
|
newMap.RowCount = ROW_COUNT;
|
||||||
newMap.ColumnCount = COLUMN_COUNT;
|
newMap.ColumnCount = COLUMN_COUNT;
|
||||||
newMap.DefenderStartingPositions = new StartingPositionList();
|
newMap.DefenderStartingPositions = new StartingPositionList();
|
||||||
for (int i = 0; i < ATTACKER_ID_COUNT; i++)
|
for (int i = 0; i < ATTACKER_ID_COUNT; i++) {
|
||||||
{
|
|
||||||
newMap.AttackerStartingPositions.Add(new StartingPositionList());
|
newMap.AttackerStartingPositions.Add(new StartingPositionList());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < newMap.RowCount * newMap.ColumnCount; i++)
|
for (int i = 0; i < newMap.RowCount * newMap.ColumnCount; i++) {
|
||||||
{
|
|
||||||
var terrain = new Net.Eagle0.Shardok.Common.Terrain();
|
var terrain = new Net.Eagle0.Shardok.Common.Terrain();
|
||||||
terrain.Type = TerrainType.Plains;
|
terrain.Type = TerrainType.Plains;
|
||||||
terrain.Modifier = new TileModifier();
|
terrain.Modifier = new TileModifier();
|
||||||
newMap.Terrain.Add(terrain);
|
newMap.Terrain.Add(terrain);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++) {
|
||||||
{
|
newMap.MonthlyWeather.Add(new MonthlyWeather {
|
||||||
newMap.MonthlyWeather.Add(
|
AverageTemperature = 50,
|
||||||
new MonthlyWeather
|
SunChance = 40,
|
||||||
{
|
CloudsChance = 30,
|
||||||
AverageTemperature = 50,
|
RainChance = 20,
|
||||||
SunChance = 40,
|
ThunderstormChance = 10,
|
||||||
CloudsChance = 30,
|
MaxWindMph = 25
|
||||||
RainChance = 20,
|
});
|
||||||
ThunderstormChance = 10,
|
|
||||||
MaxWindMph = 25
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
weatherPanel.MonthlyWeathers = new List<MonthlyWeather>(newMap.MonthlyWeather);
|
weatherPanel.MonthlyWeathers = new List<MonthlyWeather>(newMap.MonthlyWeather);
|
||||||
|
|
||||||
@@ -188,8 +181,7 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
gameObject.GetComponentInChildren<MouseHandler>().clickReceiver = this;
|
gameObject.GetComponentInChildren<MouseHandler>().clickReceiver = this;
|
||||||
|
|
||||||
workingFilePath = null;
|
workingFilePath = null;
|
||||||
@@ -233,47 +225,36 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
SelectTerrainTypeButton(0);
|
SelectTerrainTypeButton(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectTerrainTypeButton(int type)
|
public void SelectTerrainTypeButton(int type) {
|
||||||
{
|
|
||||||
int previouslySelected = (int)selectionMode;
|
int previouslySelected = (int)selectionMode;
|
||||||
|
|
||||||
selectionMode = (SelectionMode)type;
|
selectionMode = (SelectionMode)type;
|
||||||
buttons[type].colors = selectedColorBlock;
|
buttons[type].colors = selectedColorBlock;
|
||||||
|
|
||||||
if (previouslySelected != type)
|
if (previouslySelected != type) {
|
||||||
{
|
|
||||||
buttons[previouslySelected].colors = unselectedColorBlock;
|
buttons[previouslySelected].colors = unselectedColorBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleLongHover(int? gridIndex, Vector3 mousePosition)
|
public void HandleLongHover(int? gridIndex, Vector3 mousePosition) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleLongUIHover(IEnumerable<GameObject> hoveredObjects)
|
public void HandleLongUIHover(IEnumerable<GameObject> hoveredObjects) {
|
||||||
{
|
|
||||||
// button tooltip
|
// button tooltip
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveAs()
|
public void SaveAs() {
|
||||||
{
|
|
||||||
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
||||||
FileBrowser.SetDefaultFilter(".e0mj");
|
FileBrowser.SetDefaultFilter(".e0mj");
|
||||||
|
|
||||||
StartCoroutine(ShowSaveDialogCoroutine());
|
StartCoroutine(ShowSaveDialogCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SaveWithFilePath(string filePath)
|
private bool SaveWithFilePath(string filePath) {
|
||||||
{
|
|
||||||
var blankModifier = new TileModifier();
|
var blankModifier = new TileModifier();
|
||||||
var savedMap = new HexMap(map);
|
var savedMap = new HexMap(map);
|
||||||
foreach (var terrain in savedMap.Terrain)
|
foreach (var terrain in savedMap.Terrain) {
|
||||||
{
|
if (terrain.Modifier == blankModifier) { terrain.Modifier = null; }
|
||||||
if (terrain.Modifier == blankModifier)
|
|
||||||
{
|
|
||||||
terrain.Modifier = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
savedMap.MonthlyWeather.Clear();
|
savedMap.MonthlyWeather.Clear();
|
||||||
savedMap.MonthlyWeather.AddRange(weatherPanel.MonthlyWeathers);
|
savedMap.MonthlyWeather.AddRange(weatherPanel.MonthlyWeathers);
|
||||||
@@ -295,44 +276,32 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator ShowSaveDialogCoroutine()
|
IEnumerator ShowSaveDialogCoroutine() {
|
||||||
{
|
|
||||||
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
||||||
|
|
||||||
FileBrowser.SetDefaultFilter(".e0mj");
|
FileBrowser.SetDefaultFilter(".e0mj");
|
||||||
yield return FileBrowser.WaitForSaveDialog(FileBrowser.PickMode.Files, false, initialPath);
|
yield return FileBrowser.WaitForSaveDialog(FileBrowser.PickMode.Files, false, initialPath);
|
||||||
|
|
||||||
if (FileBrowser.Success)
|
if (FileBrowser.Success) {
|
||||||
{
|
|
||||||
var path = FileBrowser.Result[0];
|
var path = FileBrowser.Result[0];
|
||||||
if (Path.GetExtension(path) != ".e0mj")
|
if (Path.GetExtension(path) != ".e0mj") { path = Path.ChangeExtension(path, ".e0mj"); }
|
||||||
{
|
|
||||||
path = Path.ChangeExtension(path, ".e0mj");
|
|
||||||
}
|
|
||||||
var dirPath = Path.GetDirectoryName(path);
|
var dirPath = Path.GetDirectoryName(path);
|
||||||
PlayerPrefs.SetString("mapLocation", dirPath);
|
PlayerPrefs.SetString("mapLocation", dirPath);
|
||||||
|
|
||||||
bool success = SaveWithFilePath(path);
|
bool success = SaveWithFilePath(path);
|
||||||
if (!success)
|
if (!success) { throw new ArgumentException("unable to save"); }
|
||||||
{
|
|
||||||
throw new ArgumentException("unable to save");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save() { SaveWithFilePath(workingFilePath); }
|
||||||
{
|
|
||||||
SaveWithFilePath(workingFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator ShowLoadDialogCoroutine()
|
IEnumerator ShowLoadDialogCoroutine() {
|
||||||
{
|
|
||||||
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
var initialPath = PlayerPrefs.GetString("mapLocation", null);
|
||||||
|
|
||||||
yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
yield return FileBrowser
|
||||||
|
.WaitForLoadDialog(FileBrowser.PickMode.Files, false, initialPath, null);
|
||||||
|
|
||||||
if (FileBrowser.Success)
|
if (FileBrowser.Success) {
|
||||||
{
|
|
||||||
hexGrid.ClearOverlays();
|
hexGrid.ClearOverlays();
|
||||||
var path = FileBrowser.Result[0];
|
var path = FileBrowser.Result[0];
|
||||||
var dirPath = Path.GetDirectoryName(path);
|
var dirPath = Path.GetDirectoryName(path);
|
||||||
@@ -342,8 +311,7 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
|
|
||||||
var jp = new JsonParser(JsonParser.Settings.Default);
|
var jp = new JsonParser(JsonParser.Settings.Default);
|
||||||
map = jp.Parse<HexMap>(jsonText);
|
map = jp.Parse<HexMap>(jsonText);
|
||||||
while (map.AttackerStartingPositions.Count < ATTACKER_ID_COUNT)
|
while (map.AttackerStartingPositions.Count < ATTACKER_ID_COUNT) {
|
||||||
{
|
|
||||||
map.AttackerStartingPositions.Add(new StartingPositionList());
|
map.AttackerStartingPositions.Add(new StartingPositionList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,16 +325,14 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load()
|
public void Load() {
|
||||||
{
|
|
||||||
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
FileBrowser.SetFilters(true, new FileBrowser.Filter("Maps", ".e0mj"));
|
||||||
FileBrowser.SetDefaultFilter(".e0mj");
|
FileBrowser.SetDefaultFilter(".e0mj");
|
||||||
|
|
||||||
StartCoroutine(ShowLoadDialogCoroutine());
|
StartCoroutine(ShowLoadDialogCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset() {
|
||||||
{
|
|
||||||
hexGrid.ClearOverlays();
|
hexGrid.ClearOverlays();
|
||||||
hexGrid.ClearCellModifierImages();
|
hexGrid.ClearCellModifierImages();
|
||||||
map = NewHexMap();
|
map = NewHexMap();
|
||||||
@@ -378,18 +344,11 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
UpdateStartingPositions();
|
UpdateStartingPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Quit()
|
public void Quit() { Application.Quit(); }
|
||||||
{
|
|
||||||
Application.Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WeatherClicked()
|
public void WeatherClicked() { weatherPanel.gameObject.SetActive(true); }
|
||||||
{
|
|
||||||
weatherPanel.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateSaveInteractability()
|
private void UpdateSaveInteractability() {
|
||||||
{
|
|
||||||
saveButton.interactable = false;
|
saveButton.interactable = false;
|
||||||
saveAsButton.interactable = false;
|
saveAsButton.interactable = false;
|
||||||
|
|
||||||
@@ -397,11 +356,14 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
// Additionally, there must be at least two total starting position sets
|
// Additionally, there must be at least two total starting position sets
|
||||||
// (1 defender and 1+ attackers, or 2+ attackers)
|
// (1 defender and 1+ attackers, or 2+ attackers)
|
||||||
int playerCount = 0;
|
int playerCount = 0;
|
||||||
if (map.DefenderStartingPositions.Positions.Count > 0 && map.DefenderStartingPositions.Positions.Count != 10) return;
|
if (map.DefenderStartingPositions.Positions.Count > 0 &&
|
||||||
|
map.DefenderStartingPositions.Positions.Count != 10)
|
||||||
|
return;
|
||||||
if (map.DefenderStartingPositions.Positions.Count > 0) playerCount++;
|
if (map.DefenderStartingPositions.Positions.Count > 0) playerCount++;
|
||||||
for (int i = 0; i < ATTACKER_ID_COUNT; i++)
|
for (int i = 0; i < ATTACKER_ID_COUNT; i++) {
|
||||||
{
|
if (map.AttackerStartingPositions[i].Positions.Count > 0 &&
|
||||||
if (map.AttackerStartingPositions[i].Positions.Count > 0 && map.AttackerStartingPositions[i].Positions.Count != 10) return;
|
map.AttackerStartingPositions[i].Positions.Count != 10)
|
||||||
|
return;
|
||||||
if (map.AttackerStartingPositions[i].Positions.Count > 0) playerCount++;
|
if (map.AttackerStartingPositions[i].Positions.Count > 0) playerCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,21 +371,15 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
|
|
||||||
saveAsButton.interactable = true;
|
saveAsButton.interactable = true;
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(workingFilePath))
|
if (!String.IsNullOrEmpty(workingFilePath)) { saveButton.interactable = true; }
|
||||||
{
|
|
||||||
saveButton.interactable = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadConfirm(string path)
|
public void LoadConfirm(string path) {
|
||||||
{
|
|
||||||
hexGrid.ClearOverlays();
|
hexGrid.ClearOverlays();
|
||||||
using (var fileStream = File.OpenRead(path))
|
using (var fileStream = File.OpenRead(path)) using (
|
||||||
using (CodedInputStream input = new CodedInputStream(fileStream))
|
CodedInputStream input = new CodedInputStream(fileStream)) {
|
||||||
{
|
|
||||||
map = HexMap.Parser.ParseFrom(input);
|
map = HexMap.Parser.ParseFrom(input);
|
||||||
while (map.AttackerStartingPositions.Count < ATTACKER_ID_COUNT)
|
while (map.AttackerStartingPositions.Count < ATTACKER_ID_COUNT) {
|
||||||
{
|
|
||||||
map.AttackerStartingPositions.Add(new StartingPositionList());
|
map.AttackerStartingPositions.Add(new StartingPositionList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,33 +392,24 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
UpdateStartingPositions();
|
UpdateStartingPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePrimaryClick(int clickedIndex)
|
public void HandlePrimaryClick(int clickedIndex) {
|
||||||
{
|
|
||||||
HandleUpdateToOneIndex(clickedIndex, includeTogglables: true);
|
HandleUpdateToOneIndex(clickedIndex, includeTogglables: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleSecondaryClick(int clickedIndex)
|
public void HandleSecondaryClick(int clickedIndex) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsWater(TerrainType type)
|
private bool IsWater(TerrainType type) {
|
||||||
{
|
|
||||||
return type == TerrainType.StillWater || type == TerrainType.River;
|
return type == TerrainType.StillWater || type == TerrainType.River;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleUpdateToOneIndex(int clickedIndex, bool includeTogglables)
|
private void HandleUpdateToOneIndex(int clickedIndex, bool includeTogglables) {
|
||||||
{
|
if (!includeTogglables && selectionMode > SelectionMode.river) { return; }
|
||||||
if (!includeTogglables && selectionMode > SelectionMode.river)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newTerrain = map.Terrain[ProtoPositionFromGridIndex(clickedIndex)];
|
var newTerrain = map.Terrain[ProtoPositionFromGridIndex(clickedIndex)];
|
||||||
var defenderPositions = map.DefenderStartingPositions.Positions;
|
var defenderPositions = map.DefenderStartingPositions.Positions;
|
||||||
Coords coords = GridIndexToMapCoords(clickedIndex);
|
Coords coords = GridIndexToMapCoords(clickedIndex);
|
||||||
|
|
||||||
switch (selectionMode)
|
switch (selectionMode) {
|
||||||
{
|
|
||||||
case SelectionMode.plains:
|
case SelectionMode.plains:
|
||||||
case SelectionMode.forest:
|
case SelectionMode.forest:
|
||||||
case SelectionMode.hills:
|
case SelectionMode.hills:
|
||||||
@@ -475,92 +422,70 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.stillWater:
|
case SelectionMode.stillWater:
|
||||||
case SelectionMode.river:
|
case SelectionMode.river: {
|
||||||
{
|
var oldBridge = newTerrain.Modifier.Bridge;
|
||||||
var oldBridge = newTerrain.Modifier.Bridge;
|
|
||||||
|
|
||||||
newTerrain = new Net.Eagle0.Shardok.Common.Terrain();
|
newTerrain = new Net.Eagle0.Shardok.Common.Terrain();
|
||||||
newTerrain.Modifier = new TileModifier();
|
newTerrain.Modifier = new TileModifier();
|
||||||
if (oldBridge != null)
|
if (oldBridge != null) { newTerrain.Modifier.Bridge = oldBridge; }
|
||||||
{
|
|
||||||
newTerrain.Modifier.Bridge = oldBridge;
|
|
||||||
}
|
|
||||||
|
|
||||||
newTerrain.Type = terrainTypeFromSelectionMode(selectionMode);
|
newTerrain.Type = terrainTypeFromSelectionMode(selectionMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectionMode.ice:
|
case SelectionMode.ice:
|
||||||
if (!IsWater(newTerrain.Type))
|
if (!IsWater(newTerrain.Type)) { return; }
|
||||||
{
|
if (newTerrain.Modifier?.Ice == null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (newTerrain.Modifier?.Ice == null)
|
|
||||||
{
|
|
||||||
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
||||||
|
|
||||||
newTerrain.Modifier.Ice = new TileModifier.Types.SingleModifier();
|
newTerrain.Modifier.Ice = new TileModifier.Types.SingleModifier();
|
||||||
newTerrain.Modifier.Ice.Integrity = 50;
|
newTerrain.Modifier.Ice.Integrity = 50;
|
||||||
}
|
} else if (newTerrain.Modifier != null)
|
||||||
else if (newTerrain.Modifier != null) newTerrain.Modifier.Ice = null;
|
newTerrain.Modifier.Ice = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.bridge:
|
case SelectionMode.bridge:
|
||||||
if (!IsWater(newTerrain.Type))
|
if (!IsWater(newTerrain.Type)) { return; }
|
||||||
{
|
if (newTerrain.Modifier?.Bridge == null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (newTerrain.Modifier?.Bridge == null)
|
|
||||||
{
|
|
||||||
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
||||||
|
|
||||||
newTerrain.Modifier.Bridge = new TileModifier.Types.SingleModifier();
|
newTerrain.Modifier.Bridge = new TileModifier.Types.SingleModifier();
|
||||||
newTerrain.Modifier.Bridge.Integrity = 100.0;
|
newTerrain.Modifier.Bridge.Integrity = 100.0;
|
||||||
}
|
} else if (newTerrain.Modifier != null)
|
||||||
else if (newTerrain.Modifier != null) newTerrain.Modifier.Bridge = null;
|
newTerrain.Modifier.Bridge = null;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.castle:
|
case SelectionMode.castle:
|
||||||
if (newTerrain.Modifier?.Castle == null)
|
if (newTerrain.Modifier?.Castle == null) {
|
||||||
{
|
|
||||||
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
if (newTerrain.Modifier == null) newTerrain.Modifier = new TileModifier();
|
||||||
|
|
||||||
newTerrain.Modifier.Castle = new TileModifier.Types.SingleModifier();
|
newTerrain.Modifier.Castle = new TileModifier.Types.SingleModifier();
|
||||||
newTerrain.Modifier.Castle.Integrity = 100.0;
|
newTerrain.Modifier.Castle.Integrity = 100.0;
|
||||||
}
|
} else if (newTerrain.Modifier != null)
|
||||||
else if (newTerrain.Modifier != null) newTerrain.Modifier.Castle = null;
|
newTerrain.Modifier.Castle = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.fire:
|
case SelectionMode.fire:
|
||||||
if (newTerrain.Modifier.Fire == null)
|
if (newTerrain.Modifier.Fire == null) {
|
||||||
{
|
|
||||||
newTerrain.Modifier.Fire = new TileModifier.Types.SingleModifier();
|
newTerrain.Modifier.Fire = new TileModifier.Types.SingleModifier();
|
||||||
}
|
} else if (newTerrain.Modifier != null)
|
||||||
else if (newTerrain.Modifier != null) newTerrain.Modifier.Fire = null;
|
newTerrain.Modifier.Fire = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.attackerStartingPositions:
|
case SelectionMode.attackerStartingPositions:
|
||||||
if (defenderPositions.Contains(coords))
|
if (defenderPositions.Contains(coords)) { defenderPositions.Remove(coords); }
|
||||||
{
|
|
||||||
defenderPositions.Remove(coords);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < ATTACKER_ID_COUNT; i++)
|
for (int i = 0; i < ATTACKER_ID_COUNT; i++) {
|
||||||
{
|
|
||||||
if (i == selectedAttackerId) continue;
|
if (i == selectedAttackerId) continue;
|
||||||
if (map.AttackerStartingPositions[i].Positions.Contains(coords))
|
if (map.AttackerStartingPositions[i].Positions.Contains(coords)) {
|
||||||
{
|
|
||||||
map.AttackerStartingPositions[i].Positions.Remove(coords);
|
map.AttackerStartingPositions[i].Positions.Remove(coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.AttackerStartingPositions[selectedAttackerId].Positions.Contains(coords))
|
if (map.AttackerStartingPositions[selectedAttackerId].Positions.Contains(coords)) {
|
||||||
{
|
|
||||||
map.AttackerStartingPositions[selectedAttackerId].Positions.Remove(coords);
|
map.AttackerStartingPositions[selectedAttackerId].Positions.Remove(coords);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
map.AttackerStartingPositions[selectedAttackerId].Positions.Add(coords);
|
map.AttackerStartingPositions[selectedAttackerId].Positions.Add(coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,20 +493,15 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionMode.defenderStartingPositions:
|
case SelectionMode.defenderStartingPositions:
|
||||||
for (int i = 0; i < ATTACKER_ID_COUNT; i++)
|
for (int i = 0; i < ATTACKER_ID_COUNT; i++) {
|
||||||
{
|
if (map.AttackerStartingPositions[i].Positions.Contains(coords)) {
|
||||||
if (map.AttackerStartingPositions[i].Positions.Contains(coords))
|
|
||||||
{
|
|
||||||
map.AttackerStartingPositions[i].Positions.Remove(coords);
|
map.AttackerStartingPositions[i].Positions.Remove(coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defenderPositions.Contains(coords))
|
if (defenderPositions.Contains(coords)) {
|
||||||
{
|
|
||||||
defenderPositions.Remove(coords);
|
defenderPositions.Remove(coords);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
defenderPositions.Add(coords);
|
defenderPositions.Add(coords);
|
||||||
}
|
}
|
||||||
UpdateStartingPositions();
|
UpdateStartingPositions();
|
||||||
@@ -589,76 +509,84 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
var imageTerrain = new Net.Eagle0.Shardok.Common.Terrain(newTerrain);
|
var imageTerrain = new Net.Eagle0.Shardok.Common.Terrain(newTerrain);
|
||||||
if (snowToggle.isOn)
|
if (snowToggle.isOn) {
|
||||||
{
|
|
||||||
if (imageTerrain.Modifier == null) imageTerrain.Modifier = new TileModifier();
|
if (imageTerrain.Modifier == null) imageTerrain.Modifier = new TileModifier();
|
||||||
imageTerrain.Modifier.Snow = new TileModifier.Types.SingleModifier { Integrity = 50 };
|
imageTerrain.Modifier.Snow = new TileModifier.Types.SingleModifier { Integrity = 50 };
|
||||||
}
|
}
|
||||||
var image = imageForTerrainTracker.GetImageForTerrain(imageTerrain, randomNumberForCellIndex[ProtoPositionFromGridIndex(clickedIndex)], Month);
|
var image = imageForTerrainTracker.GetImageForTerrain(
|
||||||
|
imageTerrain,
|
||||||
|
randomNumberForCellIndex[ProtoPositionFromGridIndex(clickedIndex)],
|
||||||
|
Month);
|
||||||
|
|
||||||
map.Terrain[ProtoPositionFromGridIndex(clickedIndex)] = newTerrain;
|
map.Terrain[ProtoPositionFromGridIndex(clickedIndex)] = newTerrain;
|
||||||
hexGrid.SetCellTerrainImage(clickedIndex, image);
|
hexGrid.SetCellTerrainImage(clickedIndex, image);
|
||||||
hexGrid.SetCellModifierImage(clickedIndex, newTerrain.Modifier?.Bridge == null ? null : bridgeImage);
|
hexGrid.SetCellModifierImage(
|
||||||
hexGrid.SetCellModifierEffect(clickedIndex, newTerrain.Modifier?.Fire == null ? null : fireEffectPrefab);
|
clickedIndex,
|
||||||
|
newTerrain.Modifier?.Bridge == null ? null : bridgeImage);
|
||||||
|
hexGrid.SetCellModifierEffect(
|
||||||
|
clickedIndex,
|
||||||
|
newTerrain.Modifier?.Fire == null ? null : fireEffectPrefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RedrawAll()
|
private void RedrawAll() {
|
||||||
{
|
for (int row = 0; row < map.RowCount; row++) {
|
||||||
for (int row = 0; row < map.RowCount; row++)
|
for (int column = 0; column < map.ColumnCount; column++) {
|
||||||
{
|
|
||||||
for (int column = 0; column < map.ColumnCount; column++)
|
|
||||||
{
|
|
||||||
int gridIndex = row * map.ColumnCount + column;
|
int gridIndex = row * map.ColumnCount + column;
|
||||||
int randomNumber = randomNumberForCellIndex[ProtoPositionFromGridIndex(gridIndex)];
|
int randomNumber = randomNumberForCellIndex[ProtoPositionFromGridIndex(gridIndex)];
|
||||||
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
int cellIndex = (map.RowCount - 1 - row) * map.ColumnCount + column;
|
||||||
|
|
||||||
var imageTerrain = new Net.Eagle0.Shardok.Common.Terrain(map.Terrain[gridIndex]);
|
var imageTerrain = new Net.Eagle0.Shardok.Common.Terrain(map.Terrain[gridIndex]);
|
||||||
if (snowToggle.isOn)
|
if (snowToggle.isOn) {
|
||||||
{
|
|
||||||
if (imageTerrain.Modifier == null) imageTerrain.Modifier = new TileModifier();
|
if (imageTerrain.Modifier == null) imageTerrain.Modifier = new TileModifier();
|
||||||
imageTerrain.Modifier.Snow = new TileModifier.Types.SingleModifier { Integrity = 50 };
|
imageTerrain.Modifier.Snow =
|
||||||
|
new TileModifier.Types.SingleModifier { Integrity = 50 };
|
||||||
}
|
}
|
||||||
|
|
||||||
var image = imageForTerrainTracker.GetImageForTerrain(imageTerrain, randomNumber, Month);
|
var image = imageForTerrainTracker.GetImageForTerrain(
|
||||||
|
imageTerrain,
|
||||||
|
randomNumber,
|
||||||
|
Month);
|
||||||
|
|
||||||
hexGrid.SetCellTerrainImage(cellIndex, image);
|
hexGrid.SetCellTerrainImage(cellIndex, image);
|
||||||
hexGrid.SetCellModifierImage(cellIndex, imageTerrain.Modifier?.Bridge == null ? null : bridgeImage);
|
hexGrid.SetCellModifierImage(
|
||||||
hexGrid.SetCellModifierEffect(cellIndex, imageTerrain.Modifier?.Fire == null ? null : fireEffectPrefab);
|
cellIndex,
|
||||||
|
imageTerrain.Modifier?.Bridge == null ? null : bridgeImage);
|
||||||
|
hexGrid.SetCellModifierEffect(
|
||||||
|
cellIndex,
|
||||||
|
imageTerrain.Modifier?.Fire == null ? null : fireEffectPrefab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStartingPositions()
|
private void UpdateStartingPositions() {
|
||||||
{
|
|
||||||
int attackerCount = map.AttackerStartingPositions[selectedAttackerId].Positions.Count;
|
int attackerCount = map.AttackerStartingPositions[selectedAttackerId].Positions.Count;
|
||||||
int defenderCount = map.DefenderStartingPositions.Positions.Count;
|
int defenderCount = map.DefenderStartingPositions.Positions.Count;
|
||||||
string attackerCountString = attackerCount.ToString();
|
string attackerCountString = attackerCount.ToString();
|
||||||
if (attackerCount == 0 || attackerCount == 10)
|
if (attackerCount == 0 || attackerCount == 10) {
|
||||||
{
|
|
||||||
attackerCountString = $"<color=#00FF00FF>{attackerCountString}</color>";
|
attackerCountString = $"<color=#00FF00FF>{attackerCountString}</color>";
|
||||||
}
|
}
|
||||||
string defenderCountString = defenderCount.ToString();
|
string defenderCountString = defenderCount.ToString();
|
||||||
if (defenderCount == 10)
|
if (defenderCount == 10) {
|
||||||
{
|
|
||||||
attackerCountString = $"<color=#00FF00FF>{defenderCountString}</color>";
|
attackerCountString = $"<color=#00FF00FF>{defenderCountString}</color>";
|
||||||
}
|
}
|
||||||
attackerStartingPositionsButton.GetComponentInChildren<Text>().text = $"Attacker Start Positions ({attackerCountString})";
|
attackerStartingPositionsButton.GetComponentInChildren<Text>().text =
|
||||||
defenderStartingPositionsButton.GetComponentInChildren<Text>().text = $"Defender Start Positions ({defenderCountString})";
|
$"Attacker Start Positions ({attackerCountString})";
|
||||||
|
defenderStartingPositionsButton.GetComponentInChildren<Text>().text =
|
||||||
|
$"Defender Start Positions ({defenderCountString})";
|
||||||
|
|
||||||
hexGrid.ClearOverlays();
|
hexGrid.ClearOverlays();
|
||||||
for (int i = 0; i < ATTACKER_ID_COUNT; i++)
|
for (int i = 0; i < ATTACKER_ID_COUNT; i++) {
|
||||||
{
|
string text =
|
||||||
string text = $"{attackerStartingPositionsDropdown.options[i].text.Split(' ')[0]} ({map.AttackerStartingPositions[i].Positions.Count})";
|
$"{attackerStartingPositionsDropdown.options[i].text.Split(' ')[0]} ({map.AttackerStartingPositions[i].Positions.Count})";
|
||||||
foreach (Coords attackerPosition in map.AttackerStartingPositions[i].Positions)
|
foreach (Coords attackerPosition in map.AttackerStartingPositions[i].Positions) {
|
||||||
{
|
|
||||||
int targetIndex = MapCoordsToGridIndex(attackerPosition);
|
int targetIndex = MapCoordsToGridIndex(attackerPosition);
|
||||||
Color primaryColor = Color.Lerp(Color.red, Color.green, (i / (float)(ATTACKER_ID_COUNT - 1)));
|
Color primaryColor =
|
||||||
|
Color.Lerp(Color.red, Color.green, (i / (float)(ATTACKER_ID_COUNT - 1)));
|
||||||
Color secondaryColor = Color.white;
|
Color secondaryColor = Color.white;
|
||||||
hexGrid.OverlayCell(targetIndex, primaryColor, secondaryColor, null, text);
|
hexGrid.OverlayCell(targetIndex, primaryColor, secondaryColor, null, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (Coords defenderPosition in map.DefenderStartingPositions.Positions)
|
foreach (Coords defenderPosition in map.DefenderStartingPositions.Positions) {
|
||||||
{
|
|
||||||
int targetIndex = MapCoordsToGridIndex(defenderPosition);
|
int targetIndex = MapCoordsToGridIndex(defenderPosition);
|
||||||
Color secondaryColor = Color.white;
|
Color secondaryColor = Color.white;
|
||||||
hexGrid.OverlayCell(targetIndex, Color.black, secondaryColor, null, null);
|
hexGrid.OverlayCell(targetIndex, Color.black, secondaryColor, null, null);
|
||||||
@@ -667,74 +595,61 @@ public class MapEditorController : MonoBehaviour, IClickReceiver
|
|||||||
UpdateSaveInteractability();
|
UpdateSaveInteractability();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleDrag(int startIndex, int finishIndex)
|
public void HandleDrag(int startIndex, int finishIndex) {
|
||||||
{
|
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleHover(int gridIndex)
|
public void HandleHover(int gridIndex) {
|
||||||
{
|
|
||||||
var terrain = map.Terrain[ProtoPositionFromGridIndex(gridIndex)];
|
var terrain = map.Terrain[ProtoPositionFromGridIndex(gridIndex)];
|
||||||
|
|
||||||
string description = terrain.Type.ToString();
|
string description = terrain.Type.ToString();
|
||||||
if (terrain.Modifier?.Castle != null)
|
if (terrain.Modifier?.Castle != null) {
|
||||||
{
|
|
||||||
description += $"<b> (Castle [{(int)terrain.Modifier.Castle.Integrity.Value}])</b>";
|
description += $"<b> (Castle [{(int)terrain.Modifier.Castle.Integrity.Value}])</b>";
|
||||||
}
|
}
|
||||||
if (terrain.Modifier?.Fire != null)
|
if (terrain.Modifier?.Fire != null) {
|
||||||
{
|
|
||||||
description += "<b><color=#FF0000FF> (Fire)</color></b>";
|
description += "<b><color=#FF0000FF> (Fire)</color></b>";
|
||||||
}
|
}
|
||||||
if (terrain.Modifier?.Ice != null)
|
if (terrain.Modifier?.Ice != null) {
|
||||||
{
|
description +=
|
||||||
description += $"<b><color=#0000FFFF> (Frozen [{(int)terrain.Modifier.Ice.Integrity.Value}])</color></b>";
|
$"<b><color=#0000FFFF> (Frozen [{(int)terrain.Modifier.Ice.Integrity.Value}])</color></b>";
|
||||||
}
|
}
|
||||||
if (terrain.Modifier?.Snow != null)
|
if (terrain.Modifier?.Snow != null) {
|
||||||
{
|
description +=
|
||||||
description += $"<b><color=#0000FFFF> (Snow [{(int)terrain.Modifier.Snow.Integrity.Value}])</color></b>";
|
$"<b><color=#0000FFFF> (Snow [{(int)terrain.Modifier.Snow.Integrity.Value}])</color></b>";
|
||||||
}
|
}
|
||||||
if (terrain.Modifier?.Bridge != null)
|
if (terrain.Modifier?.Bridge != null) {
|
||||||
{
|
|
||||||
description += $"<b> (Bridge [{(int)terrain.Modifier.Bridge.Integrity.Value}])</b>";
|
description += $"<b> (Bridge [{(int)terrain.Modifier.Bridge.Integrity.Value}])</b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
tileInfoText.text = description;
|
tileInfoText.text = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RedrawCommandOverlays(int? mouseDownGridIndex, int? currentMouseGridIndex)
|
public void RedrawCommandOverlays(int? mouseDownGridIndex, int? currentMouseGridIndex) {
|
||||||
{
|
|
||||||
HandleUpdateToOneIndex(currentMouseGridIndex.Value, includeTogglables: false);
|
HandleUpdateToOneIndex(currentMouseGridIndex.Value, includeTogglables: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleMouseRightDownOnNewTile(int mouseDownGridIndex, int currentMouseGridIndex)
|
public void HandleMouseRightDownOnNewTile(int mouseDownGridIndex, int currentMouseGridIndex) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WinterOrSnowToggled(bool value)
|
public void WinterOrSnowToggled(bool value) {
|
||||||
{
|
|
||||||
snowToggle.interactable = winterToggle.isOn;
|
snowToggle.interactable = winterToggle.isOn;
|
||||||
RedrawAll();
|
RedrawAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
Coords GridIndexToMapCoords(int gridIndex)
|
Coords GridIndexToMapCoords(int gridIndex) {
|
||||||
{
|
|
||||||
Coords coords = new Coords();
|
Coords coords = new Coords();
|
||||||
coords.Row = map.RowCount - 1 - gridIndex / map.ColumnCount;
|
coords.Row = map.RowCount - 1 - gridIndex / map.ColumnCount;
|
||||||
coords.Column = gridIndex % map.ColumnCount;
|
coords.Column = gridIndex % map.ColumnCount;
|
||||||
|
|
||||||
return coords;
|
return coords;
|
||||||
}
|
}
|
||||||
int ProtoPositionFromGridIndex(int gridIndex)
|
int ProtoPositionFromGridIndex(int gridIndex) {
|
||||||
{
|
|
||||||
int row = map.RowCount - 1 - gridIndex / map.ColumnCount;
|
int row = map.RowCount - 1 - gridIndex / map.ColumnCount;
|
||||||
int column = gridIndex % map.ColumnCount;
|
int column = gridIndex % map.ColumnCount;
|
||||||
|
|
||||||
return row * map.ColumnCount + column;
|
return row * map.ColumnCount + column;
|
||||||
}
|
}
|
||||||
int MapCoordsToGridIndex(Coords mapCoords)
|
int MapCoordsToGridIndex(Coords mapCoords) {
|
||||||
{
|
|
||||||
int gridRow = map.RowCount - 1 - mapCoords.Row;
|
int gridRow = map.RowCount - 1 - mapCoords.Row;
|
||||||
return gridRow * map.ColumnCount + mapCoords.Column;
|
return gridRow * map.ColumnCount + mapCoords.Column;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+250
-905
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user