public IEnumerator Live() { List <HexTile> tiles = CombatManager.activeWorld.tiles; List <int> next = new List <int>(); List <int> toAdd = new List <int>(); List <int> glyphed = new List <int>(); for (int i = 0; i < castedTiles.Count; i++) { next.Add(castedTiles[i]); } //be alive for a few gens, then give castedTiles for (int i = 0; i < generations; i++) { //start at origin //check neighbor's tiletype, height, and state foreach (int t in next) { HexTile ht = tiles[t]; //find out value of this tile in next gen //check neighbors int sum = 0; foreach (int n in ht.neighbors) { HexTile nt = tiles[n]; if (nt.generation > ht.generation) { sum += 2; } if (nt.generation == ht.generation) { sum += 1; } //no need to write the += 0 case toAdd.Add(n); } if (rules[sum]) { if (ht.generation == World.zeroState) { ht.generation = World.oneState; ht.ChangeType(ht.type); } if (ht.generation == World.oneState) { ht.generation = glyph; glyphed.Add(ht.index); ht.ChangeType(ht.type); } if (ht.generation == glyph) { //glyph next step ht.generation = World.oneState; glyphed.Remove(ht.index); ht.ChangeType(ht.type); } } } for (int n = 0; n < toAdd.Count; n++) { if (!next.Contains(toAdd[n])) { next.Add(toAdd[n]); } } yield return(new WaitForSeconds(0.5f)); } //cast spells on glyphs foreach (int t in glyphed) { RuneHex rh = new WaterAttackI(); // spells.SingleTargetHexes[glyph]; //castedtiles test List <int> c = new List <int>(); c.Add(t); rh.Initialize(c); //Debug.Log("getting here"); rh.Cast(t); yield return(null); } yield return(null); }