예제 #1
0
 public override void reloadSprite()
 {
     this.Sprite = new AnimatedSprite("Characters\\Monsters\\Ghost");
     this.Sprite.LoadTexture(ModEntry.GetBossTexture(GetType()));
 }
예제 #2
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);

            if (Health <= 0)
            {
                return;
            }

            // fire!

            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;

            List <Farmer> farmers = new List <Farmer>();

            FarmerCollection.Enumerator enumerator = currentLocation.farmers.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (enumerator.Current.currentLocation == currentLocation && enumerator.Current.GetBoundingBox().Intersects(GetBoundingBox()))
                {
                    enumerator.Current.takeDamage((int)Math.Round(20 * difficulty), true, null);
                    totalFireTime = 0;
                    nextFireTime  = 10;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(1000, 2000);
                }
            }

            if (attackState.Value == 0 && withinPlayerThreshold(20))
            {
                firing.Set(false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 50;
                    totalFireTime = 3000;
                    return;
                }
            }
            else if (totalFireTime > 0)
            {
                Farmer player = Player;
                if (!firing.Value)
                {
                    if (player != null)
                    {
                        faceGeneralDirection(player.Position, 0, false);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(true);
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X, (float)GetBoundingBox().Center.Y);
                        faceGeneralDirection(player.Position, 0, false);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            fire_angle = 90f;
                            break;

                        case 1:
                            fire_angle = 0f;
                            break;

                        case 2:
                            fire_angle = 270f;
                            break;

                        case 3:
                            fire_angle = 180f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * 3.1415926535897931 / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * 3.1415926535897931 / 180.0), -(float)Math.Sin((double)fire_angle * 3.1415926535897931 / 180.0));
                        shot_velocity *= 5f;

                        for (int i = 0; i < 8; i++)
                        {
                            bool one   = i < 4;
                            bool two   = i % 4 < 2;
                            bool three = i % 2 == 0;

                            Vector2 v = new Vector2((three ? shot_velocity.X : shot_velocity.Y) * (one ? -1 : 1), (three ? shot_velocity.Y : shot_velocity.X) * (two ? -1 : 1));
                            //v = ModEntry.RotateVector(v, j);
                            BasicProjectile projectile = new BossProjectile((int)(5 * difficulty), 766, 0, 1, 0.196349546f, v.X, v.Y, shot_origin, "", "", false, false, currentLocation, this, true, null, 13, true);
                            projectile.IgnoreLocationCollision       = true;
                            projectile.ignoreTravelGracePeriod.Value = true;
                            projectile.maxTravelDistance.Value       = 512;
                            currentLocation.projectiles.Add(projectile);

                            if (!ModEntry.IsLessThanHalfHealth(this))
                            {
                                i++;
                            }
                        }
                        if (ModEntry.IsLessThanHalfHealth(this))
                        {
                            j += 1;
                        }
                        j %= 360;


                        nextFireTime = 20;
                    }
                }
                if (totalFireTime <= 0)
                {
                    totalFireTime = 0;
                    nextFireTime  = 20;
                    attackState.Set(0);

                    timeUntilNextAttack = 0;
                }
            }
        }
예제 #3
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));
                    }
                }
            }
        }