Completed course 2 adn 3, working on 4

This commit is contained in:
2026-03-20 17:34:22 +00:00
parent 623ad6f509
commit db966bab55
507 changed files with 67348 additions and 4667 deletions

View File

@@ -28,6 +28,15 @@ public class UnitSelection : MonoBehaviour
// Update is called once per frame
void Update()
{
//mouse down
if(Input.GetMouseButtonDown(0))
{
startPos = Input.mousePosition;
ToggleSelectionVisual(false);
selectedUnits = new List<Unit>();
TrySelect(Input.mousePosition);
startPos = Input.mousePosition;
}
//mouse up
if(Input.GetMouseButtonUp(0))
{
@@ -38,14 +47,6 @@ public class UnitSelection : MonoBehaviour
{
UpdateSelectionBox(Input.mousePosition);
}
//mouse down
if(Input.GetMouseButtonDown(0))
{
startPos = Input.mousePosition;
ToggleSelectionVisual(false);
selectedUnits = new List<Unit>();
TrySelect(Input.mousePosition);
}
}
//called when we release the selection box
@@ -110,4 +111,13 @@ public class UnitSelection : MonoBehaviour
unit.ToggleSelectionVisual(selected);
}
}
//removes all destroyed or missing units from the selected list
public void RemoveNullUnitsFromSelection()
{
for(int x = 0; x < selectedUnits.Count; x++)
{
if(selectedUnits[x] == null)
selectedUnits.RemoveAt(x);
}
}
}