예제 #1
0
 private void InitialHealth()
 {
     if (healthPoints < 0)
     {
         healthPoints = statSystem.GetStat(Stat.Health);
     }
     maxHealth = statSystem.GetStat(Stat.Health);
 }
예제 #2
0
 private void Start()
 {
     healthPoints.ForceInit();
     if (checkForBlock)
     {
         guard = GetComponent <GuardController>();
     }
     maxHealth = baseStats.GetStat(Stat.Health);
 }
예제 #3
0
        private float GetInitialHealth()
        {
            if (_baseStats)
            {
                return(_baseStats.GetStat(Stat.Health));
            }

            Debug.LogError("BaseStats is missing -> " + name);
            return(0);
        }
예제 #4
0
        private void AwardExperience(GameObject instigator)
        {
            Experience experience = instigator.GetComponent <Experience>();

            if (experience == null)
            {
                return;
            }

            experience.GainExperience(baseStats.GetStat(Stat.ExperienceReward));
        }
예제 #5
0
 private void Start()
 {
     if (gameObject.CompareTag("Player"))
     {
         baseStats.onLevelUp += UpdateHealth;
     }
     if (healthPoints < 0)
     {
         healthPoints = baseStats.GetStat(Stat.Health);
     }
 }
예제 #6
0
        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()));
     }
 }
예제 #8
0
파일: Fighter.cs 프로젝트: UnityRPGv2/RPG
        // 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);
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
파일: Shop.cs 프로젝트: Moontok/RPG-Project
        private float GetBarterDiscount()
        {
            BaseStats baseStats = currentShopper.GetComponent <BaseStats>();
            float     discount  = baseStats.GetStat(Stat.BuyingDiscountPercentage);

            return(1 - Mathf.Min(discount, maximumBarterDiscount) / 100);
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
 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
        }
예제 #14
0
    //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);
    }
예제 #15
0
        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();
        }
예제 #16
0
        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);
 }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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);
        }
예제 #21
0
 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());
     }
 }
예제 #22
0
        // 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);
                // }
            }
        }
예제 #23
0
 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;
            }
        }
예제 #25
0
        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();
        }
예제 #26
0
 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);
         }
     }
 }
예제 #27
0
        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);
                }
            }
        }
예제 #28
0
        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);
        }
예제 #29
0
 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);
                 }
             }
         }
     }
 }
예제 #30
0
        // 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();
        }