Guest User

Untitled

a guest
Jan 28th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class CharacterCharacteristics : BaseCharacterCharacteristics
  4. {
  5.     private int _strength;
  6.     private int _agility;
  7.     private int _intelligence;
  8.     private int _maxHealth;
  9.     private int _health;
  10.     private float _healthRegeneration;
  11.     private int _maxMana;
  12.     private int _mana;
  13.     private float _manaRegeneration;
  14.     private float _armor;
  15.     private float _attackSpeed;
  16.     private int[] _damage = new int[2];
  17.     private int _magicResistance;
  18.     [SerializeField] private float _movementSpeed;
  19.     [SerializeField] private float _attackRange;
  20.  
  21.     private void Awake()
  22.     {
  23.         SetInitialCharacteristics();
  24.     }
  25.  
  26.     protected override void SetInitialCharacteristics()
  27.     {
  28.         _strength = strength;
  29.         _agility = agility;
  30.         _intelligence = intelligence;
  31.        
  32.         _maxHealth = health + _strength * 20;
  33.         _health = _maxHealth;
  34.         _healthRegeneration = healthRegeneration + _strength * 0.1f;
  35.  
  36.         _maxMana = mana + _intelligence * 12;
  37.         _mana = _maxMana;
  38.         _manaRegeneration = manaRegeneration + _intelligence * 0.05f;
  39.  
  40.         _armor = armor + _agility * 0.15f;
  41.         _attackSpeed = attackSpeed + _agility * 0.017f;
  42.  
  43.         switch (mainAttribute)
  44.         {
  45.             case MainAttribute.Strength:
  46.                 _damage[0] = damage[0] + _strength;
  47.                 _damage[1] = damage[1] + _strength;
  48.                 break;
  49.            
  50.             case MainAttribute.Agility:
  51.                 _damage[0] = damage[0] + _agility;
  52.                 _damage[1] = damage[1] + _agility;
  53.                 break;
  54.            
  55.             case MainAttribute.Intelligence:
  56.                 _damage[0] = damage[0] + _intelligence;
  57.                 _damage[1] = damage[1] + _intelligence;
  58.                 break;
  59.         }
  60.  
  61.         _magicResistance = (int)(magicResistance + _strength * 0.08f);
  62.        
  63.         _movementSpeed = movementSpeed;
  64.         _attackRange = attackRange;
  65.     }
  66.  
  67.     public float GetMovementSpeed()
  68.     {
  69.         return _movementSpeed;
  70.     }
  71.  
  72.     public float GetAttackRange()
  73.     {
  74.         return _attackRange;
  75.     }
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment