/// <summary> /// Load saved entity data /// </summary> public static void Load() { var savedJson = PlayerPrefs.GetString(GAME_ID); if (savedJson == null || savedJson.Length <= 0) { // generate default level data // .... var maxHealthValue = 100f; var maxArmorValue = 10f; Random.InitState(DateTime.Now.Second); for (var i = 0; i < Random.Range(1, 10); i++) { var damagebleData = new DamagebleData(Random.Range(1f, maxHealthValue), Random.Range(1f, maxArmorValue), i); // show debug information damagebleData.DebugData(); // just for test damagebleData.ApplyDamage(Random.Range(1f, maxHealthValue)); } } else { var player = JsonHelper.FromJson <DamagebleData>(savedJson); _entities = player.ToList(); // use some fabric to generate entity // .... // show debug information foreach (var damagebleData in _entities) { damagebleData.DebugData(); } } }
/// <summary> /// Register entity /// </summary> /// <param name="data">entity model data</param> public static void RegisterEntity(DamagebleData data) { _entities.Add(data); }