mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 17:43:12 +02:00
merloj: Fixed bug with empty squad
This commit is contained in:
parent
150f828c22
commit
06c13568c1
@ -78,7 +78,7 @@ MonoBehaviour:
|
||||
MySquad: {fileID: 0}
|
||||
rangeAttack: 3
|
||||
rangeView: 1
|
||||
damageAttack: 1
|
||||
damageAttack: 10
|
||||
speedAttack: 2
|
||||
lastAttackTick: -1
|
||||
target: {fileID: 0}
|
||||
|
||||
@ -63,6 +63,19 @@ public class Squad : MonoBehaviour
|
||||
soldiers.RemoveFromList(soldier);
|
||||
((Soldier)soldier).MySquad = null;
|
||||
soldier.OnDeath.RemoveListener(RemoveSoldierFromSquad);
|
||||
|
||||
if (soldiers.GetCount() == 0)
|
||||
{
|
||||
Soldier[] objs = FindObjectsOfType<Soldier>();
|
||||
|
||||
foreach (Soldier obj in objs)
|
||||
{
|
||||
if (obj != soldier && obj.GetOwnTeam() == ownTeam)
|
||||
{
|
||||
AddSoldierToSquad(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSpottedEnemy(Entity enemy)
|
||||
|
||||
@ -63,6 +63,11 @@ public class TTLList<T> where T : UnityEngine.Object
|
||||
return new List<T>(dict.Keys);
|
||||
}
|
||||
|
||||
public int GetCount()
|
||||
{
|
||||
return dict.Count;
|
||||
}
|
||||
|
||||
// ---------- private methods
|
||||
|
||||
// DEBUG - Changes a view list to see soldiers active in squad in inspector
|
||||
|
||||
Loading…
Reference in New Issue
Block a user