public void GenerateAttack(List <string> attackList) { DumbFunction <int, int> .DestroyAllChild(transform); foreach (string attackName in attackList) { AttackData attackData = dataManager.GetAttackData(attackName); attackButtonText.text = attackName; switch (attackData.attackType) { case 0: Instantiate(attackButton, transform).onClick.AddListener(delegate { Debug.Log("ENTERING SINGLE TARGET ATTACK"); GenerateEnemy(AttackSystem.EnemyList(Battlefield.turnList), attackName); }); Debug.Log("Single target generated"); break; case 1: Instantiate(attackButton, transform).onClick.AddListener(delegate { Debug.Log("ENTERING ALL ROUND ATTACK"); foreach (EntityBase target in AttackSystem.EnemyList(Battlefield.turnList).Values) // the turnlist will be changed with the enemyList in the future { ToAttack(target, attackName); // attack all } }); Debug.Log("All attack target generated"); break; case -1: Debug.Log("Invalid attack"); break; } } AdjustButton(transform); Debug.Log("Attack Generation done"); }