Example #1
0
    void GetEnemyHighlight()
    {
        GameObject enemyUnit = playerCursor.GetComponent <SelectionCursor>().enemy;

        if (playerCursor.GetComponent <SelectionCursor>().enemy != null && playerCursor.GetComponent <SelectionCursor>().player != null && (enemyTurnManger.GetComponent <EnemyTurnManager>() as MonoBehaviour).enabled == false && (playerTurnManager.GetComponent <PlayerTurnManager>() as MonoBehaviour).enabled == true)
        {
            enemyUnit = playerCursor.GetComponent <SelectionCursor>().enemy;
        }
        else
        {
            enemyUnit = null;
        }

        if (enemyUnit != null)
        {
            FEHostileUnit enemyStats = enemyUnit.GetComponent <CursorBlock>().enemy.GetComponent <FEHostileUnit>();

            enemyHighlight.enabled = true;

            enemyStatsText[0].text = "" + enemyStats.GetCurrentHP() + "/" + enemyStats.maxHp;
            enemyStatsText[1].text = "" + enemyStats.atk;
            enemyStatsText[2].text = "" + enemyStats.def;
            enemyStatsText[3].text = "" + enemyStats.spd;
            enemyStatsText[4].text = "" + enemyStats.lck;
        }
        else
        {
            foreach (var text in enemyStatsText)
            {
                text.text = "";
            }

            enemyHighlight.enabled = false;
        }
    }
Example #2
0
    void LoadAttackState()
    {
        FEFriendlyUnit playerStats = player.GetComponent <FEFriendlyUnit>();
        FEHostileUnit  enemyStats  = null;

        playerAnimator = player.GetComponent <Animator>();

        enemyStats = enemy.GetComponent <CursorBlock>().enemy.GetComponent <FEHostileUnit>();

        int accuracy = 69;

        if (enemy == null)
        {
            attacking = false;
            Debug.Log("No Enemy");
            return;
        }

        int playerChance = accuracy + playerStats.skl * 2 + playerStats.lck / 2;
        int enemyChance  = accuracy + enemyStats.skl * 2 + enemyStats.lck / 2;

        bool playerHit = (Random.Range(0, 100) <= playerChance);
        bool enemyHit  = (Random.Range(0, 100) <= enemyChance);

        if (playerHit)
        {
            attacking = true;
            GetComponent <AudioSource>().PlayOneShot(hitSound);
            attackAnimation = StartCoroutine("AttackAnimation");
            playerAnimator.SetBool("attackPhase", attacking);

            bool crit     = (Random.Range(0, 100) <= playerStats.lck);
            bool outSpeed = playerStats.GetCurrentSpd() > (enemyStats.GetCurrentSpd() + 5);
            int  damage   = playerStats.atk - enemyStats.def;

            if (damage <= 1)
            {
                damage = 1;
            }

            if (outSpeed)
            {
                damage *= 2;
            }

            if (crit)
            {
                GetComponent <AudioSource>().PlayOneShot(critSound);
                damage *= 3;
            }

            if (damage >= enemyStats.GetCurrentHP())
            {
                enemy.GetComponent <CursorBlock>().enemy.GetComponent <FEHostileUnit>().SendMessage("TakeDamage", damage);
                enemy = null;
            }
            else
            {
                enemy.GetComponent <CursorBlock>().enemy.GetComponent <FEHostileUnit>().SendMessage("TakeDamage", damage);
            }
        }

        if (enemyStats && enemy != null)
        {
            bool crit     = (Random.Range(0, 100) <= playerStats.lck);
            bool outSpeed = enemyStats.GetCurrentSpd() > (playerStats.GetCurrentSpd() + 5);
            int  damage   = enemyStats.atk - playerStats.def;

            if (damage <= 1)
            {
                damage = 1;
            }

            if (outSpeed)
            {
                damage *= 2;
            }

            if (crit)
            {
                damage *= 3;
            }

            player.GetComponent <FEFriendlyUnit>().SendMessage("TakeDamage", damage);
        }

        attacking = false;
    }