// uses individual character's attributes variables combined with random slight modification to // come up with damage per blow. Also does a random check for mega hit based on the particular // character's chances/attribute of that happening. public void CalculateDamageToOpponent() { if (null == FisticuffsController.Instance) { Debug.LogError("CharacterBehaviors::CalculateDamageToOpponent - FisticuffsController.Instance not set. Is there one in the scene?"); return; } int myOpponentListNum = 0; if (myPositionInControllerList == 0) // if I am position 0, opponent is position 1, otherwise it's vice versa and myOpponentListNum remains 0 { myOpponentListNum = 1; } Transform opponentCharacter = FisticuffsController.Instance.cardsInPlay[myOpponentListNum].transform; CharacterBehaviors opponentBehaviors = opponentCharacter.gameObject.GetComponent <CharacterBehaviors>(); float randomDamageModifier = Random.Range(-1.0f, 1.0f); float randomDefenseModifier = Random.Range(-.1f, .1f); float damageBeforeDefense = (damageGivenPerPunch + randomDamageModifier); float damageCalc = damageBeforeDefense - (opponentBehaviors.defenseModifier * damageBeforeDefense); float damageFinal; int rollForMassiveHit = Random.Range(0, 1001); if (rollForMassiveHit <= chanceOfMassiveHit) { damageFinal = FisticuffsController.Instance.megaDamageAmount; } else { damageFinal = damageCalc; } opponentBehaviors.ReceiveDamage(damageFinal); }