How can i list methods?
public List<???> Actions = new List<???>();
and then i would call the top one in the list every time previous method is completed or something like that.
Or is there a better way to do this?
How can i list methods?
public List<???> Actions = new List<???>();
and then i would call the top one in the list every time previous method is completed or something like that.
Or is there a better way to do this?
It depends how complex and OOP you want to go with this. In the simplest case:
using System;
using System.Collections.Generic;
using UnityEngine;
public class ActionClass : MonoBehaviour
{
private List<Action> actions;
private void Start()
{
actions = new List<Action>();
actions.Add(Action1);
actions.Add(Action2);
actions.Add(Action3);
}
private void Action1() { }
private void Action2() { }
private void Action3() { }
}
Something like Sims is sure to do it much more involved. An OOP base would look something in the lines of:
using System.Collections.Generic;
using UnityEngine;
public class AbilityClass : MonoBehaviour
{
private List<Ability> actions;
private void Start()
{
actions = new List<Ability>();
actions.Add(new WatchTV());
actions.Add(new TakeBath());
actions.Add(new MakeFood(3));
}
}
public abstract class Ability
{
public abstract void Do();
}
public class WatchTV : Ability
{
public override void Do()
{
Debug.Log("Watching TV");
}
}
public class TakeBath : Ability
{
public override void Do()
{
Debug.Log("Taking a bath");
}
}
public class MakeFood : Ability
{
public int servings;
public MakeFood(int servings)
{
this.servings = servings;
}
public override void Do()
{
Debug.Log("Making food");
}
}