예제 #1
0
    private BehaviourTree.BaseNode CreateNode(BTModel.BehaviourTreeNode data)
    {
        switch (data.name.ToLower()) //toLower convierte el string en minusculas
        {
        case "repeatuntilfailure":
            return(new BehaviourTree.RepeatUntilFail(data.id));

        case "sequence":
            /*  if (data.description == "Hungry") { return new BehaviourTree.Sequence("ae1d73ce - db2f - 4bf9 - bf8c - 0c2781954d3f"); }*/   //añadidomíoFALLA
            return(new BehaviourTree.Sequence(data.id));

        case "priority":
            return(new BehaviourTree.Selector(data.id));

        case "wait":
            int ms = System.Convert.ToInt32(data.properties["milliseconds"]);
            return(new Wait(data.id, ms, this));

        case "getnextposition":
            Debug.Log("voy a buscar posicion");
            return(new GetNextPosition(data.id, this));

        case "movetoposition":
            return(new MoveToPosition(data.id, this));

        //hunugryyy....-----------.----------------.------------.----------------
        case "hungry?":
            return(new Hungry(data.id, this));

        case "foodavailable?":
            return(new FoodAvailable(data.id, this));

        case "findfood":
            return(new FindFood(data.id, this));

        case "eat":
            return(new Eat(data.id, this));

        case "createfruitmix":
            return(new CreateFruitMix(data.id, this));


        default:
            return(new BehaviourTree.NoopNode(data.id, data.name));
        }
    }
예제 #2
0
파일: NPC.cs 프로젝트: dakkua/ia-bt-unity
    private BehaviourTree.BaseNode CreateNode(BTModel.BehaviourTreeNode data)
    {
        switch (data.name.ToLower())
        {
        case "repeatuntilfailure":
            return(new BehaviourTree.RepeatUntilFail(data.id));

        case "sequence":
            return(new BehaviourTree.Sequence(data.id));

        case "priority":
            return(new BehaviourTree.Selector(data.id));

        case "wait":
            int ms = System.Convert.ToInt32(data.properties["milliseconds"]);
            return(new Wait(data.id, ms));

        case "getnextposition":
            return(new GetNextPosition(data.id, this));

        case "movetoposition":
            return(new MoveToPosition(data.id, this));

        case "onplayerhungry":
            return(new onPlayerHungry(data.id, hungry_bar));

        case "isfoodavailable":
            return(new isFoodAvailable(data.id, this));

        case "onplayerfindfood":
            return(new onPlayerFindFood(data.id, this));

        case "onplayereat":
            return(new onPlayerEat(data.id, this, player_animator, hungry_bar));

        default:
            return(new BehaviourTree.NoopNode(data.id, data.name));
        }
    }