private void InitialHealth() { if (healthPoints < 0) { healthPoints = statSystem.GetStat(Stat.Health); } maxHealth = statSystem.GetStat(Stat.Health); }
private void Start() { healthPoints.ForceInit(); if (checkForBlock) { guard = GetComponent <GuardController>(); } maxHealth = baseStats.GetStat(Stat.Health); }
private float GetInitialHealth() { if (_baseStats) { return(_baseStats.GetStat(Stat.Health)); } Debug.LogError("BaseStats is missing -> " + name); return(0); }
private void AwardExperience(GameObject instigator) { Experience experience = instigator.GetComponent <Experience>(); if (experience == null) { return; } experience.GainExperience(baseStats.GetStat(Stat.ExperienceReward)); }
private void Start() { if (gameObject.CompareTag("Player")) { baseStats.onLevelUp += UpdateHealth; } if (healthPoints < 0) { healthPoints = baseStats.GetStat(Stat.Health); } }
private float CalculateMagicDamage() { attackerIntellect = attackerStats.GetStat(Stat.Intellect); defenderMagicResist = defenderStats.GetStat(Stat.MagicResistance); float damageBeforeMagicResist = weaponDamage + intMultiplier * attackerIntellect; float damageReductionFromMagicResist = defenderMagicResist * magicResistEffect; float totaldamageBeforeCrit = (damageBeforeMagicResist - damageReductionFromMagicResist) * random.Next(randomMin, randomMax) / 100; float critMultiplier = CritMultipler(); return(totaldamageBeforeCrit * critMultiplier * weaponSpeed); }
protected void RedrawStatDisplay() { foreach (var statText in statTextLines) { statText.SetValue(characterStats.GetStat(statText.GetStat())); } }
// Animation Event void Hit() { if (target == null) { return; } float damage = GetComponent <BaseStats>().GetStat(Stat.Damage); BaseStats targetBaseStats = target.GetComponent <BaseStats>(); if (targetBaseStats != null) { float defence = targetBaseStats.GetStat(Stat.Defence); damage /= 1 + defence / damage; } if (currentWeapon.value != null) { currentWeapon.value.OnHit(); } if (currentWeaponConfig.HasProjectile()) { currentWeaponConfig.LaunchProjectile(rightHandTransform, leftHandTransform, target, gameObject, damage); } else { target.TakeDamage(gameObject, damage); } }
private bool CanAttack() { float weaponSpeed; if (currentWeapon) { weaponSpeed = currentWeapon.GetSpeed(); } else { weaponSpeed = currentSpell.GetSpeed(); } int numOfAttacks = baseStats.GetStat(CharacterStat.attacksPerRound); float timeBetweenAttacks = Constant.meleeRound / Mathf.Min(numOfAttacks, weaponSpeed); if (timeSinceLastAttack > timeBetweenAttacks) { return(true); } else { return(false); } }
private float GetBarterDiscount() { BaseStats baseStats = currentShopper.GetComponent <BaseStats>(); float discount = baseStats.GetStat(Stat.BuyingDiscountPercentage); return(1 - Mathf.Min(discount, maximumBarterDiscount) / 100); }
public float CalculateDamage(GameObject instigator, Health target, Weapon weapon) { attackerStats = instigator.GetComponent <BaseStats>(); attackerLevel = attackerStats.GetLevel(); attackerCritChange = attackerStats.GetStat(Stat.CritPercentage); weaponDamage = weapon.WeaponDamage; weaponSpeed = weapon.WeaponSpeed; defenderStats = target.GetComponent <BaseStats>(); defenderLevel = defenderStats.GetLevel(); float hitChance = random.Next(1, 100); if (hitChance <= (hitEqualLevel + hitChangePrLevel * (attackerLevel - defenderLevel))) { if (weapon.IsMagicAttack) { return(CalculateMagicDamage()); } else { return(CalculateMeleeDamage()); } } else //miss { Debug.Log("Miss"); return(0f); } }
private void AssignSkillVariables() { myName = baseStats.GetStatText(Stat.Name) + " "; nameText.text = myName; timeSinceLastAttack = 0; idleTimeBetweenHits = baseStats.GetStat(Stat.IdleTime); }
private void MainLoop() { int numberOfLevelsToAdd = CalculateLevels(); restNeeded = numberOfLevelsToAdd * TimeDefination.hour; for (int levelsAdded = 0; levelsAdded < numberOfLevelsToAdd; levelsAdded++) { baseStats.AddLevel(); AddHealth(); AddSkillPoints(characterClass.GetSkillPoints()); AddFeats(); AddAbilityBonus(); } xPTracker.SetXPGoal(baseStats.GetStat(CharacterStat.xPRequirement)); // TODO: add restNeeded to elapsedGameTime }
//AnimationEvent private void Hit() { if (target == null) { return; } if (currentWeapon != null) { currentWeapon.OnHit(); } hitSoundEvent.Invoke(); float damage = baseStats.GetStat(Stats.Damage); target.TakeDamage(gameObject, damage); }
private void Update() { //do not regenerate if dead if (GetComponent <Health>().IsDead()) { return; } //Check if current magic level is less than level maximum float maxmagic = m_BaseStats.GetStat(StatType.Magic); if (m_CurrentMagic.value < maxmagic) { //Check if enough time has passed since last boost to magic value if (m_TimeSinceLastRegen > m_MagicRegenTime) { float maxMagic = m_BaseStats.GetStat(StatType.Magic); //Determine the smaller of the two. Difference between current and max or the regen percentage of the max float amount = Mathf.Min(maxMagic - m_CurrentMagic.value, m_BaseStats.GetStat(StatType.MagicRegen) * maxMagic); //Restore magic and reset timer RestoreMagic(amount); m_TimeSinceLastRegen = 0; } } UpdateTimers(); }
private void FollowerSetup() { skillCooldown = new Dictionary <FollowerAttackName, float>(); float metabolism = baseFeedee.GetStat(FeedeeStat.Metabolism); attackSpeed = baseStats.GetStat(Stat.AttackSpeed); cooldownReduction = baseStats.GetStat(Stat.CooldownReduction); actionRecovery = attackSpeed * metabolism / 100; digestSpeed = metabolism / 24; manaConversion = metabolism * baseStats.GetStat(Stat.Spirit) / 10000; AssignHungerStats(); StartCoroutine(BuildConsumableList()); isFoodListUpdated = true; // Add basic buffs to queue StartingAttackQueue(); }
private void Start() { if (health < 0) { health = baseStats.GetStat(Stat.Health); } CheckHealthPoint(null); }
protected float CalculateDamage() { float total = 0; float atkPower = fighter.GetStat(Stat.AttackPower); atkPower *= GetStat(AttackStat.Power, currentHitCount); if (GetStatBool(AttackStat.Bloodlust, currentHitCount)) { float hPercent = target.GetPercentage(); float mult = 100; if (hPercent < 50) { mult += 78 - Mathf.Floor(hPercent / 5) * 4; } else if (hPercent < 95) { mult += 76 - Mathf.Floor(hPercent / 5) * 4; } atkPower *= (mult / 100); } // Reduce by enemy defense float enemyDef = targetStats.GetStat(Stat.Defense); float enemyReduction = targetStats.GetStat(Stat.DamageReduction) / 100; total = Mathf.Ceil(atkPower / enemyDef) * (1 - enemyReduction); // Get player damage modifier float damageMod = 1 + fighter.GetStat(Stat.Damage) / 100; total *= damageMod; if (CalculateCriticalHit()) { float critPower = fighter.GetStat(Stat.CritDamage) / 100; total *= critPower; } return(total); }
public bool StartFight() { _enemiesInFOV = enemiesInFOV.Items; if (_enemiesInFOV.Count == 0) { Cancel(); return(false); } if (_timeScinceLastAttack > baseStats.GetStat(Stat.AttackSpeed)) { _timeScinceLastAttack = 0f; _actionScheduler.StartAction(this); var position = FindClosestEnemyPosition(); RotateToClosestEnemy(position); UpdateAnimator(); return(true); } return(false); }
private float CalculateDamage() { float total = 0; float atkPower = fighter.GetStat(Stat.AttackPower); atkPower *= GetAttackStat(MonAtkStat.Power, currentHitCount); float enemyDef = targetStats.GetStat(Stat.Defense); float enemyReduction = targetStats.GetStat(Stat.DamageReduction) / 100; total = Mathf.Ceil(atkPower / enemyDef) * (1 - enemyReduction); if (CalculateCriticalHit()) { // Monsters don't have crit damage stat, subbing in 2x damage for now float critPower = 2f; // fighter.GetStat(Stat.CritDamage) / 100; total *= critPower; } return(total); }
private void ApplyConsumableItemEffect(BaseStats target) { if (item.GetIsPercentage()) { int value = Mathf.FloorToInt((target.GetStat(item.GetAttributeToModify()) * item.GetAdditiveModifiers()) / 100); target.ModifyStatPermanent(item.GetAttributeToModify(), value); } else { target.ModifyStatPermanent(item.GetAttributeToModify(), item.GetAdditiveModifiers()); } }
// private void TriggerAttack() // { // anim.ResetTrigger("stopAttack"); // anim.SetTrigger("attack"); // } // private void OnCollisionEnter(Collision other) { // print("collision enter: " + other.gameObject.name); // } private void OnTriggerEnter(Collider other) { if (this.gameObject.tag.Equals("Player")) { HandlePlayerHit(other); } else { // if(other.gameObject.name=="Player"){ // print("target: " + target.gameObject.name); // print("other: " + other.gameObject.name); // print("can trigger: " + currentWeapon.value.GetCanTrigger()); // } if (target == null) { return; } if (!currentWeapon.value.GetCanTrigger()) { return; } if (target != other.gameObject.GetComponent <Health>()) { return; } if (target.GetInstigatorDamageCooldown(character) > 0) { return; } float damage = baseStat.GetStat(Stat.Damage); Armour armour = other.gameObject.GetComponent <Armour>(); if (target.IsDamageTaken(character, damage)) { if (currentWeapon.value != null) { currentWeapon.value.OnHit(armour.GetArmourType()); } } // if (currentWeaponConfig.hasProjectile()) // { // currentWeaponConfig.LaunchProjectile(rightHandTransform, leftHandTransform, target, gameObject, damage); // } // else // { // target.TakeDamage(gameObject, damage); // } } }
public virtual void RecalculateStats() { atkPower = baseStats.GetStat(Stat.AttackPower); atkSpeed = baseStats.GetStat(Stat.AttackSpeed); damageMod = baseStats.GetStat(Stat.Damage); critFactor = baseStats.GetStat(Stat.CritFactor); cdr = baseStats.GetStat(Stat.CooldownReduction); critPower = baseStats.GetStat(Stat.CritDamage); }
public void Setup(Stat stat) { switch (stat) { case Stat.Health: titleText.text = "Health"; bodyText.text = health.GetHealth() + " / " + baseStats.GetStat(Stat.Health); break; case Stat.Mana: titleText.text = "Mana"; bodyText.text = mana.ManaValue + " / " + baseStats.GetStat(Stat.Mana); break; case Stat.Experience: titleText.text = "Experience"; bodyText.text = experience.GetExperiencePoints() + " / " + baseStats.GetPointsForNextLevel(); if (baseStats.CalculateLevel() == 1) { bodyText.text = experience.GetExperiencePoints() + " / " + baseStats.GetPointsForCurrentLevel(); } break; } }
public object GetAV(string av) { if (av.Contains(".")) { string firstPart = av.Substring(0, av.IndexOf('.')); string secondPart = av.Substring(av.IndexOf('.') + 1); if (firstPart == "BaseStats") { return(BaseStats.GetStat(secondPart)); } else if (firstPart == "DerivedStats") { return(DerivedStats.GetStat(secondPart)); } else if (firstPart == "Conditions") { string fqConditionName = GetType().Namespace + "." + secondPart.ToString(); Condition newC = (Condition)Activator.CreateInstance(Type.GetType(fqConditionName)); bool found = false; foreach (Condition c in Conditions) { if (c.GetType() == newC.GetType()) { found = true; break; } } return(found); } else if (firstPart == "ExtraData") { return(ExtraData[secondPart]); } } else { //search and get property return(GetType().GetProperty(av).GetValue(this, null)); } //fail throw new KeyNotFoundException(); }
private void ApplyConsumableItemEffect(BaseStats target) { if (isPercentage) { int value = Mathf.FloorToInt((target.GetStat(attributteToModify) * modifier) / 100); target.ModifyStatPermanent(attributteToModify, value); } else { if (attributteToModify == StatsAtributte.Health || attributteToModify == StatsAtributte.SkillPoints) { target.HealStat(attributteToModify, modifier); } else { target.ModifyStatPermanent(attributteToModify, modifier); } } }
public void Hit() { if (target) { float damage = baseStats.GetStat(Stat.Damage); if (currentWeapon.value) { currentWeapon.value.OnHit(); } if (currentWeaponConfig.HasProjectile()) { currentWeaponConfig.LaunchProjectile(rightHandTransform, leftHandTransform, target, gameObject, damage); } else { target.TakeDamage(gameObject, damage); } } }
private void Update() { //Get the players level, XP and the range of XP for the level int level = m_BaseStats.GetLevel(); float xp = m_XPComp.GetCurrentXP(); float levelXP = m_BaseStats.GetStat(StatType.LevelXp); float baseXP = 0; //If current level is 1 then baseXP is 0 if (level > 1) { baseXP = m_BaseStats.GetStatAtLevel(StatType.LevelXp, level - 1); } //Amount of XP that needs to be earned to move from current level to next float xpRange = levelXP - baseXP; //Update Display bar m_ImageForeground.localScale = new Vector3((xp - baseXP) / xpRange, 1, 1); }
public void LoadPartyPanels() { if (playerTeam == null) { playerTeam = GameObject.FindWithTag("Player").GetComponent <PlayerTeam>(); } if (playerTeam != null) { CharacterSheet[] team = playerTeam.GetPlayerTeam(); if (team != null) { for (int i = 0; i < team.Length; i++) { if (team[i] != null) { partyPanels[i].SetActive(true); BaseStats currentStats = team[i].GetStats(); partyMemberInfo[i].name.text = team[i].GetCharName().ToUpper(); partyMemberInfo[i].type.text = currentStats.GetStatType().ToString().ToUpper(); partyMemberInfo[i].level.text = "LVL " + currentStats.GetLevel(); partyMemberInfo[i].hp.text = currentStats.GetStat(StatsAtributte.Health) + "/" + currentStats.GetStat(StatsAtributte.MaxHealth); partyMemberInfo[i].hpSlider.maxValue = currentStats.GetStat(StatsAtributte.MaxHealth); partyMemberInfo[i].hpSlider.value = currentStats.GetStat(StatsAtributte.Health); partyMemberInfo[i].sp.text = currentStats.GetStat(StatsAtributte.SkillPoints) + "/" + currentStats.GetStat(StatsAtributte.MaxSkillPoints);; partyMemberInfo[i].spSlider.maxValue = currentStats.GetStat(StatsAtributte.MaxSkillPoints); partyMemberInfo[i].spSlider.value = currentStats.GetStat(StatsAtributte.SkillPoints); partyMemberInfo[i].charImage.sprite = team[i].GetSprite(); if (currentStats.GetStatusCondition() != StatusCondition.None) { partyMemberInfo[i].statusCondition.gameObject.SetActive(true); partyMemberInfo[i].statusCondition.text = currentStats.GetStatusCondition().ToString().ToUpper(); } else { partyMemberInfo[i].statusCondition.gameObject.SetActive(false); } } else { partyPanels[i].SetActive(false); } } } } }
// Animation Trigger private void Hit() { if (m_Target != null) { if (m_CurrentWeapon.Value != null) { m_CurrentWeapon.Value.OnHit(m_Target); } float damage = m_BaseStats.GetStat(Stat.Damage); if (m_CurrentWeaponConfig.HasProjectile()) { m_CurrentWeaponConfig.LaunchProjectile(rightHandTransform, leftHandTransform, m_Target, gameObject, damage, UpdateTargetUi); } else { m_Target.TakeDamage(gameObject, damage); } } UpdateTargetUi?.Invoke(); }