Exemplo n.º 1
0
    public IEnumerator UsePotionSequence()
    {
        battleState = BattleState.TakingAction;
        Services.battleMenuManager.AllowInput(false);

        // I guess play an animation where the player uses a potion or whatever and then you know like sparkly particles etc etc it'll look real cool yeah
        yield return(new WaitForSeconds(0.75f));

        // Use the thingy majingy :-)
        Services.potionManager.Use();

        for (int i = 0; i < battleSelves.Length; i++)
        {
            DamageNumber healNumber = Instantiate(damageNumberPrefab).GetComponent <DamageNumber>();
            healNumber.transform.position  = battleSelves[i].transform.position;
            healNumber.transform.position += damageNumberOffset;
            healNumber.Initialize(Services.potionManager.healthValue, DamageNumber.HitType.Heal);
        }

        yield return(new WaitForSeconds(0.75f));

        battleState = BattleState.AwaitingInput;
        Services.battleMenuManager.AllowInput(true);

        yield return(null);
    }
Exemplo n.º 2
0
    public IEnumerator AttackSequence()
    {
        battleState = BattleState.TakingAction;
        Services.battleMenuManager.AllowInput(false);

        foreach (BattleSelf battleSelf in battleSelves)
        {
            battleSelf.m_Animator.SetTrigger("Attack Trigger");
        }

        yield return(new WaitForSeconds(1.5f));

        // Show damage numbers
        int deaths = 0;

        foreach (BattleSelf battleSelf in battleSelves)
        {
            // Get damage
            DamageNumber.HitType hitType = DamageNumber.HitType.Normal;
            int damageValue = GetDamageValue(out hitType);

            // Display critical hit effects
            if (hitType == DamageNumber.HitType.Critical)
            {
                // Add more shit here later
            }

            // Test for miss
            if (Services.playerStats.accuracy <= Random.value)
            {
                hitType     = DamageNumber.HitType.Miss;
                damageValue = 0;
            }

            DamageNumber damageNumber = Instantiate(damageNumberPrefab).GetComponent <DamageNumber>();
            damageNumber.transform.position = battleSelf.transform.position + damageNumberOffset;
            damageNumber.Initialize(damageValue, hitType);
            battleSelf.HP -= damageValue;

            if (battleSelf.HP <= 0)
            {
                deaths++;
            }
        }

        // If at least one battleSelf has died.
        if (deaths > 0)
        {
            // If both players die, trigger their death animation without spawning a corpse.
            foreach (BattleSelf battleSelf in battleSelves)
            {
                if (battleSelf.HP <= 0)
                {
                    if (deaths == 2)
                    {
                        battleSelf.Die(false);
                    }
                    else
                    {
                        battleSelf.Die(true);
                    }
                }
            }

            yield return(new WaitForSeconds(2.5f));

            StartCoroutine(BattleEndSequence());
            yield return(null);
        }
        else
        {
            battleState = BattleState.AwaitingInput;
            Services.battleMenuManager.AllowInput(true);
        }

        yield return(null);
    }