Browse Source

Flank UI WIP

bolt_update
laurids 3 years ago
parent
commit
d6e0d4a039
20 changed files with 345 additions and 54 deletions
  1. +3
    -3
      Assets/GWConquest/Prefabs/BattleFormationUI.prefab
  2. +2
    -2
      Assets/GWConquest/Prefabs/BattleUnitIcon.prefab
  3. +2
    -2
      Assets/GWConquest/Prefabs/FlankUI.prefab
  4. +19
    -19
      Assets/GWConquest/Scenes/GalaxyMap.unity
  5. +53
    -7
      Assets/GWConquest/Scripts/Battle.cs
  6. +6
    -0
      Assets/GWConquest/Scripts/ServerCallbacks.cs
  7. +20
    -1
      Assets/GWConquest/Scripts/UI/BattleArmyPanel.cs
  8. +14
    -0
      Assets/GWConquest/Scripts/UI/BattleFlankUI.cs
  9. +7
    -2
      Assets/GWConquest/Scripts/UI/BattleFormationUI.cs
  10. +30
    -2
      Assets/GWConquest/Scripts/UI/BattleUI.cs
  11. +39
    -5
      Assets/GWConquest/Scripts/UI/BattleUnitIcon.cs
  12. +3
    -1
      Assets/GWConquest/Scripts/UI/DistrictIcon.cs
  13. +1
    -1
      Assets/GWConquest/Scripts/UI/DragDropElement.cs
  14. +12
    -0
      Assets/GWConquest/Scripts/Unit.cs
  15. +7
    -7
      Assets/GWConquest/Textures/Effects/Explosion 04/BattleUnitIcon.controller
  16. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
  17. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb
  18. +87
    -0
      Assets/Photon/PhotonBolt/project.json
  19. +38
    -0
      ProjectSettings/PackageManagerSettings.asset
  20. +2
    -2
      ProjectSettings/ProjectVersion.txt

+ 3
- 3
Assets/GWConquest/Prefabs/BattleFormationUI.prefab View File

@ -130,7 +130,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 89, y: -11} m_AnchoredPosition: {x: 89, y: -11}
m_SizeDelta: {x: -692.99646, y: 59.742905}
m_SizeDelta: {x: -96, y: 59.742905}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!222 &1816981237351840948 --- !u!222 &1816981237351840948
CanvasRenderer: CanvasRenderer:
@ -243,7 +243,7 @@ PrefabInstance:
- target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea, - target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 39.5
value: 7
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea, - target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea,
type: 3} type: 3}
@ -283,7 +283,7 @@ PrefabInstance:
- target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea, - target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea,
type: 3} type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
value: 0.5
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea, - target: {fileID: 1687732570946376589, guid: 70bba337c1bb2d64e83a214cd4a781ea,
type: 3} type: 3}


+ 2
- 2
Assets/GWConquest/Prefabs/BattleUnitIcon.prefab View File

@ -432,7 +432,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1687732571317619585} m_GameObject: {fileID: 1687732571317619585}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name: m_Name:
@ -444,7 +444,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 89dcc12d2e6cfac4cb7e843686f1dc3b, type: 3}
m_Sprite: {fileID: 0}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1


+ 2
- 2
Assets/GWConquest/Prefabs/FlankUI.prefab View File

@ -31,8 +31,8 @@ RectTransform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}


+ 19
- 19
Assets/GWConquest/Scenes/GalaxyMap.unity View File

@ -6670,7 +6670,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &99124966 --- !u!224 &99124966
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -37303,7 +37303,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &704414502 --- !u!224 &704414502
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -41242,7 +41242,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &765894939 --- !u!224 &765894939
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -45898,7 +45898,7 @@ PrefabInstance:
- target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47, - target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: -60
value: -169.99994
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47, - target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47,
type: 3} type: 3}
@ -45938,7 +45938,7 @@ PrefabInstance:
- target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47, - target: {fileID: 7870129596896663125, guid: 8b0edf9c7ac699a4da4b06f9b352ff47,
type: 3} type: 3}
propertyPath: m_Pivot.y propertyPath: m_Pivot.y
value: 0.5
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8b0edf9c7ac699a4da4b06f9b352ff47, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 8b0edf9c7ac699a4da4b06f9b352ff47, type: 3}
@ -45963,7 +45963,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &858778290 --- !u!224 &858778290
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -53570,12 +53570,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: 0
value: 1
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: 0
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
@ -53755,7 +53755,7 @@ PrefabInstance:
- target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0.000030517578
value: 0.000061035156
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
@ -63487,7 +63487,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1184608294 --- !u!224 &1184608294
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -63511,9 +63511,9 @@ RectTransform:
m_Father: {fileID: 853420528} m_Father: {fileID: 853420528}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -146, y: 236}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: -146, y: -238}
m_SizeDelta: {x: 206.46652, y: 207.34766} m_SizeDelta: {x: 206.46652, y: 207.34766}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1185316499 --- !u!1 &1185316499
@ -66146,7 +66146,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1242157414 --- !u!224 &1242157414
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -109481,7 +109481,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1996625630 --- !u!224 &1996625630
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -115791,7 +115791,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &2120604532 --- !u!224 &2120604532
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -116846,12 +116846,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: 0
value: 1
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: 0
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483005084366, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
@ -116866,7 +116866,7 @@ PrefabInstance:
- target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 77748483683952273, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: -0.000030517578
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1357256667308970758, guid: f69b4b94559d7a14d99e0d870647c1f9, - target: {fileID: 1357256667308970758, guid: f69b4b94559d7a14d99e0d870647c1f9,
type: 3} type: 3}


+ 53
- 7
Assets/GWConquest/Scripts/Battle.cs View File

@ -204,17 +204,23 @@ namespace GWConquest
if(hasChanges) if(hasChanges)
{ {
var ui = IngameUI.Instance.PlanetView.BattleUI;
if(ui.isActiveAndEnabled)
{
ui.PlayerPanel.UpdateIcons();
ui.EnemyPanel.UpdateIcons();
}
SetUIDirty();
} }
} }
public void SetUIDirty(bool updatePositions=false)
{
var ui = IngameUI.Instance.PlanetView.BattleUI;
if(ui.isActiveAndEnabled)
{
if(updatePositions) {
ui.UpdateFormations();
}
ui.UpdateIcons();
}
}
private void SimulateUnitAction(Unit unit) private void SimulateUnitAction(Unit unit)
{ {
BoltLog.Info("Simulating action for unit {0} on turn {1}", unit, BattleTurn); BoltLog.Info("Simulating action for unit {0} on turn {1}", unit, BattleTurn);
@ -259,6 +265,30 @@ namespace GWConquest
} }
} }
public void MoveUnitToFlank(Unit unit, BattleFlank flank, int flankIndex)
{
if(flank.Player != unit.Player)
{
BoltLog.Error("Tried to move unit {0} of player {1} to flank {2} of player {3}", unit, unit.Player, flank, flank.Player);
}
else if(flank.MaxUnitCount <= flankIndex)
{
BoltLog.Error("Tried to move unit {0} to flank index {1} on flank {2} with size {3}", unit, flankIndex, flank, flank.MaxUnitCount);
}
else if(flank.GetUnit(flankIndex) != null)
{
BoltLog.Error("Tried to move unit {0} to flank index {1} on flank {2}, but it was already occupied by {3}", unit, flankIndex, flank, flank.GetUnit(flankIndex));
}
else {
BoltLog.Info("Moving unit {0} to flank index {1} on flank {2}", unit, flankIndex, flank);
unit.BattleState = BattleUnitState.OnFlank;
flank.SetUnit(flankIndex, unit);
SetUIDirty(updatePositions: true);
}
}
private static bool Check(float chance) { private static bool Check(float chance) {
return Random.Range(0f, 1f) <= chance; return Random.Range(0f, 1f) <= chance;
} }
@ -290,5 +320,21 @@ namespace GWConquest
} }
} }
}
public enum BattleUnitState {
InReserve,
OnFlank,
Arriving,
Departing,
MovingToFlank,
MovingToReserve
}
public enum RevealState {
Visible,
FullHidden,
ClassHidden
} }
} }

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

