示例#1
0
 public void RemoveEnemy(EnemyDisplay enemy)
 {
     enemies.Remove(enemy);
     SetCardTargets();
     if (enemies.Count <= 0)
     {
         //tell the combat controller that the player killed all the enemies
         EnemyState.Invoke(6);
     }
 }
示例#2
0
    public void setEnemyDisplay(EnemyDisplay display)
    {
        bool thisIsDumb = true;

        enemies.ForEach(enemy =>
        {
            enemy.GetComponent <Enemy>().setDisplay(display, thisIsDumb);
            thisIsDumb = !thisIsDumb;
        });
    }
 public void DeployEncounter()
 {
     for (int i = 0; i < encounter.encounterData.Length; i++)
     {
         if (encounter.encounterData[i] != null)
         {
             GameObject   inst    = Instantiate(encounter.enemyPrefab.gameObject, spawnPoints[i].position, Quaternion.identity, enemyPanel.transform);
             EnemyDisplay display = inst.GetComponent <EnemyDisplay>();
             display.enemy             = encounter.encounterData[i];
             inst.transform.localScale = new Vector3(54f, 54f, 54f);
         }
     }
 }
示例#4
0
    private void DrawEnemy()
    {
        var battle       = _currentBattle;
        var enemyDisplay = EnemyDisplay.Get(battle.enemies.Count - 1);

        Show(enemyDisplay.DisplayContainerName);

        var count = battle.enemies.Count;

        for (var i = 0; i < count; i++)
        {
            var containerName = enemyDisplay.ContainerNames[i] + "_" + count;
            DrawSpriteToGameObject(battle.enemies[i].image, containerName);
        }
    }
示例#5
0
    public void setDisplay(EnemyDisplay display, bool r)
    {
        switch (display)
        {
        case EnemyDisplay.Complex:
            toggleComplex(r);
            break;

        case EnemyDisplay.Invisible:
            toggleInvisible();
            break;

        case EnemyDisplay.Simple:
            toggleSimple();
            break;
        }
    }
示例#6
0
    // SELECTORS
    public void OnSelectEnemy(int index)
    {
        if (_enemies[index].currentHp <= 0)
        {
            return;
        }

        var count        = _currentBattle.enemies.Count;
        var enemyDisplay = EnemyDisplay.Get(count - 1);

        GetEnemiesPresentIndexes().ForEach(i =>
        {
            SetColorToGameObject(Color.white, enemyDisplay.ContainerNames[i] + "_" + count);
        });

        SetColorToGameObject(Color.yellow, enemyDisplay.ContainerNames[index] + "_" + count);

        SelectedEnemyIndex = index;
    }
示例#7
0
    private IEnumerator HeroAttack()
    {
        // definir inimigo
        var index = SelectedEnemyIndex;
        var enemy = _enemies[index];

        // executar regra pré ataque
        ExecuteRule(RuleType.BeforeHeroAttack);

        // definir quem ataca
        var heroes = _heroes.FindAll(h => h.IsPresent);
        var hero   = heroes[_currentHeroIndex];

        // atacar
        var previousHp = enemy.currentHp;

        BattleService.Attack(hero, enemy);

        var currentHp = enemy.currentHp;

        // verificar se causou dano
        var enemyDisplay = EnemyDisplay.Get(_enemies.Count - 1);
        var tagName      = enemyDisplay.ContainerNames[index] + "_" + _enemies.Count;

        var attackValue = previousHp - currentHp;

        if (_strongestAttack < attackValue)
        {
            _strongestAttack = attackValue;
            HeroWhoGaveTheStrongestAttack = hero;
        }

        if (previousHp != currentHp)
        {
            for (var i = 0; i < 5; i++)
            {
                yield return(new WaitForSeconds(0.1f));

                SetColorToGameObject(Color.red, tagName);

                yield return(new WaitForSeconds(0.1f));

                SetColorToGameObject(Color.white, tagName);
            }
        }

        // alterar status da vida
        if (currentHp <= 0)
        {
            enemy.isPresent = false;

            SetColorToGameObject(Color.black, tagName);
        }

        // verificar se existem inimigos vivos
        var thereAreEnemiesAlive = _enemies.Any(e => e.isPresent);

        if (!thereAreEnemiesAlive)
        {
            //TODO: Verificar se toda a equipe ganha xp, mesmo se tiver morrido.
            HeroBattleCalculator.CalculateTheExperienceGained(heroes, _enemies);


            SkillsViewerService.GetInstance().Heroes = _heroes.ConvertAll(h => h.Name).ToArray();
            SceneManager.LoadScene(_currentBattle.whereToGoWhenTheBattleIsOver);
        }

        // executar regra pos ataque
        ExecuteRule(RuleType.AfterHeroAttack);

        var count = heroes.FindAll(h => h.IsPresent).Count;

        // se Existir aliados continuar ataque
        if (_currentHeroIndex + 1 < count)
        {
            _currentHeroIndex++;
            DrawAttackMenu();
            yield break;
        }

        // ir para a próxima fase da batalha
        _currentHeroIndex = 0;
        DrawDefenseMenu();
    }
示例#8
0
 public void AddEnemy(EnemyDisplay enemy)
 {
     enemies.Add(enemy);
     SetCardTargets();
 }
示例#9
0
 void Start()
 {
     enemyDisplay = GetComponent <EnemyDisplay>();
 }