예제 #1
0
 public static void TrySpawnCryptDust(CloudCryptDust cloud, IEnumerable <Tile> tiles, Random random)
 {
     foreach (var tile in tiles)
     {
         TrySpawnCryptDust(cloud, tile, random);
     }
 }
예제 #2
0
        public static void TrySpawnCryptDust(CloudCryptDust cloud, Tile tile, Random random)
        {
            var part = cloud.Get(tile);
            List <CryptDustSpawnPos> spawnList = new List <CryptDustSpawnPos>();

            if (part == null)
            {
                return;
            }

            foreach (var spawn in CryptDustSpawn.AllSpawns)
            {
                if (part.Duration >= spawn.TimeMin && part.Duration <= spawn.TimeMax)
                {
                    spawnList.Add(new CryptDustSpawnPos(spawn, part.Tile));
                }
            }

            foreach (var partOther in cloud.Parts)
            {
                int dist = Math.Max(Math.Abs(partOther.MapTile.X - part.MapTile.X), Math.Abs(partOther.MapTile.Y - part.MapTile.Y));
                foreach (var spawn in spawnList)
                {
                    if (spawn.Size >= dist)
                    {
                        spawn.Count++;
                    }
                }
            }

            spawnList.RemoveAll(spawn => !spawn.Valid);
            if (spawnList.Any())
            {
                var picked = spawnList.Pick(random);
                cloud.Remove(tile.GetNearby(picked.Size));

                foreach (var enemy in picked.Spawn.Spawn(cloud.World, tile))
                {
                    enemy.AddControlTurn();
                    new Smoke(cloud.World, enemy.VisualTarget, Vector2.Zero, 0, 15);
                }
            }
        }