Example #1
0
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        ContinueBehavior continueMove = new ContinueBehavior(-1);
        MoveBehavior     moveBehavior = new MoveBehavior();

        MoveBehavior.MoveBehaviorInfo moveBehaviorInfo = new MoveBehavior.MoveBehaviorInfo();
        moveBehaviorInfo.speed  = mapObject.GetAttribute <MapObjectArtAttribute>().MaxSpeed + 0.1f;
        moveBehaviorInfo.dir    = Vector3.right;
        moveBehaviorInfo.targer = mapObject;
        moveBehavior.Enviorment = moveBehaviorInfo;
        continueMove.AddBehavior(moveBehavior);
        behaviorTree.AddBehavior("move", continueMove, BehaviorTree.NodeType.ParallelOr);

        ContinueBehavior    continueTouchZombie = new ContinueBehavior(-1);
        TouchZombieBehavior touchZombieBehavior = new TouchZombieBehavior();

        TouchZombieBehavior.TouchZombieBehaviorInfo touchZombieInfo = new TouchZombieBehavior.TouchZombieBehaviorInfo();
        touchZombieInfo.dir            = Vector3.right;
        touchZombieInfo.distance       = 1f;
        touchZombieInfo.mapObject      = mapObject;
        touchZombieBehavior.Enviorment = touchZombieInfo;
        continueTouchZombie.AddBehavior(touchZombieBehavior);
        behaviorTree.AddBehavior("TouchZombie", continueTouchZombie, BehaviorTree.NodeType.ParallelOr);


        ContinueBehavior  continueTouchWall = new ContinueBehavior(-1);
        TouchWallBehavior touchWallBehavior = new TouchWallBehavior();

        TouchWallBehavior.TouchBehaviorInfo touchWallInfo = new TouchWallBehavior.TouchBehaviorInfo();
        touchWallInfo.dir            = Vector3.right;
        touchWallInfo.distance       = 1f;
        touchWallInfo.mapObject      = mapObject;
        touchWallBehavior.Enviorment = touchWallInfo;
        continueTouchWall.AddBehavior(touchWallBehavior);
        behaviorTree.AddBehavior("touchWall", continueTouchWall, BehaviorTree.NodeType.Serial);


        SingleNodeBehavior   singleNodeBehavior  = new SingleNodeBehavior();
        BulletAttackBehavior plantAttackBehavior = new BulletAttackBehavior();

        BulletAttackBehavior.BulletAttackBehaviorInfo plantAttackBehaviorInfo = new BulletAttackBehavior.BulletAttackBehaviorInfo();
        plantAttackBehaviorInfo.Attack    = 1;
        plantAttackBehaviorInfo.mapObject = mapObject;
        plantAttackBehavior.Enviorment    = plantAttackBehaviorInfo;
        singleNodeBehavior.AddBehavior(plantAttackBehavior);
        behaviorTree.AddBehavior("attack", singleNodeBehavior, BehaviorTree.NodeType.Serial);



        return(behaviorTree);
    }
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        SingleNodeBehavior     singleNodeBehavior    = new SingleNodeBehavior();
        AddDailyActionBehavior addZombieMoveBehavior = new AddDailyActionBehavior();

        AddDailyActionBehavior.AddDailyActionBehaviorInfo zombieMoveBehaviorInfo = new AddDailyActionBehavior.AddDailyActionBehaviorInfo();
        zombieMoveBehaviorInfo.mapObject   = mapObject;
        zombieMoveBehaviorInfo.dailyAction = new ZombieMoveDailyAction();
        addZombieMoveBehavior.Enviorment   = zombieMoveBehaviorInfo;
        singleNodeBehavior.AddBehavior(addZombieMoveBehavior);
        behaviorTree.AddBehavior("add", singleNodeBehavior, BehaviorTree.NodeType.Serial);

        return(behaviorTree);
    }
Example #3
0
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        CreateFireBulletBehavior createMapObjectBehavior = new CreateFireBulletBehavior();

        CreateFireBulletBehavior.CreateFireBulletInfo createBehaviorInfo = new CreateFireBulletBehavior.CreateFireBulletInfo();
        createBehaviorInfo.Position        = mapObject.GetAttribute <MapObjectArtAttribute>().transform.position + new Vector3(0.2f, 0, 0);
        createMapObjectBehavior.Enviorment = createBehaviorInfo;
        SingleNodeBehavior singleBehavior = new SingleNodeBehavior();

        singleBehavior.AddBehavior(createMapObjectBehavior);
        behaviorTree.AddBehavior("create", singleBehavior, BehaviorTree.NodeType.Serial);


        return(behaviorTree);
    }
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        MapObjectAttribute mapOjectAttribute = mapObject.GetAttribute <MapObjectAttribute>();

        IntervalBehavior    intervalBehavior    = new IntervalBehavior(10, -1);
        TouchZombieBehavior touchZombieBehavior = new TouchZombieBehavior();

        TouchZombieBehavior.TouchZombieBehaviorInfo touchZombieInfo = new TouchZombieBehavior.TouchZombieBehaviorInfo();
        touchZombieInfo.dir            = Vector3.right;
        touchZombieInfo.distance       = GameDefine.Art.GardenCellSize.x * (GameDefine.Garden.GardenWidth - mapOjectAttribute.Position.x + 0.5f);
        touchZombieInfo.mapObject      = mapObject;
        touchZombieBehavior.Enviorment = touchZombieInfo;
        intervalBehavior.AddBehavior(touchZombieBehavior);
        behaviorTree.AddBehavior("TouchZombie", intervalBehavior, BehaviorTree.NodeType.Serial);


        SingleNodeBehavior singleNodeBehavior = new SingleNodeBehavior();

        UseSkillBehavior useSkillBehavior = new UseSkillBehavior();

        UseSkillBehavior.UseSkillBehaviorInfo useSkillBehaviorInfo = new UseSkillBehavior.UseSkillBehaviorInfo();
        useSkillBehaviorInfo.mapObject = mapObject;
        useSkillBehaviorInfo.skill     = new FireBulletSkill();
        useSkillBehavior.Enviorment    = useSkillBehaviorInfo;
        singleNodeBehavior.AddBehavior(useSkillBehavior);

        AddDailyActionBehavior addDailyActionBehavior = new AddDailyActionBehavior();

        AddDailyActionBehavior.AddDailyActionBehaviorInfo addDailyActionBehaviorInfo = new AddDailyActionBehavior.AddDailyActionBehaviorInfo();
        addDailyActionBehaviorInfo.mapObject   = mapObject;
        addDailyActionBehaviorInfo.dailyAction = new TriggerShooterDailyAction();
        addDailyActionBehavior.Enviorment      = addDailyActionBehaviorInfo;
        singleNodeBehavior.AddBehavior(addDailyActionBehavior);

        behaviorTree.AddBehavior("skill", singleNodeBehavior, BehaviorTree.NodeType.Serial);

        return(behaviorTree);
    }
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        ContinueBehavior          continueBehavior          = new ContinueBehavior(-1);
        TouchAttachObjectBehavior touchAttachObjectBehavior = new TouchAttachObjectBehavior();

        TouchAttachObjectBehavior.TouchBehaviorInfo touchBehaviorInfo = new TouchAttachObjectBehavior.TouchBehaviorInfo();
        touchBehaviorInfo.layerMask          = 1 << LayerMask.NameToLayer(GameDefine.Layer.Bullet);
        touchBehaviorInfo.distance           = 1f;
        touchBehaviorInfo.mapObject          = mapObject;
        touchAttachObjectBehavior.Enviorment = touchBehaviorInfo;
        continueBehavior.AddBehavior(touchAttachObjectBehavior);

        behaviorTree.AddBehavior("touchBullet", continueBehavior, BehaviorTree.NodeType.Serial);

        SingleNodeBehavior singleNodeBehavior = new SingleNodeBehavior();
        AddAttachBehavior  addAttachBehavior  = new AddAttachBehavior();

        AddAttachBehavior.AddAttachBehaviorInfo addAttachBehaviorInfo = new AddAttachBehavior.AddAttachBehaviorInfo();
        addAttachBehaviorInfo.Fire   = 1;
        addAttachBehavior.Enviorment = addAttachBehaviorInfo;
        singleNodeBehavior.AddBehavior(addAttachBehavior);

        AddDailyActionBehavior addDailyActionBehavior = new AddDailyActionBehavior();

        AddDailyActionBehavior.AddDailyActionBehaviorInfo addDailyActionBehaviorInfo = new AddDailyActionBehavior.AddDailyActionBehaviorInfo();
        addDailyActionBehaviorInfo.mapObject   = mapObject;
        addDailyActionBehaviorInfo.dailyAction = new TorchwoodDailyAction();
        addDailyActionBehavior.Enviorment      = addDailyActionBehaviorInfo;

        singleNodeBehavior.AddBehavior(addDailyActionBehavior);

        behaviorTree.AddBehavior("addFire", singleNodeBehavior, BehaviorTree.NodeType.Serial);


        return(behaviorTree);
    }
    public override BehaviorTree Create()
    {
        BehaviorTree behaviorTree = new BehaviorTree();

        ContinueBehavior continueMove = new ContinueBehavior(-1);
        MoveBehavior     moveBehavior = new MoveBehavior();

        MoveBehavior.MoveBehaviorInfo moveBehaviorInfo = new MoveBehavior.MoveBehaviorInfo();
        moveBehaviorInfo.speed  = mapObject.GetAttribute <MapObjectArtAttribute>().MaxSpeed + 0.1f;
        moveBehaviorInfo.dir    = Vector3.left;
        moveBehaviorInfo.targer = mapObject;
        moveBehavior.Enviorment = moveBehaviorInfo;
        continueMove.AddBehavior(moveBehavior);
        behaviorTree.AddBehavior("move", continueMove, BehaviorTree.NodeType.ParallelOr);


        ContinueBehavior  continueTouchWall = new ContinueBehavior(-1);
        TouchWallBehavior touchWallBehavior = new TouchWallBehavior();

        TouchWallBehavior.TouchBehaviorInfo touchWallInfo = new TouchWallBehavior.TouchBehaviorInfo();
        touchWallInfo.dir            = Vector3.left;
        touchWallInfo.distance       = 1.6f;
        touchWallInfo.mapObject      = mapObject;
        touchWallBehavior.Enviorment = touchWallInfo;
        continueTouchWall.AddBehavior(touchWallBehavior);
        behaviorTree.AddBehavior("touchWall", continueTouchWall, BehaviorTree.NodeType.ParallelOr);


        ContinueBehavior   continueTouchZombie = new ContinueBehavior(-1);
        TouchPlantBehavior touchPlantBehavior  = new TouchPlantBehavior();

        TouchPlantBehavior.TouchBehaviorInfo touchPlantInfo = new TouchPlantBehavior.TouchBehaviorInfo();
        touchPlantInfo.dir            = Vector3.left;
        touchPlantInfo.distance       = 1.6f;
        touchPlantInfo.mapObject      = mapObject;
        touchPlantBehavior.Enviorment = touchPlantInfo;
        continueTouchZombie.AddBehavior(touchPlantBehavior);
        behaviorTree.AddBehavior("TouchPlant", continueTouchZombie, BehaviorTree.NodeType.Serial);


        IntervalBehavior     intervalBehavior     = new IntervalBehavior(5, -1);
        ZombieAttackBehavior zombieAttackBehavior = new ZombieAttackBehavior();

        ZombieAttackBehavior.ZombieAttackBehaviorInfo zombieAttackInfo = new ZombieAttackBehavior.ZombieAttackBehaviorInfo();
        zombieAttackInfo.mapObject      = mapObject;
        zombieAttackInfo.Attack         = 1;
        zombieAttackBehavior.Enviorment = zombieAttackInfo;
        intervalBehavior.AddBehavior(zombieAttackBehavior);
        behaviorTree.AddBehavior("attack", intervalBehavior, BehaviorTree.NodeType.Serial);


        SingleNodeBehavior     singleNodeBehavior     = new SingleNodeBehavior();
        AddDailyActionBehavior addDailyActionBehavior = new AddDailyActionBehavior();

        AddDailyActionBehavior.AddDailyActionBehaviorInfo addDailyActionBehaviorInfo = new AddDailyActionBehavior.AddDailyActionBehaviorInfo();
        addDailyActionBehaviorInfo.mapObject   = mapObject;
        addDailyActionBehaviorInfo.dailyAction = new TriggerZombieMoveDailyAction();
        addDailyActionBehavior.Enviorment      = addDailyActionBehaviorInfo;
        singleNodeBehavior.AddBehavior(addDailyActionBehavior);
        behaviorTree.AddBehavior("daily", singleNodeBehavior, BehaviorTree.NodeType.Serial);


        return(behaviorTree);
    }