Browse Source

Bewegungen Boden - Weltall Part 1

bolt_update
laurids 3 years ago
parent
commit
70e0df7ffa
17 changed files with 8121 additions and 34 deletions
  1. +4
    -3
      Assets/GWConquest/Prefabs/UI/TransportUI/TransportUIElement.prefab
  2. +3
    -3
      Assets/GWConquest/Resources/PlanetConnection.prefab
  3. +7787
    -1
      Assets/GWConquest/Scenes/GalaxyMap.unity
  4. +2
    -0
      Assets/GWConquest/Scripts/BattleFlank.cs
  5. +79
    -3
      Assets/GWConquest/Scripts/Formation.cs
  6. +2
    -0
      Assets/GWConquest/Scripts/Planet.cs
  7. +32
    -0
      Assets/GWConquest/Scripts/PlanetConnection.cs
  8. +4
    -0
      Assets/GWConquest/Scripts/ServerCallbacks.cs
  9. +12
    -6
      Assets/GWConquest/Scripts/UI/BattleArmyPanel.cs
  10. +2
    -1
      Assets/GWConquest/Scripts/UI/FleetIconsUI.cs
  11. +15
    -3
      Assets/GWConquest/Scripts/UI/TransportUI.cs
  12. +96
    -10
      Assets/GWConquest/Scripts/UI/TransportUIElement.cs
  13. +1
    -1
      Assets/GWConquest/Scripts/UI/TransportUIUnitIcon.cs
  14. +2
    -1
      Assets/GWConquest/Scripts/Unit.cs
  15. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
  16. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb
  17. +80
    -2
      Assets/Photon/PhotonBolt/project.json

+ 4
- 3
Assets/GWConquest/Prefabs/UI/TransportUI/TransportUIElement.prefab View File

@ -387,8 +387,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 15.419983, y: -70}
m_SizeDelta: {x: -54.027466, y: 120}
m_AnchoredPosition: {x: 15.419922, y: -70}
m_SizeDelta: {x: -54.027466, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &4672820892231590445
MonoBehaviour:
@ -456,7 +456,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -10}
m_SizeDelta: {x: -20, y: 60}
m_SizeDelta: {x: -20, y: 190}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &2673194344194583630
MonoBehaviour:
@ -486,6 +486,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
SpriteImage: {fileID: 2673194343256469687}
ImageTransform: {fileID: 2673194344478261959}
NameText: {fileID: 2673194343329978765}
Arrow: {fileID: 2673194343700811299}
ChildrenTransform: {fileID: 2673194343769095890}


+ 3
- 3
Assets/GWConquest/Resources/PlanetConnection.prefab View File

@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 5208040857522702121}
- component: {fileID: 526244009083771565}
m_Layer: 0
m_Name: Line
m_Name: PlanetConnection
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -94,8 +94,8 @@ LineRenderer:
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 0.050980393}
key1: {r: 1, g: 1, b: 1, a: 0.050980393}
key0: {r: 1, g: 1, b: 1, a: 0.6117647}
key1: {r: 1, g: 1, b: 1, a: 0.6117647}
key2: {r: 0, g: 0, b: 0, a: 1}
key3: {r: 0, g: 0, b: 0, a: 0.003921569}
key4: {r: 0, g: 0, b: 0, a: 0}


+ 7787
- 1
Assets/GWConquest/Scenes/GalaxyMap.unity
File diff suppressed because it is too large
View File


+ 2
- 0
Assets/GWConquest/Scripts/BattleFlank.cs View File

@ -16,6 +16,8 @@ namespace GWConquest {
set => state.Battle = value?.entity;
}
public bool IsSpace => Battle.IsSpaceBattle;
public int MaxUnitCount {
get => state.MaxUnitCount;
set => state.MaxUnitCount = value;


+ 79
- 3
Assets/GWConquest/Scripts/Formation.cs View File

@ -35,11 +35,17 @@ namespace GWConquest
{
newZone.OnFormationArrived(this);
}
BoltLog.Info("Current zone changed from {0} to {1} on formation {2}", lastZone, newZone, this);
lastZone = newZone;
}
}
public ZoneType ZoneType {
get => state.IsSpace ? ZoneType.Space : ZoneType.Ground;
set => state.IsSpace = value == ZoneType.Space;
}
public Player Player
{
get
@ -92,6 +98,21 @@ namespace GWConquest
public ZoneList PathQueue;
public Formation MovementTargetFormation {
get => state.MovementTargetFormation?.GetComponent<Formation>();
set => state.MovementTargetFormation = value?.entity;
}
public bool IsEmbarked {
get => state.IsEmbarked;
set => state.IsEmbarked = value;
}
public Formation ParentFormation {
get => state.ParentFormation?.GetComponent<Formation>();
set => state.ParentFormation = value?.entity;
}
public GameObject fleetIcon;
public GameObject movingArmyPrefab;
@ -105,6 +126,11 @@ namespace GWConquest
[System.NonSerialized]
public bool IsExpandedInMenu = true;
public bool CanMove
{
get => !state.IsInTransit;
}
public void TryMoveToPlanet(Planet planet)
{
if(entity.IsControlled && !state.IsInTransit
@ -122,7 +148,7 @@ namespace GWConquest
}
}
public void StartMovingOnPath(List<Zone> path)
public void StartMovingOnPath(List<Zone> path, Formation targetFormation=null)
{
if (path.Count > 1 && entity.IsControlled && !state.IsInTransit)
{
@ -137,6 +163,10 @@ namespace GWConquest
evnt.PathQueue = zoneListToken;
}
if(targetFormation != null)
{
evnt.TargetFormation = targetFormation.entity;
}
evnt.Send();
}
else
@ -173,6 +203,9 @@ namespace GWConquest
animDistanceCovered = 0;
if(state.IsInTransit)
{
var originZone = Zone.GetFromId(state.CurrentTransition.OriginZone);
var targetZone = Zone.GetFromId(state.CurrentTransition.TargetZone);
if(state.CurrentTransition.IsCurved) {
movingArmyIcon = Instantiate(movingArmyPrefab);
movingArmyIcon.transform.SetParent(FindObjectOfType<IngameUI>().PlanetView.DistrictIcons);
@ -182,14 +215,19 @@ namespace GWConquest
movingArmyIcon.GetComponentInChildren<UnityEngine.UI.Text>().color = Player.Color;
Transform circleTransform = movingArmyIcon.GetComponentInChildren<UnityEngine.UI.Image>().transform;
Camera cam = Camera.main;
Vector3 originPoint = RectTransformUtility.WorldToScreenPoint(cam, Zone.GetFromId(state.CurrentTransition.OriginZone).transform.position);
Vector3 targetPoint = RectTransformUtility.WorldToScreenPoint(cam, Zone.GetFromId(state.CurrentTransition.TargetZone).transform.position);
Vector3 originPoint = RectTransformUtility.WorldToScreenPoint(cam, originZone.transform.position);
Vector3 targetPoint = RectTransformUtility.WorldToScreenPoint(cam, targetZone.transform.position);
circleTransform.localRotation = Quaternion.FromToRotation(Vector3.up, targetPoint-originPoint);
} else {
fleetIcon.SetActive(true);
fleetIcon.GetComponent<Renderer>().material.color = Player.Color;
}
if(originZone.planet == targetZone.planet)
{
originZone.planet.InTransitFormations.Add(this);
}
}
else
@ -200,6 +238,12 @@ namespace GWConquest
Destroy(movingArmyIcon);
movingArmyIcon = null;
}
var planet = currentZone.planet;
if(planet.InTransitFormations.Contains(this))
{
planet.InTransitFormations.Remove(this);
}
}
@ -226,6 +270,14 @@ namespace GWConquest
StartCoroutine(ContinueMovingOnPath());
}
else if(MovementTargetFormation != null)
{
if(MovementTargetFormation.entity.IsAttached && MovementTargetFormation.currentZone == currentZone)
{
MovementTargetFormation.AddSubFormation(this);
}
MovementTargetFormation = null;
}
}
}
}
@ -351,6 +403,26 @@ namespace GWConquest
}
}
public void AddSubFormation(Formation f)
{
SubFormationEntities.Add(f.entity);
f.ParentFormation = this;
f.IsEmbarked = true;
}
public void RemoveSubFormation(Formation f)
{
SubFormationEntities.Remove(f.entity);
f.ParentFormation = null;
f.IsEmbarked = false;
}
public bool CanCarry(Formation f)
{
return !IsEmbarked;
// TODO inventory capacity
}
public event Action OnUnitsChanged;
@ -440,5 +512,9 @@ namespace GWConquest
}
public enum FormationState {
Idle, PreparingMovement, FinishingMovement, Moving
}
}

