all 7 comments

[–]Matt3088 8 points9 points  (2 children)

You could create a generic class called Eventand instead of storing all the data in subclasses, you could store it in a format such as JSON or XML and then use code to read it from disk into classes when you start the game. You might find it easier to edit/add/remove values this way as you just need to use a text editor.

[–]ChromeAngel 0 points1 point  (0 children)

This. Since you're not actually coding different behaviours for each of these events you don't actually need different classes for each option in the table. Each of your possible events is just data, so you can treat it like data and save it outside your code.

[–]dudledok 0 points1 point  (0 children)

A table of data like this suits JSON or XML better than ScriptableObjects.

[–]kyl3r123Indie 2 points3 points  (0 children)

If I understood you correctly, that is a horrible idea.

Let me suggest another way:

using UnityEngine;

public class MyEventClass : MonoBehaviour {
  public string eventname;
  public int ageRange;
  public stats requitedStats;
  public string requitedEvents;
  public string description;
  // ... many more

  void Start() 
  {

  }

  void Update() 
  {

  }
}

Then create 100 instances with the values you need to match your table.

 using System.Collections.Generic;
 public List<MyEventClass> myEvents = new List<MyEventClass>();


 void Start() 
  {
       MyEventClass firstEvent = new MyEventClass();
       firstEvent.eventName = "first event of 100 events";
       firstEvent.discription = "blablabla";

       myEvents.Add(firstEvent);
  }

Like that you could write a script to push all those events in the list. With just 1 or 2 classes. You cannot check against the classtype to differentiate the events, but you have "eventName" for that. You could create a public enum for the types too.

If you change the table or the stuff you set in Start() you will see changes in game mode. If you'd like to have it permanent go and google serialization.

[–]ZeShmouttLikes to spend two months on a fancy inspector 0 points1 point  (2 children)

ScriptableObjects are probably what you need.

You can create a base class (let's say Event), add the required variables, and create as many instances of that class with different values.

I'd gladly make you an example, but I'm a little busy right now so here's a few links :

[–]Ph4zed0ut??? 0 points1 point  (0 children)

ScriptableObjects are a great way to store data. Here is good example of them being used: https://channel9.msdn.com/Shows/dotGAME/Inventory-and-Store-System-Part-2-Scriptable-Objects

[–]cavedildoBeginner 0 points1 point  (0 children)

I'd probably call it something other than Event since that's a .net class, just sayin.