using UnityEngine; using System.Collections; using System.Collections.Generic; public class UpgradeUtil { public enum Quality { Common = 0, Rare = 1, Epic = 2, Legendary = 3, // Heirloom = 4, } private static System.Array qualityArr = System.Enum.GetValues(typeof(Quality)); public static Quality GetQualityByCode(int code) { return (Quality)qualityArr.GetValue (code); } private static Color[] qualityBorderColorArr = new Color[]{ new Color(1f, 1f, 1f, 1f), new Color(75f/255f, 150f/255f, 255f/255f, 1f), new Color(219f/255f, 135f/255f, 255f/255f, 1f), new Color(255f/255f, 175f/255f, 135f/255f, 1f) }; private static Color[] qualityTxtColorArr = new Color[]{ new Color(1f, 1f, 1f, 1f), new Color(58f/255f, 157f/255f, 255f/255f, 1f), new Color(130f/255f, 58f/255f, 255f/255f, 1f), new Color(255f/255f, 136f/255f, 58f/255f, 1f) }; private static int[] UpgradeCountArr = new int[]{ 2, 4, 10, 20, 40, 80, 150, 300, 600, 1200, 2400, 4800 }; private static int[] MaxLevelArr = new int[]{12, 10, 8, 5}; private static int[] price0 = new int[]{5, 20, 50, 150, 400, 1000, 2000, 4000, 8000, 16000, 32000}; private static int[] price1 = new int[]{50, 150, 400, 1000, 2000, 4000, 8000, 16000, 32000}; private static int[] price2 = new int[]{400, 1000, 2000, 4000, 8000, 16000, 32000}; private static int[] price3 = new int[]{4000, 8000, 16000, 32000}; private static List priceList = new List{ price0, price1, price2, price3}; public static int GetUpgradeCount(int level) { int index = level - 1; if (index < 0) return 0; if(index >= UpgradeCountArr.Length) return UpgradeCountArr[UpgradeCountArr.Length - 1]; return UpgradeCountArr[index]; } public static int GetUpgradePrice(int level, Quality quality) { int index = level - 1; if (index < 0) return 0; int[] priceArr = priceList [quality.GetHashCode ()]; if (index >= priceArr.Length) return 0; return priceArr [index]; } public static Color GetCommonBorderColor() { return qualityBorderColorArr [Quality.Common.GetHashCode ()]; } public static Color GetBorderColor(Quality quality) { return qualityBorderColorArr [quality.GetHashCode ()]; } public static Color GetTextColor(Quality quality) { return qualityTxtColorArr [quality.GetHashCode ()]; } public static int GetMaxLevel(Quality quality) { return MaxLevelArr [quality.GetHashCode ()]; } public static float HpBase = 300f; // 1% hp public static float DmgBase = 10f; // 1% damage per second public static float GetHp(float value) { return value * HpBase; } public static float GetDamage(float value) { return value * DmgBase; } }