예제 #1
0
        ////////////// DAMAGE AND STAT FUNCTIONS ////////////////

        /// <summary>
        /// Calculate how much damage is taken.
        /// </summary>
        /// <param name="move">Move the monster is hit with.</param>
        /// <param name="attacker">Monster who attacked.</param>
        /// <returns>Updated currentHP after damage and <see cref="DamageDetails"/>.</returns>
        public DamageDetails TakeDamage(MoveObj move, MonsterObj attacker)
        {
            // Critical hit chance is 6.25%.
            var critical = 1f;

            if (UnityEngine.Random.value * 100f <= 6.25f)
            {
                critical = 2f;
            }

            // Type effectiveness defined in TypeChart.
            float type = TypeChart.GetEffectiveness(move.Base.Type, Base.PrimaryType) *
                         TypeChart.GetEffectiveness(move.Base.Type, Base.SecondaryType);

            var damageDetails = new DamageDetails()
            {
                Critical          = critical,
                TypeEffectiveness = type,
                Downed            = false
            };

            float attack  = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack;
            float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense;

            // Damage calculation based on the original game's formula.
            float modifiers = UnityEngine.Random.Range(0.85f, 1f) * type * critical;
            float a         = (2 * attacker.Level + 10) / 250f;
            float d         = a * move.Base.Power * (attack / defense) + 2;
            int   damage    = Mathf.FloorToInt(d * modifiers);

            UpdateHp(damage);
            return(damageDetails);
        }
예제 #2
0
 /// <summary>
 /// Add a new monster to the team.
 /// </summary>
 /// <remarks>If the party is full the monster is added to the bank.</remarks>
 /// <param name="newMonster">Monster to add to the list.</param>
 public void AddMonster(MonsterObj newMonster)
 {
     if (_monsters.Count < 6)
     {
         _monsters.Add(newMonster);
     }
     else
     {
         //TODO - send to storage bank
     }
 }
예제 #3
0
        /// <summary>
        /// Setup function to prepare the monster in the battle screen.
        /// </summary>
        /// <param name="monster">Monster to setup.</param>
        public void Setup(MonsterObj monster)
        {
            Monster       = monster;
            _image.sprite = _isPlayerMonster ? Monster.Base.LeftSprite : Monster.Base.RightSprite;

            _hud.gameObject.SetActive(true);
            _hud.SetData(monster);

            _image.color         = _originalColor;
            transform.localScale = new Vector3(1, 1, 1);
            PlayBattleStartAnimation();
        }
예제 #4
0
        /// <summary>
        /// Get the next healthy monster in the party.
        /// </summary>
        /// <returns>Next monster in the list of monsters.</returns>
        public MonsterObj GetHealthyMonster()
        {
            MonsterObj healthyMonster = _monsters.FirstOrDefault(x => x.CurrentHp > 0);

            return(healthyMonster);
        }