Completed course 2 adn 3, working on 4
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user