Browse Source

Victory Screen, Parallax Improvements

bolt_update
laurids 3 years ago
parent
commit
c38ca3e284
18 changed files with 4984 additions and 2641 deletions
  1. BIN
      Assets/Exo planets/Textures/Skybox star/Stars_background 2.tga
  2. +6
    -5
      Assets/Exo planets/Textures/Skybox star/Stars_background 2.tga.meta
  3. +1
    -1
      Assets/GWConquest/Materials/stars.mat
  4. +2005
    -0
      Assets/GWConquest/Prefabs/UI/OptionsMenu.prefab
  5. +7
    -0
      Assets/GWConquest/Prefabs/UI/OptionsMenu.prefab.meta
  6. +246
    -0
      Assets/GWConquest/Prefabs/UI/UnitInfoPanel/UnitClassIconLarge.prefab
  7. +7
    -0
      Assets/GWConquest/Prefabs/UI/UnitInfoPanel/UnitClassIconLarge.prefab.meta
  8. +1726
    -17
      Assets/GWConquest/Scenes/GalaxyMap.unity
  9. +686
    -2509
      Assets/GWConquest/Scenes/MainMenu.unity
  10. +56
    -16
      Assets/GWConquest/Scripts/Battle.cs
  11. +5
    -0
      Assets/GWConquest/Scripts/BattleLog.cs
  12. +16
    -0
      Assets/GWConquest/Scripts/Formation.cs
  13. +8
    -0
      Assets/GWConquest/Scripts/Parallax.cs
  14. +150
    -66
      Assets/GWConquest/Scripts/UI/BattleUI.cs
  15. +30
    -27
      Assets/GWConquest/Scripts/Unit.cs
  16. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll
  17. BIN
      Assets/Photon/PhotonBolt/assemblies/bolt.user.dll.mdb
  18. +35
    -0
      Assets/Photon/PhotonBolt/project.json

BIN
Assets/Exo planets/Textures/Skybox star/Stars_background 2.tga View File


+ 6
- 5
Assets/Exo planets/Textures/Skybox star/Stars_background 2.tga.meta View File

@ -3,7 +3,7 @@ guid: ebc1ef83e3fdc074897586fcf2a1257f
TextureImporter: TextureImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}
serializedVersion: 10
serializedVersion: 11
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
enableMipMap: 1 enableMipMap: 1
@ -34,9 +34,9 @@ TextureImporter:
filterMode: -1 filterMode: -1
aniso: 2 aniso: 2
mipBias: -100 mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1 nPOTScale: 1
lightmap: 0 lightmap: 0
compressionQuality: 50 compressionQuality: 50
@ -49,7 +49,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 2 alphaUsage: 2
alphaIsTransparency: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1 spriteTessellationDetail: -1
textureType: 0 textureType: 0
textureShape: 1 textureShape: 1
@ -57,6 +57,7 @@ TextureImporter:
maxTextureSizeSet: 0 maxTextureSizeSet: 0
compressionQualitySet: 0 compressionQualitySet: 0
textureFormatSet: 0 textureFormatSet: 0
applyGammaDecoding: 0
platformSettings: platformSettings:
- serializedVersion: 3 - serializedVersion: 3
buildTarget: DefaultTexturePlatform buildTarget: DefaultTexturePlatform


+ 1
- 1
Assets/GWConquest/Materials/stars.mat View File

@ -40,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MainTex: - _MainTex:
m_Texture: {fileID: 2800000, guid: f3c6207eed726f647a77351fd08df05e, type: 3}
m_Texture: {fileID: 2800000, guid: ebc1ef83e3fdc074897586fcf2a1257f, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MetallicGlossMap: - _MetallicGlossMap:


+ 2005
- 0
Assets/GWConquest/Prefabs/UI/OptionsMenu.prefab
File diff suppressed because it is too large
View File


+ 7
- 0
Assets/GWConquest/Prefabs/UI/OptionsMenu.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 90bfe4a417176ed4a9cafec61263a6fb
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 246
- 0
Assets/GWConquest/Prefabs/UI/UnitInfoPanel/UnitClassIconLarge.prefab View File

@ -0,0 +1,246 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6815987389502116021
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6815987389502116018}
- component: {fileID: 6815987389502116017}
- component: {fileID: 6815987389502116016}
- component: {fileID: 6815987389502116019}
m_Layer: 5
m_Name: Count
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6815987389502116018
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987389502116021}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6815987390155653560}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 58, y: 0}
m_SizeDelta: {x: 0, y: 53}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &6815987389502116017
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987389502116021}
m_CullTransparentMesh: 0
--- !u!114 &6815987389502116016
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987389502116021}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: c47f9c9ae53006b46bef8b5c48a002a5, type: 3}
m_FontSize: 34
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 50
m_Alignment: 5
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0
--- !u!114 &6815987389502116019
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987389502116021}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0
--- !u!1 &6815987390155653563
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6815987390155653560}
- component: {fileID: 6815987390155653558}
- component: {fileID: 1138806303401438636}
- component: {fileID: 857289834285570048}
m_Layer: 5
m_Name: UnitClassIconLarge
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6815987390155653560
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390155653563}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 6815987390313110544}
- {fileID: 6815987389502116018}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 10, y: 0}
m_SizeDelta: {x: 77, y: 53}
m_Pivot: {x: 0, y: 1}
--- !u!222 &6815987390155653558
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390155653563}
m_CullTransparentMesh: 0
--- !u!114 &1138806303401438636
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390155653563}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name:
m_EditorClassIdentifier:
Padding: 0
Horizontal: 1
Vertical: 0
--- !u!114 &857289834285570048
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390155653563}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 37142a45667f8764a81893026e91ce40, type: 3}
m_Name:
m_EditorClassIdentifier:
Icon: {fileID: 6815987390313110545}
Amount: {fileID: 6815987389502116016}
--- !u!1 &6815987390313110547
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6815987390313110544}
- component: {fileID: 6815987390313110542}
- component: {fileID: 6815987390313110545}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6815987390313110544
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390313110547}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6815987390155653560}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 53, y: 53}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &6815987390313110542
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390313110547}
m_CullTransparentMesh: 0
--- !u!114 &6815987390313110545
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390313110547}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1

+ 7
- 0
Assets/GWConquest/Prefabs/UI/UnitInfoPanel/UnitClassIconLarge.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a56da3162d4abbd4c8843cb7eb895034
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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


+ 686
- 2509
Assets/GWConquest/Scenes/MainMenu.unity
File diff suppressed because it is too large
View File


+ 56
- 16
Assets/GWConquest/Scripts/Battle.cs View File

@ -54,7 +54,7 @@ namespace GWConquest
public IEnumerable<BattleFlank> AllFlanks public IEnumerable<BattleFlank> AllFlanks
{ {
get => State.Flanks.Select(e => e.GetComponent<BattleFlank>());
get => State.Flanks.Where(e => e != null).Select(e => e.GetComponent<BattleFlank>());
} }
public Zone Zone { public Zone Zone {
@ -69,6 +69,11 @@ namespace GWConquest
get => Zone.zoneType == ZoneType.Space; get => Zone.zoneType == ZoneType.Space;
} }
public bool IsOver {
get => State.IsOver;
set => State.IsOver = value;
}
public override void Attached() public override void Attached()
{ {
FormationList = new EntityList(State, "FormationList"); FormationList = new EntityList(State, "FormationList");
@ -139,6 +144,8 @@ namespace GWConquest
} }
} }
f.RemoveDeadUnits();
OnFormationsChanged(); OnFormationsChanged();
} }
@ -155,29 +162,62 @@ namespace GWConquest
{ {
base.SimulateOwner(); base.SimulateOwner();
var gm = GameManager.Instance;
if(!IsOver)
{
var gm = GameManager.Instance;
var players = AllPlayers;
var playerCount = players.Count();
var players = AllPlayers;
var playerCount = players.Count();
if(playerCount <= 1)
{
if(playerCount <= 0)
if(playerCount <= 1)
{ {
BoltLog.Info("No players in Battle {0}!", this);
}
else {
var finalPlayer = players.First();
BoltLog.Info("Player {0} is only one left in Battle {1}!", finalPlayer, this);
if(playerCount <= 0)
{
BoltLog.Info("No players in Battle {0}!", this);
}
else {
var finalPlayer = players.First();
BoltLog.Info("Player {0} is only one left in Battle {1}!", finalPlayer, this);
}
Zone.CurrentBattle = null;
SetBattleOver();
//Destroy(gameObject);
} }
Zone.CurrentBattle = null;
SimulateTurn();
}
Destroy(gameObject);
}
public void SetBattleOver()
{
IsOver = true;
var victoriousPlayer = AllPlayers.FirstOrDefault();
if(victoriousPlayer != null)
{
State.VictorID = victoriousPlayer.PlayerId;
}
else {
State.VictorID = -1;
} }
SimulateTurn();
foreach(Unit unit in AllUnits)
{
unit.CurrentFlank = null;
unit.BattleState = BattleUnitState.InReserve;
unit.SetActionCooldown(0f);
}
foreach(var flank in AllFlanks.ToList())
{
BoltNetwork.Destroy(flank.gameObject);
Destroy(flank.gameObject);
}
} }
private void SimulateTurn() private void SimulateTurn()


