Exemple #1
0
		public void Initialize(AIRuntimeController controller){
			this.owner = controller;
			queueActions = new List<BaseAction> ();
			updateActions = new List<BaseAction> ();

			for(int i=0;i< actions.Count;i++) {
				actions[i]=(BaseAction)ScriptableObject.Instantiate(actions[i]);
				actions[i].owner=owner;
				actions[i].OnAwake();
				if(actions[i].queue){
					queueActions.Add(actions[i]);
				}else{
					updateActions.Add(actions[i]);
				}
			}
			for(int k=0;k<transitions.Count;k++) {
				transitions[k]=(BaseTransition)ScriptableObject.Instantiate(transitions[k]);
				for(int i=0;i<transitions[k].conditions.Count;i++){
					transitions[k].conditions[i]=(BaseCondition)ScriptableObject.Instantiate(transitions[k].conditions[i]);
					transitions[k].conditions[i].owner=owner;
				}
				
				transitions[k].owner=owner;
			}
			this.DoAwake ();

		}
Exemple #2
0
	protected void setAiController(string aiFilePath){
		runtimeController = gameObject.AddComponent<AIRuntimeController> ();
		AISystem.AIController aic = null;
		aic = (AISystem.AIController)Resources.Load (aiFilePath);
		runtimeController.originalController = aic;
		runtimeController.SetAIController ();
	}
        public void Initialize(AIRuntimeController controller)
        {
            this.owner    = controller;
            queueActions  = new List <BaseAction> ();
            updateActions = new List <BaseAction> ();

            for (int i = 0; i < actions.Count; i++)
            {
                actions[i]       = (BaseAction)ScriptableObject.Instantiate(actions[i]);
                actions[i].owner = owner;
                actions[i].OnAwake();
                if (actions[i].queue)
                {
                    queueActions.Add(actions[i]);
                }
                else
                {
                    updateActions.Add(actions[i]);
                }
            }
            for (int k = 0; k < transitions.Count; k++)
            {
                transitions[k] = (BaseTransition)ScriptableObject.Instantiate(transitions[k]);
                for (int i = 0; i < transitions[k].conditions.Count; i++)
                {
                    transitions[k].conditions[i]       = (BaseCondition)ScriptableObject.Instantiate(transitions[k].conditions[i]);
                    transitions[k].conditions[i].owner = owner;
                }

                transitions[k].owner = owner;
            }
            this.DoAwake();
        }
Exemple #4
0
    public static Vector3 GetVector3(this AIRuntimeController controller, string name)
    {
        NamedParameter param = controller.GetParameter(name);

        if (param is GameObjectParameter)
        {
            return(((GameObjectParameter)param).Value.transform.position);
        }
        Vector3Parameter v = (Vector3Parameter)controller.GetParameter(name);

        return(v != null ? v.Value : Vector3.zero);
    }
 private void DebugState(State node)
 {
     lastDebugController = (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <AIRuntimeController>() != null) ? Selection.activeGameObject.GetComponent <AIRuntimeController> () : lastDebugController;
     if (EditorApplication.isPlaying && lastDebugController != null && node.id == lastDebugController.CurrentState.id)
     {
         if (lastDebugState == null || lastDebugState.id != node.id)
         {
             debugProgress  = 0;
             lastDebugState = node;
         }
         GUI.Box(new Rect(node.position.x + 5, node.position.y + 20, debugProgress, 5), "", "MeLivePlayBar");
     }
 }
Exemple #6
0
    public static float GetFloatOrInt(this AIRuntimeController controller, string name)
    {
        NamedParameter param = controller.GetParameter(name);

        if (param != null)
        {
            if (param is FloatParameter)
            {
                return(controller.GetFloat(name));
            }
            else
            {
                return(controller.GetInt(name));
            }
        }
        Debug.Log("null");
        return(0);
    }
    private void Update()
    {
        if (EditorApplication.isPlaying)
        {
            debugProgress += Time.deltaTime * 30;
            if (debugProgress > 142)
            {
                debugProgress = 0;
            }
            Repaint();
        }

        if (Selection.activeGameObject != null && Selection.activeGameObject != lastSelection && Selection.activeGameObject.GetComponent <AIRuntimeController> () != null)
        {
            lastSelection = Selection.activeGameObject;
            AIRuntimeController runtime = Selection.activeGameObject.GetComponent <AIRuntimeController>();
            Init(runtime.originalController);
        }
    }
