Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.46 KB | None | 0 0
  1. /// <summary>
  2.         /// Gets the elements.
  3.         /// </summary>
  4.         /// <param name="ragemode">if set to <c>true</c> [ragemode].</param>
  5.         /// <param name="transformed">if set to <c>true</c> [transformed].</param>
  6.         /// <returns></returns>
  7.         public Dictionary<StatType, float> GetElements(bool ragemode, bool transformed)
  8.         {
  9.             var normaldict = new Dictionary<StatType, short>();
  10.             var ragedict = new Dictionary<StatType, short>();
  11.  
  12.             //Elements
  13.             foreach (var element in Constants.ElementList)
  14.             {
  15.                 GetElement(normaldict, ragedict, element, ragemode);
  16.             }
  17.  
  18.             //Determine total elements.
  19.             int normaltotal = 0;
  20.  
  21.             foreach (var element in normaldict)
  22.             {
  23.                 normaltotal += element.Value;
  24.             }
  25.  
  26.             int ragetotal = 0;
  27.  
  28.             foreach (var element in ragedict)
  29.             {
  30.                 ragetotal += element.Value;
  31.             }
  32.  
  33.             //Determine physical element.
  34.  
  35.             //Get equip type
  36.             EquipType type = GetWeaponType(transformed);
  37.  
  38.             //Get type data and assign it.
  39.             var typedata = EquipDataManager.GetEquipData(type.ToString());
  40.  
  41.             if (normaltotal != Constants.MaxUpgradeLevel)
  42.             {
  43.                 if (normaldict.ContainsKey(typedata.DamageType))
  44.                 {
  45.                     short value = normaldict[typedata.DamageType];
  46.  
  47.                     value += (byte)(Constants.MaxUpgradeLevel - normaltotal);
  48.                     normaldict.Remove(typedata.DamageType);
  49.                     normaldict.Add(typedata.DamageType, value);
  50.                 }
  51.                 else
  52.                 {
  53.                     normaldict.Add(typedata.DamageType, (byte) (Constants.MaxUpgradeLevel - normaltotal));
  54.                 }
  55.             }
  56.  
  57.             if (ragetotal != Constants.MaxUpgradeLevel)
  58.             {
  59.                 if (ragedict.ContainsKey(typedata.DamageType))
  60.                 {
  61.                     short value = ragedict[typedata.DamageType];
  62.  
  63.                     value += (byte)(Constants.MaxUpgradeLevel - ragetotal);
  64.                     ragedict.Remove(typedata.DamageType);
  65.                     ragedict.Add(typedata.DamageType, value);
  66.                 }
  67.                 else
  68.                 {
  69.                     ragedict.Add(typedata.DamageType, (byte)(Constants.MaxUpgradeLevel - ragetotal));
  70.                 }
  71.             }
  72.  
  73.             //Low Rank Status
  74.             foreach (var statuseffect in Constants.LowRankStatusEffects)
  75.             {
  76.                 GetElement(normaldict, ragedict, statuseffect, ragemode);  
  77.             }
  78.            
  79.             //High Rank Status
  80.             foreach (var statuseffect in Constants.HighRankStatusEffects)
  81.             {
  82.                 GetElement(normaldict, ragedict, statuseffect, ragemode);
  83.             }
  84.            
  85.             //Make the total dict.
  86.             var totaldict = new Dictionary<StatType, short>();
  87.  
  88.             //Assign the values of normaldict, checking for ragedict as well.
  89.             foreach (var element in normaldict)
  90.             {
  91.                 if (ragedict.ContainsKey(element.Key))
  92.                 {
  93.                     totaldict.Add(element.Key, (short) (element.Value + ragedict[element.Key]));
  94.                 }
  95.                 else
  96.                 {
  97.                     totaldict.Add(element.Key, element.Value);
  98.                 }
  99.             }
  100.  
  101.             //Add what's missing in ragedict.
  102.             foreach (var element in ragedict)
  103.             {
  104.                 if (totaldict.ContainsKey(element.Key))
  105.                 {
  106.                     continue;
  107.                 }
  108.  
  109.                 totaldict.Add(element.Key, element.Value);
  110.             }
  111.  
  112.             //Assign actual values.
  113.             var floatdict = new Dictionary<StatType, float>();
  114.  
  115.             foreach (var element in totaldict)
  116.             {
  117.                 floatdict.Add(element.Key, element.Value / (float) Constants.MaxUpgradeLevel);
  118.             }
  119.  
  120.             return floatdict;
  121.         }
  122.  
  123.         /// <summary>
  124.         /// Gets the element.
  125.         /// </summary>
  126.         /// <param name="normaldict">The normaldict.</param>
  127.         /// <param name="ragedict">The ragedict.</param>
  128.         /// <param name="type">The type.</param>
  129.         /// <param name="ragemode">if set to <c>true</c> [ragemode].</param>
  130.         private void GetElement(Dictionary<StatType, short> normaldict, Dictionary<StatType, short> ragedict, StatType type, bool ragemode)
  131.         {
  132.             var value = GetStat(type);
  133.  
  134.             if (value > 0)
  135.             {
  136.                 normaldict.Add(type, value);
  137.             }
  138.  
  139.             //Don't do shit with rage if it isn't in rage mode.
  140.             if (!ragemode)
  141.             {
  142.                 return;
  143.             }
  144.  
  145.             value = GetRageStat(type);
  146.  
  147.             if (value > 0)
  148.             {
  149.                 ragedict.Add(type, value);
  150.             }
  151.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement