Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4.  
  5. public abstract class Agent : MonoBehaviour {
  6.     public abstract float GetValue();
  7. }
  8.  
  9. public class Utility : MonoBehaviour {
  10.     public AnimationCurve curve;
  11.     public Agent agent;
  12.     public float urgency {
  13.         get {
  14.             return curve.Evaluate(agent.GetValue());
  15.         }
  16.     }
  17. }
  18.  
  19. public abstract class Action : MonoBehaviour {
  20.     public abstract List<Tuple<Utility, float>> Impacts();
  21.     public bool Available();
  22.     public void Run();
  23. }
  24.  
  25. public class Controller : MonoBehaviour {
  26.     private Utility[] utilities;
  27.     private Action[] actions;
  28.  
  29.     private void Start() {
  30.         utilities = GetComponentsInChildren<Utility>();
  31.         actions = GetComponentsInChildren<Action>();
  32.     }
  33.  
  34.     public void JustDoIt() {
  35.         // find most urgent utility in utilities
  36.         // find the action that impacts the most positively that utility
  37.         //   and the least negatively other utilities
  38.         //   and that is Available()
  39.         action.Run();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement