Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- using System.Collections;
- public abstract class Agent : MonoBehaviour {
- public abstract float GetValue();
- }
- public class Utility : MonoBehaviour {
- public AnimationCurve curve;
- public Agent agent;
- public float urgency {
- get {
- return curve.Evaluate(agent.GetValue());
- }
- }
- }
- public abstract class Action : MonoBehaviour {
- public abstract List<Tuple<Utility, float>> Impacts();
- public bool Available();
- public void Run();
- }
- public class Controller : MonoBehaviour {
- private Utility[] utilities;
- private Action[] actions;
- private void Start() {
- utilities = GetComponentsInChildren<Utility>();
- actions = GetComponentsInChildren<Action>();
- }
- public void JustDoIt() {
- // find most urgent utility in utilities
- // find the action that impacts the most positively that utility
- // and the least negatively other utilities
- // and that is Available()
- action.Run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement