// Use this for initialization void Start() { if (aSkin == null) { aSkin = (GUISkin)Resources.Load("AILabel"); } if (aSkin == null) { aSkin = new GUISkin(); } myCarController = GetComponent <CarController>(); allCars = Data.GetAllCars(); planner = new HTNPlanner(1.5f); plannerThread = new Thread(retrievePlanner); plannerThread.Start(); myRand = new System.Random(System.Guid.NewGuid().GetHashCode()); }
// Start is called before the first frame update void Start() { lvlMgr = FindObjectOfType <LevelManager>(); player = FindObjectOfType <Self>(); agent = GetComponent <NavMeshAgent>(); /* Build a HTN */ // var root = new CompoundTask(); // htn = new HTNPlanner(root); // var ApproachCrate = new ApproachObject("crate"); // var PickUpCrate = new ObstaclePickUp("crate"); // var ApproachPlayer = new ApproachPlayer(); // var ThrowObstacle = new ThrowObstacle(); // var ApproachRock = new ApproachObject("rock"); // var PickUpRock = new ObstaclePickUp("rock"); // var ApproachRandom = new ApproachRandom(); // var getCrate = new CompoundTask(); // getCrate.AddMethod(new List<Task>() { ApproachCrate, PickUpCrate}); // var getRock = new CompoundTask(); // getRock.AddMethod(new List<Task>() { ApproachRock, PickUpRock }); // root.AddMethod(new List<Task>() { getCrate, ApproachPlayer, ThrowObstacle, ApproachRandom }); // root.AddMethod(new List<Task>() { getRock, ApproachPlayer, ThrowObstacle, ApproachRandom }); var root = new CompoundTask(); htn = new HTNPlanner(root); var ApproachCrate = new ApproachObject("crate"); var PickUpCrate = new ObstaclePickUp("crate"); var ApproachPlayer = new ApproachPlayer(); var ThrowObstacle = new ThrowObstacle(); var ApproachRock = new ApproachObject("rock"); var PickUpRock = new ObstaclePickUp("rock"); var ApproachRandom = new ApproachRandom(); var attackUsingCrate = new CompoundTask(); attackUsingCrate.AddMethod(new List <Task>() { ApproachCrate, PickUpCrate, ApproachPlayer, ThrowObstacle }); attackUsingCrate.AddMethod(new List <Task>() { ApproachPlayer, ThrowObstacle }); var attackUsingRock = new CompoundTask(); attackUsingRock.AddMethod(new List <Task>() { ApproachRock, PickUpRock, ApproachPlayer, ThrowObstacle }); attackUsingRock.AddMethod(new List <Task>() { ApproachPlayer, ThrowObstacle }); var move = new CompoundTask(); move.AddMethod(new List <Task>() { ApproachRandom }); move.AddMethod(new List <Task>() { ApproachPlayer }); root.AddMethod(new List <Task>() { attackUsingCrate }); root.AddMethod(new List <Task>() { attackUsingRock }); root.AddMethod(new List <Task>() { move }); }
// Use this for initialization void Start() { if (aSkin == null) aSkin = (GUISkin)Resources.Load("AILabel"); if (aSkin == null) aSkin = new GUISkin(); myCarController = GetComponent<CarController>(); allCars = Data.GetAllCars(); planner = new HTNPlanner(1.5f); plannerThread = new Thread(retrievePlanner); plannerThread.Start(); myRand = new System.Random(System.Guid.NewGuid().GetHashCode()); }
// METHODS void Start() { planner = new HTNPlanner(typeof(Domain), new Domain().GetMethodsDict(), typeof(Domain)); }