Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

What is the best way to create a wave/subwave based system?

Discussion in 'Scripting' started by RegularTetragon, Aug 7, 2014.

  1. RegularTetragon

    RegularTetragon

    Joined:
    Feb 10, 2013
    Posts:
    4
    I'm trying to make a game which is effectively a cross between Quake and MvM + Cats, so I've got a question:
    What is the best way to implement waves and subwaves? My idea is using a JSON file that looks something like this:
    {
    "wave":[[[0,0,0],[0,0,0],[0,0,0]],[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]]
    }
    I'm not entirely sure how I should go about parsing or storing something like this. Help would be great!
     
  2. RegularTetragon

    RegularTetragon

    Joined:
    Feb 10, 2013
    Posts:
    4
    Okay, I've decided I'm using LitJSON, but every update it throws an error: "Argument Exception: The key has to be a string"
    I am using the following validated JSON
    {
    "wave":
    [
    [
    [0,0,0],
    [0,0,0],
    [0,0,0],
    [0,0,0],
    [0,0,0]
    ],
    [
    [0,0,0,0,0],
    [0,0,0,0,0],
    [0,0,0,0,0]
    ],
    [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ]
    ]
    }
    and the error is being called, I would assume, the line at which I try to get stuff from it, i.e.:
    for (int i = 0;i<=JLevel["wave"][wave][subWave].Count;i++){}//Will add stuff in between the brackets of course.
    If I could get this debugged I think I'd be set, but I'm fairly certain I'm doing this right. JLevel is initialized as JsonData before any method declarations, and being set as

    JLevel = JsonMapper.ToObject (Level.text);

    every update. Level contains a text asset which contains the JSON above.
    I don't really get what I'm doing wrong here. Any ideas?
     
  3. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
    Hey. Yeah I'm trying to get litJson to deserialize arrays of arrays as well.
    Have you found anything?
     
  4. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63