Appropriate data format for storing Fighting Game moves (C#)

55 Views Asked by At

I am currently trying to develop a small fighting game in Unity (Be aware that I have close to no C# experience as I am a Javascript developer). Said game contains Objects of the Class Move which contains an Array of MoveFrame.

I need to store the data to create the MoveFrames of a Move in an easily human-readable and editable format so that other people are able to edit these values on the fly.

MoveFrame looks like this:

public class MoveFrame
{
    private Rect[] hurtboxes { get; }
    private hitbox[] hitboxes { get; }
    private Rect collision { get; }
    private int velocity { get; }
    private bool counter { get; }

    public MoveFrame(Rect[] hurt, hitbox[] hit, Rect coll, int velo, bool ch)
    {
        hurtboxes = hurt;
        hitboxes = hit;
        collision = coll;
        velocity = velo;
        counter = ch;
    }

    public struct hitbox
    {
        int hId;
        int dmg;
        bool scale;
        Rect[] ground;
        Rect[] air;
    }

}

I was considering JSON as it would likely fit my needs for said problem quite well, but I am unsure if there is any way to parse it in C#.

Are there any fitting dataformats which you can easily parse in C# that would be appropriate for said problem?

2

There are 2 best solutions below

0
Renan Ruan On

You can achieve that using ScriptableObjects. They are unity assets that stay stored inside your game, and let you access and modify their data throw the inspector windows in a very readable and human-friendly way

0
JonasH On

Json is very commonly used in c#, and is the most common choice for human readable data currently. The two most common libraries are system.text.json, and newtonsoft.json. But unity3D also have some built in support.

But I would probably recommend creating some kind of editor for your data. Editing json by hand can quickly become tiresome. It also increases the risk of mistakes, and it is no fun hunting for some missing comma in a huge file.