private void ReturnUnit(RedemptionTDType type, LiteUnit unit) { var unitsPoolList = unitsPool[type]; var unitsIndex = unitsPoolIndex[type]; if (unitsIndex > 0) { unit.transform.parent = unitsPoolParent; unit.transform.position = Vector3.zero; unitsPoolIndex[type]--; unitsIndex = unitsPoolIndex[type]; unitsPoolList[unitsIndex] = unit; unit.gameObject.SetActive(false); } }
private void SpawnResourceDrops(LiteUnit liteUnit, Vector3 pos) { var enemy = liteUnit.HeavyReference as Enemy; if (enemy == null) { return; } var numToSpawn = UnityEngine.Random.Range(0, enemy.MaxResourceDrops); var units = objectPool.GetUnits(objectPool.GetResourceDropType(enemy.Color), numToSpawn); var count = 0; var resourceMode = UnitMode.CreateUnitMode(); foreach (var resourceDrop in units) { var position = new Vector3(pos.x + UnityEngine.Random.Range(-0.1f, 0.1f), pos.y + UnityEngine.Random.Range(-0.1f, 0.1f), -1f); resourceDrop.SpawnObject(count, position, resourceMode); count++; } }