public void CreateChildren(GameStateNode state, int depth) { if (depth == 0) { return; } List <playerStateNode> attackers; List <playerStateNode> defenders; state.children = new List <GameStateNode> (); CreateClone.updateHealth(state.entities, "Players"); CreateClone.updateHealth(state.entities, "Enemies"); if (state.enemysTurn) { attackers = state.entities.enemies; defenders = state.entities.players; } else { defenders = state.entities.enemies; attackers = state.entities.players; } for (int i = 0; i < attackers.Count; ++i) { for (int j = 0; j < defenders.Count; ++j) { List <position> possibleMoves; string type = CreateClone.EntityType(!state.enemysTurn, i); if (type == "attacker") { possibleMoves = attacker(CreateClone.entityRange(!state.enemysTurn, i), defenders[j].pos); } else if (type == "healler") { possibleMoves = healler(defenders[j].pos); } else //if(type == "diagnoller"){ { possibleMoves = diagnoller(defenders[j].pos); } foreach (position pos in possibleMoves) { //Debug.Log(pos); if (!CanGoTo(pos, ref state.entities)) { continue; } CreateClone.UpdatePos(!state.enemysTurn, i, pos); CreateClone.attack(!state.enemysTurn, i); state.children.Add(new GameStateNode(state, CreateClone.getStates(), i)); CreateChildren(state.children[state.children.Count - 1], depth - 1); CreateClone.updateHealth(state.entities, "Players"); CreateClone.updateHealth(state.entities, "Enemies"); } } } }