public void UpdateCombatStats(Entity companion, CombatStat stat, int value) { if (!Companions.ContainsKey(companion)) { return; } switch (stat) { case CombatStat.Kills: Companions[companion].Kills += value; break; case CombatStat.DamageDealt: Companions[companion].DamageDealt += value; break; case CombatStat.DamageReceived: Companions[companion].DamageReceived += value; break; default: throw new ArgumentOutOfRangeException(nameof(stat), stat, null); } }
public void SetTarget(CombatStat _combatStats, GameObject _target, int _damage, bool _isPlayer, float _statusChance, float _criticalChance) { combatStats = _combatStats; statusChance = _statusChance; target = _target; damage = _damage; criticalChance = _criticalChance; isPlayer = _isPlayer; //Height and location CapsuleCollider measurements = target.gameObject.GetComponent<CapsuleCollider>(); float height = measurements.height * heightPercentage; targetLocation = new Vector3(target.transform.position.x, target.transform.position.y + height, target.transform.position.z); //Obtain necessary component information if(isPlayer) { player = target.GetComponent<PlayerCombatCharacter>(); } else { enemy = target.GetComponent<EnemyCombatCharacter>(); } launch = true; }
public async Task <ushort> GetMaxBaseStamina() { await EnsureCacheIsValid(); maxStamina = maxStamina ?? allPokemonsCache.Max(poke => poke.Stamina); return(maxStamina.Value); }
public async Task <ushort> GetMaxBaseDefense() { await EnsureCacheIsValid(); maxDefense = maxDefense ?? allPokemonsCache.Max(poke => poke.Defense); return(maxDefense.Value); }
public async Task <ushort> GetMaxBaseAttack() { await EnsureCacheIsValid(); maxAttack = maxAttack ?? allPokemonsCache.Max(poke => poke.Attack); return(maxAttack.Value); }
public void SetPlayerStats() { UnitStats = new Dictionary <StatType, float>(); UnitType = PlayerUnitData.PlayerUnitClass; if (UnitType != null && UnitType.ClassStatSettings.Length > 0) { UnitType.GenerateStats(this); } CurrentHP = new CombatStat(StatType.HEALTH, this); CurrentStamina = new CombatStat(StatType.STAMINA, this); }
void Melee(CombatStat attackStat) { Vector3 pos = transform.position; for (int i = 0; i < targettable.Count; i++) { Vector3 vec = targettable[i].transform.position; Vector3 direction = vec - pos; if (Vector3.Dot(direction, transform.forward) < 1) { if (targettable [i].GetComponent <EnemyCombat> ().stats.isAttackable) { float dmg = attackStat.dmgCalc(); targettable [i].GetComponent <EnemyCombat> ().stats.applyDmg(dmg); } } } }
void Melee(CombatStat attackStat) { Vector3 pos = transform.position; for (int i = 0; i < targettable.Count; i++) { Vector3 vec = targettable[i].transform.position; Vector3 direction = vec - pos; if (Vector3.Dot(direction, transform.forward) < 1) { if (targettable [i].GetComponent <EnemyCombat> ().stats.isAttackable) { float dmg = attackStat.dmgCalc(); targettable [i].GetComponent <EnemyCombat> ().stats.applyDmg(dmg); Vector3 textpos = transform.position; textpos.y += 2f; stats.stamina -= attackStat.weight; Instantiate(textOutline, textpos, Quaternion.identity).GetComponent <textFloat> ().text = dmg.ToString(); } } } }
public StatSliderDisplay(Slider s) { StatSlider = s; StatToDisplay = new CombatStat(); }
public void SetDamage(CombatStat _opposingStat, int _damageType, int _damage, float _statusEffectChance, float _criticalChance) { int element = _damageType; Color textColour = Color.white; float textSize = 1f; /* switch(_damageType) { case 1: textColour = Color.green; break; case 2: textColour = Color.red; break; case 3: textColour = Color.yellow; break; case 4: textColour = Color.blue; break; } */ // Calculate if dodged attack bool dodged = false; float evasionChance = 0f; //print ("Opposing accuracy = " + _opposingStat.accuracy); //print ("Agility = " + stat.agility); evasionChance = ((float)stat.agility / (float)_opposingStat.accuracy) * 100f; int randomEvasionChance = Random.Range (0, 100); //print ("Random Evasion Chance = " + randomEvasionChance); evasionChance = Random.Range (0,(int)evasionChance); //print ("Evasion Chance = " + evasionChance); if(randomEvasionChance < evasionChance) { dodged = true; //If Projectile if(hitByProjectile && incomingProjectile) { incomingProjectile.SendMessage ("TargetMiss",SendMessageOptions.DontRequireReceiver); hitByProjectile = false; } } else { dodged = false; //If Projectile if(hitByProjectile && incomingProjectile) { incomingProjectile.SendMessage ("TargetHit",SendMessageOptions.DontRequireReceiver); hitByProjectile = false; } //Send Message to Elemental Reaction Script to Activate Elemental Reaction if(element > 0) { elementalReaction.ActivateElementalEffect (element); } } if(dodged) { //Dodge attack ShowDamageText ("Miss", textColour, textSize); } else //Did not dodge attack, then calculate damages { int criticalHitChance = (int)((_criticalChance * (float)_opposingStat.luck) * criticalChanceIntegrity); //print (criticalHitChance); //Damage Calculations - If its a critical hit if(Random.Range (0,100) <= criticalHitChance) { //Then critical hit _damage = (int)((float)_damage * (float)criticalHitIntegrity); textSize = 1.5f; //GameObject.FindGameObjectWithTag ("Combat Manager").SendMessage ("CriticalCameraOn", gameObject,SendMessageOptions.DontRequireReceiver); ShowDamageText ("Critical", textColour, textSize); //print ("CRITICAL HIT"); } //No Debuff can be afflicted when shield is up if(shield > 0) //if shield is still active { if(defending) { _damage /= 2; } if(shieldWeakness == element) //If weakness { if(shieldRuptured) { _damage *= 4; //quadruple damage textSize += 0.5f; } else { _damage *= 2; //Double damage } shield -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize + 0.25f); } } else if(shieldResistance == element) //if resistance { _damage /= 2; shield -= _damage; //Half damage if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize - 0.25f); } } else if (shieldAffinity == element) //Shield is the same as damage, convert to health { _damage = -_damage; shield -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText ((-_damage).ToString (), textColour, textSize - 0.25f); } } else { //Deduct the amount of damage to shield shield -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize - 0.25f); } } if(shield < 0) { shield = 0; //Hide shield objects for (int i = 0; i < shieldHiddenReveals.Length; i++) { shieldHiddenReveals[i].gameObject.SetActive (false); } } else { if(!shieldRuptured) { //shieldIntegrity -= _damage; if(shieldIntegrity <= 0) { shieldRuptured = true; shieldReveal = true; RevealShieldAffinity (); GameObject.FindGameObjectWithTag ("Combat Manager").SendMessage ("CriticalCameraOn", gameObject,SendMessageOptions.DontRequireReceiver); } } } if(shield > shieldMax) { shield = shieldMax; } //Set Stagger anim.SetTrigger ("Stagger"); } else //Damage will go to health { //Status Effect Formula: Attack StatusChance minus by enemy weak-strength. float statusEffectChance = 0f; int statusEffectVerdict = Random.Range (0, 100); int maxStatusDuration = 1; //Status effect chance should only have a limit if(_statusEffectChance > 2f) { _statusEffectChance = 2f; } //Defence is a resistance factor when shield is down if(defending) { _damage /= 2; } _damage -= (int)((float)stat.defence/2f); if(_damage <= 0) { _damage = 1; //Make sure damage doesn't fall into a negative } if(affinityRevealed) { if(affinityWeakness == element) { if(affinityRevealed) { _damage *= 4; //quadruple damage textSize += 0.5f; } else { _damage *= 2; //Double damage } stat.health -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize + 0.25f); } statusEffectChance = _statusEffectChance * (((float)Random.Range (100,150))/100f); //Calcualte Status Effect Chance maxStatusDuration = statusWeaknessDuration; //Calculate a random max duration } else if (affinityResistance == element) { _damage /= 2; stat.health -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize + 0.25f); } statusEffectChance = _statusEffectChance * (((float)Random.Range (100,150))/100f); //Calcualte Status Effect Chance maxStatusDuration = statusResistedDuration; //Calculate a random max duration } else if (affinity == element) { stat.health -= -_damage; if(_statusEffectChance < 0.4f) { ShowDamageText ("+" + (_damage).ToString (), textColour, textSize + 0.25f); } statusEffectChance = _statusEffectChance * (((float)Random.Range (100,150))/100f); //Calcualte Status Effect Chance maxStatusDuration = statusStrengthDuration; //Calculate a random max duration } else { stat.health -= _damage; if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize + 0.25f); } statusEffectChance = _statusEffectChance * (((float)Random.Range (100,150))/100f); //Calcualte Status Effect Chance maxStatusDuration = statusStandardDuration; //Calculate a random max duration } } else { stat.health -= _damage - (int)((float)_damage * sealedDamageReduction); if(_statusEffectChance < 0.4f) { ShowDamageText (_damage.ToString (), textColour, textSize + 0.25f); } statusEffectChance = _statusEffectChance * (((float)Random.Range (100,150))/100f); //Calcualte Status Effect Chance maxStatusDuration = statusStandardDuration; //Calculate a random max duration } //Calculate whether a debuff has been afflicted if(statusEffectVerdict < (int)(statusEffectChance * 100f)) { //maxStatusDuration = Random.Range (1, maxStatusDuration); switch(element) { case 1: //Earth Status Effect //Condemned: Decrease Defence and Accuracy. Prevents Healing //print ("I am condemned"); SetCondemned (maxStatusDuration); break; case 2: //Fire Status Effect //Burning: Fire Damage over time. Decrease attack. //print ("I am burning"); SetBurning (maxStatusDuration); break; case 3: //Lightning Status Effect //Stun: Disables moves //print ("I am stunned"); SetStunned (maxStatusDuration); break; case 4: //Water Status Effect //Rust: Increase debuff chance. Also decreases speed and agility //print ("I am rusted"); SetRusted (maxStatusDuration); break; } } //Health management - if health reaches 0 - Player dies if(stat.health <= 0) { stat.health = 0; EnemyDown (); } else { if(!affinityRevealed) { //healthIntegrity -= _damage; if(healthIntegrity <= 0) { RevealHealthAffinity (); affinityRevealed = true; healthReveal = true; GameObject.FindGameObjectWithTag ("Combat Manager").SendMessage ("CriticalCameraOn", gameObject,SendMessageOptions.DontRequireReceiver); } } } if(stat.health > stat.healthMax) { stat.health = stat.healthMax; } //If Health is lower than 70% and not shattered turn Low Health Animation on if(stat.health <= 0) { if(stat.health <= stat.healthBase * 0.70) { if(affinityRevealed) { anim.SetBool ("Low Health", true); } else { if(stat.health <= stat.healthBase * 0.30) { anim.SetBool ("Low Health", true); } else { anim.SetBool ("Low Health", false); } } } else { anim.SetBool ("Low Health", false); } //Set Stagger anim.SetTrigger ("Stagger"); } //Show damage screen if(_damage > 200 && healthReveal) { switch(_damageType) { case 0: //white CombatCamera.control.ScreenEffect (1); break; case 1: //Green CombatCamera.control.ScreenEffect (2); break; case 2: //Red CombatCamera.control.ScreenEffect (3); break; case 3: //Yellow CombatCamera.control.ScreenEffect (4); break; case 4: //Cyan CombatCamera.control.ScreenEffect (5); break; } } } gameObject.SendMessage ("UpdateTutorialUI", SendMessageOptions.DontRequireReceiver); //print ("I took " + _damage +" damage....Ouch"); //print ("Shield = " + shield); //print ("Health = " + stat.health); } }
//Obtain stat information from spawn, this is done by recieving level information from the spawner public void InitiateEnemyStats(int _level) { //Construct stats stat = new CombatStat(_level, shieldAffinity, shield, healthStrength, actionPointStrength, attackStrength, defenceStrength, agilityStrength, luckStrength, accuracyStrength, speedStrength); characterLevel = _level; //Obtain the Elemental Reaction Component elementalReaction = gameObject.GetComponent<EnemyElementalReaction>(); iniIndex = EnemyIndex (); }
public void SetDamage(CombatStat _opposingStat, int _damageType, int _damage, float _statusEffectChance, float _criticalChance) { int element = _damageType; Color textColour = Color.white; float textSize = 1f; // Calculate if dodged attack bool dodged = false; float evasionChance = 0f; //print ("Opposing accuracy = " + _opposingStat.accuracy); //print ("Agility = " + stat.agility); evasionChance = ((float)stat.agility / (float)_opposingStat.accuracy) * 100f; int randomEvasionChance = Random.Range (0, 100); //print ("Random Evasion Chance = " + randomEvasionChance); evasionChance = Random.Range (0,(int)evasionChance); //print ("Evasion Chance = " + evasionChance); if(randomEvasionChance < evasionChance) { dodged = true; //If Projectile if(hitByProjectile && incomingProjectile) { incomingProjectile.SendMessage ("TargetMiss",SendMessageOptions.DontRequireReceiver); hitByProjectile = false; } if(!overwatchCall) { //Play Dodge Animation anim.SetTrigger ("Dodge"); } } else { dodged = false; //If Projectile if(hitByProjectile && incomingProjectile) { incomingProjectile.SendMessage ("TargetHit",SendMessageOptions.DontRequireReceiver); hitByProjectile = false; } //Send Message to Elemental Reaction Script to Activate Elemental Reaction if(element > 0) { elementalReaction.ActivateElementalEffect (element); } } //If Not overwatch protected if(!overwatchProtected) { if(dodged) { if(!overwatchCall) { //Dodge attack ShowDamageText ("Miss", textColour, textSize); } else { ShowDamageText ("0", textColour, textSize); } } else //Did not dodge attack, then calculate damages { int criticalHitChance = (int)((_criticalChance * (float)_opposingStat.luck) * criticalChanceIntegrity); //print (criticalHitChance); //Damage Calculations - If its a critical hit if(Random.Range (0,100) <= criticalHitChance) { //Then critical hit _damage = (int)((float)_damage * (float)criticalHitIntegrity); textSize = 1.5f; ShowDamageText ("Critical", textColour, textSize); //print ("CRITICAL HIT"); //GameObject.FindGameObjectWithTag ("Combat Manager").SendMessage ("CriticalCameraOn", gameObject, SendMessageOptions.DontRequireReceiver); } //No Debuff can be afflicted when shield is up if(stat.shield > 0) //if shield is still active { //Defence _damage -= (int)((float)stat.defence/2f); if(_damage <= 0) { _damage = 1; //Make sure damage doesn't fall into a negative } //If Defending if(defend) { //Deactivate Icon statusUI.protectedPanel.gameObject.SetActive (false); if(element == defendElement) { _damage /= (int)(defendResistance * 4f); } else { _damage /= (int)(defendResistance * 2f); } //Check for enemies nearby if(CheckForNearbyEnemy() != null) { //If there is an enemy nearby go into a counter attack anim.SetTrigger ("Counter"); //Counterattack damage CounterAttack (defendElement); } else { //If there is no enemy nearby block animation anim.SetTrigger ("Block"); } } else { //Set Shielded Stagger anim.SetTrigger ("Stagger"); } if(shieldWeakness == element) //If weakness { _damage *= 2; //Double damage stat.shield -= _damage; textSize += 0.25f; } else if(shieldResistance == element) //if resistance { _damage /= 2; stat.shield -= _damage; //Half damage textSize -= 0.25f; } else if (stat.shieldAffinity == element) //Shield is the same as damage, convert to health { _damage /= 4; stat.shield -= _damage; textSize -= 0.25f; } else { //Deduct the amount of damage to shield stat.shield -= _damage; textSize -= 0.25f; } if(stat.shield > stat.shieldMax) { stat.shield = stat.shieldMax; } if(stat.shield < 0) { stat.shield = 0; } //Show text damage ShowDamageText (_damage.ToString (), textColour, textSize); } else //Damage will go to health { //Status Effect Formula: Attack StatusChance minus by enemy weak-strength. float statusEffectChance = 0f; int statusEffectVerdict = Random.Range (0, 100); int maxStatusDuration = 3; //Status effect chance should only have a limit if(_statusEffectChance > 2f) { _statusEffectChance = 2f; } //Defence is a resistance factor _damage -= (int)((float)stat.defence/2f); if(_damage <= 0) { _damage = 1; //Make sure damage doesn't fall into a negative } //If Defending if(defend) { //Deactivate Icon statusUI.protectedPanel.gameObject.SetActive (false); if(element == defendElement) { _damage /= (int)(defendResistance * 4f); } else { _damage /= (int)(defendResistance * 2f); } //Check for enemies nearby if(CheckForNearbyEnemy() != null) { //If there is an enemy nearby go into a counter attack anim.SetTrigger ("Counter"); //Counterattack damage CounterAttack (defendElement); } else { //If there is no enemy nearby block animation anim.SetTrigger ("Block"); } } else { //Set Stagger anim.SetTrigger ("Stagger"); } //Calculate damage stat.health -= _damage; //Show Damage Text ShowDamageText (_damage.ToString (), textColour, 0.75f); //Calcualte Status Effect Chance statusEffectChance = _statusEffectChance; //Calculate whether a debuff has been afflicted and if not defending if(statusEffectVerdict <= (int)(statusEffectChance * 100f) && !defend) { maxStatusDuration = Random.Range (1, maxStatusDuration); switch(element) { case 1: //Earth Status Effect //Condemned: Decrease Defence and Accuracy. Prevents Healing //print ("I am condemned"); SetCondemned (maxStatusDuration); break; case 2: //Fire Status Effect //Burning: Fire Damage over time. Decrease attack. //print ("I am burning"); SetBurning (maxStatusDuration); break; case 3: //Lightning Status Effect //Stun: Disables moves //print ("I am stunned"); SetStunned (maxStatusDuration); break; case 4: //Water Status Effect //Rust: Increase debuff chance. Also decreases speed and agility //print ("I am rusted"); SetRusted (maxStatusDuration); break; } } //Health management - if health reaches 0 - Player dies if(stat.health > stat.healthMax) { stat.health = stat.healthMax; } //If Health is lower than 30% and not shattered turn Low Health Animation on if(stat.health > 0) { if(stat.health <= stat.healthBase * 0.30) { anim.SetBool ("Low Health", true); } else { anim.SetBool ("Low Health", false); } } if(stat.health <= 0) { stat.health = 0; statusUI.UpdateStatHealth(); //Update health UI PlayerDown (); } } print ("I took " + _damage +" damage....Ouch and I now have " + stat.health + " health and " + stat.shield + " shield"); //Update Save Health GameObject.FindGameObjectWithTag ("Combat Spawner").SendMessage ("SetIndexPlayerInformation", PlayerIndex (),SendMessageOptions.DontRequireReceiver); if(stat.health > 0) { statusUI.UpdateStatHealth(); //Update health UI print ("Updating Stat Health UI"); } } } else { //Call overwatch to protect CombatManager.playerStats[overwatchIndex].TeleportToProtect (gameObject); //Overwatch dodge animation anim.SetTrigger ("Next"); //Calculate Damage output here float reducedDamage = 2f; if(_damageType == overwatchElement) { reducedDamage = 4f; } switch (overwatchElement) { case 0: reducedDamage += CombatManager.playerStats[overwatchIndex].character.level / 100f; break; case 1: //Earth reducedDamage += CombatManager.playerStats[overwatchIndex].character.earthAffinity / 100f; break; case 2: //Fire reducedDamage += CombatManager.playerStats[overwatchIndex].character.fireAffinity / 100f; break; case 3: //Lightning reducedDamage += CombatManager.playerStats[overwatchIndex].character.lightningAffinity / 100f; break; case 4: //Water reducedDamage += CombatManager.playerStats[overwatchIndex].character.waterAffinity / 100f; break; } _damage /= (int)reducedDamage; //Send Damage Output to Overwatch Volunteer CombatManager.playerStats[overwatchIndex].SetDamage (_opposingStat, _damageType, _damage, 0f, 0f); //Need to make sure index is out of range overwatchIndex = -1; //No Longer overwatched overwatchProtected = false; ////statusUI.DeactivateDebuff (overwatchElement + 3); statusUI.protectedPanel.gameObject.SetActive (false); } }
//Obtain stat information from spawn, this is done by recieving level information from the spawner public void InitiatePlayerStats(Character _character) { //This character now defined with its character stats character = _character; //Construct stats stat = new CombatStat(character.level, character.currentShieldAffinity, character.currentShield, healthStrength, actionPointStrength, attackStrength, defenceStrength, agilityStrength, luckStrength, accuracyStrength, speedStrength); //Make sure player character health is at current health stat.health = character.currentHealth; if(stat.health > stat.healthMax) { stat.health = stat.healthMax; } //Make sure player AP is at current AP stat.actionPoints = character.currentAP; if(stat.actionPoints > stat.actionPointMax) { stat.actionPoints = stat.actionPointMax; } //Obtain the Elemental Reaction Component elementalReaction = gameObject.GetComponent<PlayerElementalReaction>(); //iniIndex = PlayerIndex (); }
//Obtain stat information from spawn, this is done by recieving level information from the spawner public void InitiateEnemyStats(int _level) { //Construct stats stat = new CombatStat(_level, shieldAffinity, shield, healthStrength, actionPointStrength, attackStrength, defenceStrength, agilityStrength, luckStrength, accuracyStrength, speedStrength); //Calculate Integrity shieldIntegrity = (int)((float)shield * (float)((float)shieldIntegrity/100f)); healthIntegrity = (int)((float)stat.health * (float)((float)healthIntegrity/100f)); //Obtain the Elemental Reaction Component elementalReaction = gameObject.GetComponent<EnemyElementalReaction>(); //print (character.levelMaxExperience); //print (stat.health); }