コード例 #1
0
    private void Awake()
    {
        Service = SkillsViewerService.GetInstance();
        Heroes  = Service.Heroes;

        if (Heroes == null || Heroes.Length == 0)
        {
            throw new HeroesInvalidArgumentException();
        }

        SkillService = SkillService.GetInstance();
        HeroService  = HeroService.GetInstance();

        CurrentHeroIndex     = 0;
        LastCurrentHeroIndex = -1;
        SelectedSkillIndex   = -1;

        SelectKnowledge = GameObject.FindGameObjectWithTag("SelectKnowledge");
        SelectKnowledge.transform.localScale = new Vector3(0, 0, 0);

        SkillTitle       = GameObject.FindGameObjectWithTag("Skill_tittle").GetComponent <Text>();
        SkillDescription = GameObject.FindGameObjectWithTag("Skill_description").GetComponent <Text>();

        AddSkillError = GameObject.FindGameObjectWithTag("AddSkillError");
        AddSkillError.transform.localScale = new Vector3(0, 0, 0);
    }
コード例 #2
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();
    }
コード例 #3
0
ファイル: CampManager.cs プロジェクト: renantdesouza/CSC
 public void OnClickSkill()
 {
     SkillsViewerService.GetInstance().Heroes = new[] { SelectedHeroName };
     SceneManager.LoadScene("SkillsViewer");
 }