I have been working with a friend of mine to create a pirate game. What I am trying to do in this script is create a list for each of the attributes per crew member. The problem I am running into is that I do not know how to reference a particular attribute from each list(crew member). My eventual hope is that these lists will store the separate crew member’s attributes and can easily be accessed by the player through UI. Any and all criticism and advise would be very welcome and appreciated.
Here is my code:
using UnityEngine;
using System.Collections;
public class CrewManager : MonoBehaviour {
public int totalCrewNum = 0;
private int crewNum;
private int Name;
private int Health;
private int Discipline;
private int Fighting;
private int Aim;
private int Experience;
private int Navigation;
private int Charm;
private int Reputation;
private int Luck;
private int Bounty;
// Use this for initialization
void Awake ()
{
// When the game boots up i want the script to generate 10 random crew members
while(totalCrewNum < 10)
{
totalCrewNum++;
createCrew();
}
}
// Update is called once per frame
void Update ()
{
// These lines I want to count up the total
// crew number and add that number to the
//list where it can be referenced easier
string listNum = “Attributes” + totalCrewNum;
}
void createCrew ()
{
// creates the attributes of a random crew member
ArrayList listNum = new ArrayList();
listNum.Add(Name);
listNum.Add(Health);
listNum.Add(Discipline);
listNum.Add(Fighting);
listNum.Add(Aim);
listNum.Add(Experience);
listNum.Add(Navigation);
listNum.Add(Charm);
listNum.Add(Reputation);
listNum.Add(Bounty);
listNum.Add(Luck);
Health = Random.Range(1,100);
Discipline = Random.Range(1,100);
Fighting = Random.Range(1,100);
Aim = Random.Range(1,100);
Experience = Random.Range(1,100);
Navigation = Random.Range(1,100);
Charm = Random.Range(1,100);
Reputation = Random.Range(-100,100);
Bounty = Random.Range(1,100);
Luck = Random.Range(1,100);
Name = Random.Range(1,100);
// This will assign Random names to crew members
if(Name == 1)
{
Name.ToString(“Matt”);
}
else
{
Name.ToString(“Undeclared”);
}
}
}