|
@ -13,9 +13,9 @@ namespace GWConquest |
|
|
private NetworkVariable<FixedString128Bytes> battleName = new NetworkVariable<FixedString128Bytes>(); |
|
|
private NetworkVariable<FixedString128Bytes> battleName = new NetworkVariable<FixedString128Bytes>(); |
|
|
private GWNetworkList<NullableNetworkBehaviourReference> flanks = new GWNetworkList<NullableNetworkBehaviourReference>(); |
|
|
private GWNetworkList<NullableNetworkBehaviourReference> flanks = new GWNetworkList<NullableNetworkBehaviourReference>(); |
|
|
private NetworkVariable<int> flankCount = new NetworkVariable<int>(); |
|
|
private NetworkVariable<int> flankCount = new NetworkVariable<int>(); |
|
|
private NetworkVariable<bool> isOver = new NetworkVariable<bool>(); |
|
|
|
|
|
private NetworkVariable<int> victorID = new NetworkVariable<int>(); |
|
|
private NetworkVariable<int> victorID = new NetworkVariable<int>(); |
|
|
private NetworkVariable<float> preparingCooldown = new NetworkVariable<float>(); |
|
|
|
|
|
|
|
|
private NetworkVariable<float> phaseCooldown = new NetworkVariable<float>(); |
|
|
|
|
|
private NetworkVariable<BattlePhase> battlePhase = new NetworkVariable<BattlePhase>(); |
|
|
|
|
|
|
|
|
public GameObject BattleFlankPrefab; |
|
|
public GameObject BattleFlankPrefab; |
|
|
|
|
|
|
|
@ -125,19 +125,19 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
public bool IsOver |
|
|
public bool IsOver |
|
|
{ |
|
|
{ |
|
|
get => isOver.Value; |
|
|
|
|
|
set => isOver.Value = value; |
|
|
|
|
|
|
|
|
get => Phase == BattlePhase.Finished; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public float PreparingCooldown |
|
|
|
|
|
|
|
|
public float PhaseCooldown |
|
|
{ |
|
|
{ |
|
|
get => preparingCooldown.Value; |
|
|
|
|
|
set => preparingCooldown.Value = value; |
|
|
|
|
|
|
|
|
get => phaseCooldown.Value; |
|
|
|
|
|
private set => phaseCooldown.Value = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public bool IsInPreparing |
|
|
|
|
|
|
|
|
public BattlePhase Phase |
|
|
{ |
|
|
{ |
|
|
get => PreparingCooldown > 0; |
|
|
|
|
|
|
|
|
get => battlePhase.Value; |
|
|
|
|
|
private set => battlePhase.Value = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Player Victor |
|
|
public Player Victor |
|
@ -174,7 +174,8 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
public void Init() |
|
|
public void Init() |
|
|
{ |
|
|
{ |
|
|
PreparingCooldown = GameManager.Instance.BattlePreparingCooldown; |
|
|
|
|
|
|
|
|
Phase = BattlePhase.Command; |
|
|
|
|
|
PhaseCooldown = GameManager.Instance.BattleCommandPhaseLength; |
|
|
|
|
|
|
|
|
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; |
|
@ -240,15 +241,8 @@ namespace GWConquest |
|
|
{ |
|
|
{ |
|
|
if (IsSpawned && IsServer) |
|
|
if (IsSpawned && IsServer) |
|
|
{ |
|
|
{ |
|
|
if (IsInPreparing) |
|
|
|
|
|
{ |
|
|
|
|
|
PreparingCooldown -= Time.fixedDeltaTime; |
|
|
|
|
|
if (PreparingCooldown <= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
PreparingCooldown = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (!IsOver) |
|
|
|
|
|
|
|
|
var phase = Phase; |
|
|
|
|
|
if (phase == BattlePhase.Combat) |
|
|
{ |
|
|
{ |
|
|
var gm = GameManager.Instance; |
|
|
var gm = GameManager.Instance; |
|
|
|
|
|
|
|
@ -276,6 +270,25 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
SimulateTurn(); |
|
|
SimulateTurn(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (phase != BattlePhase.Finished) |
|
|
|
|
|
{ |
|
|
|
|
|
PhaseCooldown -= Time.fixedDeltaTime; |
|
|
|
|
|
if (PhaseCooldown <= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
PhaseCooldown = 0; |
|
|
|
|
|
if (phase == BattlePhase.Command) |
|
|
|
|
|
{ |
|
|
|
|
|
Phase = BattlePhase.Combat; |
|
|
|
|
|
} |
|
|
|
|
|
else if (phase == BattlePhase.Combat) |
|
|
|
|
|
{ |
|
|
|
|
|
Phase = BattlePhase.Command; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -283,7 +296,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
public void SetBattleOver() |
|
|
public void SetBattleOver() |
|
|
{ |
|
|
{ |
|
|
IsOver = true; |
|
|
|
|
|
|
|
|
Phase = BattlePhase.Finished; |
|
|
|
|
|
|
|
|
var victoriousPlayer = AllPlayers.FirstOrDefault(); |
|
|
var victoriousPlayer = AllPlayers.FirstOrDefault(); |
|
|
if (victoriousPlayer != null) |
|
|
if (victoriousPlayer != null) |
|
@ -767,4 +780,11 @@ namespace GWConquest |
|
|
FullHidden, |
|
|
FullHidden, |
|
|
ClassHidden |
|
|
ClassHidden |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public enum BattlePhase |
|
|
|
|
|
{ |
|
|
|
|
|
Command, |
|
|
|
|
|
Combat, |
|
|
|
|
|
Finished |
|
|
|
|
|
} |
|
|
} |
|
|
} |