示例#1
0
        public override void run()
        {
            if (seen)
            {
                if ((target.position - actor.position).Length() < 2000)
                {
                    actor.force = -target.velocity;
                    actor.force.Normalize();
                    actor.force *= .1f;



                    shotcooldown--;
                    if (shotcooldown <= 0)
                    {
                        // makes shots occur at .5 to 1.5 shotrate
                        shotcooldown = shotrate;
                        // Shoot
                        shootBehavior.run();
                    }
                }
                else
                {
                    seen = false;
                }
            }
            else
            {
                if ((target.position - actor.position).Length() < 700 && actor.world.hasLineOfSight(actor.position, target.position, true))
                {
                    seen = true;
                }
            }
        }
        public OctoBehavior(Octo actor, Actor target)
            : base(actor)
        {
            this.actor            = actor;
            this.target           = target;
            this.pathFindBehavior = new PathfindBehavior(actor, target, .06f);

            this.shootBehavior         = new ShootAttack(actor);
            shootBehavior.target       = target;
            shootBehavior.speed        = 6;
            shootBehavior.projectileId = actor.world.actorFactory.getActorId("SlimeBall");

            actor.octoball.addEndAct(
                (frame) => {
                shootBehavior.run(); actor.world.tileEngine.audioComponent.playSound(actor.audioSet[1], false);
            }
                );

            actor.octoball.addEndAct(
                (frame) => {
                actor.anim.reset(); actor.anim = actor.floatingAnimation; shotcooldown = 100f;
            }
                );

            this.shotcooldown = 160f;
            this.shotrate     = 140f;
        }
 public override void run()
 {
     if (!added)
     {
         (actor.world as GameWorld).blobCount++;
         added = true;
     }
     if (seen)
     {
         // Within follow distance
         if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST)
         {
             pathFindBehavior.run();
             if (fork)
             {
                 shotcooldown--;
                 if (shotcooldown <= 0 && pathFindBehavior.canSee && (actor.world as GameWorld).blobCount < Constants.MAX_WORLD_BLOBS)
                 {
                     // makes shots occur at .5 to 1.5 shotrate
                     shotcooldown = shotrate + (float)(actor.world.tileEngine.randGen.NextDouble() * shotrate);
                     // Shoot
                     shootBehavior.run();
                 }
             }
         }
         else
         {
             seen = false;
         }
     }
     else
     {
         if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true))
         {
             seen       = true;
             actor.anim = new Animation(0, 3, 8f + (float)actor.world.tileEngine.randGen.NextDouble(), true);
         }
     }
 }
示例#4
0
 public override void run()
 {
     if (seen)
     {
         float dist = (target.position - actor.position).Length();
         if (dist < 700)
         {
             if (dist > 150)
             {
                 pathFindBehavior.run();
             }
             shotcooldown--;
             if (shotcooldown <= 0)
             {
                 if (target != null)
                 {
                     // makes shots occur at .5 to 1.5 shotrate
                     shootBehavior.speed = (target.position - actor.position).Length() * .05f;
                     shootBehavior.run();
                     shotcooldown = 20f;
                 }
             }
         }
         else
         {
             seen = false;
         }
     }
     else
     {
         if ((target.position - actor.position).Length() < 700 && actor.world.hasLineOfSight(actor.position, target.position, true))
         {
             seen = true;
         }
     }
 }