예제 #1
0
        public override void behaviorAtGameTick(GameTime time)
        {
            if (GetBoundingBox().Right < -Game1.tileSize)
            {
                facingRight.Value = true;
                position.X        = -Game1.tileSize;
                position.Y        = Game1.random.Next(4, 15) * Game1.tileSize;
            }
            else if (GetBoundingBox().Left > currentLocation.Map.DisplayWidth + Game1.tileSize)
            {
                facingRight.Value = false;
                position.X        = currentLocation.Map.DisplayWidth + Game1.tileSize - TEX_WIDTH;
                position.Y        = Game1.random.Next(4, 15) * Game1.tileSize;
            }

            moveLeft  = true;
            moveRight = false;
            if (facingRight.Value)
            {
                moveLeft  = false;
                moveRight = true;
            }

            if (stunTimer.Value >= STUN_TIME / 2)
            {
                moveLeft  = false;
                moveRight = false;
            }
            if (stunTimer.Value > 0)
            {
                stunTimer.Value -= time.ElapsedGameTime.Milliseconds;
            }

            position.Y += (float)Math.Sin(time.TotalGameTime.TotalSeconds * 5) * 3;

            base.behaviorAtGameTick(time);

            shootPlayerTimer.Value -= time.ElapsedGameTime.Milliseconds;
            if (shootPlayerTimer.Value-- <= 0)
            {
                Vector2    velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, this.Player);
                Projectile proj = new DebuffingProjectile(14, 7, 4, 4, 0.1963495f, velocityTowardPlayer.X, velocityTowardPlayer.Y, new Vector2((float)this.GetBoundingBox().X, (float)this.GetBoundingBox().Y), currentLocation, this);
                currentLocation.projectiles.Add(proj);
                shootPlayerTimer.Value = SHOOT_DELAY;
            }

            spawnRocksTimer.Value -= time.ElapsedGameTime.Milliseconds;
            if (spawnRocksTimer.Value-- <= 0)
            {
                Rectangle region = new Rectangle(4, 7, 15 - 4, 15 - 7);
                for (int i = 3 + Game1.random.Next(5); i >= 0; --i)
                {
                    Vector2 spot = new Vector2(region.X + Game1.random.Next(region.Width), region.Y + Game1.random.Next(region.Height));
                    if (currentLocation.Objects.ContainsKey(spot))
                    {
                        continue;
                    }

                    int rock = Game1.random.Next(47, 54);
                    rock = rock + rock % 2;
                    var obj = new StardewValley.Object(spot, rock, "Stone", true, false, false, false)
                    {
                        MinutesUntilReady = 3
                    };

                    currentLocation.Objects.Add(spot, obj);
                }
                spawnRocksTimer.Value = SPAWN_ROCKS_DELAY / 2 + Game1.random.Next(SPAWN_ROCKS_DELAY);
            }

            spawnEnemyTimer.Value -= time.ElapsedGameTime.Milliseconds;
            if (spawnEnemyTimer.Value-- <= 0)
            {
                Rectangle region = new Rectangle(4, 7, 15 - 4, 15 - 7);
                for (int i = 1 + Game1.random.Next(3); i >= 0; --i)
                {
                    int x   = region.X + Game1.random.Next(region.Width);
                    int y   = region.Y + Game1.random.Next(region.Height);
                    Bat bat = new Bat(new Vector2(x * Game1.tileSize, y * Game1.tileSize), MineShaft.frostArea);
                    bat.focusedOnFarmers = true;
                    currentLocation.characters.Add(bat);
                }
                spawnEnemyTimer.Value = SPAWN_ENEMY_DELAY / 3 + Game1.random.Next(SPAWN_ENEMY_DELAY);
            }
        }
예제 #2
0
 public override void behaviorAtGameTick(GameTime time)
 {
     base.behaviorAtGameTick(time);
     nearFarmer.Value = (withinPlayerThreshold(10) || base.focusedOnFarmers);
     if (projectileIntroTimer.Value <= 0f && projectileOutroTimer.Value <= 0f)
     {
         if (Math.Abs(xVelocity) <= 1f && Math.Abs(yVelocity) <= 1f && nearFarmer.Value)
         {
             Vector2 trajFinder = Vector2.Normalize(position.Value - findPlayer().position.Value) * Game1.random.Next(25, 50);
             trajFinder.X *= -1f;
             if (canMoveTimer > 0f)
             {
                 canMoveTimer -= (float)time.ElapsedGameTime.TotalMilliseconds;
             }
             if (!justThrust && Sprite.CurrentFrame == 2 && canMoveTimer <= 0f)
             {
                 justThrust = true;
                 Vector2 traj = Vector2.Normalize(position.Value - findPlayer().position.Value + new Vector2(Game1.random.Next(-64, 64))) * Game1.random.Next(25, 50);
                 traj.X *= -1f;
                 setTrajectory(traj);
                 lastRotation.Value = (float)Math.Atan2(0f - yVelocity, xVelocity) + (float)Math.PI / 2f;
                 base.currentLocation.playSound("squid_move");
                 canMoveTimer = 500f;
             }
         }
         else if (!nearFarmer.Value)
         {
             lastRotation.Value = 0f;
         }
     }
     if ((Math.Abs(xVelocity) >= 10f || Math.Abs(yVelocity) >= 10f) && Game1.random.NextDouble() < 0.25)
     {
         Game1.multiplayer.broadcastSprites(base.currentLocation, new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Rectangle((Game1.random.NextDouble() < 0.5) ? 135 : 140, 234, 5, 5), base.Position + new Vector2(32f, 32 + Game1.random.Next(-8, 8)), flipped: false, 0.01f, Color.White)
         {
             interval             = 9999f,
             holdLastFrame        = true,
             alphaFade            = 0.01f,
             motion               = new Vector2(0f, -1f),
             xPeriodic            = true,
             xPeriodicLoopTime    = Game1.random.Next(800, 1200),
             xPeriodicRange       = Game1.random.Next(8, 20),
             scale                = 4f,
             drawAboveAlwaysFront = true
         });
     }
     if ((float)projectileIntroTimer > 0f)
     {
         projectileIntroTimer.Value -= (float)time.ElapsedGameTime.TotalMilliseconds;
         shakeTimer = 10;
         if (Game1.random.NextDouble() < 0.25)
         {
             Game1.multiplayer.broadcastSprites(base.currentLocation, new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Rectangle((Game1.random.NextDouble() < 0.5) ? 135 : 140, 234, 5, 5), base.Position + new Vector2(21 + Game1.random.Next(-21, 21), squidYOffset / 2 + 32 + Game1.random.Next(-32, 32)), flipped: false, 0.01f, Color.White)
             {
                 interval             = 9999f,
                 holdLastFrame        = true,
                 alphaFade            = 0.01f,
                 motion               = new Vector2(0f, -1f),
                 xPeriodic            = true,
                 xPeriodicLoopTime    = Game1.random.Next(800, 1200),
                 xPeriodicRange       = Game1.random.Next(8, 20),
                 scale                = 4f,
                 drawAboveAlwaysFront = true
             });
         }
         if ((float)projectileIntroTimer < 0f)
         {
             projectileOutroTimer.Value = 500f;
             base.IsWalkingTowardPlayer = false;
             new Vector2(base.Position.X, base.Position.Y + 64f);
             Halt();
             Vector2             trajectory = Utility.getVelocityTowardPlayer(Utility.Vector2ToPoint(getStandingPosition()), 8f, base.Player);
             DebuffingProjectile projectile = new DebuffingProjectile(27, 8, 3, 4, 0f, trajectory.X, trajectory.Y, getStandingPosition() - new Vector2(32f, -squidYOffset), base.currentLocation, this);
             projectile.height.Value = 48f;
             base.currentLocation.projectiles.Add(projectile);
             base.currentLocation.playSound("debuffSpell");
             nextFire = Game1.random.Next(1200, 3500);
         }
     }
     else if ((float)projectileOutroTimer > 0f)
     {
         projectileOutroTimer.Value -= (float)time.ElapsedGameTime.TotalMilliseconds;
     }
     nextFire = Math.Max(0f, nextFire - (float)time.ElapsedGameTime.Milliseconds);
     if (withinPlayerThreshold(6) && nextFire == 0f && (float)projectileIntroTimer <= 0f && Math.Abs(xVelocity) < 1f && Math.Abs(yVelocity) < 1f && Game1.random.NextDouble() < 0.003 && canMoveTimer <= 0f && base.currentLocation.getTileIndexAt(getTileX(), getTileY(), "Back") != -1 && base.currentLocation.getTileIndexAt(getTileX(), getTileY(), "Buildings") == -1 && base.currentLocation.getTileIndexAt(getTileX(), getTileY(), "Front") == -1)
     {
         projectileIntroTimer.Value = 1000f;
         lastRotation.Value         = 0f;
         base.currentLocation.playSound("squid_bubble");
     }
 }