|
|
@ -2,6 +2,7 @@ |
|
|
|
using System.Linq; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
namespace GWConquest |
|
|
|
{ |
|
|
@ -12,12 +13,12 @@ namespace GWConquest |
|
|
|
[HideInInspector] |
|
|
|
public GameObject unitIconPrefab; |
|
|
|
|
|
|
|
private Zone _currentZone; |
|
|
|
private Zone lastZone; |
|
|
|
public Zone currentZone |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return _currentZone; |
|
|
|
return Zone.GetFromId(state.CurrentZone); |
|
|
|
} |
|
|
|
set |
|
|
|
{ |
|
|
@ -28,16 +29,16 @@ namespace GWConquest |
|
|
|
private void OnZoneChanged() |
|
|
|
{ |
|
|
|
Zone newZone = Zone.GetFromId(state.CurrentZone); |
|
|
|
if(_currentZone != null) |
|
|
|
if(lastZone != null) |
|
|
|
{ |
|
|
|
_currentZone.OnFormationDeparting(this); |
|
|
|
lastZone.OnFormationDeparting(this); |
|
|
|
} |
|
|
|
if(newZone != null) |
|
|
|
{ |
|
|
|
newZone.OnFormationArrived(this); |
|
|
|
} |
|
|
|
BoltLog.Info("Current zone changed from {0} to {1} on formation {2}", _currentZone, newZone, this); |
|
|
|
_currentZone = newZone; |
|
|
|
BoltLog.Info("Current zone changed from {0} to {1} on formation {2}", lastZone, newZone, this); |
|
|
|
lastZone = newZone; |
|
|
|
} |
|
|
|
|
|
|
|
public Player Player |
|
|
@ -102,18 +103,17 @@ namespace GWConquest |
|
|
|
|
|
|
|
public void StartMovingOnPath(List<Zone> path) |
|
|
|
{ |
|
|
|
if (path.Count > 0 && entity.IsControlled && !state.IsInTransit) |
|
|
|
if (path.Count > 1 && entity.IsControlled && !state.IsInTransit) |
|
|
|
{ |
|
|
|
path.Reverse(); |
|
|
|
|
|
|
|
MoveFormationEvent evnt = MoveFormationEvent.Create(Bolt.GlobalTargets.OnlyServer); |
|
|
|
evnt.Formation = entity; |
|
|
|
evnt.TargetZone = Zone.GetZoneId(path[0]); |
|
|
|
if(path.Count > 1) |
|
|
|
evnt.TargetZone = Zone.GetZoneId(path[1]); |
|
|
|
if(path.Count > 2) |
|
|
|
{ |
|
|
|
|
|
|
|
BoltListToken<Zone> zoneListToken = new BoltListToken<Zone>( |
|
|
|
packet => Zone.GetFromId(packet.ReadInt()), (packet, zone) => packet.WriteInt(Zone.GetZoneId(zone)), |
|
|
|
path.GetRange(1, path.Count-1).ToArray()); |
|
|
|
path.GetRange(2, path.Count-2).ToArray()); |
|
|
|
evnt.PathQueue = zoneListToken; |
|
|
|
|
|
|
|
} |
|
|
@ -192,17 +192,32 @@ namespace GWConquest |
|
|
|
{ |
|
|
|
CoveredDistance += movementSpeed * BoltNetwork.FrameDeltaTime; |
|
|
|
if (CoveredDistance >= state.CurrentTransition.TransitionLength) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
currentZone = Zone.GetFromId(state.CurrentTransition.TargetZone); |
|
|
|
state.CurrentTransition.OriginZone = -1; |
|
|
|
state.CurrentTransition.TargetZone = -1; |
|
|
|
state.CurrentTransition.TransitionLength = 0; |
|
|
|
CoveredDistance = 0; |
|
|
|
state.IsInTransit = false; |
|
|
|
|
|
|
|
if(PathQueue.Count > 0) |
|
|
|
{ |
|
|
|
StartCoroutine(ContinueMovingOnPath()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerator ContinueMovingOnPath() |
|
|
|
{ |
|
|
|
yield return new WaitForSeconds(0.1f); |
|
|
|
Zone z = PathQueue.First(); |
|
|
|
PathQueue.RemoveAt(0); |
|
|
|
MoveToZone(z); |
|
|
|
} |
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
{ |
|
|
|