@ -68,5 +68,11 @@ namespace GWConquest
DistrictFactory factory = evnt.Factory.GetComponent<DistrictFactory>(); DistrictFactory factory = evnt.Factory.GetComponent<DistrictFactory>();
factory.AddProductionQueueEntry(evnt.UnitClass, evnt.Player.GetComponent<Player>()); factory.AddProductionQueueEntry(evnt.UnitClass, evnt.Player.GetComponent<Player>());
} }
public override void OnEvent(MoveUnitToFlankEvent evnt)
{
var flank = evnt.Flank.GetComponent<BattleFlank>();
flank.Battle.MoveUnitToFlank(evnt.Unit.GetComponent<Unit>(), flank, evnt.FlankIndex);
}
} }
} }

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

@ -52,11 +52,12 @@ namespace GWConquest {
{ {
var formations = GetBattleFormations().ToList(); var formations = GetBattleFormations().ToList();
foreach(var fui in FormationUIList)
foreach(var fui in FormationUIList.ToList())
{ {
if(formations.Contains(fui.Formation)) if(formations.Contains(fui.Formation))
{ {
formations.Remove(fui.Formation); formations.Remove(fui.Formation);
fui.UpdateUnitIcons();
} }
else { else {
fui.OnRemove(); fui.OnRemove();
@ -145,5 +146,23 @@ namespace GWConquest {
} }
} }
public void OnIconDragged(BattleUnitIcon icon, BattleUnitIcon target)
{
if(icon.Unit.BattleState == BattleUnitState.InReserve)
{
var flankUI = target.GetComponentInParent<BattleFlankUI>();
if(flankUI != null)
{
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();
}
}
}
} }
} }

+ 14
- 0
Assets/GWConquest/Scripts/UI/BattleFlankUI.cs View File

@ -47,6 +47,20 @@ namespace GWConquest {
rt.sizeDelta = new Vector2(Cols * IconSize, rowCount * IconSize); rt.sizeDelta = new Vector2(Cols * IconSize, rowCount * IconSize);
} }
public void UpdateIcons()
{
for(int i = 0; i < Icons.Length; i++)
{
var icon = Icons[i];
var unit = BattleFlank.GetUnit(i);
if(icon.Unit != unit)
{
icon.Init(unit);
}
icon.UpdateIcon();
}
}
} }
} }

+ 7
- 2
Assets/GWConquest/Scripts/UI/BattleFormationUI.cs View File

@ -48,11 +48,16 @@ namespace GWConquest {
return CurrentHeight; return CurrentHeight;
} }
public IEnumerable<Unit> GetShownUnits()
{
return Formation.Units.Where(u => u.BattleState == BattleUnitState.InReserve);
}
public void UpdateUnitIcons() public void UpdateUnitIcons()
{ {
var units = Formation.Units.ToList();
var units = GetShownUnits().ToList();
foreach(var icon in IconList)
foreach(var icon in IconList.ToList())
{ {
if(units.Contains(icon.Unit)) if(units.Contains(icon.Unit))
{ {


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

@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System.Linq;
namespace GWConquest { namespace GWConquest {
public class BattleUI : MonoBehaviour { public class BattleUI : MonoBehaviour {
@ -23,10 +24,11 @@ namespace GWConquest {
public void InitFlankPanel(){ public void InitFlankPanel(){
float width = FlankPanel.rect.width;
var rect = FlankPanel.rect;
//float uiWidth = FlankUIs[0].RectTransform.rect.width; //float uiWidth = FlankUIs[0].RectTransform.rect.width;
float x = width/4;
float x = rect.width/4;
FlankUIs = new BattleFlankUI[Battle.FlankCount]; FlankUIs = new BattleFlankUI[Battle.FlankCount];
for(int i = 0; i < Battle.FlankCount; i++) for(int i = 0; i < Battle.FlankCount; i++)
@ -44,6 +46,22 @@ namespace GWConquest {
} }
var PlayerUIs = FlankUIs.Where(ui => ui.BattleFlank.Player == Player.CurrentPlayer).ToList();
for(int i = 0; i < PlayerUIs.Count; i++)
{
var pos = new Vector2(-x, -(i+1) * rect.height / (PlayerUIs.Count+1));
PlayerUIs[i].RectTransform.anchoredPosition = pos;
}
var EnemyUIs = FlankUIs.Where(ui => ui.BattleFlank.Player != Player.CurrentPlayer).ToList();
for(int i = 0; i < EnemyUIs.Count; i++)
{
var pos = new Vector2(x, -(i+1) * rect.height / (EnemyUIs.Count+1));
EnemyUIs[i].RectTransform.anchoredPosition = pos;
}
} }
@ -54,5 +72,15 @@ namespace GWConquest {
EnemyPanel.UpdateFormations(); EnemyPanel.UpdateFormations();
} }
public void UpdateIcons()
{
PlayerPanel.UpdateIcons();
EnemyPanel.UpdateIcons();
foreach(var flankUI in FlankUIs)
{
flankUI.UpdateIcons();
}
}
} }
} }

+ 39
- 5
Assets/GWConquest/Scripts/UI/BattleUnitIcon.cs View File

@ -2,7 +2,7 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
namespace GWConquest { namespace GWConquest {
public class BattleUnitIcon : MonoBehaviour {
public class BattleUnitIcon : DragDropElement {
public Image IconImage; public Image IconImage;
@ -18,6 +18,8 @@ namespace GWConquest {
[System.NonSerialized] [System.NonSerialized]
public Unit Unit; public Unit Unit;
private RectTransform ImageTransform;
public static int Compare(Unit a, Unit b) public static int Compare(Unit a, Unit b)
{ {
return (int) (a.entity.NetworkId.PackedValue - b.entity.NetworkId.PackedValue); return (int) (a.entity.NetworkId.PackedValue - b.entity.NetworkId.PackedValue);
@ -31,18 +33,28 @@ namespace GWConquest {
public void Init(Unit u) public void Init(Unit u)
{ {
Unit = u; Unit = u;
Unit.CurrentIcon = this;
if(Unit != null)
{
Unit.CurrentIcon = this;
IconImage.sprite = Unit.Class.Sprite;
IconImage.sprite = Unit.Class.Sprite;
IconImage.enabled = true;
}
else {
IconImage.sprite = null;
IconImage.enabled = false;
}
ImageTransform = IconImage.GetComponent<RectTransform>();
} }
public void OnClick(){ public void OnClick(){
GetComponentInParent<BattleArmyPanel>().OnIconClicked(this);
GetComponentInParent<BattleArmyPanel>()?.OnIconClicked(this);
} }
public void UpdateIcon() public void UpdateIcon()
{ {
if(Unit.Hitpoints < Unit.Class.Hitpoints)
if(Unit != null && Unit.Hitpoints < Unit.Class.Hitpoints)
{ {
HealthBarGO.SetActive(true); HealthBarGO.SetActive(true);
float percentage = (float) Unit.Hitpoints / Unit.Class.Hitpoints; float percentage = (float) Unit.Hitpoints / Unit.Class.Hitpoints;
@ -78,6 +90,28 @@ namespace GWConquest {
SoundEffects.Instance.PlayEffect("GlancingHit"); SoundEffects.Instance.PlayEffect("GlancingHit");
} }
public override RectTransform rectTransform => ImageTransform;
public override bool OnDragFinished()
{
if(Unit != null)
{
foreach(BattleUnitIcon icon in FindObjectsOfType<BattleUnitIcon>())
{
var iconRT = icon.GetComponent<RectTransform>();
Vector3 mousePos = Input.mousePosition;
if(RectTransformUtility.RectangleContainsScreenPoint(iconRT, mousePos))
{
GetComponentInParent<BattleArmyPanel>()?.OnIconDragged(this, icon);
break;
}
}
}
return true;
}
} }
} }

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

@ -92,7 +92,7 @@ namespace GWConquest
EnemyIndicatorMask.enabled = false; EnemyIndicatorMask.enabled = false;
} }
BattleIcon.SetActive(district.Zone.HasBattle);
} }
private void Update() { private void Update() {
@ -105,6 +105,8 @@ namespace GWConquest
animator.SetBool("Producing", producing); animator.SetBool("Producing", producing);
} }
} }
BattleIcon.SetActive(district.Zone.HasBattle);
} }
public void OpenBattleMenu() public void OpenBattleMenu()


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

@ -13,7 +13,7 @@ namespace GWConquest
private bool hasMoved = false; private bool hasMoved = false;
public RectTransform rectTransform
public virtual RectTransform rectTransform
{ {
get => GetComponent<RectTransform>(); get => GetComponent<RectTransform>();
} }


+ 12
- 0
Assets/GWConquest/Scripts/Unit.cs View File

@ -39,6 +39,16 @@ namespace GWConquest
get => Formation.Player; get => Formation.Player;
} }
public BattleUnitState BattleState {
get => (BattleUnitState) state.BattleState;
set => state.BattleState = (int) value;
}
public RevealState RevealState {
get => (RevealState) state.RevealState;
set => state.RevealState = (int) value;
}
[System.NonSerialized] [System.NonSerialized]
public BattleUnitIcon CurrentIcon; public BattleUnitIcon CurrentIcon;
@ -88,6 +98,8 @@ namespace GWConquest
} }
} }
} }
} }

