I’m working on a fairly simple Space Harrier style game and I have two things that I need some advice on.
Firstly I’m working on setting up enemy wave data. To do this I’m using a big list of arrays but I’ve read that generic lists are better and I should use them instead. I’ve already used them in some parts of my work, but when it comes to storing enemy wave data I’m having trouble as I need to store lists inside lists (and in some cases lists inside lists inside lists!) It’s not too messy and I’m the only one who’ll ever see it but I’ve no idea how to populate the nested lists.
The data I’m refering to is the whole level of waves. I’d like to feed the data by index to each enemy wave container gameObject that I create, so I can move through eeach one by one until the end of the list. A small example of some of it (two waves…):
// Enemy container # 0 1
isEnemyDebugData = [[true,false], [false,false]];
enemyTypeData = [[0, 0], [0, 0]];
enemyXData = [[-1.0, 1.0], [-1.0, 1.0]];
enemyYData = [[0.5, 1.0], [0.5, 0.5]];
enemyZData = [[0.0, 0.0], [0.0, 0.0]];
Currently I’ve [[0,0,0], [0,0,0]] type code, as everything is being converted from array to list, but listname.Add() and listname.AddRange() cause errors when I try to fill them this way. What is the correct way to fill a nested list?
I’m not a programmer but I’d still like to keep things in best practice where I can. I’ve read that classes are a better way of doing things and I’m currently in the process of writing a small EnemyWave class that will store the wave data, but I’m seeing a lot of similarities with just adding a enemyWave script to a gameObject as a component, something I’ve already done. I suppose what I’m asking is “is there a need to use classes rather than scripts as components in this instance?”
I’m relatively new to programming, as normally I only do art asset stuff, animating, rigging, etc., so please forgive me if my terms aren’t quite correct or this is a very newbie question. ![]()
edit: In case it’s not clear (no idea if it would be) I’m working in Javascript.