Browse Source

More Battle stuff

master
Laurids Jeppe 5 months ago
parent
commit
b459f9aa28
4 changed files with 54 additions and 21 deletions
  1. +20
    -8
      Assets/GWConquest/Scenes/GalaxyMap.unity
  2. +9
    -3
      Assets/GWConquest/Scripts/Battle.cs
  3. +17
    -2
      Assets/GWConquest/Scripts/GameManager.cs
  4. +8
    -8
      Assets/GWConquest/Scripts/UI/BattleUI.cs

+ 20
- 8
Assets/GWConquest/Scenes/GalaxyMap.unity View File

@ -28409,7 +28409,9 @@ MonoBehaviour:
BetweenTransitionLengthFactor: 60 BetweenTransitionLengthFactor: 60
battleTurnLength: 30 battleTurnLength: 30
battleTurnDeviation: 10 battleTurnDeviation: 10
battlePreparingCooldown: 30
battleBeginPhaseLength: 0
battleCommandPhaseLength: 20
battleCombatPhaseLength: 20
moveToFlankCooldown: 15 moveToFlankCooldown: 15
moveToReserveCooldown: 15 moveToReserveCooldown: 15
unitDeathCooldown: 60 unitDeathCooldown: 60
@ -46406,7 +46408,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &765894939 --- !u!224 &765894939
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -61803,12 +61805,12 @@ PrefabInstance:
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
value: 1
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
@ -62230,6 +62232,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 28.300781 value: 28.300781
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4175708910377210784, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 10
objectReference: {fileID: 0}
- target: {fileID: 4437373468136562986, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 4437373468136562986, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
@ -124479,7 +124486,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1} m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -107.51172} m_AnchoredPosition: {x: 0, y: -107.51172}
m_SizeDelta: {x: 115, y: 40.225113}
m_SizeDelta: {x: 0, y: 40.225113}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1981011823 --- !u!114 &1981011823
MonoBehaviour: MonoBehaviour:
@ -125581,7 +125588,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1996625630 --- !u!224 &1996625630
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -133019,12 +133026,12 @@ PrefabInstance:
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
value: 1
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
@ -133311,6 +133318,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 28.300781 value: 28.300781
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4175708910377210784, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 10
objectReference: {fileID: 0}
- target: {fileID: 4437373468136562986, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 4437373468136562986, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x


+ 9
- 3
Assets/GWConquest/Scripts/Battle.cs View File

@ -140,6 +140,11 @@ namespace GWConquest
private set => battlePhase.Value = value; private set => battlePhase.Value = value;
} }
public float PhaseCooldownPercent
{
get => PhaseCooldown / GameManager.Instance.GetBattlePhaseLength(Phase);
}
public Player Victor public Player Victor
{ {
get => Player.GetPlayerById(victorID.Value); get => Player.GetPlayerById(victorID.Value);
@ -174,8 +179,8 @@ namespace GWConquest
public void Init() public void Init()
{ {
Phase = BattlePhase.Command;
PhaseCooldown = GameManager.Instance.BattleCommandPhaseLength;
Phase = BattlePhase.Begin;
PhaseCooldown = GameManager.Instance.GetBattlePhaseLength(BattlePhase.Begin);
flankCount.Value = Zone.zoneType == ZoneType.Ground ? 3 : 1; flankCount.Value = Zone.zoneType == ZoneType.Ground ? 3 : 1;
int maxUnitPerFlank = Zone.zoneType == ZoneType.Ground ? 29 : 86; int maxUnitPerFlank = Zone.zoneType == ZoneType.Ground ? 29 : 86;
@ -230,7 +235,7 @@ namespace GWConquest
public void OnFormationsChanged() public void OnFormationsChanged()
{ {
var ui = FindObjectOfType<BattleUI>();
var ui = FindAnyObjectByType<BattleUI>();
if (ui != null && ui.isActiveAndEnabled) if (ui != null && ui.isActiveAndEnabled)
{ {
ui.UpdateFormations(); ui.UpdateFormations();
@ -783,6 +788,7 @@ namespace GWConquest
public enum BattlePhase public enum BattlePhase
{ {
Begin,
Command, Command,
Combat, Combat,
Finished Finished


+ 17
- 2
Assets/GWConquest/Scripts/GameManager.cs View File

@ -27,12 +27,27 @@ namespace GWConquest
private float battleTurnDeviation; private float battleTurnDeviation;
public float BattleTurnDeviation { get => battleTurnDeviation * TimeScale; } public float BattleTurnDeviation { get => battleTurnDeviation * TimeScale; }
[SerializeField]
private float battleBeginPhaseLength;
[SerializeField] [SerializeField]
private float battleCommandPhaseLength; private float battleCommandPhaseLength;
public float BattleCommandPhaseLength { get => battleCommandPhaseLength * TimeScale; }
[SerializeField] [SerializeField]
private float battleCombatPhaseLength; private float battleCombatPhaseLength;
public float BattleCombatPhaseLength { get => battleCombatPhaseLength * TimeScale; }
public float GetBattlePhaseLength(BattlePhase phase)
{
switch(phase)
{
case BattlePhase.Begin:
return battleBeginPhaseLength * TimeScale;
case BattlePhase.Command:
return battleCommandPhaseLength * TimeScale;
case BattlePhase.Combat:
return battleCombatPhaseLength * TimeScale;
default:
return 0f;
}
}
[SerializeField] [SerializeField]
private float moveToFlankCooldown; private float moveToFlankCooldown;


+ 8
- 8
Assets/GWConquest/Scripts/UI/BattleUI.cs View File

@ -64,14 +64,14 @@ namespace GWConquest
[System.NonSerialized] [System.NonSerialized]
public Unit SelectingTargetUnit; public Unit SelectingTargetUnit;
[System.NonSerialized] [System.NonSerialized]
public bool IsInPreparing = false;
public BattlePhase CurrentPhase = BattlePhase.Command;
public void SetBattle(Battle battle) public void SetBattle(Battle battle)
{ {
Battle = battle; Battle = battle;
SelectingTarget = false; SelectingTarget = false;
SelectingTargetUnit = null; SelectingTargetUnit = null;
IsInPreparing = Battle.IsInPreparing;
CurrentPhase = Battle.Phase;
InitFlankPanel(); InitFlankPanel();
@ -82,7 +82,7 @@ namespace GWConquest
FixedUpdate(); FixedUpdate();
if (Battle.IsInPreparing)
if (CurrentPhase == BattlePhase.Command)
{ {
SoundEffects.Instance.PlayMusic("MusicPreparing"); SoundEffects.Instance.PlayMusic("MusicPreparing");
} }
@ -94,7 +94,7 @@ namespace GWConquest
public void Close() public void Close()
{ {
if (Battle.IsInPreparing)
if (CurrentPhase == BattlePhase.Command)
{ {
SoundEffects.Instance.StopMusic(); SoundEffects.Instance.StopMusic();
} }
@ -263,24 +263,24 @@ namespace GWConquest
private void Update() private void Update()
{ {
if (Battle.IsInPreparing)
if (Battle.Phase == BattlePhase.Command)
{ {
PreparingBarGO.SetActive(true); PreparingBarGO.SetActive(true);
StrengthBarsGO.SetActive(false); StrengthBarsGO.SetActive(false);
PreparingBar.fillAmount = 1f - Battle.PreparingCooldown / GameManager.Instance.BattlePreparingCooldown;
PreparingBar.fillAmount = 1f - Battle.PhaseCooldownPercent;
} }
else else
{ {
PreparingBarGO.SetActive(false); PreparingBarGO.SetActive(false);
StrengthBarsGO.SetActive(true); StrengthBarsGO.SetActive(true);
if (IsInPreparing)
if (CurrentPhase == BattlePhase.Command)
{ {
SoundEffects.Instance.StopMusic(); SoundEffects.Instance.StopMusic();
SoundEffects.Instance.PlayEffect("BattleStarting"); SoundEffects.Instance.PlayEffect("BattleStarting");
} }
} }
IsInPreparing = Battle.IsInPreparing;
CurrentPhase = Battle.Phase;
UpdateFormations(); UpdateFormations();
UpdateIcons(); UpdateIcons();


Loading…
Cancel
Save