Advertisement
GoodNoodle

CreatureBase

Feb 7th, 2024
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public enum Habitates
  6. {
  7.     Fire,
  8.     Water,
  9.     Earth,
  10.     Ice,
  11.     Darkness,
  12.     Etharial
  13. }
  14.  
  15. [CreateAssetMenu(fileName = "Creature", menuName = "Creature/Create New")]
  16. public class CreatureBase : ScriptableObject
  17. {
  18.     [SerializeField] string name;
  19.  
  20.     public int ID;
  21.  
  22.     [TextArea]
  23.     [SerializeField] string description;
  24.  
  25.     [SerializeField] Sprite leftSprite;
  26.     [SerializeField] Sprite rightSprite;
  27.  
  28.     [SerializeField] CreatureType type1;
  29.     [SerializeField] CreatureType type2;
  30.  
  31.     [SerializeField] Habitates creatureHabitates;
  32.  
  33.     //base stats
  34.  
  35.     [SerializeField] int attack;
  36.     [SerializeField] int defense;
  37.     [SerializeField] int maxhp;
  38.    // [SerializeField] int spAttack;
  39.    // [SerializeField] int spDefense;
  40.     [SerializeField] int speed;
  41.     [SerializeField] int maxMp;
  42.     [SerializeField] int currentmp;
  43.  
  44.     [SerializeField] int expGain;
  45.     [SerializeField] GrowthRate growthRate;
  46.  
  47.     [SerializeField] int catchRate = 255;
  48.  
  49.     public const int maxMoves = 10;
  50.  
  51.     [SerializeField] List<LearnableMoves> learnableMoves;
  52.     [SerializeField] List<MoveBase> learnableByItems;
  53.  
  54.     [SerializeField] List<Evolution> evolutions;
  55.  
  56.     [SerializeField] public CreatureBase instance;
  57.     private void Awake()
  58.     {
  59.         instance= this;
  60.     }
  61.     public int GetExpForLevel(int level)
  62.     {
  63.         if(growthRate == GrowthRate.Fast)
  64.         {
  65.             return 4 * (level * level * level) / 5;
  66.         }
  67.         else if (growthRate == GrowthRate.MediumFast)
  68.         {
  69.             return level * level * level;
  70.         }
  71.  
  72.         return -1;
  73.     }
  74.     public string Name
  75.     {
  76.         get { return name; }
  77.     }
  78.  
  79.     public string Description {
  80.        
  81.         get { return description; }
  82.     }
  83.     public Sprite Leftsprite
  84.     {
  85.         get { return leftSprite; }
  86.     }
  87.  
  88.     public Sprite RightSprite
  89.     {
  90.         get { return rightSprite; }
  91.     }
  92.     public CreatureType Type1
  93.     {
  94.         get { return type1; }
  95.     }
  96.     public CreatureType Type2
  97.     {
  98.         get { return type2; }
  99.     }
  100.  
  101.     public int Attack
  102.     {
  103.         get { return attack; }
  104.     }
  105.  
  106.     public int Defense
  107.     {
  108.         get { return defense; }
  109.     }
  110.  
  111.     public int MaxHP
  112.     {
  113.         get { return maxhp; }
  114.     }
  115.     public int MaxMP
  116.     {
  117.         get { return maxMp; }
  118.     }
  119.  
  120.     public int CurrentMP
  121.     {
  122.         get { return currentmp; }
  123.     }
  124.  
  125.     public List<LearnableMoves> LearnableMoves
  126.     {
  127.         get { return learnableMoves; }
  128.     }
  129.  
  130.     public List<MoveBase> LearnableByItems => learnableByItems;
  131.  
  132.     public List<Evolution> Evolutions => evolutions;
  133.  
  134.    // public int SpAttack
  135.    // {
  136.     //    get { return spAttack; }
  137.   //  }
  138.  
  139.  //   public int SpDefense
  140.   //  {
  141.    //     get { return spDefense; }
  142.    // }
  143.  
  144.     public int Speed
  145.     {
  146.         get { return speed; }
  147.     }
  148.  
  149.     public int CatchRate => catchRate;
  150.  
  151.     public int ExpGain => expGain;
  152.  
  153.     public GrowthRate GrowthRate => growthRate;
  154.  
  155.     public Habitates getHabitate { get { return creatureHabitates; } }
  156.  
  157. }
  158.  
  159. [System.Serializable]
  160. public class LearnableMoves
  161. {
  162.     [SerializeField] MoveBase moveBase;
  163.     [SerializeField] int level;
  164.  
  165.     public MoveBase Base {
  166.         get { return moveBase; }
  167.  
  168.         }
  169.  
  170.     public int Level
  171.     {
  172.         get { return level; }
  173.     }
  174. }
  175.  
  176. [System.Serializable]
  177. public class Evolution
  178. {
  179.     [SerializeField] CreatureBase evolveInto;
  180.     [SerializeField] int requiredLevel;
  181.     [SerializeField] ItemBase requiredItem;
  182.  
  183.     public CreatureBase EvolveInto => evolveInto;
  184.     public int RequiredLevel => requiredLevel;
  185.  
  186.     public ItemBase RequiredItem => requiredItem;
  187. }
  188. public enum CreatureType
  189. {
  190.     normal,
  191.     fire,
  192.     water,
  193.     darkness,
  194.     ice,
  195.     earth,
  196.     ethareal
  197. }
  198.  
  199. public enum GrowthRate
  200. {
  201.     Fast,
  202.     MediumFast,
  203. }
  204. public enum Stat
  205. {
  206.     Attack,
  207.     Defense,
  208.     SpDefense,
  209.     SpAttack,
  210.     Speed,
  211.  
  212.     // to boost move accuracy
  213.     Accuracy,
  214.     Evasion,
  215.    
  216. }
  217.  
  218.  
  219.  
  220. public class TypeChart
  221. {
  222.    static float[][] chart =
  223.     {
  224.         //                    NOR  FIR  WAT
  225.        /* NOR*/ new float [] {1f,   1f, 1f},
  226.        /* FIR*/ new float [] {1f,  .5f,.5f},
  227.        /* WAT*/ new float [] {1f,   2f,.5f}
  228.     };
  229.  
  230.     public static float GetEffectivness(CreatureType attackType, CreatureType defenseType)
  231.     {
  232.         if (attackType == CreatureType.normal || defenseType == CreatureType.normal)
  233.             return 1;
  234.  
  235.         int row = (int)attackType - 1;
  236.         int col = (int)defenseType - 1;
  237.  
  238.         return chart[row][col];
  239.     }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement