Пример #1
0
    public void CheckHitEnemies()
    {
        if (!hero.IsAttacking())
        {
            return;
        }

        Vector3 pos     = hero.GetStrikePosition();
        Vector3 heroPos = hero.transform.position;
        int     hitId   = hero.GetHitId();

        hitList.Clear();
        for (int i = 0; i < objectList.Count; i++)
        {
            IEnemy enemyObj = objectList[i];
            if (enemyObj != null && enemyObj.IsAlive() && enemyObj.CheckHit(pos, hitId))
            {
                enemyObj.Hit();
                hitList.Add(enemyObj);
            }
        }

        if (hitList.Count == 0)
        {
            return;
        }

        hero.strikeHits += hitList.Count;
        SoundHandler.PlaySlash();

        int hitScores      = 0;
        int kills          = 0;
        int killScores     = 0;
        int killMultiplier = 1;

        int     bombs   = 0;
        Vector3 bombPos = Vector3.zero;

        for (int i = 0; i < hitList.Count; i++)
        {
            IEnemy hitEnemy = hitList[i];
            if (hitEnemy == null)
            {
                continue;
            }

            if (hitEnemy.IsBomb())
            {
                bombs++;
                bombPos = hitEnemy.GetPosition();
            }

            if (hitEnemy.IsAlive())
            {
                hitScores += hitEnemy.GetHitScore();
            }
            else
            {
                kills++;
                killScores += hitEnemy.GetKillScore();
                Vector3 enemyPos = hitEnemy.GetPosition();
                Vector3 dir      = enemyPos - heroPos;
                EffectsHandler.PlaySlash(enemyPos, dir);

                hitEnemy.Kill();
                RemoveEnemy(hitEnemy);
            }
        }
        hitList.Clear();

        if (kills >= 10)
        {
            killMultiplier = 5;
        }
        else if (kills >= 5)
        {
            killMultiplier = 3;
        }
        else if (kills >= 3)
        {
            killMultiplier = 2;
        }

        int totalScore = hitScores + killMultiplier * killScores;

        score += totalScore;

        results.score         += totalScore;
        results.enemiesKilled += kills;

        UIManager.GetInstance().UpdateScore(score);

        if (bombs > 0)
        {
            EffectsHandler.PlayBomb(bombPos);
            SoundHandler.GetInstance().PlayEnemySFX("bomb1");
            results.bombed = true;
            LostTheGirl();
        }
        else if (hero.strikeHits >= 10)
        {
            EffectsHandler.PlayCombo();
        }
    }