I am making a top down shooter for android and I am just looking for some advice on the best way to organise classes etc.
Currently, for characters and enemies I have a BaseStat : Monobehaviour class (holds all common variables for both enemies and players), EnemyStat : BaseStat class (variables common to only all enemies), PlayerStat : BaseStat (variables common to only all enemies). Then each individual enemy would have attached their own script, inheriting from EnemyStat, and the same for each player. The only problem with this at the moment is that the inspector of each player/enemy is just a long list of variables and isn’t very easy to read, or nice to look at (could this be made better using arrays of lists? Not to savvy with either of them).
Is this a good design idea? It seems pretty flexible in terms of adding new stats, players and enemies and I’m just wondering if i’ll run into any issues further down the line because of it.
I’ll probably be doing a similar inheritance system for my weapon stats also,but when it comes to my weapons and enemy/player behaviours I was thinking a component based approach would be the best way, as it allows for easy customisation.
I’m new to developing and to Unity so I would just like some advice now rather than later when it becomes more of a pain to change my system, if necessary. I have heard about scriptable objects, but don’t really know how I could apply the to my own game.
Base Class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class BaseStat : MonoBehaviour {
public int maxLvl = 100;
public int curLvl;
public float maxHP;
public float curHP;
public float maxArmor;
public float minArmor;
public float maxMoveSpd; //Base
public float curMoveSpd; //Set to max, can be altered for buffs/debuffs
}
Enemy Class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyStat : BaseStat {
protected string atkType;
public float maxAtk;
public float minAtk;
public float maxAtkSpd; //Base
/*[HideInInspector]*/public float curAtkSpd; //Set to max, can be altered for buffs/debuffs
public float atkRng;
private static float atkSpdTimer = 0f; //Compared to AtkSpd
public int expVal; //Not sure if these should stay here
public int scoreVal; //Not sure if these should stay here
void Start () {
curHP = maxHP;
curMoveSpd = maxMoveSpd;
curAtkSpd = maxAtkSpd;
}
}
Player Class
All stats not finished yet:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerStat : BaseStat {
public float proLvl; //Proficiency - Directly affects reload spd and gun dmg
//public int maxStatPnts;
//public int curStatPnts;
void Awake () {
curHP = maxHP;
curMoveSpd = maxMoveSpd;
}
}