Hello everyone, pleased to be on the forum.
I'm currently undertaking some game development in Visual Studio, in my spare time. I've been programming for a few months, in Java, and now am having a go at C#. I have however run into a little snag with lists. I'm trying to create a board game, in which the characters move one step at a time around the board.
What I would like to know (as I've been searching for quite a while), is how to cycle through a List, and how to edit the contents of a list. In Java, I could use List.size() I believe, what is the C# equivalent?
Here is a snippet of the code I am using:
//create a list of properties
List <Properties>properties = new List<Properties>();
//initialize all the properties
properties.Add(new Properties([B](pos1)[/B], "GO", false, false, 0, 0, 0, 0, false, false));
properties.Add(new Properties([B](pos2)[/B], "Derelict Building", false, false, 200, 6, 60, 200, false, false));
properties.Add(new Properties([B](pos3)[/B], "Shooting Range", false, false, 200, 8, 80, 200, false, false));
properties.Add(new Properties([B](pos4)[/B], "Youth Hostel", false, false, 0, 100, 250, 0, false, false));
I want to cycle through the list, and say that if a variable, player1pos, is equal to pos(i) (the emboldened items), then to decrement the value of a dice roll and move to the next item in the list.
Here's a vague attempt at the code that obviously drew up syntactic errors...
if(player1)
{
int x = diceRoll.Roll(1,6);
if (x != 0)
{
for (int i; i < properties.size(); i++)
{
if (player1pos == properties.pos(i))
{
player1pos = properties.pos(i + 1);
x = x - 1;
}
}
}
}
Each position (pos1, pos2, pos3, player1pos) is a co-ordinate of the type Vector2.
So basically, I want to cycle through a list, and to isolate the position variables.