/* Initializes all the stats of the weapon based on its type. */ private void initializeStats() { int[] dmg = null; float[] rof = null, amo = null; Stat_Cost[] dmg_c = null, rof_c = null, amo_c = null; // Initializes stats and stat costs based on the weapon type if (type.CompareTo(WEAPON_TYPE.sword) == 0) { dmg = new int[] { 15, 33, 68, 134, 248, 426, 683, 1035, 1499, 2090, 2825 }; rof = new float[] { 2.85f, 3f, 3.2f, 3.55f, 3.95f, 4.5f }; amo = new float[] { 105f, 83f, 78f, 70f, 60f, 43f }; dmg_c = new Stat_Cost[] { new Stat_Cost(0, 11), new Stat_Cost(0, 19), new Stat_Cost(0, 27), new Stat_Cost(0, 35), new Stat_Cost(0, 44), new Stat_Cost(0, 53), new Stat_Cost(0, 62), new Stat_Cost(8, 71), new Stat_Cost(12, 80), new Stat_Cost(18, 90) }; rof_c = new Stat_Cost[] { new Stat_Cost(1, 0), new Stat_Cost(3, 0), new Stat_Cost(6, 0), new Stat_Cost(11, 24), new Stat_Cost(18, 58) }; amo_c = new Stat_Cost[] { new Stat_Cost(6, 12), new Stat_Cost(8, 19), new Stat_Cost(11, 32), new Stat_Cost(16, 51), new Stat_Cost(24, 65) }; } else if (type.CompareTo(WEAPON_TYPE.rifle) == 0) { dmg = new int[] { 6, 25, 57, 100, 155, 222, 300, 391, 493, 606, 733 }; rof = new float[] { 4, 6, 9, 13, 18, 23 }; amo = new float[] { 13f, 10f, 7f, 5f, 3f, 1f }; dmg_c = new Stat_Cost[] { new Stat_Cost(0, 14), new Stat_Cost(0, 23), new Stat_Cost(0, 32), new Stat_Cost(0, 41), new Stat_Cost(0, 51), new Stat_Cost(0, 60), new Stat_Cost(0, 70), new Stat_Cost(10, 80), new Stat_Cost(15, 90), new Stat_Cost(21, 100) }; rof_c = new Stat_Cost[] { new Stat_Cost(3, 0), new Stat_Cost(5, 0), new Stat_Cost(8, 0), new Stat_Cost(13, 26), new Stat_Cost(22, 62) }; amo_c = new Stat_Cost[] { new Stat_Cost(3, 6), new Stat_Cost(5, 14), new Stat_Cost(8, 28), new Stat_Cost(12, 47), new Stat_Cost(18, 65) }; } else if (type.CompareTo(WEAPON_TYPE.shotgun) == 0) { dmg = new int[] { 3, 16, 39, 70, 111, 161, 219, 287, 264, 450, 545 }; rof = new float[] { 2, 3, 4, 5, 7, 9 }; amo = new float[] { 21f, 17f, 13f, 10f, 7f, 5f }; dmg_c = new Stat_Cost[] { new Stat_Cost(0, 5), new Stat_Cost(0, 11), new Stat_Cost(0, 17), new Stat_Cost(0, 24), new Stat_Cost(0, 31), new Stat_Cost(0, 43), new Stat_Cost(0, 46), new Stat_Cost(4, 53), new Stat_Cost(7, 61), new Stat_Cost(12, 70) }; rof_c = new Stat_Cost[] { new Stat_Cost(3, 0), new Stat_Cost(7, 0), new Stat_Cost(13, 0), new Stat_Cost(21, 30), new Stat_Cost(30, 70) }; amo_c = new Stat_Cost[] { new Stat_Cost(4, 8), new Stat_Cost(7, 16), new Stat_Cost(11, 29), new Stat_Cost(15, 43), new Stat_Cost(20, 70) }; } else if (type.CompareTo(WEAPON_TYPE.grenade) == 0) { dmg = new int[] { 24, 65, 119, 183, 260, 347, 447, 557, 680, 813, 960 }; rof = new float[] { 2.15f, 2.3f, 2.45f, 2.65f, 2.9f, 3.25f }; amo = new float[] { 52f, 50f, 47f, 43f, 38f, 32f }; dmg_c = new Stat_Cost[] { new Stat_Cost(0, 8), new Stat_Cost(0, 14), new Stat_Cost(0, 20), new Stat_Cost(0, 28), new Stat_Cost(0, 35), new Stat_Cost(0, 43), new Stat_Cost(0, 52), new Stat_Cost(6, 61), new Stat_Cost(10, 70), new Stat_Cost(15, 80) }; rof_c = new Stat_Cost[] { new Stat_Cost(5, 0), new Stat_Cost(8, 0), new Stat_Cost(13, 0), new Stat_Cost(19, 28), new Stat_Cost(26, 66) }; amo_c = new Stat_Cost[] { new Stat_Cost(3, 7), new Stat_Cost(6, 21), new Stat_Cost(10, 37), new Stat_Cost(15, 55), new Stat_Cost(22, 75) }; } /* stats[0] = damage * stats[1] = rate of fire * stats[2] = ammo consumption */ stats[0] = new Stat(STAT_TYPE.damage, dmg, dmg_c); stats[1] = new Stat(STAT_TYPE.rate_of_fire, rof, rof_c); stats[2] = new Stat(STAT_TYPE.ammo, amo, amo_c); }
/** * Creates a stat of the given type with the given costs; * The sc array should have one less value than the vals array! */ public Stat (STAT_TYPE t, int[] vals, Stat_Cost[] sc) { type = t; values = new float[vals.Length]; for (int idx = 0; idx < vals.Length; ++idx) { values[idx] = vals[idx]; } pointer = 0; costs = sc; }
public Player_Stats() { int[] val_temp = new int[11]; Stat_Cost[] cost_temp = new Stat_Cost[10]; // initialize health values for (int idx = 0; idx < val_temp.Length; ++idx) { val_temp[idx] = (int)(1.5f * idx * idx) + 8 * idx + 5; } // initialize stat costs for (int idx = 0; idx < cost_temp.Length; ++idx) { cost_temp[idx] = new Stat_Cost(0, (int)(0.35f * idx * idx) + 9 * idx + 6); } MAX_HEALTH = new Stat(STAT_TYPE.health, val_temp, cost_temp); health = (int)MAX_HEALTH.current(); HP_raised = true; val_temp = new int[11]; cost_temp = new Stat_Cost[10]; // initialize shield values for (int idx = 0; idx < val_temp.Length; ++idx) { val_temp[idx] = (int)(0.55f * idx * idx) + 5 * idx + 3; } // initialize stat costs for (int idx = 0; idx < cost_temp.Length; ++idx) { cost_temp[idx] = new Stat_Cost((int)(0.19f * idx * idx) + 2 * idx + 3, 0); } MAX_SHIELD = new Stat(STAT_TYPE.shield, val_temp, cost_temp); shield = (int)MAX_SHIELD.current(); Shield_raised = true; WEAPONS = new WeaponStats[4]; WEAPONS[0] = new WeaponStats(0); WEAPONS[1] = new WeaponStats(1); WEAPONS[2] = new WeaponStats(2); WEAPONS[3] = new WeaponStats(3); held_weapon = WEAPON_TYPE.sword; scrap = 0; //2573 energyCores = 0; //1197 MEDPACKS = new Stat(STAT_TYPE.other, new int[] { 0, 1, 2, 3 }, new Stat_Cost[] { new Stat_Cost(1, 5), new Stat_Cost(3, 18), new Stat_Cost(5, 43) }); }
public Player_Stats() { int[] val_temp = new int[11]; Stat_Cost[] cost_temp = new Stat_Cost[10]; // initialize health values for (int idx = 0; idx < val_temp.Length; ++idx) { val_temp[idx] = (int)(1.5f * idx * idx) + 8 * idx + 5; } // initialize stat costs for (int idx = 0; idx < cost_temp.Length; ++idx) { cost_temp[idx] = new Stat_Cost(0, (int)(0.35f * idx * idx) + 9 * idx + 6); } MAX_HEALTH = new Stat(STAT_TYPE.health, val_temp, cost_temp); health = (int)MAX_HEALTH.current(); HP_raised = true; val_temp = new int[11]; cost_temp = new Stat_Cost[10]; // initialize shield values for (int idx = 0; idx < val_temp.Length; ++idx) { val_temp[idx] = (int)(0.55f * idx * idx) + 5 * idx + 3; } // initialize stat costs for (int idx = 0; idx < cost_temp.Length; ++idx) { cost_temp[idx] = new Stat_Cost((int)(0.19f * idx * idx) + 2 * idx + 3, 0); } MAX_SHIELD = new Stat(STAT_TYPE.shield, val_temp, cost_temp); shield = (int)MAX_SHIELD.current(); Shield_raised = true; WEAPONS = new WeaponStats[4]; WEAPONS[0] = new WeaponStats(0); WEAPONS[1] = new WeaponStats(1); WEAPONS[2] = new WeaponStats(2); WEAPONS[3] = new WeaponStats(3); held_weapon = WEAPON_TYPE.sword; scrap = 0; //2573 energyCores = 0; //1197 MEDPACKS = new Stat(STAT_TYPE.other, new int[] { 0, 1, 2, 3 }, new Stat_Cost[] { new Stat_Cost(1, 5), new Stat_Cost(3, 18), new Stat_Cost(5, 43) } ); }
/* Draws the fields of the given stat display */ private void drawStatDisplay(StatDisplay display) { // display title GUI.Label(display.labels[0], display.name + " (" + display.stat.pointer_value() + ")"); // Determines if the stat value is capped bool is_last = display.stat.next() == -1; // Determines if the player can afford the next upgrade Stat_Cost for_next = display.stat.next_cost(); bool can_buy = for_next == null || (for_next.scrap_cost <= p.stats.get_scrap() && for_next.ecore_cost <= p.stats.get_ecores()); GUI.enabled = !is_last && can_buy; if (GUI.enabled) { // Text color green indicates that a stat can be upgraded currently GUI.skin.button.normal.textColor = Color.green; GUI.skin.button.fontStyle = FontStyle.Bold; } else if (!is_last) { GUI.skin.button.normal.textColor = Color.red; } // Create button to increment the pointer if (GUI.Button(display.buttons[0], "+") && GUI.enabled) { int origin = 0; // Store the original value of the player's health if (display.stat.type == STAT_TYPE.health) { origin = (int)p.stats.MAX_HEALTH.current(); } display.stat.increment(); // Subtract cost from player stats if (for_next != null) { p.stats.change_scrap(-for_next.scrap_cost); p.stats.change_ecores(-for_next.ecore_cost); } // Indicate that the max values of either health or shield changed, so that sliders will update if (display.stat.type == STAT_TYPE.health) { // Restore health equal to the change in health p.stats.change_health((int)p.stats.MAX_HEALTH.current() - origin); p.stats.HP_raised = true; } else if (display.stat.type == STAT_TYPE.shield) { // Fully restore shield p.stats.change_shield((int)p.stats.MAX_SHIELD.current()); p.stats.Shield_raised = true; } else { // Updates the player's weapon if necessary p.updateWeapons(); } } GUI.skin.button.normal.textColor = Color.white; GUI.skin.button.fontStyle = FontStyle.Normal; /* Do NOT uncomment!! * * GUI.enabled = display.stat.pointer_value() > 0; * // Decrement a stat value and return the cost of the upgrade * if (GUI.Button(display.buttons[1], "-") && GUI.enabled) { * display.stat.decrement(); * * // Readd cost of the upgrade to player stats * if (display.stat.next_cost() != null) { * p.stats.change_scrap(display.stat.next_cost().scrap_cost); * p.stats.change_ecores(display.stat.next_cost().ecore_cost); * } * * // Indicate that the max values of either health or shield changed, so that sliders will update * if (display.stat.type == STAT_TYPE.health) { * p.stats.HP_raised = true; * } else if (display.stat.type == STAT_TYPE.shield) { * p.stats.Shield_raised = true; * } * }*/ GUI.enabled = true; // show cost for next upgrade GUI.Label(display.labels[1], "cost (scrap | e. cores): " + ((for_next == null) ? "-- | --" : (for_next.scrap_cost + " | " + for_next.ecore_cost))); // show current value GUI.Label(display.labels[2], "" + display.stat.current()); // display arrows GUI.Label(display.labels[3], ">>"); // show next value (or '--' if no such element exists) GUI.Label(display.labels[4], (is_last) ? "--" : "" + display.stat.next(), lbl_grn_text); }
/** * Creates a stat of the given type with the given costs; * The sc array should have one less value than the vals array! */ public Stat (STAT_TYPE t, float[] vals, Stat_Cost[] sc) { type = t; values = vals; pointer = 0; costs = sc; }