IEnumerator Attack(int ability, WaifuDetails attacker, WaifuDetails defender) { bool defenderDefeated = false; bool attackerDefeated = false; Ability move = attacker.waifu.MyAbilties.abilityList[ability]; dialogueText.text = attacker.waifu.CharacterName + " uses " + move.AbilityName + "!"; yield return(new WaitForSeconds(1)); float levelAdjustmentBonus = 0.0f; if (MyPlayerNum == state) // my turn use my level { levelAdjustmentBonus = networkClient.MyLevel / 10; } else // other players turn // use their level { levelAdjustmentBonus = networkClient.OpponentLevel / 10; } defenderDefeated = defender.TakeDamage((int)((levelAdjustmentBonus + attacker.waifu.Attack) * move.AttackMultipier * (1.0f + 0.05f * attacker.buffs[(int)BUFF_ARRAY.ATTACK]))); attackerDefeated = attacker.Recoil((int)(move.CostHp)); // buffs and debuffs attacker.buffs[(int)BUFF_ARRAY.ATTACK] = move.SelfBuff[(int)BUFF_ARRAY.ATTACK]; attacker.buffs[(int)BUFF_ARRAY.DEFENCE] = move.SelfBuff[(int)BUFF_ARRAY.DEFENCE]; attacker.buffs[(int)BUFF_ARRAY.LOVE] = move.SelfBuff[(int)BUFF_ARRAY.LOVE]; attacker.buffs[(int)BUFF_ARRAY.ATTACK] -= move.SelfDebuff[(int)BUFF_ARRAY.ATTACK]; attacker.buffs[(int)BUFF_ARRAY.DEFENCE] -= move.SelfDebuff[(int)BUFF_ARRAY.DEFENCE]; attacker.buffs[(int)BUFF_ARRAY.LOVE] -= move.SelfDebuff[(int)BUFF_ARRAY.LOVE]; defender.buffs[(int)BUFF_ARRAY.ATTACK] = move.SelfBuff[(int)BUFF_ARRAY.ATTACK]; defender.buffs[(int)BUFF_ARRAY.DEFENCE] = move.SelfBuff[(int)BUFF_ARRAY.DEFENCE]; defender.buffs[(int)BUFF_ARRAY.LOVE] = move.SelfBuff[(int)BUFF_ARRAY.LOVE]; defender.buffs[(int)BUFF_ARRAY.ATTACK] -= move.SelfDebuff[(int)BUFF_ARRAY.ATTACK]; defender.buffs[(int)BUFF_ARRAY.DEFENCE] -= move.SelfDebuff[(int)BUFF_ARRAY.DEFENCE]; defender.buffs[(int)BUFF_ARRAY.LOVE] -= move.SelfDebuff[(int)BUFF_ARRAY.LOVE]; dialogueText.text = move.Description; yield return(new WaitForSeconds(1)); attacker.Rest((int)((levelAdjustmentBonus + attacker.waifu.Love) * move.LoveMultiplier * (1.0f + 0.05f * attacker.buffs[(int)BUFF_ARRAY.LOVE]))); UpdateCharactersUI(); yield return(new WaitForSeconds(2)); if (CheckPlayerWin()) { state = BattleState.WIN; EndBattle(); } if (CheckEnemyWin()) { state = BattleState.LOOSE; EndBattle(); } Debug.Log("Move Made"); if (state == BattleState.PLAYER2) { state = BattleState.PLAYER1; MoveAvailble = true; Player1Turn(); } else if (state == BattleState.PLAYER1) { state = BattleState.PLAYER2; MoveAvailble = true; Player2Turn(); } }
/// <summary> /// Called when an attack occurs to process the attack effect /// </summary> /// <param name="ability"></param> /// <param name="attacker"></param> /// <param name="defender"></param> /// <returns></returns> IEnumerator Attack(int ability, WaifuDetails attacker, WaifuDetails defender) { bool defenderDefeated = false; bool attackerDefeated = false; //if player 1 use player abilities if not use the preset abilities for enemy Ability move = (attacker == playerDetails ? playerAbilities[ability]: attacker.waifu.MyAbilties.abilityList[ability]); dialogueText.text = attacker.waifu.CharacterName + " uses " + move.AbilityName + "!"; yield return(new WaitForSeconds(1)); //generate a hit chance for our roll float hitChance = UnityEngine.Random.Range(0.0f, 1.0f); //check to see if the hit will succeed if (hitChance > move.PercentChance) { //missed so update the text dialogueText.text = attacker.waifu.CharacterName + " failed to use " + move.AbilityName + "!"; yield return(new WaitForSeconds(1)); } else // ability hit succeeds { //check if escaping if (move.AbilityName == "Escape") { dialogueText.text = attacker.waifu.CharacterName + " managed to " + move.AbilityName + "!"; Debug.Log("Escaped!"); Escape(); //return to the city scene } defenderDefeated = defender.TakeDamage((int)(attacker.waifu.Attack * move.AttackMultipier * (1.0f + 0.05f * attacker.buffs[(int)BUFF_ARRAY.ATTACK]))); attackerDefeated = attacker.Recoil((int)(move.CostHp)); // buffs and debuffs attacker.buffs[(int)BUFF_ARRAY.ATTACK] = move.SelfBuff[(int)BUFF_ARRAY.ATTACK]; attacker.buffs[(int)BUFF_ARRAY.DEFENCE] = move.SelfBuff[(int)BUFF_ARRAY.DEFENCE]; attacker.buffs[(int)BUFF_ARRAY.LOVE] = move.SelfBuff[(int)BUFF_ARRAY.LOVE]; attacker.buffs[(int)BUFF_ARRAY.ATTACK] -= move.SelfDebuff[(int)BUFF_ARRAY.ATTACK]; attacker.buffs[(int)BUFF_ARRAY.DEFENCE] -= move.SelfDebuff[(int)BUFF_ARRAY.DEFENCE]; attacker.buffs[(int)BUFF_ARRAY.LOVE] -= move.SelfDebuff[(int)BUFF_ARRAY.LOVE]; defender.buffs[(int)BUFF_ARRAY.ATTACK] = move.SelfBuff[(int)BUFF_ARRAY.ATTACK]; defender.buffs[(int)BUFF_ARRAY.DEFENCE] = move.SelfBuff[(int)BUFF_ARRAY.DEFENCE]; defender.buffs[(int)BUFF_ARRAY.LOVE] = move.SelfBuff[(int)BUFF_ARRAY.LOVE]; defender.buffs[(int)BUFF_ARRAY.ATTACK] -= move.SelfDebuff[(int)BUFF_ARRAY.ATTACK]; defender.buffs[(int)BUFF_ARRAY.DEFENCE] -= move.SelfDebuff[(int)BUFF_ARRAY.DEFENCE]; defender.buffs[(int)BUFF_ARRAY.LOVE] -= move.SelfDebuff[(int)BUFF_ARRAY.LOVE]; dialogueText.text = move.Description; yield return(new WaitForSeconds(1)); //process healing attacker.Rest((int)(attacker.waifu.Love * move.LoveMultiplier * (1.0f + 0.05f * attacker.buffs[(int)BUFF_ARRAY.LOVE]))); //play ability effects move.PlayEffects(attacker.transform, defender.transform); if (move.Clip != null) { audioSource.clip = move.Clip; audioSource.Play(); } } //update ui elements UpdateCharactersUI(); yield return(new WaitForSeconds(2)); //check states if (CheckEnemyWin()) { state = BattleState.LOOSE; EndBattle(); } if (CheckPlayerWin()) { state = BattleState.WIN; EndBattle(); } //transition turns if (state == BattleState.PLAYER2) { state = BattleState.PLAYER1; Player1Turn(); } else if (state == BattleState.PROCESSING) { state = BattleState.PLAYER2; StartCoroutine(EnemyTurn()); } }