Пример #1
0
    IEnumerator PlayerAttack()
    {
        if (target == 1)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitOne.TakeDamage(playerUnit.GetAttackDamage());

                if (moldUnitOne.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitOne.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitOne, 2f, 1));
                }
            }
        }

        else if (target == 2)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitTwo.TakeDamage(gm.playerBattle.GetComponent <PlayerBattle>().GetAttackDamage());

                if (moldUnitTwo.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitTwo.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitTwo, 2f, 2));
                }
            }
        }

        else if (target == 3)
        {
            if (playerUnit.AttemptAttack())
            {
                bossUnit.TakeDamage(true, gm.playerBattle.GetComponent <PlayerBattle>().GetAttackDamage());

                if (bossUnit.GetHealth() <= 0.0f)
                {
                    experienceGained += 10 * 0.2f;
                    SceneManager.LoadScene("To Be Continued");
                }
            }
        }

        if (currEnemies == 0)
        {
            Destroy(moldUnitOne.gameObject);
            Destroy(moldUnitTwo.gameObject);
        }

        yield return(new WaitForSeconds(4f));

        state = BattleState.ENEMYTURN;
        EnemyTurn();
    }
Пример #2
0
    IEnumerator PlayerAttack()
    {
        if (target == 1)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitOne.TakeDamage(2.0f);


                if (moldUnitOne.currHealth <= 0.0f)
                {
                    numEnemies--;
                    experienceGained += moldUnitOne.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitOne, 2f));
                }
            }
        }

        else if (target == 2)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitTwo.TakeDamage(2.0f);

                if (moldUnitTwo.currHealth <= 0.0f)
                {
                    numEnemies--;
                    experienceGained += moldUnitTwo.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitTwo, 2f));
                }
            }
        }

        else if (target == 3)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitThree.TakeDamage(2.0f);

                if (moldUnitThree.currHealth <= 0.0f)
                {
                    numEnemies--;
                    experienceGained += moldUnitThree.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitThree, 2f));
                }
            }
        }

        else if (target == 4)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitFour.TakeDamage(2.0f);

                if (moldUnitFour.currHealth <= 0.0f)
                {
                    numEnemies--;
                    experienceGained += moldUnitFour.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitFour, 2f));
                }
            }
        }

        if (numEnemies == 0)
        {
            yield return(new WaitForSeconds(3f));

            dialogueText.text = "You recieved " + experienceGained * 10 + " XP";

            if (gm.GetLevel() == 1)
            {
                int chanceGlue = Random.Range(1, 100);

                if (chanceGlue == 42)
                {
                    loot.Add("Glue");
                    dialogueText.text += "\nMOLD dropped some glue. Strange. How did it get a chunk of glue?";
                }

                int chanceSoap = Random.Range(1, 100);

                if (chanceSoap <= 10)
                {
                    loot.Add("Soap");
                    dialogueText.text += "\nMOLD dropped a bit of soap. Could be useful.";
                }
            }

            gm.AddLoot(loot);
            gm.SetExperiencePoints(experienceGained);
            state = BattleState.WON;
            FreeRoam();
        }

        else
        {
            yield return(new WaitForSeconds(3f));

            state = BattleState.ENEMYTURN;
            EnemyTurn();
        }
    }
Пример #3
0
    IEnumerator PlayerAttack()
    {
        if (target == 1)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitOne.TakeDamage(playerUnit.GetAttackDamage());

                if (moldUnitOne.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitOne.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitOne, 2f, 1));
                }
            }
        }

        else if (target == 2)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitTwo.TakeDamage(playerUnit.GetAttackDamage());

                if (moldUnitTwo.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitTwo.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitTwo, 2f, 2));
                }
            }
        }

        else if (target == 3)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitThree.TakeDamage(gm.playerBattle.GetComponent <PlayerBattle>().GetAttackDamage());

                if (moldUnitThree.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitThree.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitThree, 2f, 3));
                }
            }
        }

        else if (target == 4)
        {
            if (playerUnit.AttemptAttack())
            {
                moldUnitFour.TakeDamage(gm.playerBattle.GetComponent <PlayerBattle>().GetAttackDamage());

                if (moldUnitFour.currHealth <= 0.0f)
                {
                    currEnemies--;
                    experienceGained += moldUnitFour.GetLevel() * 0.2f;
                    StartCoroutine(RemoveEnemy(moldUnitFour, 2f, 4));
                }
            }
        }

        if (currEnemies == 0)
        {
            string endBattle = "You recieved " + experienceGained * 10 + " XP";
            float  delay     = 5f;

            if (gm.GetLevel() == 1)
            {
                int chanceGlue = Random.Range(1, 100);

                if (chanceGlue <= 5)
                {
                    loot.Add("Glue");
                    endBattle += "\nMOLD dropped some glue. Strange. How did it get a chunk of glue?";
                    delay     += 15f;
                }

                int chanceSoap = Random.Range(1, 100);

                if (chanceSoap >= 80)
                {
                    loot.Add("Soap");
                    endBattle += "\nMOLD dropped a bit of soap. Could be useful.";
                    delay     += 10f;
                }
            }

            StartCoroutine(PrintText(endBattle));

            yield return(new WaitForSeconds(delay));

            gm.AddLoot(loot);
            gm.SetExperiencePoints(experienceGained);
            state = BattleState.WON;
            FreeRoam();
        }

        else
        {
            yield return(new WaitForSeconds(3f));

            state = BattleState.ENEMYTURN;
            EnemyTurn();
        }
    }