Exemple #8
0
		public void Initialize(AIRuntimeController controller){
			this.owner = controller;
			queueActions = new List<BaseAction> ();
			updateActions = new List<BaseAction> ();

			for(int i=0;i< actions.Count;i++)
			{
				BaseAction keep = actions[ i ];
				if ( actions[ i ] == null )
				{
					continue;
				}
				actions[ i ] = (BaseAction)ScriptableObject.Instantiate( actions[ i ] );
				if ( actions[ i ] == null )
				{
					Debug.LogError( "Invalid Action! : " + keep.name );
					continue;
				}
				actions[ i ].owner = owner;
				actions[i].OnAwake();
				if(actions[i].queue){
					queueActions.Add(actions[i]);
				}else{
					updateActions.Add(actions[i]);
				}
			}
			for(int k=0;k<transitions.Count;k++) {
				transitions[k]=(BaseTransition)ScriptableObject.Instantiate(transitions[k]);
				for(int i=0;i<transitions[k].conditions.Count;i++){
					transitions[k].conditions[i]=(BaseCondition)ScriptableObject.Instantiate(transitions[k].conditions[i]);
					transitions[k].conditions[i].owner=owner;
				}
				
				transitions[k].owner=owner;
			}
			this.DoAwake ();

		}
Exemple #9
0
 private void OnEnable()
 {
     runtimeController = (AIRuntimeController)target;
 }
Exemple #10
0
 public static Vector3 GetValue(this AIRuntimeController controller, Vector3Parameter param)
 {
     return(string.IsNullOrEmpty(param.Name) ? param.Value : controller.GetVector3(param.Name));
 }
Exemple #11
0
 public static string GetValue(this AIRuntimeController controller, StringParameter param)
 {
     return(string.IsNullOrEmpty(param.Name) ? param.Value : controller.GetString(param.Name));
 }
Exemple #12
0
 //->
 public static float GetValue(this AIRuntimeController controller, FloatParameter param)
 {
     return(string.IsNullOrEmpty(param.Name) ? param.Value : controller.GetFloat(param.Name));
 }
Exemple #13
0
    public static void SetBool(this AIRuntimeController controller, string name, bool value)
    {
        BoolParameter param = (BoolParameter)controller.GetParameter(name);

        param.Value = value;
    }
Exemple #14
0
    public static bool GetBool(this AIRuntimeController controller, string name)
    {
        BoolParameter param = (BoolParameter)controller.GetParameter(name);

        return(param != null ? param.Value : false);
    }
Exemple #15
0
 public static GameObject GetValue(this AIRuntimeController controller, GameObjectParameter param)
 {
     return(string.IsNullOrEmpty(param.Name) ? param.Value : controller.GetGameObject(param.Name));
 }
Exemple #16
0
    public static GameObject GetGameObject(this AIRuntimeController controller, string name)
    {
        GameObjectParameter param = (GameObjectParameter)controller.GetParameter(name);

        return(param != null ? param.Value : null);
    }
Exemple #17
0
    public static void SetVector3(this AIRuntimeController controller, string name, Vector3 value)
    {
        Vector3Parameter param = (Vector3Parameter)controller.GetParameter(name);

        param.Value = value;
    }
 public static Character GetCharacter(this AIRuntimeController ai)
 {
     return(ai.GetComponent <Character>());
 }
Exemple #19
0
    public static void SetInt(this AIRuntimeController controller, string name, int value)
    {
        IntParameter param = (IntParameter)controller.GetParameter(name);

        param.Value = value;
    }
Exemple #20
0
    public static void SetFloat(this AIRuntimeController controller, string name, float value)
    {
        FloatParameter param = (FloatParameter)controller.GetParameter(name);

        param.Value = value;
    }
Exemple #21
0
    public static float GetFloat(this AIRuntimeController controller, string name)
    {
        FloatParameter param = (FloatParameter)controller.GetParameter(name);

        return(param != null ? param.Value : 0);
    }
Exemple #22
0
    public static void SetGameObject(this AIRuntimeController controller, string name, GameObject go)
    {
        GameObjectParameter param = (GameObjectParameter)controller.GetParameter(name);

        param.Value = go;
    }
Exemple #23
0
    public static int GetInt(this AIRuntimeController controller, string name)
    {
        IntParameter param = (IntParameter)controller.GetParameter(name);

        return(param != null ? param.Value : 0);
    }
Exemple #24
0
    public static string GetString(this AIRuntimeController controller, string name)
    {
        StringParameter param = (StringParameter)controller.GetParameter(name);

        return(param != null ? param.Value : string.Empty);
    }
	private void DebugState(State node){
		lastDebugController = (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent<AIRuntimeController>() != null) ? Selection.activeGameObject.GetComponent<AIRuntimeController> () : lastDebugController;
		if (EditorApplication.isPlaying && lastDebugController != null && node.id==lastDebugController.CurrentState.id) {
			if(lastDebugState== null || lastDebugState.id != node.id){
				debugProgress=0;
				lastDebugState=node;
			}
			GUI.Box(new Rect(node.position.x+5,node.position.y+20,debugProgress,5),"", "MeLivePlayBar");
		}
	}
Exemple #26
0
    public static void SetString(this AIRuntimeController controller, string name, string value)
    {
        StringParameter param = (StringParameter)controller.GetParameter(name);

        param.Value = value;
    }
	private void OnEnable(){
		runtimeController = (AIRuntimeController)target;
	}