Skip to content

Commit 576e885

Browse files
committed
Update selection highlighting to use team-based colors
Modified SelectionHighlighter to set outline color based on team comparison, showing blue for same team and red for others. Updated InputController to pass team IDs when enabling highlights. Cleaned up unused code and comments in SelectionHighlighter and Vehicle classes.
1 parent f416463 commit 576e885

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

Red Strike/Assets/InputController/InputController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private void HandleObjectSelection()
226226

227227
if (targetHighlighter != null) targetHighlighter.DisableHighlight();
228228
targetHighlighter = GetHighlighter(unit.gameObject);
229-
targetHighlighter?.EnableHighlight();
229+
targetHighlighter?.EnableHighlight(teamId, unit.teamId);
230230
}
231231
else
232232
{
@@ -245,15 +245,15 @@ private void HandleObjectSelection()
245245
if (currentSelectedVehicle != null)
246246
{
247247
vehicleHighlighter = GetHighlighter(unit.gameObject);
248-
vehicleHighlighter?.EnableHighlight();
248+
vehicleHighlighter?.EnableHighlight(teamId, unit.teamId);
249249
vehiclesHUDController?.ShowVehicleDetails(currentSelectedVehicle);
250250
audioSource.PlayOneShot(selectionSound);
251251
}
252252
break;
253253

254254
case Unit.UnitType.Building:
255255
tempBuildingHighlighter = GetHighlighter(unit.gameObject);
256-
tempBuildingHighlighter?.EnableHighlight();
256+
tempBuildingHighlighter?.EnableHighlight(teamId, unit.teamId);
257257

258258
var building = unit.GetComponent<BuildingPlacement.Buildings.Building>();
259259
if (building != null)
Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
using UnityEngine;
2-
using System.Collections.Generic;
32

43
namespace InputController
54
{
65
[RequireComponent(typeof(Outline.Scripts.Outline))]
76
public class SelectionHighlighter : MonoBehaviour
87
{
9-
private Renderer[] renderersToHighlight;
10-
private List<Material> materials = new List<Material>();
11-
private List<Color> originalColors = new List<Color>();
12-
138
private Outline.Scripts.Outline outline;
149

15-
public Color selectionColor;
16-
1710
private void Awake()
1811
{
19-
outline = gameObject.GetComponent<Outline.Scripts.Outline>();
20-
21-
if (renderersToHighlight == null || renderersToHighlight.Length == 0)
22-
renderersToHighlight = GetComponentsInChildren<Renderer>();
23-
24-
foreach (var rend in renderersToHighlight)
25-
{
26-
foreach (var mat in rend.materials)
27-
{
28-
materials.Add(mat);
29-
if (mat.HasProperty("_Color")) originalColors.Add(mat.color);
30-
else originalColors.Add(Color.white);
31-
}
32-
}
12+
outline = GetComponent<Outline.Scripts.Outline>();
13+
if(outline != null) outline.enabled = false;
3314
}
3415

35-
public void EnableHighlight()
16+
public void EnableHighlight(int viewerTeamId, int objectTeamId)
3617
{
18+
if (outline == null) return;
19+
3720
outline.enabled = true;
38-
outline.OutlineColor = selectionColor;
21+
22+
if (viewerTeamId == objectTeamId)
23+
{
24+
outline.OutlineColor = Color.blue;
25+
}
26+
else
27+
{
28+
outline.OutlineColor = Color.red;
29+
}
3930
}
4031

4132
public void DisableHighlight()
4233
{
4334
if (outline != null) outline.enabled = false;
4435
}
4536
}
46-
}
37+
}

Red Strike/Assets/VehicleSystem/Vehicles/Vehicle.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ public class Vehicle : Unit.Unit
2929

3030
[Networked] public NetworkId TargetNetworkId { get; set; }
3131

32-
// [Networked] ekledik ki UI ve Logic her yerde aynı olsun
3332
[Networked] protected int currentAmmunition_bullet { get; set; }
3433
[Networked] protected int currentAmmunition_rocket { get; set; }
3534

36-
// Bu değişkenler yerel kalabilir
3735
protected float bulletCooldownTimer = 0f;
3836
protected float rocketCooldownTimer = 0f;
3937
protected int reloadCounter_bullet = 0;

0 commit comments

Comments
 (0)