Browse Source

Transition Weltall -> Boden

bolt_update
laurids 3 years ago
parent
commit
6c1af68257
2 changed files with 40 additions and 10 deletions
  1. +23
    -1
      Assets/GWConquest/Scripts/Formation.cs
  2. +17
    -9
      Assets/GWConquest/Scripts/UI/TransportUIElement.cs

+ 23
- 1
Assets/GWConquest/Scripts/Formation.cs View File

@ -180,6 +180,14 @@ namespace GWConquest
{ {
if(entity.IsOwner && !state.IsInTransit) if(entity.IsOwner && !state.IsInTransit)
{ {
if(IsEmbarked)
{
if(ParentFormation != null && ParentFormation.entity.IsAttached)
{
ParentFormation.RemoveSubFormation(this);
}
}
state.CurrentTransition.OriginZone = Zone.GetZoneId(currentZone); state.CurrentTransition.OriginZone = Zone.GetZoneId(currentZone);
state.CurrentTransition.TargetZone = Zone.GetZoneId(target); state.CurrentTransition.TargetZone = Zone.GetZoneId(target);
bool isGroundTransition = target.zoneType == ZoneType.Ground; bool isGroundTransition = target.zoneType == ZoneType.Ground;
@ -251,7 +259,21 @@ namespace GWConquest
public override void SimulateOwner() public override void SimulateOwner()
{ {
if(IsEmbarked)
{
if(ParentFormation != null && ParentFormation.entity.IsAttached)
{
if(currentZone != ParentFormation.currentZone)
{
currentZone = ParentFormation.currentZone;
}
}
else {
BoltLog.Error("Formation {0} lost its parent formation {1}!", this, ParentFormation);
ParentFormation = null;
IsEmbarked = false;
}
}
if(state.IsInTransit) if(state.IsInTransit)
{ {
CoveredDistance += movementSpeed * BoltNetwork.FrameDeltaTime; CoveredDistance += movementSpeed * BoltNetwork.FrameDeltaTime;


+ 17
- 9
Assets/GWConquest/Scripts/UI/TransportUIElement.cs View File

@ -227,17 +227,25 @@ namespace GWConquest
{ {
if(Formation.ZoneType == ZoneType.Ground) if(Formation.ZoneType == ZoneType.Ground)
{ {
if (!Formation.IsEmbarked && ui.Type == ObjectType.District && ui.District.Zone.zoneType == ZoneType.Ground)
if (ui.Type == ObjectType.District && ui.District.Zone.zoneType == ZoneType.Ground)
{ {
// Transition Boden -> Boden
var goalZone = ui.District.Zone;
var pathfinding = Formation.currentZone.planet.pathfindingGraph;
var shortestPath = pathfinding.FindShortestPath(Formation, Formation.currentZone, goalZone);
if (shortestPath != null)
if(!Formation.IsEmbarked)
{ {
Formation.StartMovingOnPath(shortestPath.zones);
// Transition Boden -> Boden
var goalZone = ui.District.Zone;
var pathfinding = Formation.currentZone.planet.pathfindingGraph;
var shortestPath = pathfinding.FindShortestPath(Formation, Formation.currentZone, goalZone);
if (shortestPath != null)
{
Formation.StartMovingOnPath(shortestPath.zones);
}
}
else {
// Transition Weltall -> Boden
var goalZone = ui.District.Zone;
var path = new List<Zone>() {Formation.currentZone, goalZone};
Formation.StartMovingOnPath(path);
} }
} }
else if (ui.Type == ObjectType.Formation && ui.Formation.ZoneType == ZoneType.Space) else if (ui.Type == ObjectType.Formation && ui.Formation.ZoneType == ZoneType.Space)
{ {
@ -248,7 +256,7 @@ namespace GWConquest
// Transition Boden -> Weltall // Transition Boden -> Weltall
var goalZone = ui.Formation.currentZone; var goalZone = ui.Formation.currentZone;
var path = new List<Zone>() {Formation.currentZone, goalZone}; var path = new List<Zone>() {Formation.currentZone, goalZone};
Formation.StartMovingOnPath(path, ui.Formation);
Formation.StartMovingOnPath(path, targetFormation: ui.Formation);
} }
else { else {
// Transition Weltall -> Weltall (Flottenwechsel) // Transition Weltall -> Weltall (Flottenwechsel)


Loading…
Cancel
Save