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(); 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); }