Creating a game inventory, form base list boxes and it must be random
Right I have this problem in my forum game i'm making, I have stats and everything working right, it's a battle arena where you have your char and he fights in an arena and levels up .etc buys equipment. Semi text based but with button pressing.
Right I have come to a problem, I want randomly generated armor name and stats that's put into a list box so when a user clicks on an item it will display said item and their randomly generated stats.
Something like when the armory is visited via a button it generates a random number of objects aka armor and weapons, so each new visit is all new equipment. the equation is simple it goes something like: StrengthStat * characterlvl + offsetnumber, this would be applied for intellect/health or any type of stat, because the level would scale wilt he gear being generated there for i would only have to generate the name which I have set up.
My real problem is when I click on said item, the stats need to hold for that particular item, then transfer over to the characters inventory. How would I go about this? I can't do an array because i'd have 50 million arrays x amount for x amount of stats, there has to be a better way.
Here's my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Armor_Generator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string Name1;
public string Name2;
public string Name3;
public int Namesel;
public int Namesel2;
public int armorgen;
private void btnGen_Click(object sender, EventArgs e)
{
if (lisarmor.selected == null)
{
txtArmor.text == "Please select and item";
}
else
{
// Randoms the generator
Random rand = new Random((int)DateTime.Now.Ticks);
Namesel = rand.Next(1, 4);
Namesel2 = rand.Next(1, 4);
// Picks the names
name1part();
name2part();
// Displays the names
lisArmor.Items.Add(Name1 + " of " + Name2);
}
}
public void name1part()
{
if (Namesel == 1)
{
Name1 = "Smashies armor";
}
if (Namesel == 2)
{
Name1 = "Black armor";
}
if (Namesel == 3)
{
Name1 = "Breakable";
}
}
public void name2part()
{
if (Namesel2 == 1)
{
Name2 = "Desperation";
}
if (Namesel2 == 2)
{
Name2 = "Breakdown";
}
if (Namesel2 == 3)
{
Name2 = "the Zombie";
}
}
private void btnEq_Click(object sender, EventArgs e)
{
lisEq.Items.Add(lisArmor.SelectedItem);
lisArmor.Items.Remove(lisArmor.SelectedItem);
}
private void btnUEq_Click(object sender, EventArgs e)
{
lisArmor.Items.Add(lisEq.SelectedItem);
lisEq.Items.Remove(lisEq.SelectedItem);
}
}
}
I have 2 list boxes "lisEq" and "lisArmor"
i have 1 text box txtArmor is the out put for the stats.etc
I have 3 buttons:
btnEq which transfers over an item from lis armor to make it like it equips
btnUEq which transfers the selected item back to unequip status
btnGen which generates the armor word do far...
Alrighty i'll be watching this thread...I was thinking an array list and have item 1 generate 1 array with index 0 being the name 1 being the str the item has, 2 for being the int 3 for hp and so on, and to clear it if index 0,1,2,3 had a 0 value you'd clear the name and it would look like that item doesn't have it.
Sorry for the lengthy post!
Edit: Also I was also thinking some type of group array like 0, 1, 2, 3
is reserved for item 1 4, 5, 6, 7 is for item 2 and hold the values in
there or something.