+ 7
- 7
Assets/GWConquest/Textures/Effects/Explosion 04/BattleUnitIcon.controller View File

@ -139,14 +139,14 @@ AnimatorStateTransition:
m_Mute: 0 m_Mute: 0
m_IsExit: 0 m_IsExit: 0
serializedVersion: 3 serializedVersion: 3
m_TransitionDuration: 0.15
m_TransitionDuration: 0.1
m_TransitionOffset: 0 m_TransitionOffset: 0
m_ExitTime: 0.75 m_ExitTime: 0.75
m_HasExitTime: 0 m_HasExitTime: 0
m_HasFixedDuration: 1 m_HasFixedDuration: 1
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
m_CanTransitionToSelf: 0
--- !u!1102 &-3473988378507739373 --- !u!1102 &-3473988378507739373
AnimatorState: AnimatorState:
serializedVersion: 5 serializedVersion: 5
@ -194,14 +194,14 @@ AnimatorStateTransition:
m_Mute: 0 m_Mute: 0
m_IsExit: 0 m_IsExit: 0
serializedVersion: 3 serializedVersion: 3
m_TransitionDuration: 0.15
m_TransitionDuration: 0.1
m_TransitionOffset: 0 m_TransitionOffset: 0
m_ExitTime: 0.75 m_ExitTime: 0.75
m_HasExitTime: 0 m_HasExitTime: 0
m_HasFixedDuration: 1 m_HasFixedDuration: 1
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
m_CanTransitionToSelf: 0
--- !u!1102 &-886644631191437290 --- !u!1102 &-886644631191437290
AnimatorState: AnimatorState:
serializedVersion: 5 serializedVersion: 5
@ -300,14 +300,14 @@ AnimatorStateTransition:
m_Mute: 0 m_Mute: 0
m_IsExit: 0 m_IsExit: 0
serializedVersion: 3 serializedVersion: 3
m_TransitionDuration: 0.15
m_TransitionDuration: 0.1
m_TransitionOffset: 0 m_TransitionOffset: 0
m_ExitTime: 0.75 m_ExitTime: 0.75
m_HasExitTime: 0 m_HasExitTime: 0
m_HasFixedDuration: 1 m_HasFixedDuration: 1
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
m_CanTransitionToSelf: 0
--- !u!1102 &3856284254593435620 --- !u!1102 &3856284254593435620
AnimatorState: AnimatorState:
serializedVersion: 5 serializedVersion: 5
@ -371,7 +371,7 @@ AnimatorStateMachine:
m_ChildStates: m_ChildStates:
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 4230381212576871578} m_State: {fileID: 4230381212576871578}
m_Position: {x: 430, y: -60, z: 0}
m_Position: {x: 450, y: -80, z: 0}
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 3856284254593435620} m_State: {fileID: 3856284254593435620}
m_Position: {x: 430, y: 50, z: 0} m_Position: {x: 430, y: 50, z: 0}


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


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


