public void Drop(int2 dropSpot) { Entity entityToDrop = null; if (alwaysDropTable.Count > 0) { entityToDrop = entityManager.Spawn(alwaysDropTable[0].EntityName); } if (entityToDrop == null) { int totalWeight = 0; for (int i = 0; i < lootTable.Count; i++) { totalWeight += lootTable[i].Weight; } int cumulativeWeight = 0; int randomNumber = Random.Range(0, totalWeight); string entityName = null; int j = 0; while (entityName == null && j < lootTable.Count) { cumulativeWeight += lootTable[j].Weight; if (cumulativeWeight > randomNumber) { entityName = lootTable[j].EntityName; } j++; } if (string.IsNullOrEmpty(entityName) == false) { entityToDrop = entityManager.Spawn(entityName); } } if (entityToDrop != null) { if (entityToDrop.GetComponent <Item>() != null) { mapManager.AddItem(entityToDrop, dropSpot); } else if (entityToDrop.GetComponent <Actor>() != null) { mapManager.AddActor(entityToDrop, dropSpot); } else { mapManager.AddProp(entityToDrop, dropSpot); } DOTween.Sequence() .Append ( entityToDrop.transform.DOLocalMoveY(entityToDrop.transform.localPosition.y + 1f, 0.3f) .SetEase(Ease.OutBack) ) .Append ( entityToDrop.transform.DOLocalMoveY(entityToDrop.transform.localPosition.y, 0.4f) .SetEase(Ease.OutBounce) ); } }