+ 2
- 0
Assets/GWConquest/Scripts/Planet.cs View File

@ -38,6 +38,8 @@ namespace GWConquest
private PlanetIndicatorUI indicatorUI;
public List<Formation> InTransitFormations = new List<Formation>();
public Zone[] GetZones(ZoneType type)
{
switch (type)


+ 32
- 0
Assets/GWConquest/Scripts/PlanetConnection.cs View File

@ -12,6 +12,35 @@ namespace GWConquest
public bool drawLine = true;
private LineRenderer lineRenderer;
private Color neutralColor;
private void FixedUpdate() {
if(Application.isPlaying)
{
Color color1 = neutralColor;
Color color2 = neutralColor;
if(planet1 != null)
{
var player1 = planet1.ControllingPlayer;
if(player1 != null)
{
color1 = player1.Faction.FactionColor;
}
}
if(planet2 != null)
{
var player2 = planet2.ControllingPlayer;
if(player2 != null)
{
color2 = player2.Faction.FactionColor;
}
}
lineRenderer.startColor = Util.UpdateColorRGB(lineRenderer.startColor, color1);
lineRenderer.endColor = Util.UpdateColorRGB(lineRenderer.endColor, color2);
}
}
#if UNITY_EDITOR
private void Update()
{
@ -52,6 +81,9 @@ namespace GWConquest
{
planet2.connections.Add(this);
}
lineRenderer = GetComponent<LineRenderer>();
neutralColor = lineRenderer.startColor;
}
}


+ 4
- 0
Assets/GWConquest/Scripts/ServerCallbacks.cs View File

@ -53,6 +53,10 @@ namespace GWConquest
var queueToken = evnt.PathQueue as ZoneListToken;
formation.PathQueue.FromToken(queueToken);
}
if(evnt.TargetFormation != null)
{
formation.state.MovementTargetFormation = evnt.TargetFormation;
}
}
public override void OnEvent(AddProductionEvent evnt)


+ 12
- 6
Assets/GWConquest/Scripts/UI/BattleArmyPanel.cs View File

@ -177,16 +177,22 @@ namespace GWConquest {
}
else if(icon.Unit.BattleState == BattleUnitState.InReserve && icon.Unit.CanGoToFlank)
{
var unitTypeFits = Battle.IsSpaceBattle == (icon.Unit.Class.ZoneType == ZoneType.Space);
var flankUI = target.GetComponentInParent<BattleFlankUI>();
if(flankUI != null)
if(flankUI != null && unitTypeFits)
{
var flankIndex = System.Array.IndexOf(flankUI.Icons, target);
var ev = MoveUnitToFlankEvent.Create(Bolt.GlobalTargets.OnlyServer);
ev.Unit = icon.Unit.entity;
ev.Flank = flankUI.BattleFlank.entity;
ev.FlankIndex = flankIndex;
ev.Send();
if(flankUI.BattleFlank.GetUnit(flankIndex) == null)
{
var ev = MoveUnitToFlankEvent.Create(Bolt.GlobalTargets.OnlyServer);
ev.Unit = icon.Unit.entity;
ev.Flank = flankUI.BattleFlank.entity;
ev.FlankIndex = flankIndex;
ev.Send();
}
}
}
}


+ 2
- 1
Assets/GWConquest/Scripts/UI/FleetIconsUI.cs View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace GWConquest
@ -31,7 +32,7 @@ namespace GWConquest
Camera cam = Camera.main;
var formations = zone.Formations;
var formations = zone.Formations.Where(f => f.ZoneType == ZoneType.Space).ToList();
int formationCount = formations.Count;
if(formationCount > 0)


+ 15
- 3
Assets/GWConquest/Scripts/UI/TransportUI.cs View File

@ -103,10 +103,17 @@ namespace GWConquest
itemStacks = districts.SelectMany(d => d.Inventory);
objects = districts.Cast<object>();
if(CurrentPlanet.InTransitFormations.Count > 0)
{
objects = objects.Append(CurrentPlanet);
}
}
else if(panel == SpacePanel)
{
var fleets = CurrentPlanet.GetMainZone(ZoneType.Space).Formations;
IEnumerable<Formation> fleets = CurrentPlanet.GetMainZone(ZoneType.Space).Formations;
fleets = fleets.Where(f => f.ZoneType == ZoneType.Space);
itemStacks = fleets.SelectMany(f => f.AllItems);
@ -118,14 +125,19 @@ namespace GWConquest
if(obj is District)
{
elementComp.IsDistrict = true;
elementComp.Type = TransportUIElement.ObjectType.District;
elementComp.District = obj as District;
}
else if(obj is Formation)
{
elementComp.IsDistrict = false;
elementComp.Type = TransportUIElement.ObjectType.Formation;
elementComp.Formation = obj as Formation;
}
else if(obj is Planet)
{
elementComp.Type = TransportUIElement.ObjectType.Planet;
elementComp.Planet = obj as Planet;
}
else {
BoltLog.Error("Displayed object is neither District or Formation: {0}", obj);
}


+ 96
- 10
Assets/GWConquest/Scripts/UI/TransportUIElement.cs View File

@ -5,9 +5,10 @@ using System.Linq;
namespace GWConquest
{
public class TransportUIElement : MonoBehaviour, IUpdatable<object>
public class TransportUIElement : DragDropElement, IUpdatable<object>
{
public Image SpriteImage;
public RectTransform ImageTransform;
public Text NameText;
public RectTransform Arrow;
@ -31,8 +32,13 @@ namespace GWConquest
private List<TransportUIItemIcon> ItemIconList = new List<TransportUIItemIcon>();
public enum ObjectType
{
District, Formation, Planet
}
[System.NonSerialized]
public bool IsDistrict;
public ObjectType Type;
[System.NonSerialized]
public District District;
@ -40,6 +46,9 @@ namespace GWConquest
[System.NonSerialized]
public Formation Formation;
[System.NonSerialized]
public Planet Planet;
[System.NonSerialized]
public bool IsExpanded = true;
@ -56,7 +65,11 @@ namespace GWConquest
private IEnumerable<ItemStack> GetAllItems()
{
if(IsDistrict)
if(Type == ObjectType.Planet)
{
return Enumerable.Empty<ItemStack>();
}
else if(Type == ObjectType.District)
{
return District.Inventory;
}
@ -67,9 +80,13 @@ namespace GWConquest
private IEnumerable<Formation> GetSubFormations()
{
if(IsDistrict)
if(Type == ObjectType.Planet)
{
return District.Zone.Formations;
return Planet.InTransitFormations;
}
else if(Type == ObjectType.District)
{
return District.Zone.Formations.Where(f => !f.IsEmbarked);
}
else {
return Formation.SubFormations;
@ -118,14 +135,14 @@ namespace GWConquest
elementRT.localScale = Vector3.one;
var elementComp = subElGO.GetComponent<TransportUIElement>();
elementComp.IsDistrict = false;
elementComp.Type = ObjectType.Formation;
elementComp.Formation = d as Formation;
elementComp.Rebuild();
return elementComp;
});
if(!IsDistrict)
if(Type == ObjectType.Formation)
{
var AllUnits = Formation.Units.Where(u => u != Formation.HeroUnit);
GWLayout.UpdateGameObjects(UnitIconList, AllUnits.ToList(), unit => {
@ -159,8 +176,11 @@ namespace GWConquest
UnitIconsTransform.SetAsLastSibling();
ItemIconsTransform.SetAsLastSibling();
if(IsDistrict)
if(Type == ObjectType.Planet)
{
NameText.text = "In Transit";
}
else if(Type == ObjectType.District)
{
SpriteImage.sprite = District.GetCurrentSprite();
NameText.text = District.GetDistrictName();
@ -176,7 +196,11 @@ namespace GWConquest
public object GetObject()
{
if(IsDistrict)
if(Type == ObjectType.Planet)
{
return Planet;
}
else if(Type == ObjectType.District)
{
return District;
}
@ -185,6 +209,68 @@ namespace GWConquest
}
}
public override RectTransform rectTransform => ImageTransform;
public override void OnDragBegin()
{
ChildrenTransform.gameObject.SetActive(false);
Arrow.gameObject.SetActive(false);
NameText.gameObject.SetActive(false);
}
public override bool OnDragFinished()
{
var mousePos = Input.mousePosition;
foreach(var ui in FindObjectsOfType<TransportUIElement>())
{
if (RectTransformUtility.RectangleContainsScreenPoint(ui.GetComponent<RectTransform>(), mousePos))
{
if(Formation.ZoneType == ZoneType.Ground)
{
if (!Formation.IsEmbarked && 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)
{
Formation.StartMovingOnPath(shortestPath.zones);
}
}
else if (ui.Type == ObjectType.Formation && ui.Formation.ZoneType == ZoneType.Space)
{
if(ui.Formation.CanCarry(Formation))
{
if(!Formation.IsEmbarked)
{
// Transition Boden -> Weltall
var goalZone = ui.Formation.currentZone;
var path = new List<Zone>() {Formation.currentZone, goalZone};
Formation.StartMovingOnPath(path, ui.Formation);
}
else {
// Transition Weltall -> Weltall (Flottenwechsel)
// TODO
}
}
}
}
}
}
ChildrenTransform.gameObject.SetActive(true);
Arrow.gameObject.SetActive(true);
NameText.gameObject.SetActive(true);
return true;
}
public override bool CanDrag()
{
return Type == ObjectType.Formation && Formation.CanMove;
}
}
}


+ 1
- 1
Assets/GWConquest/Scripts/UI/TransportUIUnitIcon.cs View File

@ -35,7 +35,7 @@ namespace GWConquest
public override bool OnDragFinished()
{
if (!ParentElement.IsDistrict && Unit.Class.IsHero)
if (ParentElement.Type == TransportUIElement.ObjectType.Formation && Unit.Class.IsHero)
{
var LeaderIcon = ParentElement.SpriteImage.rectTransform;
if (RectTransformUtility.RectangleContainsScreenPoint(LeaderIcon, Input.mousePosition))


+ 2
- 1
Assets/GWConquest/Scripts/Unit.cs View File

@ -144,7 +144,8 @@ namespace GWConquest
playerFormation = formationEntity.GetComponent<Formation>();
playerFormation.gameObject.name = "Formation_" + formationEntity.NetworkId.PackedValue.ToString();
playerFormation.Player = player;
playerFormation.currentZone = zone;
playerFormation.currentZone = zone;
playerFormation.ZoneType = uc.ZoneType;
}
BoltEntity unitEntity = BoltNetwork.Instantiate(BoltPrefabs.Unit);


BIN
Assets/Photon/PhotonBolt/assemblies/bolt.user.dll View File


BIN
Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb View File


+ 80
- 2
Assets/Photon/PhotonBolt/project.json View File

@ -23,6 +23,23 @@
"SnapMagnitude": 10.0
}
},
{
"Name": "IsSpace",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeBool, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
"ExtrapolationErrorTolerance": 0.25,
"_ExtrapolationCorrectionFrames": 6,
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
},
{
"Name": "IsInTransit",
"Enabled": true,
@ -177,6 +194,57 @@
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
},
{
"Name": "MovementTargetFormation",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
"ExtrapolationErrorTolerance": 0.25,
"_ExtrapolationCorrectionFrames": 6,
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
},
{
"Name": "IsEmbarked",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeBool, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
"ExtrapolationErrorTolerance": 0.25,
"_ExtrapolationCorrectionFrames": 6,
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
},
{
"Name": "ParentFormation",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
"ExtrapolationErrorTolerance": 0.25,
"_ExtrapolationCorrectionFrames": 6,
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
}
],
"PacketMaxBits": 512,
@ -592,7 +660,6 @@
{
"Name": "Formation",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
@ -605,7 +672,6 @@
{
"Name": "TargetZone",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
@ -628,6 +694,18 @@
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "TargetFormation",
"Enabled": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
}
],
"EntitySenders": 3,


Loading…
Cancel
Save