Beispiel #1
0
        public void SpawnPlateItem(List <FoodItem> foodItems)
        {
            var spawns = GetAvailableSpawns();

            if (!spawns.Any())
            {
                return;
            }

            var spawn = spawns[Global.RNG.Next(0, spawns.Count)];

            var rng      = new [] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
            var foodItem = rng[Global.RNG.Next(0, rng.Length)] == 0 && foodItems.Count > 0
                ? _foodLoader.RandomItem(foodItems)
                : _foodLoader.Random();

            var plate  = _plates.PlatesList[(int)spawn.x][(int)spawn.y];
            var sprite = FoodLoader.CreateSprite(foodItem.Texture);

            sprite.Position = plate.GlobalPosition;

            var foodSpawn = new FoodSpawn {
                Name = foodItem.Name, Position = spawn, Sprite = sprite
            };

            _spawns.Add(spawn);
            _foodSpawns.Add(foodSpawn);
            _plates.PlateSpawns.Add(spawn);
            _foodContainer.AddChild(sprite);
        }
Beispiel #2
0
 public FoodSpawner(Plates plates, FoodLoader foodLoader, Node2D foodContainer)
 {
     _plates        = plates;
     _foodLoader    = foodLoader;
     _foodContainer = foodContainer;
 }