+ 87
- 0
Assets/Photon/PhotonBolt/project.json View File

@ -637,6 +637,24 @@
"ExtrapolationMaxFrames": 9, "ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0 "SnapMagnitude": 10.0
} }
},
{
"Name": "BattleState",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeInteger, bolt.compiler",
"MaxValue": 255
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyStateSettings, bolt.compiler",
"ExtrapolationErrorTolerance": 0.25,
"_ExtrapolationCorrectionFrames": 6,
"ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0
}
} }
], ],
"PacketMaxBits": 512, "PacketMaxBits": 512,
@ -1303,6 +1321,75 @@
"Name": "BattleFlankState", "Name": "BattleFlankState",
"Guid": "b15bfd78-d5db-4d5f-b238-6a1404090291", "Guid": "b15bfd78-d5db-4d5f-b238-6a1404090291",
"Groups": [] "Groups": []
},
{
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [
{
"Name": "Unit",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "Flank",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
},
{
"Name": "FlankIndex",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeInteger, bolt.compiler",
"MaxValue": 255
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
}
],
"Name": "MoveUnitToFlankEvent",
"Guid": "77ef4859-2899-4c6c-85b6-176c93b60157",
"Groups": []
},
{
"$type": "Bolt.Compiler.EventDefinition, bolt.compiler",
"Properties": [
{
"Name": "Unit",
"Enabled": true,
"Expanded": true,
"ReplicationMode": 1,
"Priority": 1,
"PropertyType": {
"$type": "Bolt.Compiler.PropertyTypeEntity, bolt.compiler"
},
"AssetSettings": {
"$type": "Bolt.Compiler.PropertyEventSettings, bolt.compiler"
}
}
],
"Name": "MoveUnitToReserveEvent",
"Guid": "0903b28c-f966-427e-b2f4-d1a6652803f0",
"Groups": []
} }
], ],
"ActiveGroup": "Everything" "ActiveGroup": "Everything"

+ 38
- 0
ProjectSettings/PackageManagerSettings.asset View File

@ -0,0 +1,38 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier: UnityEditor:UnityEditor.PackageManager.UI:PackageManagerProjectSettings
m_ScopedRegistriesSettingsExpanded: 1
oneTimeWarningShown: 0
m_Registries:
- m_Id: main
m_Name:
m_Url: https://packages.unity.com
m_Scopes: []
m_IsDefault: 1
m_UserSelectedRegistryName:
m_UserAddingNewScopedRegistry: 0
m_RegistryInfoDraft:
m_ErrorMessage:
m_Original:
m_Id:
m_Name:
m_Url:
m_Scopes: []
m_IsDefault: 0
m_Modified: 0
m_Name:
m_Url:
m_Scopes:
-
m_SelectedScopeIndex: 0

+ 2
- 2
ProjectSettings/ProjectVersion.txt View File

@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.11f1
m_EditorVersionWithRevision: 2019.4.11f1 (2d9804dddde7)
m_EditorVersion: 2019.4.12f1
m_EditorVersionWithRevision: 2019.4.12f1 (225e826a680e)

Loading…
Cancel
Save