private void CreateItem() { _currentAmountFood++; var item = Instantiate(_foodPrefab, _world.transform).GetComponent <IWorldItem>(); item.OnDestroyed += OnDestroyedItem; _world.AddItem(item); }
public ISnake Create(int initialLength, Vector3Int position, Vector3 direction) { var instance = Instantiate(_prefab); var snake = instance.GetComponent <ISnake>(); (snake as Snake).Construct(initialLength, position, direction, _world); OnCreated?.Invoke(snake); _world.AddItem(snake, false); return(snake); }