示例#1
0
    public ITask ConfigureBehavior()
    {
        List <ITask> taskList = new List <ITask>();

        ITask Human               = new isHuman(creature);
        ITask HumanAndDog         = new isHuman(creature);
        ITask NotHuman            = new isNotHuman(creature);
        ITask CheckIfDogIsPresent = new isRobotDogPresent(creature);
        ITask ShootAir            = new shootAir(creature);
        ITask ShootHuman          = new shootHuman(creature);
        ITask ShootCreature       = new shootCreature(creature);
        ITask petDog              = new petDog(creature);

        //not a human, shoot the creature
        taskList.Add(Human);
        taskList.Add(ShootAir);

        Sequence SpareTheHuman = new Sequence(taskList);

        taskList = new List <ITask>();

        taskList.Add(NotHuman);
        taskList.Add(ShootCreature);

        Sequence SaveTheHuman = new Sequence(taskList);

        taskList = new List <ITask>();

        taskList.Add(CheckIfDogIsPresent);
        taskList.Add(Human);
        taskList.Add(ShootHuman);
        taskList.Add(petDog);


        Sequence SaveTheDog = new Sequence(taskList);

        taskList = new List <ITask>();

        taskList.Add(SaveTheDog);
        taskList.Add(SpareTheHuman);
        taskList.Add(SaveTheHuman);


        Selector selector = new Selector(taskList);

        return(selector);
    }
示例#2
0
    Task ConfigureBehavior()
    {
        List <Task> taskList = new List <Task>();

        Task Human         = new IsTrue(creature.isHuman);
        Task Dog           = new IsTrue(creature.isDogPresent);
        Task NotHuman      = new IsFalse(creature.isHuman);
        Task NoDog         = new IsFalse(creature.isDogPresent);
        Task saveHuman     = new saveHuman(creature);
        Task walkAround    = new walkAround(creature);
        Task ShootAir      = new shootAir(creature);
        Task ShootHuman    = new shootHuman(creature);
        Task ShootCreature = new shootCreature(creature);
        Task petDog        = new petDog(creature);
        Task takeDog       = new takeDog(creature);


        taskList.Add(Human);
        taskList.Add(NoDog);
        taskList.Add(walkAround);
        taskList.Add(ShootAir);

        Sequence SpareTheHuman = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(NotHuman);
        taskList.Add(NoDog);
        taskList.Add(saveHuman);
        taskList.Add(ShootCreature);

        Sequence SaveTheHuman = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(Dog);
        taskList.Add(Human);
        taskList.Add(ShootHuman);
        taskList.Add(petDog);
        taskList.Add(takeDog);

        Sequence SaveTheDog = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(Dog);
        taskList.Add(NotHuman);
        taskList.Add(ShootCreature);
        taskList.Add(petDog);
        taskList.Add(takeDog);

        Sequence SaveTheDogFromMonster = new Sequence(taskList);

        taskList = new List <Task>();

        taskList.Add(SaveTheDog);
        taskList.Add(SpareTheHuman);
        taskList.Add(SaveTheHuman);
        taskList.Add(SaveTheDogFromMonster);


        Selector selector = new Selector(taskList);

        return(selector);
    }