예제 #1
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);


            if (Health <= 0)
            {
                return;
            }

            this.lastGhost  = Math.Max(0f, this.lastGhost - (float)time.ElapsedGameTime.Milliseconds);
            this.lastDebuff = Math.Max(0f, this.lastDebuff - (float)time.ElapsedGameTime.Milliseconds);

            if (withinPlayerThreshold(10))
            {
                if (lastDebuff == 0f)
                {
                    Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);
                    if (ModEntry.IsLessThanHalfHealth(this))
                    {
                        for (int i = 0; i < 12; i++)
                        {
                            Vector2 trajectory = ModEntry.VectorFromDegree(i * 30) * 10f;
                            currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, trajectory.X, trajectory.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                        }
                    }
                    else
                    {
                        currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, velocityTowardPlayer.X, velocityTowardPlayer.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                    }


                    this.lastDebuff = Game1.random.Next(3000, 6000);
                }
                if (lastGhost == 0f)
                {
                    int ghosts = 0;
                    using (NetCollection <NPC> .Enumerator enumerator = currentLocation.characters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NPC j = enumerator.Current;
                            if (j is ToughGhost)
                            {
                                ghosts++;
                            }
                        }
                    }
                    if (ghosts < (Health < MaxHealth / 2 ? this.MaxGhosts * 2 : this.MaxGhosts))
                    {
                        GameLocation aLocation = currentLocation;
                        currentLocation.characters.Add(new ToughGhost(Position, difficulty)
                        {
                            focusedOnFarmers = true
                        });
                        this.lastGhost = (float)Game1.random.Next(3000, 80000);
                    }
                }
            }
        }
예제 #2
0
        public override void behaviorAtGameTick(GameTime time)
        {
            typeof(SquidKidBoss).BaseType.GetField("lastFireball", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this as SquidKid, 1000f);
            base.behaviorAtGameTick(time);
            if (Health <= 0)
            {
                return;
            }

            if (this.withinPlayerThreshold(20))
            {
                this.lastIceBall   = Math.Max(0f, this.lastIceBall - (float)time.ElapsedGameTime.Milliseconds);
                this.lastLightning = Math.Max(0f, this.lastLightning - (float)time.ElapsedGameTime.Milliseconds);

                if (!startedLightning && lastLightning < (ModEntry.IsLessThanHalfHealth(this) ? 500f : 1000f))
                {
                    startedLightning = true;

                    List <Farmer> farmers = new List <Farmer>();
                    FarmerCollection.Enumerator enumerator = currentLocation.farmers.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        farmers.Add(enumerator.Current);
                    }
                    playerPosition = farmers[Game1.random.Next(0, farmers.Count)].position;

                    Microsoft.Xna.Framework.Rectangle lightningSourceRect = new Rectangle(0, 0, 16, 16);
                    float   markerScale  = 8f;
                    Vector2 drawPosition = playerPosition + new Vector2(-16 * markerScale / 2 + 32f, -16 * markerScale / 2 + 32f);

                    Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("TileSheets\\Projectiles", lightningSourceRect, 9999f, 1, 999, drawPosition, false, Game1.random.NextDouble() < 0.5, (playerPosition.Y + 32f) / 10000f + 0.001f, 0.025f, Color.White, markerScale, 0f, 0f, 0f, false)
                    {
                        light       = true,
                        lightRadius = 2f,
                        delayBeforeAnimationStart = 200,
                        lightcolor = Color.Black
                    });
                }

                if (lastLightning == 0f)
                {
                    startedLightning = false;
                    lightningStrike(playerPosition);
                    lastLightning = Game1.random.Next(1000, 2000) * (ModEntry.IsLessThanHalfHealth(this) ? 1 : 2);
                }
                if (lastIceBall == 0f)
                {
                    Vector2 trajectory = ModEntry.VectorFromDegree(Game1.random.Next(0, 360)) * 10f;
                    currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, trajectory.X, trajectory.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));

                    projectileCount++;

                    if (projectileCount >= (ModEntry.IsLessThanHalfHealth(this) ? 8 : 4))
                    {
                        projectileCount = 0;
                        lastIceBall     = Game1.random.Next(1200, 3500);
                    }
                    else
                    {
                        lastIceBall = 100;
                    }
                    if (lastIceBall != 0f && Game1.random.NextDouble() < 0.05)
                    {
                        Halt();
                        setTrajectory((int)Utility.getVelocityTowardPlayer(Utility.Vector2ToPoint(base.getStandingPosition()), 8f, base.Player).X, (int)(-(int)Utility.getVelocityTowardPlayer(Utility.Vector2ToPoint(base.getStandingPosition()), 8f, base.Player).Y));
                    }
                }
            }
        }