/// <summary> /// Calculates the hit chance for the player /// </summary> public float calculateHitChance(ARMOR_TYPE armor, DAMAGE_TYPE damage) { Debug.Log(" CRIT CHANCE : " + damageData [damage] [armor].critChance + " DAMAGE AMOUNT : " + damageData [damage] [armor].damage + " HIT CHANCE : " + damageData [damage] [armor].hitChance); return(damageData [damage] [armor].hitChance); }
private void OnGUI() { GUILayout.Label("Base Properties", EditorStyles.boldLabel); _name = EditorGUILayout.TextField("Name", _name); _type = (ARMOR_TYPE)EditorGUILayout.EnumPopup("Type", _type); _reduceValue = EditorGUILayout.Slider("Reload Time", _reduceValue, 0, 1); GUILayout.Label("Detail Properties", EditorStyles.boldLabel); switch (_type) { case ARMOR_TYPE.HELMET: break; case ARMOR_TYPE.VEST: break; } if (GUILayout.Button("Confirm")) { // Make Json data } else if (GUILayout.Button("Cancel")) { // Cancel window.Close(); } }
public Armor(ARMOR_TYPE type, ARMOR_SLOT slot, int physicalDefense, int magicalDefense, int evasion) : this(type, slot) { this.physicalDefense = physicalDefense; this.magicalDefense = magicalDefense; this.evasion = evasion; }
// Constructors public Armor() { type = ARMOR_TYPE.NOTYPE; slot = ARMOR_SLOT.NOSLOT; physicalDefense = 0; magicalDefense = 0; evasion = 0; }
/// <summary> /// Calculates the damage dealt. /// </summary> /// <returns>The damage.</returns> /// <param name="armor">Armor.</param> /// <param name="damage">Damage.</param> /// <param name="baseDamage">Base damage.</param> public float calculateDamage(ARMOR_TYPE armor, DAMAGE_TYPE damage, int baseDamage) { int damageCalculation = Mathf.RoundToInt(baseDamage * damageData [damage] [armor].damage); return(damageCalculation); }
} // END DamageData constructor public DamageData(TextAsset file) { // open and read file in string[] lines = file.text.Split('\n'); // for the population phase, we'll store a list of our header column // so that we can use that for our dictionary List <DAMAGE_TYPE> headerColumn = new List <DAMAGE_TYPE>(); // instantiate our dictionary damageData = new Dictionary <DAMAGE_TYPE, Dictionary <ARMOR_TYPE, Damage> > (); int rowIndex = 0; foreach (var line in lines) { // split the line string[] columns = line.Split(','); int columnIndex = 0; ARMOR_TYPE columnName = new ARMOR_TYPE(); if (columns.Length < 7) { continue; } // walk over columns foreach (var column in columns) { // split our column into its 3 values if that is appropriate (ie we are not in column 0 and we are not in row 0) if (columnIndex != 0 && rowIndex != 0) { // get the damage type we are on from our header column (minus one, because our columns don't start at 0) DAMAGE_TYPE tempDamageType = headerColumn[columnIndex - 1]; //Debug.Log ("ROW > 0, COLUMN > 0 : " + column); string[] dataItems = column.Split('\t'); Damage damageVal = new Damage(); // make a loop over the split details here for (int i = 0; i < dataItems.Length; i++) { // let's trim and translate to float float chanceItem = float.Parse(dataItems[i].Trim()); if (i == 0) { // add this item to our dictionary damageVal.hitChance = chanceItem; } else if (i == 1) { damageVal.damage = chanceItem; } else { damageVal.critChance = chanceItem; } damageData [tempDamageType] [columnName] = damageVal; } } // if we are in here, we are in our first row, but we can ignore our first column else if (columnIndex != 0 && rowIndex == 0) { //Debug.Log ("ROW == 0, COLUMN > 0 : " + column); DAMAGE_TYPE tempDamageType = (DAMAGE_TYPE)Enum.Parse(typeof(DAMAGE_TYPE), column); // add to our list of columns headerColumn.Add(tempDamageType); // create a new dictionary for each item damageData.Add(tempDamageType, new Dictionary <ARMOR_TYPE, Damage> ()); } // otherwise, if we are not in row 0, and we have a column index of 0... get our column name else if (columnIndex == 0 && rowIndex != 0) { //Debug.Log ("ROW > 0, COLUMN == 0 : " + column); columnName = (ARMOR_TYPE)Enum.Parse(typeof(ARMOR_TYPE), column); // foreach of our header columns, add new dictionary for this armor type foreach (var columnItem in headerColumn) { damageData [columnItem].Add(columnName, new Damage()); } } // update our column number columnIndex++; } // update our line number rowIndex++; } }
public Armor(ARMOR_TYPE type, ARMOR_SLOT slot) : this() { this.type = type; this.slot = slot; }