Example #1
0
    public void GenerateEnemy(Dictionary <string, EntityBase> enemyList, string attackName)
    {
        DumbFunction <int, int> .DestroyAllChild(transform);

        Text buttonText = enemyButton.GetComponentInChildren <Text>();

        foreach (KeyValuePair <string, EntityBase> data in enemyList)
        {
            buttonText.text = data.Key;
            Button attackTarget = Instantiate(enemyButton, transform);
            attackTarget.onClick.AddListener(delegate { ToAttack(data.Value, attackName); });
        }
        AdjustButton(transform);
    }
Example #2
0
    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");
    }