start of draft option upgrades
This commit is contained in:
parent
e78ae0cda1
commit
db9c828e63
7 changed files with 235 additions and 2 deletions
|
|
@ -146,5 +146,30 @@ namespace TD.Gameplay
|
|||
unlockedTypeIds.Add(towerTypeId);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Server-only: replaces a previously unlocked tower type with a different one (an
|
||||
/// upgrade pick) — every tower of that type placed from now on uses the new definition.
|
||||
/// Already-placed towers keep whatever type they were placed with; this only changes
|
||||
/// what's placeable going forward. No-op if the old type isn't currently unlocked or
|
||||
/// the new one already is. Returns true if the swap happened.
|
||||
/// </summary>
|
||||
public bool ServerUpgradeTower(int oldTypeId, int newTypeId)
|
||||
{
|
||||
if (!IsServer) return false;
|
||||
if (newTypeId <= 0) return false;
|
||||
if (Contains(newTypeId)) return false;
|
||||
|
||||
for (int i = 0; i < unlockedTypeIds.Count; i++)
|
||||
{
|
||||
if (unlockedTypeIds[i] == oldTypeId)
|
||||
{
|
||||
unlockedTypeIds.RemoveAt(i);
|
||||
unlockedTypeIds.Add(newTypeId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue