|
@ -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)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |