Forge War - Arrays of All Dimensions

July 26, 2013

So coding has been moving along. I've moved into the quest phase of the game and working in C# has provided one continued annoyance for me.

All right, in AS3, when I want to grab a variable dynamically (as in do I want to grab "Player1Quest" or "Player2Quest" depending on if some other variable "i" is 1 or 2), then that is totally easy. I set up a construction: this, and I can grab the variable by constructing the string of its name. If I'm grabbing a movie clip object or something it gets a little more complicated, but there's still a simple way to do it.

No so in C# my friends! Well, there may be a way, but I have yet to find it, and I've done some looking. So instead of doing something like:
this=25;
I have 2 options - the smart way and the stupid way. Of course, up until this point, I've been using the stupid way. The stupid way being a series of "if" statements that add a much of needless lines to your code:
if(i==1){Player1Quest=25;}
if(i==2){Player2Quest=25;}
etc.
This is dumb.

The other way is to not have a different variables for all this player quest business and instead just have an array called "PlayerQuest." Oh, holy crap, I'm a genius. Or at least not a moron. Then you can just be, like:
PlayerQuest=25;
So much better! And I was doing this for some things, but I think I got hung up if the variable was already an array and for some reason I was apprehensive about making a 2D array. Or if it was a 2D array and I had to make a 3D array. Because I'm afraid of brackets I guess?

I don't know, but I decided I needed to go back and condense all my variables into arrays before the stupidity got too much out of hand, so that was exciting, and now I can get on with my life.


Leave a comment

Comments will be approved before showing up.


Also in Blog

CEPHALOFAIR DESIGNER DIARY ISSUE 6: GLOOMHAVEN RPG
CEPHALOFAIR DESIGNER DIARY ISSUE 6: GLOOMHAVEN RPG

April 02, 2024

Danielle talks about more updates on the Gloomhaven RPG, featuring revelations and fun from our recent Gloomcabin (Cephalofair Games' annual retreat) trip.

Read More

CEPHALOFAIR DESIGNER DIARY ISSUE 5: Buttons & Bugs
CEPHALOFAIR DESIGNER DIARY ISSUE 5: Buttons & Bugs

March 07, 2024

On today's Designer Diaries - Nikki Valens talks about what they have learned while co- designing Buttons & Bugs,  why listening to players is crucial for creating great games and how much they enjoy the process of taking games apart and rebuilding them.

Read More

NOW HIRING: Production Graphic Designer
NOW HIRING: Production Graphic Designer

March 06, 2024

Read More