Exemplo n.º 1
0
        private void CreateItem()
        {
            _currentAmountFood++;

            var item = Instantiate(_foodPrefab, _world.transform).GetComponent <IWorldItem>();

            item.OnDestroyed += OnDestroyedItem;

            _world.AddItem(item);
        }
Exemplo n.º 2
0
        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);
        }