lab  2016-03-28
lightweight ai behaviour trees framework for Unity 3D
lab.AiController Class Reference

Component to control ai behaviour. More...

Inherits MonoBehaviour.

Public Member Functions

void SetInt (string key, int val)
 Sets int parameters for ai behaviour. More...
 
int GetInt (string key)
 Gets int parameters for ai behaviour. More...
 
void SetFloat (string key, float val)
 Sets float parameters for ai behaviour. More...
 
float GetFloat (string key)
 Gets float parameters for ai behaviour. More...
 
void SetBool (string key, bool val)
 Sets bool parameters for ai behaviour. More...
 
bool GetBool (string key)
 Gets bool parameters for ai behaviour. More...
 
void SetString (string key, string val)
 Sets string parameters for ai behaviour. More...
 
string GetString (string key)
 Gets string parameters for ai behaviour. More...
 
bool Run (int i=0)
 Runs tree behaviour. More...
 

Properties

AiBehaviour Behaviour [get, set]
 Gets/Sets Behaviour for current AiController. More...
 
List< ATaskScriptTasks [get, set]
 Sets/Gets task list. More...
 
IntParameter.KeyCollection IntKeys [get]
 Gets all int parameters keys. More...
 
FloatParameter.KeyCollection FloatKeys [get]
 Gets all float parameters keys. More...
 
BoolParameter.KeyCollection BoolKeys [get]
 Gets all bool parameters keys. More...
 
StringParameter.KeyCollection StringKyes [get]
 Gets all string parameters keys. More...
 

Detailed Description

Component to control ai behaviour.

AiController inherits from MonoBehaviour, so this one should be attached to your game object. It is also responsible for binding tasks scripts with the logic (trees' tasks). Simply attach an AiBehaviour asset and tasks scripts. Use AiController to modificate AiBehaviour's parameters. Each AiController has its own copy of state for attached AiBehaviour, that means you can use same behaviour trees for many controllers.

This sample shows how to update parameters for current controller and run default behaviour tree.

using System.Collections;
using lab;
public class ExampleClass : MonoBehaviour {
public AiController controller;
void Start() {
controller.SetInt("money", 10);
if (!controller.Run()) {
Debug.Log("first tree failed.");
}
}
}

Member Function Documentation

bool lab.AiController.GetBool ( string  key)

Gets bool parameters for ai behaviour.

Parameters
keyThe name of the bool parameters.
Returns
The value for the bool parameters.
float lab.AiController.GetFloat ( string  key)

Gets float parameters for ai behaviour.

Parameters
keyThe name of the float parameters.
Returns
The value for the float parameters.
int lab.AiController.GetInt ( string  key)

Gets int parameters for ai behaviour.

Parameters
keyThe name of the int parameters.
Returns
The value for the int parameters.
string lab.AiController.GetString ( string  key)

Gets string parameters for ai behaviour.

Parameters
keyThe name of the string parameters.
Returns
The value for the string parameters.
bool lab.AiController.Run ( int  i = 0)

Runs tree behaviour.

Parameters
iIndex of tree to run. Default value is 0.
Returns
True if tree succeed. Otherwise false.
void lab.AiController.SetBool ( string  key,
bool  val 
)

Sets bool parameters for ai behaviour.

Parameters
keyThe name of the bool parameters.
valThe new value for the bool parameters.
void lab.AiController.SetFloat ( string  key,
float  val 
)

Sets float parameters for ai behaviour.

Parameters
keyThe name of the float parameters.
valThe new value for the float parameters.
void lab.AiController.SetInt ( string  key,
int  val 
)

Sets int parameters for ai behaviour.

Parameters
keyThe name of the int parameters.
valThe new value for the int parameters.
void lab.AiController.SetString ( string  key,
string  val 
)

Sets string parameters for ai behaviour.

Parameters
keyThe name of the string parameters.
valThe new value for the string parameters.

Property Documentation

AiBehaviour lab.AiController.Behaviour
getset

Gets/Sets Behaviour for current AiController.

BoolParameter.KeyCollection lab.AiController.BoolKeys
get

Gets all bool parameters keys.

FloatParameter.KeyCollection lab.AiController.FloatKeys
get

Gets all float parameters keys.

IntParameter.KeyCollection lab.AiController.IntKeys
get

Gets all int parameters keys.

StringParameter.KeyCollection lab.AiController.StringKyes
get

Gets all string parameters keys.

List<ATaskScript> lab.AiController.Tasks
getset

Sets/Gets task list.


The documentation for this class was generated from the following file: