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