Skip to content

Commit 7340107

Browse files
committed
Range ruler activation polishing
1 parent c1d50a5 commit 7340107

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

Assets/Scripts/Model/Actions/Actions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public static bool AssignTargetLockToPair(Ship.GenericShip thisShip, Ship.Generi
2626

2727
if (Letters.Count == 0) InitializeTargetLockLetters();
2828

29-
MovementTemplates.ShowRange(thisShip, targetShip);
30-
3129
if (GetRange(thisShip, targetShip) < 4)
3230
{
3331
Tokens.GenericToken existingBlueToken = thisShip.GetToken(typeof(Tokens.BlueTargetLockToken), '*');
@@ -124,7 +122,7 @@ public static bool InArcCheck(Ship.GenericShip thisShip, Ship.GenericShip anothe
124122
Vector3 vectorToTarget = objAnother.Value - objThis.Value;
125123
float angle = Vector3.Angle(vectorToTarget, vectorFacing);
126124
//Debug.Log ("Angle between " + objThis.Key + " and " + objAnother.Key + " is: " + angle.ToString ());
127-
MovementTemplates.ShowFiringArcRange(thisShip, anotherShip);
125+
128126
if (angle <= 40)
129127
{
130128
inArc = true;
@@ -221,7 +219,7 @@ public static void DeclareTarget()
221219
//check is target available for attack
222220

223221
bool inArc = InArcCheck(Selection.ThisShip, Selection.AnotherShip);
224-
int distance = GetFiringRangeAndShow(Selection.ThisShip, Selection.AnotherShip);
222+
int distance = GetFiringRange(Selection.ThisShip, Selection.AnotherShip);
225223
int attackTypesAreAvailable = Selection.ThisShip.GetAttackTypes(distance, inArc);
226224

227225
if (attackTypesAreAvailable > 1)
@@ -243,10 +241,12 @@ public static void DeclareTarget()
243241
public static void TryPerformAttack()
244242
{
245243
Game.UI.HideContextMenu();
244+
MovementTemplates.ReturnRangeRuler();
245+
246246
//TODO: CheckShot is needed before
247247
if (TargetIsLegal())
248248
{
249-
Board.ShowFiringLine(Selection.ThisShip, Selection.AnotherShip);
249+
Board.LaunchObstacleChecker(Selection.ThisShip, Selection.AnotherShip);
250250
//Call later "Combat.PerformAttack(Selection.ThisShip, Selection.AnotherShip);"
251251
}
252252
else

Assets/Scripts/Model/Phases/SubPhases/CombatSubPhase.cs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public override bool AnotherShipCanBeSelected(Ship.GenericShip targetShip)
132132
{
133133
if (targetShip.Owner.PlayerNo != Phases.CurrentSubPhase.RequiredPlayer)
134134
{
135+
MovementTemplates.ShowFiringArcRange(Selection.ThisShip, targetShip);
135136
result = true;
136137
}
137138
else

Assets/Scripts/Model/Phases/SubPhases/Temporary/SelectTargetSubPhase.cs

+2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ public override bool AnotherShipCanBeSelected(Ship.GenericShip anotherShip)
3636

3737
if (anotherShip.Owner.PlayerNo != Phases.CurrentSubPhase.RequiredPlayer)
3838
{
39+
MovementTemplates.ShowRange(Selection.ThisShip, anotherShip);
3940
if (!Actions.AssignTargetLockToPair(Selection.ThisShip, anotherShip))
4041
{
4142
Selection.ThisShip.RemoveAlreadyExecutedAction(typeof(ActionsList.TargetLockAction));
4243
Phases.CurrentSubPhase = PreviousSubPhase;
4344
Roster.AllShipsHighlightOff();
4445
UpdateHelpInfo();
46+
4547
Actions.ShowActionsPanel();
4648
return false;
4749
}

Assets/Scripts/View/Board/Board.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static Vector3 GetShotVectorToTarget(Ship.GenericShip thisShip, Ship.Gene
108108
return vectorToTarget;
109109
}
110110

111-
public static void ShowFiringLine(Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
111+
public static void LaunchObstacleChecker(Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
112112
{
113113
FiringLineCollisions = new List<Collider>();
114114

Assets/Scripts/View/Board/MovementTemplates.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public static class MovementTemplates {
1717
static MovementTemplates()
1818
{
1919
Game = GameObject.Find("GameManager").GetComponent<GameManagerScript>();
20-
Actions.OnCheckTargetIsLegal += CallShowRange;
2120
Templates = Game.PrefabsList.RulersHolderTransform;
2221
}
2322

@@ -95,11 +94,6 @@ public static void HideLastMovementRuler(){
9594
CurrentTemplate.eulerAngles = savedRulerRotation;
9695
}
9796

98-
public static void CallShowRange(ref bool result, Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
99-
{
100-
ShowRange(thisShip, anotherShip);
101-
}
102-
10397
public static void ShowRange(Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
10498
{
10599
Vector3 vectorToTarget = thisShip.GetClosestEdgesTo(anotherShip)["another"] - thisShip.GetClosestEdgesTo(anotherShip)["this"];
@@ -112,6 +106,7 @@ public static void ShowFiringArcRange(Ship.GenericShip thisShip, Ship.GenericShi
112106
Vector3 closestEdge = thisShip.GetClosestFiringEdgesTo(anotherShip)["this"];
113107
Vector3 vectorToTarget = Board.GetShotVectorToTarget(thisShip, anotherShip);
114108
ShowRangeRuler(closestEdge, vectorToTarget);
109+
if (!Actions.InArcCheck(thisShip, anotherShip)) Messages.ShowError("Out of arc");
115110
}
116111

117112
public static void ShowRangeRuler(Vector3 position, Vector3 direction)

0 commit comments

Comments
 (0)