+ 5
- 0
Assets/GWConquest/Scripts/BattleLog.cs View File

@ -88,5 +88,10 @@ namespace GWConquest
{ {
Entries.Add(new BattleLogEntry(unit, action, target, battle)); Entries.Add(new BattleLogEntry(unit, action, target, battle));
} }
public IEnumerable<BattleLogEntry> GetEntriesForBattle(Battle battle)
{
return Entries.Where(e => e.Battle.Id == battle.entity.NetworkId);
}
} }
} }

+ 16
- 0
Assets/GWConquest/Scripts/Formation.cs View File

@ -812,6 +812,22 @@ namespace GWConquest
} }
} }
public void RemoveDeadUnits()
{
for(int i = UnitEntities.Count-1; i >= 0; i--)
{
var unit = UnitEntities[i].Entity.GetComponent<Unit>();
if(unit.IsDead)
{
UnitEntities.RemoveAt(i);
OnUnitRemoved(unit);
BoltNetwork.Destroy(unit.gameObject);
Destroy(unit.gameObject);
}
}
}


+ 8
- 0
Assets/GWConquest/Scripts/Parallax.cs View File

@ -12,6 +12,8 @@ namespace GWConquest
//public float RotationFactor; //public float RotationFactor;
public float MinScale; public float MinScale;
public float MaxScale; public float MaxScale;
//public float RelativeScaleFactor;
private Vector3 CameraStartPosition; private Vector3 CameraStartPosition;
@ -38,8 +40,14 @@ namespace GWConquest
{ {
var zoomPrecent = Mathf.InverseLerp(gwCamera.minCameraZoom, gwCamera.maxCameraZoom, mainCam.orthographicSize); var zoomPrecent = Mathf.InverseLerp(gwCamera.minCameraZoom, gwCamera.maxCameraZoom, mainCam.orthographicSize);
zoomPrecent = Mathf.Sqrt(zoomPrecent);
var scale = Mathf.Lerp(MinScale, MaxScale, zoomPrecent); var scale = Mathf.Lerp(MinScale, MaxScale, zoomPrecent);
//var camTrans = mainCam.transform;
//var baseVec = RelativeScaleFactor * camTrans.forward + camTrans.right + camTrans.up;
transform.localScale = Vector3.one * scale; transform.localScale = Vector3.one * scale;
} }


+ 150
- 66
Assets/GWConquest/Scripts/UI/BattleUI.cs View File

@ -3,8 +3,10 @@ using UnityEngine.UI;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
namespace GWConquest {
public class BattleUI : MonoBehaviour {
namespace GWConquest
{
public class BattleUI : MonoBehaviour
{
public Battle Battle; public Battle Battle;
@ -40,12 +42,19 @@ namespace GWConquest {
public GameObject HeavyShotPrefab; public GameObject HeavyShotPrefab;
public RectTransform EffectsTransform; public RectTransform EffectsTransform;
public GameObject VictoryPanel;
public Text VictoryText;
public RectTransform OwnLossesTransform;
public RectTransform EnemyLossesTransform;
public GameObject LossIconPrefab;
[System.NonSerialized] [System.NonSerialized]
public bool SelectingTarget = false; public bool SelectingTarget = false;
[System.NonSerialized] [System.NonSerialized]
public Unit SelectingTargetUnit; public Unit SelectingTargetUnit;
public void SetBattle(Battle battle){
public void SetBattle(Battle battle)
{
Battle = battle; Battle = battle;
SelectingTarget = false; SelectingTarget = false;
SelectingTargetUnit = null; SelectingTargetUnit = null;
@ -57,29 +66,30 @@ namespace GWConquest {
FixedUpdate(); FixedUpdate();
} }
public void InitFlankPanel(){
public void InitFlankPanel()
{
var rect = FlankPanel.rect; var rect = FlankPanel.rect;
//float uiWidth = FlankUIs[0].RectTransform.rect.width; //float uiWidth = FlankUIs[0].RectTransform.rect.width;
float x = rect.width/4;
float x = rect.width / 4;
foreach(var ui in FlankUIs)
foreach (var ui in FlankUIs)
{ {
if(ui != null)
if (ui != null)
{ {
Destroy(ui.gameObject); Destroy(ui.gameObject);
} }
} }
//float uiHeight = 1f; //float uiHeight = 1f;
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++)
{ {
var go = Instantiate(FlankUIPrefab); var go = Instantiate(FlankUIPrefab);
var uiRT = go.GetComponent<RectTransform>(); var uiRT = go.GetComponent<RectTransform>();
uiRT.SetParent(FlankPanel); uiRT.SetParent(FlankPanel);
uiRT.localScale = Vector3.one; uiRT.localScale = Vector3.one;
@ -97,37 +107,38 @@ namespace GWConquest {
var PlayerUIs = FlankUIs.Where(ui => ui.BattleFlank.Player == Player.CurrentPlayer).ToList(); var PlayerUIs = FlankUIs.Where(ui => ui.BattleFlank.Player == Player.CurrentPlayer).ToList();
if(PlayerUIs.Count > 0)
if (PlayerUIs.Count > 0)
{ {
float startY = (float)(PlayerUIs.Count - 1) / 2f * FlankUIOffset; float startY = (float)(PlayerUIs.Count - 1) / 2f * FlankUIOffset;
for(int i = 0; i < PlayerUIs.Count; i++)
for (int i = 0; i < PlayerUIs.Count; i++)
{ {
var pos = new Vector2(-x, startY - i * FlankUIOffset); var pos = new Vector2(-x, startY - i * FlankUIOffset);
PlayerUIs[i].RectTransform.anchoredPosition = pos; PlayerUIs[i].RectTransform.anchoredPosition = pos;
} }
} }
var EnemyUIs = FlankUIs.Where(ui => ui.BattleFlank.Player != Player.CurrentPlayer).ToList(); var EnemyUIs = FlankUIs.Where(ui => ui.BattleFlank.Player != Player.CurrentPlayer).ToList();
if(EnemyUIs.Count > 0)
if (EnemyUIs.Count > 0)
{ {
float startY = (float)(EnemyUIs.Count - 1) / 2f * FlankUIOffset; float startY = (float)(EnemyUIs.Count - 1) / 2f * FlankUIOffset;
for(int i = 0; i < EnemyUIs.Count; i++)
for (int i = 0; i < EnemyUIs.Count; i++)
{ {
var pos = new Vector2(x, startY - i * FlankUIOffset); var pos = new Vector2(x, startY - i * FlankUIOffset);
EnemyUIs[i].RectTransform.anchoredPosition = pos; EnemyUIs[i].RectTransform.anchoredPosition = pos;
} }
} }
if(Battle.IsSpaceBattle)
if (Battle.IsSpaceBattle)
{ {
LandscapeImage.enabled = false; LandscapeImage.enabled = false;
} }
else {
else
{
LandscapeImage.enabled = true; LandscapeImage.enabled = true;
} }
} }
@ -138,7 +149,7 @@ namespace GWConquest {
GameObject prefab; GameObject prefab;
string audioEffect = null; string audioEffect = null;
Color color = Color.white; Color color = Color.white;
switch(weaponType)
switch (weaponType)
{ {
case WeaponType.Heavy: case WeaponType.Heavy:
prefab = HeavyShotPrefab; prefab = HeavyShotPrefab;
@ -168,7 +179,7 @@ namespace GWConquest {
var shotSize = shotRT.sizeDelta; var shotSize = shotRT.sizeDelta;
Vector3 attackerPos = attacker.rectTransform.position; Vector3 attackerPos = attacker.rectTransform.position;
Vector3 targetPos; Vector3 targetPos;
if(target.Unit.IsInReserve)
if (target.Unit.IsInReserve)
{ {
var panel = target.GetComponentInParent<BattleArmyPanel>(); var panel = target.GetComponentInParent<BattleArmyPanel>();
Vector3[] corners = new Vector3[4]; Vector3[] corners = new Vector3[4];
@ -177,10 +188,11 @@ namespace GWConquest {
float x = target.Unit.Player == Player.CurrentPlayer ? corners.Max(v => v.x) - offset : corners.Min(v => v.x) + offset; float x = target.Unit.Player == Player.CurrentPlayer ? corners.Max(v => v.x) - offset : corners.Min(v => v.x) + offset;
//float x = panel.FormationsPanelTransform.position.x; //float x = panel.FormationsPanelTransform.position.x;
float y = attackerPos.y; float y = attackerPos.y;
targetPos = new Vector3(x,y,0);
targetPos = new Vector3(x, y, 0);
//Debug.LogFormat("Rect: {0}, target pos: {1}", rect, targetPos); //Debug.LogFormat("Rect: {0}, target pos: {1}", rect, targetPos);
} }
else {
else
{
targetPos = target.rectTransform.position; targetPos = target.rectTransform.position;
} }
@ -189,7 +201,7 @@ namespace GWConquest {
shotRT.rotation = Quaternion.FromToRotation(Vector3.right, targetPos - attackerPos); shotRT.rotation = Quaternion.FromToRotation(Vector3.right, targetPos - attackerPos);
if(audioEffect != null)
if (audioEffect != null)
{ {
SoundEffects.Instance.PlayEffect(audioEffect); SoundEffects.Instance.PlayEffect(audioEffect);
} }
@ -205,7 +217,7 @@ namespace GWConquest {
{ {
PlayerPanel.UpdateIcons(); PlayerPanel.UpdateIcons();
EnemyPanel.UpdateIcons(); EnemyPanel.UpdateIcons();
foreach(var flankUI in FlankUIs)
foreach (var flankUI in FlankUIs)
{ {
flankUI.UpdateIcons(); flankUI.UpdateIcons();
} }
@ -214,51 +226,80 @@ namespace GWConquest {
private void Update() private void Update()
{ {
UpdateFormations(); UpdateFormations();
UpdateIcons();
UpdateIcons();
if(SelectingTarget)
if (SelectingTarget)
{ {
var mousePos = Input.mousePosition; var mousePos = Input.mousePosition;
foreach(var flankUI in FlankUIs)
foreach (var flankUI in FlankUIs)
{ {
if(flankUI.BattleFlank.Player != Player.CurrentPlayer)
if (flankUI.BattleFlank.Player != Player.CurrentPlayer)
{ {
var flankRT = flankUI.GetComponent<RectTransform>(); var flankRT = flankUI.GetComponent<RectTransform>();
var isSelected = RectTransformUtility.RectangleContainsScreenPoint(flankRT, mousePos); var isSelected = RectTransformUtility.RectangleContainsScreenPoint(flankRT, mousePos);
foreach(var icon in flankUI.Icons)
foreach (var icon in flankUI.Icons)
{ {
icon.GetComponent<Animator>().SetBool("Highlight", isSelected); icon.GetComponent<Animator>().SetBool("Highlight", isSelected);
} }
} }
} }
}
if(VictoryPanel.activeSelf)
{
GWLayout.UpdateLayout(OwnLossesTransform);
GWLayout.UpdateLayout(EnemyLossesTransform);
} }
} }
private void FixedUpdate() {
private void FixedUpdate()
{
var planet = Battle.Zone.planet; var planet = Battle.Zone.planet;
var battleCount = planet.GetAllBattles().Count(); var battleCount = planet.GetAllBattles().Count();
if(battleCount > 1)
if (battleCount > 1)
{ {
LeftSwitchArrow.SetActive(true); LeftSwitchArrow.SetActive(true);
RightSwitchArrow.SetActive(true); RightSwitchArrow.SetActive(true);
} }
else {
else
{
LeftSwitchArrow.SetActive(false); LeftSwitchArrow.SetActive(false);
RightSwitchArrow.SetActive(false); RightSwitchArrow.SetActive(false);
} }
BattleNameText.text = "First Battle of " + planet.planetName; BattleNameText.text = "First Battle of " + planet.planetName;
if (Battle.IsOver)
{
if(!VictoryPanel.activeSelf)
{
ShowVictoryScreen();
}
}
else
{
VictoryPanel.SetActive(false);
FlankPanel.gameObject.SetActive(true);
UpdateIndicators();
UpdateTargetSelection();
}
}
public void UpdateIndicators()
{
var formations = Battle.Zone.Formations; var formations = Battle.Zone.Formations;
var strengths = formations.GroupBy(f => f.Player, (p, fs) => new {
var strengths = formations.GroupBy(f => f.Player, (p, fs) => new
{
Player = p, Player = p,
Strength = fs.Sum(f => f.GetFormationStrength()) Strength = fs.Sum(f => f.GetFormationStrength())
} );
});
float playerStrength = strengths.Where(s => s.Player == Player.CurrentPlayer).Sum(s => s.Strength); float playerStrength = strengths.Where(s => s.Player == Player.CurrentPlayer).Sum(s => s.Strength);
float enemyStrength = strengths.Where(s => s.Player != Player.CurrentPlayer).Sum(s => s.Strength); float enemyStrength = strengths.Where(s => s.Player != Player.CurrentPlayer).Sum(s => s.Strength);
@ -268,11 +309,12 @@ namespace GWConquest {
float fullStrength = playerStrength + enemyStrength; float fullStrength = playerStrength + enemyStrength;
if(fullStrength <= 0f)
if (fullStrength <= 0f)
{ {
playerStrength = 0.5f; playerStrength = 0.5f;
} }
else {
else
{
playerStrength /= fullStrength; playerStrength /= fullStrength;
} }
@ -287,13 +329,13 @@ namespace GWConquest {
float playerMorale = formations.Where(f => f.Player == Player.CurrentPlayer).Sum(f => f.Morale); float playerMorale = formations.Where(f => f.Player == Player.CurrentPlayer).Sum(f => f.Morale);
float playerMoraleMax = formations.Where(f => f.Player == Player.CurrentPlayer).Sum(f => f.StartingMorale); float playerMoraleMax = formations.Where(f => f.Player == Player.CurrentPlayer).Sum(f => f.StartingMorale);
playerMoraleBarImage.fillAmount = playerMorale/playerMoraleMax;
playerMoraleBarImage.fillAmount = playerMorale / playerMoraleMax;
float enemyMorale = formations.Where(f => f.Player != Player.CurrentPlayer).Sum(f => f.Morale); float enemyMorale = formations.Where(f => f.Player != Player.CurrentPlayer).Sum(f => f.Morale);
float enemyMoraleMax = formations.Where(f => f.Player != Player.CurrentPlayer).Sum(f => f.StartingMorale); float enemyMoraleMax = formations.Where(f => f.Player != Player.CurrentPlayer).Sum(f => f.StartingMorale);
enemyMoraleBarImage.fillAmount = enemyMorale/enemyMoraleMax;
enemyMoraleBarImage.fillAmount = enemyMorale / enemyMoraleMax;
if(currentPlayer != null)
if (currentPlayer != null)
{ {
var playerStrengthBarImage = PlayerStrengthBar.GetComponent<Image>(); var playerStrengthBarImage = PlayerStrengthBar.GetComponent<Image>();
playerStrengthBarImage.color = Util.UpdateColorRGB(playerStrengthBarImage.color, currentPlayer.Faction.FactionColor); playerStrengthBarImage.color = Util.UpdateColorRGB(playerStrengthBarImage.color, currentPlayer.Faction.FactionColor);
@ -302,26 +344,29 @@ namespace GWConquest {
PlayerFactionText.text = currentPlayer.Faction.FactionName; PlayerFactionText.text = currentPlayer.Faction.FactionName;
PlayerFactionText.color = Util.UpdateColorRGB(PlayerFactionText.color, currentPlayer.Faction.FactionColor); PlayerFactionText.color = Util.UpdateColorRGB(PlayerFactionText.color, currentPlayer.Faction.FactionColor);
} }
if(enemyPlayer != null)
if (enemyPlayer != null)
{ {
var enemyStrengthBarImage = EnemyStrengthBar.GetComponent<Image>(); var enemyStrengthBarImage = EnemyStrengthBar.GetComponent<Image>();
enemyStrengthBarImage.color = Util.UpdateColorRGB(enemyStrengthBarImage.color, enemyPlayer.Faction.FactionColor);
enemyStrengthBarImage.color = Util.UpdateColorRGB(enemyStrengthBarImage.color, enemyPlayer.Faction.FactionColor);
enemyMoraleBarImage.color = Util.UpdateColorRGB(enemyStrengthBarImage.color, enemyPlayer.Faction.FactionColor); enemyMoraleBarImage.color = Util.UpdateColorRGB(enemyStrengthBarImage.color, enemyPlayer.Faction.FactionColor);
EnemyFactionLogo.sprite = enemyPlayer.Faction.FactionLogo; EnemyFactionLogo.sprite = enemyPlayer.Faction.FactionLogo;
EnemyFactionText.text = enemyPlayer.Faction.FactionName; EnemyFactionText.text = enemyPlayer.Faction.FactionName;
EnemyFactionText.color = Util.UpdateColorRGB(EnemyFactionText.color, enemyPlayer.Faction.FactionColor); EnemyFactionText.color = Util.UpdateColorRGB(EnemyFactionText.color, enemyPlayer.Faction.FactionColor);
} }
}
if(SelectingTarget)
public void UpdateTargetSelection()
{
if (SelectingTarget)
{ {
if(Input.GetButtonDown("Left Click"))
if (Input.GetButtonDown("Left Click"))
{ {
bool hasTarget = false; bool hasTarget = false;
BattleFlank flank = null; BattleFlank flank = null;
var mousePos = Input.mousePosition; var mousePos = Input.mousePosition;
if(RectTransformUtility.RectangleContainsScreenPoint(EnemyPanel.GetComponent<RectTransform>(), mousePos))
if (RectTransformUtility.RectangleContainsScreenPoint(EnemyPanel.GetComponent<RectTransform>(), mousePos))
{ {
hasTarget = true; hasTarget = true;
flank = null; flank = null;
@ -332,7 +377,7 @@ namespace GWConquest {
{ {
if (flankUI.BattleFlank.Player != Player.CurrentPlayer) if (flankUI.BattleFlank.Player != Player.CurrentPlayer)
{ {
if(RectTransformUtility.RectangleContainsScreenPoint(flankUI.GetComponent<RectTransform>(), mousePos))
if (RectTransformUtility.RectangleContainsScreenPoint(flankUI.GetComponent<RectTransform>(), mousePos))
{ {
hasTarget = true; hasTarget = true;
flank = flankUI.BattleFlank; flank = flankUI.BattleFlank;
@ -342,7 +387,7 @@ namespace GWConquest {
} }
} }
if(hasTarget)
if (hasTarget)
{ {
var ev = StartShellingEvent.Create(Bolt.GlobalTargets.OnlyServer); var ev = StartShellingEvent.Create(Bolt.GlobalTargets.OnlyServer);
ev.Unit = SelectingTargetUnit.entity; ev.Unit = SelectingTargetUnit.entity;
@ -353,13 +398,11 @@ namespace GWConquest {
EndTargetSelection(); EndTargetSelection();
} }
} }
} }
public void SelectIconOnFlank(BattleUnitIcon icon) public void SelectIconOnFlank(BattleUnitIcon icon)
{ {
if(Battle.IsSpaceBattle)
if (Battle.IsSpaceBattle)
{ {
var ownFlank = icon.Flank; var ownFlank = icon.Flank;
var opposingFlank = ownFlank.OpposingFlank; var opposingFlank = ownFlank.OpposingFlank;
@ -368,15 +411,16 @@ namespace GWConquest {
int attackRange = icon.Unit.Class.AttackRange; int attackRange = icon.Unit.Class.AttackRange;
Debug.Log("Selecting icon on flank"); Debug.Log("Selecting icon on flank");
foreach(var flankIcon in opposingFlank.CurrentUI.Icons)
foreach (var flankIcon in opposingFlank.CurrentUI.Icons)
{ {
int row = BattleFlank.GetRowFromIndex(flankIcon.FlankIndex); int row = BattleFlank.GetRowFromIndex(flankIcon.FlankIndex);
if(Mathf.Abs(row-ownRow) <= attackRange)
if (Mathf.Abs(row - ownRow) <= attackRange)
{ {
flankIcon.GetComponent<Animator>().SetBool("InRange", true); flankIcon.GetComponent<Animator>().SetBool("InRange", true);
} }
else {
else
{
flankIcon.GetComponent<Animator>().SetBool("InRange", false); flankIcon.GetComponent<Animator>().SetBool("InRange", false);
} }
} }
@ -403,19 +447,20 @@ namespace GWConquest {
int currentIndex = battles.IndexOf(Battle); int currentIndex = battles.IndexOf(Battle);
int newIndex; int newIndex;
if(forward)
if (forward)
{ {
newIndex = currentIndex + 1; newIndex = currentIndex + 1;
} }
else {
else
{
newIndex = currentIndex - 1; newIndex = currentIndex - 1;
} }
if(newIndex >= battles.Count)
if (newIndex >= battles.Count)
{ {
newIndex -= battles.Count; newIndex -= battles.Count;
} }
else if(newIndex < 0)
else if (newIndex < 0)
{ {
newIndex += battles.Count; newIndex += battles.Count;
} }
@ -427,12 +472,12 @@ namespace GWConquest {
public void ClickShellingButton(Unit unit) public void ClickShellingButton(Unit unit)
{ {
if(unit.Class.UnitType == UnitType.Artillery)
if (unit.Class.UnitType == UnitType.Artillery)
{ {
SelectingTarget = true; SelectingTarget = true;
SelectingTargetUnit = unit; SelectingTargetUnit = unit;
foreach(var hh in GetComponentsInChildren<HoverHighlight>())
foreach (var hh in GetComponentsInChildren<HoverHighlight>())
{ {
hh.enabled = false; hh.enabled = false;
} }
@ -440,15 +485,15 @@ namespace GWConquest {
EnemyPanel.GetComponentInChildren<HoverHighlightColor>().enabled = true; EnemyPanel.GetComponentInChildren<HoverHighlightColor>().enabled = true;
} }
} }
public void EndTargetSelection() public void EndTargetSelection()
{ {
SelectingTarget = false; SelectingTarget = false;
SelectingTargetUnit = null; SelectingTargetUnit = null;
foreach(var hh in GetComponentsInChildren<HoverHighlight>())
foreach (var hh in GetComponentsInChildren<HoverHighlight>())
{ {
hh.enabled = true; hh.enabled = true;
} }
@ -456,6 +501,45 @@ namespace GWConquest {
EnemyPanel.GetComponentInChildren<HoverHighlightColor>().enabled = false; EnemyPanel.GetComponentInChildren<HoverHighlightColor>().enabled = false;
} }
public void ShowVictoryScreen()
{
FlankPanel.gameObject.SetActive(false);
VictoryPanel.SetActive(true);
if(Battle.State.VictorID == Player.CurrentPlayer.PlayerId)
{
VictoryText.text = "VICTORY";
}
else {
VictoryText.text = "DEFEAT";
}
var losses = BattleLog.Instance.GetEntriesForBattle(Battle).Where(e => e.Action == BattleLog.BattleLogAction.Killed);
var playerLosses = losses.Where(e => e.Target.PlayerID == Player.CurrentPlayer.PlayerId);
ShowLosses(playerLosses, OwnLossesTransform);
var enemyLosses = losses.Where(e => e.Target.PlayerID != Player.CurrentPlayer.PlayerId);
ShowLosses(enemyLosses, EnemyLossesTransform);
}
private void ShowLosses(IEnumerable<BattleLog.BattleLogEntry> losses, RectTransform rt)
{
Util.DestroyAllChildren(rt);
var classes = losses.GroupBy(e => e.Target.UnitClass);
foreach (var group in classes)
{
int count = group.Count();
var go = Instantiate(LossIconPrefab);
GWLayout.InitRectTransform(go.GetComponent<RectTransform>(), rt);
go.GetComponent<TransportUIUnitClassIcon>().UpdateDisplay((group.Key, count));
}
}
} }

+ 30
- 27
Assets/GWConquest/Scripts/Unit.cs View File

@ -288,41 +288,44 @@ namespace GWConquest
public override void SimulateOwner() public override void SimulateOwner()
{ {
if(BattleState == BattleUnitState.Arriving)
if(!IsDead)
{ {
if(Formation.MovementState != FormationMovementState.Idle)
if(BattleState == BattleUnitState.Arriving)
{ {
BattleState = BattleUnitState.InReserve;
}
}
if (ActionCooldown <= 0)
{
State.ActionCooldown = 0;
if (BattleState == BattleUnitState.MovingToFlank)
{
BattleState = BattleUnitState.OnFlank;
}
else if (BattleState == BattleUnitState.MovingToReserve)
{
BattleState = BattleUnitState.InReserve;
CurrentFlank.RemoveUnit(this);
CurrentFlank = null;
if(Formation.MovementState != FormationMovementState.Idle)
{
BattleState = BattleUnitState.InReserve;
}
} }
else if(BattleState == BattleUnitState.StartingShelling)
if (ActionCooldown <= 0)
{ {
BattleState = BattleUnitState.Shelling;
State.ActionCooldown = 0;
if (BattleState == BattleUnitState.MovingToFlank)
{
BattleState = BattleUnitState.OnFlank;
}
else if (BattleState == BattleUnitState.MovingToReserve)
{
BattleState = BattleUnitState.InReserve;
CurrentFlank.RemoveUnit(this);
CurrentFlank = null;
}
else if(BattleState == BattleUnitState.StartingShelling)
{
BattleState = BattleUnitState.Shelling;
}
else if(BattleState == BattleUnitState.StoppingShelling)
{
BattleState = BattleUnitState.InReserve;
FlankTarget = null;
}
} }
else if(BattleState == BattleUnitState.StoppingShelling)
else
{ {
BattleState = BattleUnitState.InReserve;
FlankTarget = null;
State.ActionCooldown -= BoltNetwork.FrameDeltaTime;
} }
} }
else
{
State.ActionCooldown -= BoltNetwork.FrameDeltaTime;
}
} }


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


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


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

@ -1475,6 +1475,41 @@
"ExtrapolationMaxFrames": 9, "ExtrapolationMaxFrames": 9,
"SnapMagnitude": 10.0 "SnapMagnitude": 10.0
} }
},
{
"Name": "IsOver",
"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": "VictorID",
"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,


Loading…
Cancel
Save