Ejemplo n.º 1
0
 public void doneMating()
 {
     this.readyToMate     = 120000;
     this.matingCountdown = 2000;
     this.mateToPursue    = (GreenSlime)null;
     this.mateToAvoid     = (GreenSlime)null;
 }
Ejemplo n.º 2
0
        public void moveTowardOtherSlime(GreenSlime other, bool moveAway, GameTime time)
        {
            int xToGo = Math.Abs(other.getStandingX() - getStandingX());
            int yToGo = Math.Abs(other.getStandingY() - getStandingY());

            if (xToGo > 4 || yToGo > 4)
            {
                int dx = (other.getStandingX() > getStandingX()) ? 1 : (-1);
                int dy = (other.getStandingY() > getStandingY()) ? 1 : (-1);
                if (moveAway)
                {
                    dx = -dx;
                    dy = -dy;
                }
                double chanceForX = (double)xToGo / (double)(xToGo + yToGo);
                if (Game1.random.NextDouble() < chanceForX)
                {
                    tryToMoveInDirection((dx > 0) ? 1 : 3, isFarmer: false, base.DamageToFarmer, glider: false);
                }
                else
                {
                    tryToMoveInDirection((dy > 0) ? 2 : 0, isFarmer: false, base.DamageToFarmer, glider: false);
                }
            }
            Sprite.AnimateDown(time);
            if (invincibleCountdown > 0)
            {
                invincibleCountdown -= time.ElapsedGameTime.Milliseconds;
                if (invincibleCountdown <= 0)
                {
                    stopGlowing();
                }
            }
        }
Ejemplo n.º 3
0
        public void moveTowardOtherSlime(GreenSlime other, bool moveAway, GameTime time)
        {
            int num  = Math.Abs(other.getStandingX() - base.getStandingX());
            int num2 = Math.Abs(other.getStandingY() - base.getStandingY());

            if (num > 4 || num2 > 4)
            {
                int num3 = (other.getStandingX() > base.getStandingX()) ? 1 : -1;
                int num4 = (other.getStandingY() > base.getStandingY()) ? 1 : -1;
                if (moveAway)
                {
                    num3 = -num3;
                    num4 = -num4;
                }
                double num5 = (double)num / (double)(num + num2);
                if (Game1.random.NextDouble() < num5)
                {
                    base.tryToMoveInDirection((num3 > 0) ? 1 : 3, false, this.damageToFarmer, false);
                }
                else
                {
                    base.tryToMoveInDirection((num4 > 0) ? 2 : 0, false, this.damageToFarmer, false);
                }
            }
            this.sprite.AnimateDown(time, 0, "");
            if (this.invincibleCountdown > 0)
            {
                this.invincibleCountdown -= time.ElapsedGameTime.Milliseconds;
                if (this.invincibleCountdown <= 0)
                {
                    base.stopGlowing();
                }
            }
        }
Ejemplo n.º 4
0
 public void doneMating()
 {
     readyToMate        = 120000;
     matingCountdown    = 2000;
     mate               = null;
     pursuingMate.Value = false;
     avoidingMate.Value = false;
 }
Ejemplo n.º 5
0
        public override void behaviorAtGameTick(GameTime time)
        {
            if (mate == null)
            {
                pursuingMate.Value = false;
                avoidingMate.Value = false;
            }
            switch (FacingDirection)
            {
            case 2:
                if (facePosition.X > 0f)
                {
                    facePosition.X -= 2f;
                }
                else if (facePosition.X < 0f)
                {
                    facePosition.X += 2f;
                }
                if (facePosition.Y < 0f)
                {
                    facePosition.Y += 2f;
                }
                break;

            case 1:
                if (facePosition.X < 8f)
                {
                    facePosition.X += 2f;
                }
                if (facePosition.Y < 0f)
                {
                    facePosition.Y += 2f;
                }
                break;

            case 3:
                if (facePosition.X > -8f)
                {
                    facePosition.X -= 2f;
                }
                if (facePosition.Y < 0f)
                {
                    facePosition.Y += 2f;
                }
                break;

            case 0:
                if (facePosition.X > 0f)
                {
                    facePosition.X -= 2f;
                }
                else if (facePosition.X < 0f)
                {
                    facePosition.X += 2f;
                }
                if (facePosition.Y > -8f)
                {
                    facePosition.Y -= 2f;
                }
                break;
            }
            if (stackedSlimes.Value <= 0)
            {
                if ((int)ageUntilFullGrown <= 0)
                {
                    readyToMate -= time.ElapsedGameTime.Milliseconds;
                }
                else
                {
                    ageUntilFullGrown.Value -= time.ElapsedGameTime.Milliseconds;
                }
            }
            if ((bool)pursuingMate && mate != null)
            {
                if (readyToMate <= -35000)
                {
                    mate.doneMating();
                    doneMating();
                    return;
                }
                moveTowardOtherSlime(mate, moveAway: false, time);
                if (mate.mate != null && (bool)mate.pursuingMate && !mate.mate.Equals(this))
                {
                    doneMating();
                }
                else if (Vector2.Distance(getStandingPosition(), mate.getStandingPosition()) < (float)(GetBoundingBox().Width + 4))
                {
                    if (mate.mate != null && (bool)mate.avoidingMate && mate.mate.Equals(this))
                    {
                        mate.avoidingMate.Value = false;
                        mate.matingCountdown    = 2000;
                        mate.pursuingMate.Value = true;
                    }
                    matingCountdown -= time.ElapsedGameTime.Milliseconds;
                    if (base.currentLocation != null && matingCountdown <= 0 && (bool)pursuingMate && (!base.currentLocation.isOutdoors || Utility.getNumberOfCharactersInRadius(base.currentLocation, Utility.Vector2ToPoint(base.Position), 1) <= 4))
                    {
                        mateWith(mate, base.currentLocation);
                    }
                }
                else if (Vector2.Distance(getStandingPosition(), mate.getStandingPosition()) > (float)(matingRange * 2))
                {
                    mate.mate = null;
                    mate.avoidingMate.Value = false;
                    mate = null;
                }
                return;
            }
            if ((bool)avoidingMate && mate != null)
            {
                moveTowardOtherSlime(mate, moveAway: true, time);
                return;
            }
            if (readyToMate < 0 && (bool)cute)
            {
                readyToMate = -1;
                if (Game1.random.NextDouble() < 0.001)
                {
                    GreenSlime newMate = (GreenSlime)Utility.checkForCharacterWithinArea(GetType(), base.Position, base.currentLocation, new Rectangle(getStandingX() - matingRange, getStandingY() - matingRange, matingRange * 2, matingRange * 2));
                    if (newMate != null && newMate.readyToMate <= 0 && !newMate.cute && newMate.stackedSlimes.Value <= 0)
                    {
                        matingCountdown            = 2000;
                        mate                       = newMate;
                        pursuingMate.Value         = true;
                        newMate.mate               = this;
                        newMate.avoidingMate.Value = true;
                        base.addedSpeed            = 1;
                        mate.addedSpeed            = 1;
                        return;
                    }
                }
            }
            else if (!isGlowing)
            {
                base.addedSpeed = 0;
            }
            base.behaviorAtGameTick(time);
            if (readyToJump != -1)
            {
                Halt();
                base.IsWalkingTowardPlayer = false;
                readyToJump        -= time.ElapsedGameTime.Milliseconds;
                Sprite.currentFrame = 16 + (800 - readyToJump) / 200;
                if (readyToJump <= 0)
                {
                    timeSinceLastJump          = timeSinceLastJump;
                    base.Slipperiness          = 10;
                    base.IsWalkingTowardPlayer = true;
                    readyToJump         = -1;
                    invincibleCountdown = 0;
                    Vector2 trajectory = Utility.getAwayFromPlayerTrajectory(GetBoundingBox(), base.Player);
                    trajectory.X = (0f - trajectory.X) / 2f;
                    trajectory.Y = (0f - trajectory.Y) / 2f;
                    jumpEvent.Fire(trajectory);
                    setTrajectory((int)trajectory.X, (int)trajectory.Y);
                }
            }
            else if (Game1.random.NextDouble() < 0.1 && !base.focusedOnFarmers)
            {
                if (FacingDirection == 0 || FacingDirection == 2)
                {
                    if ((bool)leftDrift && !base.currentLocation.isCollidingPosition(nextPosition(3), Game1.viewport, isFarmer: false, 1, glider: false, this))
                    {
                        position.X -= base.speed;
                    }
                    else if (!leftDrift && !base.currentLocation.isCollidingPosition(nextPosition(1), Game1.viewport, isFarmer: false, 1, glider: false, this))
                    {
                        position.X += base.speed;
                    }
                }
                else if ((bool)leftDrift && !base.currentLocation.isCollidingPosition(nextPosition(0), Game1.viewport, isFarmer: false, 1, glider: false, this))
                {
                    position.Y -= base.speed;
                }
                else if (!leftDrift && !base.currentLocation.isCollidingPosition(nextPosition(2), Game1.viewport, isFarmer: false, 1, glider: false, this))
                {
                    position.Y += base.speed;
                }
                if (Game1.random.NextDouble() < 0.08)
                {
                    leftDrift.Value = !leftDrift;
                }
            }
            else if (withinPlayerThreshold() && timeSinceLastJump > (base.focusedOnFarmers ? 1000 : 4000) && Game1.random.NextDouble() < 0.01 && stackedSlimes.Value <= 0)
            {
                if (base.Name.Equals("Frost Jelly") && Game1.random.NextDouble() < 0.25)
                {
                    base.addedSpeed = 2;
                    startGlowing(Color.Cyan, border: false, 0.15f);
                }
                else
                {
                    base.addedSpeed = 0;
                    stopGlowing();
                    readyToJump = 800;
                }
            }
        }
Ejemplo n.º 6
0
        public void mateWith(GreenSlime mateToPursue, GameLocation location)
        {
            if (location.canSlimeMateHere())
            {
                GreenSlime baby = new GreenSlime(Vector2.Zero);
                Utility.recursiveFindPositionForCharacter(baby, location, getTileLocation(), 30);
                Random r = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 10 + (int)((float)scale * 100f) + (int)((float)mateToPursue.scale * 100f));
                switch (r.Next(4))
                {
                case 0:
                    baby.color.Value = new Color(Math.Min(255, Math.Max(0, color.R + r.Next((int)((float)(-color.R) * 0.25f), (int)((float)(int)color.R * 0.25f)))), Math.Min(255, Math.Max(0, color.G + r.Next((int)((float)(-color.G) * 0.25f), (int)((float)(int)color.G * 0.25f)))), Math.Min(255, Math.Max(0, color.B + r.Next((int)((float)(-color.B) * 0.25f), (int)((float)(int)color.B * 0.25f)))));
                    break;

                case 1:
                case 2:
                    baby.color.Value = Utility.getBlendedColor(color, mateToPursue.color);
                    break;

                case 3:
                    baby.color.Value = new Color(Math.Min(255, Math.Max(0, mateToPursue.color.R + r.Next((int)((float)(-mateToPursue.color.R) * 0.25f), (int)((float)(int)mateToPursue.color.R * 0.25f)))), Math.Min(255, Math.Max(0, mateToPursue.color.G + r.Next((int)((float)(-mateToPursue.color.G) * 0.25f), (int)((float)(int)mateToPursue.color.G * 0.25f)))), Math.Min(255, Math.Max(0, mateToPursue.color.B + r.Next((int)((float)(-mateToPursue.color.B) * 0.25f), (int)((float)(int)mateToPursue.color.B * 0.25f)))));
                    break;
                }
                int red   = baby.color.R;
                int green = baby.color.G;
                int blue  = baby.color.B;
                baby.Name = name;
                if (baby.Name == "Tiger Slime")
                {
                    baby.makeTigerSlime();
                }
                else if (red > 100 && blue > 100 && green < 50)
                {
                    baby.parseMonsterInfo("Sludge");
                    while (r.NextDouble() < 0.1)
                    {
                        baby.objectsToDrop.Add(386);
                    }
                    if (r.NextDouble() < 0.01)
                    {
                        baby.objectsToDrop.Add(337);
                    }
                }
                else if (red >= 200 && green < 75)
                {
                    baby.parseMonsterInfo("Sludge");
                }
                else if (blue >= 200 && red < 100)
                {
                    baby.parseMonsterInfo("Frost Jelly");
                }
                baby.Health           = ((r.NextDouble() < 0.5) ? base.Health : mateToPursue.Health);
                baby.Health           = Math.Max(1, base.Health + r.Next(-4, 5));
                baby.DamageToFarmer   = ((r.NextDouble() < 0.5) ? base.DamageToFarmer : mateToPursue.DamageToFarmer);
                baby.DamageToFarmer   = Math.Max(0, base.DamageToFarmer + r.Next(-1, 2));
                baby.resilience.Value = ((r.NextDouble() < 0.5) ? resilience : mateToPursue.resilience);
                baby.resilience.Value = Math.Max(0, (int)resilience + r.Next(-1, 2));
                baby.missChance.Value = ((r.NextDouble() < 0.5) ? missChance : mateToPursue.missChance);
                baby.missChance.Value = Math.Max(0.0, (double)missChance + (double)((float)r.Next(-1, 2) / 100f));
                baby.Scale            = ((r.NextDouble() < 0.5) ? scale : mateToPursue.scale);
                baby.Scale            = Math.Max(0.6f, Math.Min(1.5f, (float)scale + (float)r.Next(-2, 3) / 100f));
                baby.Slipperiness     = 8;
                base.speed            = ((r.NextDouble() < 0.5) ? base.speed : mateToPursue.speed);
                if (r.NextDouble() < 0.015)
                {
                    base.speed = Math.Max(1, Math.Min(6, base.speed + r.Next(-1, 2)));
                }
                baby.setTrajectory(Utility.getAwayFromPositionTrajectory(baby.GetBoundingBox(), getStandingPosition()) / 2f);
                baby.ageUntilFullGrown.Value = 120000;
                baby.Halt();
                baby.firstGeneration.Value = false;
                if (Utility.isOnScreen(base.Position, 128))
                {
                    base.currentLocation.playSound("slime");
                }
            }
            mateToPursue.doneMating();
            doneMating();
        }
Ejemplo n.º 7
0
        public override void behaviorAtGameTick(GameTime time)
        {
            TimeSpan elapsedGameTime;

            if (this.wagTimer > 0)
            {
                int wagTimer = this.wagTimer;
                elapsedGameTime = time.ElapsedGameTime;
                int totalMilliseconds = (int)elapsedGameTime.TotalMilliseconds;
                this.wagTimer = wagTimer - totalMilliseconds;
            }
            switch (this.FacingDirection)
            {
            case 0:
                if ((double)this.facePosition.X > 0.0)
                {
                    this.facePosition.X -= 2f;
                }
                else if ((double)this.facePosition.X < 0.0)
                {
                    this.facePosition.X += 2f;
                }
                if ((double)this.facePosition.Y > (double)(-Game1.pixelZoom * 2))
                {
                    this.facePosition.Y -= 2f;
                    break;
                }
                break;

            case 1:
                if ((double)this.facePosition.X < (double)(Game1.pixelZoom * 2))
                {
                    this.facePosition.X += 2f;
                }
                if ((double)this.facePosition.Y < 0.0)
                {
                    this.facePosition.Y += 2f;
                    break;
                }
                break;

            case 2:
                if ((double)this.facePosition.X > 0.0)
                {
                    this.facePosition.X -= 2f;
                }
                else if ((double)this.facePosition.X < 0.0)
                {
                    this.facePosition.X += 2f;
                }
                if ((double)this.facePosition.Y < 0.0)
                {
                    this.facePosition.Y += 2f;
                    break;
                }
                break;

            case 3:
                if ((double)this.facePosition.X > (double)(-Game1.pixelZoom * 2))
                {
                    this.facePosition.X -= 2f;
                }
                if ((double)this.facePosition.Y < 0.0)
                {
                    this.facePosition.Y += 2f;
                    break;
                }
                break;
            }
            if (this.ageUntilFullGrown <= 0)
            {
                int readyToMate = this.readyToMate;
                elapsedGameTime = time.ElapsedGameTime;
                int milliseconds = elapsedGameTime.Milliseconds;
                this.readyToMate = readyToMate - milliseconds;
            }
            else
            {
                int ageUntilFullGrown = this.ageUntilFullGrown;
                elapsedGameTime = time.ElapsedGameTime;
                int milliseconds = elapsedGameTime.Milliseconds;
                this.ageUntilFullGrown = ageUntilFullGrown - milliseconds;
            }
            if (this.mateToPursue != null)
            {
                if (this.readyToMate <= -35000)
                {
                    this.mateToPursue.doneMating();
                    this.doneMating();
                }
                else
                {
                    this.moveTowardOtherSlime(this.mateToPursue, false, time);
                    if (this.mateToPursue.mateToAvoid == null && this.mateToPursue.mateToPursue != null && !this.mateToPursue.mateToPursue.Equals((object)this))
                    {
                        this.doneMating();
                    }
                    else if ((double)Vector2.Distance(this.getStandingPosition(), this.mateToPursue.getStandingPosition()) < (double)(this.GetBoundingBox().Width + 4))
                    {
                        if (this.mateToPursue.mateToAvoid != null && this.mateToPursue.mateToAvoid.Equals((object)this))
                        {
                            this.mateToPursue.mateToAvoid     = (GreenSlime)null;
                            this.mateToPursue.matingCountdown = 2000;
                            this.mateToPursue.mateToPursue    = this;
                        }
                        int matingCountdown = this.matingCountdown;
                        elapsedGameTime = time.ElapsedGameTime;
                        int milliseconds = elapsedGameTime.Milliseconds;
                        this.matingCountdown = matingCountdown - milliseconds;
                        if (this.currentLocation == null || this.matingCountdown > 0 || this.mateToPursue == null || this.currentLocation.isOutdoors && Utility.getNumberOfCharactersInRadius(this.currentLocation, Utility.Vector2ToPoint(this.position), 1) > 4)
                        {
                            return;
                        }
                        this.mateWith(this.mateToPursue, this.currentLocation);
                    }
                    else
                    {
                        if ((double)Vector2.Distance(this.getStandingPosition(), this.mateToPursue.getStandingPosition()) <= (double)(GreenSlime.matingRange * 2))
                        {
                            return;
                        }
                        this.mateToPursue.mateToAvoid = (GreenSlime)null;
                        this.mateToPursue             = (GreenSlime)null;
                    }
                }
            }
            else if (this.mateToAvoid != null)
            {
                this.moveTowardOtherSlime(this.mateToAvoid, true, time);
            }
            else
            {
                if (this.readyToMate < 0 && this.cute)
                {
                    this.readyToMate = -1;
                    if (Game1.random.NextDouble() < 0.001)
                    {
                        GreenSlime greenSlime = (GreenSlime)Utility.checkForCharacterWithinArea(this.GetType(), this.position, Game1.currentLocation, new Rectangle(this.getStandingX() - GreenSlime.matingRange, this.getStandingY() - GreenSlime.matingRange, GreenSlime.matingRange * 2, GreenSlime.matingRange * 2));
                        if (greenSlime != null && greenSlime.readyToMate <= 0 && !greenSlime.cute)
                        {
                            this.matingCountdown         = 2000;
                            this.mateToPursue            = greenSlime;
                            greenSlime.mateToAvoid       = this;
                            this.addedSpeed              = 1;
                            this.mateToPursue.addedSpeed = 1;
                            return;
                        }
                    }
                }
                else if (!this.isGlowing)
                {
                    this.addedSpeed = 0;
                }
                this.yOffset = Math.Max(this.yOffset - (int)Math.Abs(this.xVelocity + this.yVelocity) / 2, -Game1.tileSize);
                base.behaviorAtGameTick(time);
                if (this.yOffset < 0)
                {
                    this.yOffset = Math.Min(0, this.yOffset + 4 + (this.yOffset <= -Game1.tileSize ? (int)((double)-this.yOffset / 8.0) : (int)((double)-this.yOffset / 16.0)));
                }
                int timeSinceLastJump = this.timeSinceLastJump;
                elapsedGameTime = time.ElapsedGameTime;
                int milliseconds1 = elapsedGameTime.Milliseconds;
                this.timeSinceLastJump = timeSinceLastJump + milliseconds1;
                if (this.readyToJump != -1)
                {
                    this.Halt();
                    this.IsWalkingTowardPlayer = false;
                    int readyToJump = this.readyToJump;
                    elapsedGameTime = time.ElapsedGameTime;
                    int milliseconds2 = elapsedGameTime.Milliseconds;
                    this.readyToJump         = readyToJump - milliseconds2;
                    this.sprite.CurrentFrame = 16 + (800 - this.readyToJump) / 200;
                    if (this.readyToJump <= 0)
                    {
                        this.timeSinceLastJump     = this.timeSinceLastJump;
                        this.slipperiness          = 10;
                        this.IsWalkingTowardPlayer = true;
                        this.readyToJump           = -1;
                        if (Utility.isOnScreen(this.position, 128))
                        {
                            Game1.playSound("slime");
                        }
                        Vector2 playerTrajectory = Utility.getAwayFromPlayerTrajectory(this.GetBoundingBox());
                        playerTrajectory.X = (float)(-(double)playerTrajectory.X / 2.0);
                        playerTrajectory.Y = (float)(-(double)playerTrajectory.Y / 2.0);
                        this.setTrajectory((int)playerTrajectory.X, (int)playerTrajectory.Y);
                        this.sprite.CurrentFrame = 1;
                        this.invincibleCountdown = 0;
                    }
                }
                else if (Game1.random.NextDouble() < 0.1 && !this.focusedOnFarmers)
                {
                    if (this.facingDirection == 0 || this.facingDirection == 2)
                    {
                        if (this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(3), Game1.viewport, false, 1, false, (Character)this))
                        {
                            this.position.X -= (float)this.speed;
                        }
                        else if (!this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(1), Game1.viewport, false, 1, false, (Character)this))
                        {
                            this.position.X += (float)this.speed;
                        }
                    }
                    else if (this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(0), Game1.viewport, false, 1, false, (Character)this))
                    {
                        this.position.Y -= (float)this.speed;
                    }
                    else if (!this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(2), Game1.viewport, false, 1, false, (Character)this))
                    {
                        this.position.Y += (float)this.speed;
                    }
                    if (Game1.random.NextDouble() < 0.08)
                    {
                        this.leftDrift = !this.leftDrift;
                    }
                }
                else if (this.withinPlayerThreshold() && (this.timeSinceLastJump > (this.focusedOnFarmers ? 1000 : 4000) && Game1.random.NextDouble() < 0.01))
                {
                    if (this.name.Equals("Frost Jelly") && Game1.random.NextDouble() < 0.25)
                    {
                        this.addedSpeed = 2;
                        this.startGlowing(Color.Cyan, false, 0.15f);
                    }
                    else
                    {
                        this.addedSpeed = 0;
                        this.stopGlowing();
                        this.readyToJump = 800;
                    }
                }
                if (Game1.random.NextDouble() < 0.01 && this.wagTimer <= 0)
                {
                    this.wagTimer = 992;
                }
                if ((double)Math.Abs(this.xVelocity) >= 0.5 || (double)Math.Abs(this.yVelocity) >= 0.5)
                {
                    this.sprite.AnimateDown(time, 0, "");
                }
                else if (!this.position.Equals(this.lastPosition))
                {
                    this.animateTimer = 500;
                }
                if (this.animateTimer <= 0 || this.readyToJump > 0)
                {
                    return;
                }
                int animateTimer = this.animateTimer;
                elapsedGameTime = time.ElapsedGameTime;
                int milliseconds3 = elapsedGameTime.Milliseconds;
                this.animateTimer = animateTimer - milliseconds3;
                this.sprite.AnimateDown(time, 0, "");
            }
        }
Ejemplo n.º 8
0
        public void mateWith(GreenSlime mateToPursue, GameLocation location)
        {
            if (location.canSlimeMateHere())
            {
                GreenSlime greenSlime = new GreenSlime(Vector2.Zero);
                Utility.recursiveFindPositionForCharacter((NPC)greenSlime, location, this.getTileLocation(), 30);
                Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 10 + (int)((double)this.scale * 100.0) + (int)((double)mateToPursue.scale * 100.0));
                switch (random.Next(4))
                {
                case 0:
                    greenSlime.color = new Color(Math.Min((int)byte.MaxValue, Math.Max(0, (int)this.color.R + random.Next((int)((double)-this.color.R * 0.25), (int)((double)this.color.R * 0.25)))), Math.Min((int)byte.MaxValue, Math.Max(0, (int)this.color.G + random.Next((int)((double)-this.color.G * 0.25), (int)((double)this.color.G * 0.25)))), Math.Min((int)byte.MaxValue, Math.Max(0, (int)this.color.B + random.Next((int)((double)-this.color.B * 0.25), (int)((double)this.color.B * 0.25)))));
                    break;

                case 1:
                case 2:
                    greenSlime.color = Utility.getBlendedColor(this.color, mateToPursue.color);
                    break;

                case 3:
                    greenSlime.color = new Color(Math.Min((int)byte.MaxValue, Math.Max(0, (int)mateToPursue.color.R + random.Next((int)((double)-mateToPursue.color.R * 0.25), (int)((double)mateToPursue.color.R * 0.25)))), Math.Min((int)byte.MaxValue, Math.Max(0, (int)mateToPursue.color.G + random.Next((int)((double)-mateToPursue.color.G * 0.25), (int)((double)mateToPursue.color.G * 0.25)))), Math.Min((int)byte.MaxValue, Math.Max(0, (int)mateToPursue.color.B + random.Next((int)((double)-mateToPursue.color.B * 0.25), (int)((double)mateToPursue.color.B * 0.25)))));
                    break;
                }
                int r = (int)greenSlime.color.R;
                int g = (int)greenSlime.color.G;
                int b = (int)greenSlime.color.B;
                if (r > 100 && b > 100 && g < 50)
                {
                    greenSlime.parseMonsterInfo("Sludge");
                    while (random.NextDouble() < 0.1)
                    {
                        greenSlime.objectsToDrop.Add(386);
                    }
                    if (random.NextDouble() < 0.01)
                    {
                        greenSlime.objectsToDrop.Add(337);
                    }
                }
                else if (r >= 200 && g < 75)
                {
                    greenSlime.parseMonsterInfo("Sludge");
                }
                else if (b >= 200 && r < 100)
                {
                    greenSlime.parseMonsterInfo("Frost Jelly");
                }
                greenSlime.health         = random.NextDouble() < 0.5 ? this.health : mateToPursue.health;
                greenSlime.health         = Math.Max(1, this.health + random.Next(-4, 5));
                greenSlime.damageToFarmer = random.NextDouble() < 0.5 ? this.damageToFarmer : mateToPursue.damageToFarmer;
                greenSlime.damageToFarmer = Math.Max(0, this.damageToFarmer + random.Next(-1, 2));
                greenSlime.resilience     = random.NextDouble() < 0.5 ? this.resilience : mateToPursue.resilience;
                greenSlime.resilience     = Math.Max(0, this.resilience + random.Next(-1, 2));
                greenSlime.missChance     = random.NextDouble() < 0.5 ? this.missChance : mateToPursue.missChance;
                greenSlime.missChance     = Math.Max(0.0, this.missChance + (double)random.Next(-1, 2) / 100.0);
                greenSlime.scale          = random.NextDouble() < 0.5 ? this.scale : mateToPursue.scale;
                greenSlime.scale          = Math.Max(0.6f, Math.Min(1.5f, this.scale + (float)random.Next(-2, 3) / 100f));
                greenSlime.slipperiness   = 8;
                this.speed = random.NextDouble() < 0.5 ? this.speed : mateToPursue.speed;
                if (random.NextDouble() < 0.015)
                {
                    this.speed = Math.Max(1, Math.Min(6, this.speed + random.Next(-1, 2)));
                }
                greenSlime.setTrajectory(Utility.getAwayFromPositionTrajectory(greenSlime.GetBoundingBox(), this.getStandingPosition()) / 2f);
                greenSlime.ageUntilFullGrown = 120000;
                greenSlime.Halt();
                greenSlime.firstGeneration = false;
                if (Utility.isOnScreen(this.position, 128))
                {
                    Game1.playSound("slime");
                }
            }
            mateToPursue.doneMating();
            this.doneMating();
        }
Ejemplo n.º 9
0
        public override int takeDamage(int damage, int xTrajectory, int yTrajectory, bool isBomb, double addedPrecision)
        {
            int num1 = Math.Max(1, damage - this.resilience);

            if (Game1.random.NextDouble() < this.missChance - this.missChance * addedPrecision)
            {
                num1 = -1;
            }
            else
            {
                if (Game1.random.NextDouble() < 0.025 && this.cute)
                {
                    if (!this.focusedOnFarmers)
                    {
                        this.damageToFarmer = this.damageToFarmer + this.damageToFarmer / 2;
                        this.shake(1000);
                    }
                    this.focusedOnFarmers = true;
                }
                this.slipperiness = 3;
                this.health       = this.health - num1;
                this.setTrajectory(xTrajectory, yTrajectory);
                Game1.playSound("slimeHit");
                this.readyToJump           = -1;
                this.IsWalkingTowardPlayer = true;
                if (this.health <= 0)
                {
                    Game1.playSound("slimedead");
                    ++Game1.stats.SlimesKilled;
                    if (this.mateToPursue != null)
                    {
                        this.mateToPursue.mateToAvoid = (GreenSlime)null;
                    }
                    if (this.mateToAvoid != null)
                    {
                        this.mateToAvoid.mateToPursue = (GreenSlime)null;
                    }
                    if ((int)Game1.gameMode == 3 && (double)this.scale > 1.79999995231628)
                    {
                        this.health = 10;
                        int num2 = (double)this.scale > 1.79999995231628 ? Game1.random.Next(3, 5) : 1;
                        this.scale = this.scale * 0.6666667f;
                        for (int index = 0; index < num2; ++index)
                        {
                            Game1.currentLocation.characters.Add((NPC) new GreenSlime(this.position + new Vector2((float)(index * this.GetBoundingBox().Width), 0.0f), Game1.mine.mineLevel));
                            Game1.currentLocation.characters[Game1.currentLocation.characters.Count - 1].setTrajectory(xTrajectory + Game1.random.Next(-20, 20), yTrajectory + Game1.random.Next(-20, 20));
                            Game1.currentLocation.characters[Game1.currentLocation.characters.Count - 1].willDestroyObjectsUnderfoot = false;
                            Game1.currentLocation.characters[Game1.currentLocation.characters.Count - 1].moveTowardPlayer(4);
                            Game1.currentLocation.characters[Game1.currentLocation.characters.Count - 1].scale = (float)(0.75 + (double)Game1.random.Next(-5, 10) / 100.0);
                        }
                    }
                    else
                    {
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(44, this.position, this.color * 0.66f, 10, false, 100f, 0, -1, -1f, -1, 0)
                        {
                            interval      = 70f,
                            holdLastFrame = true,
                            alphaFade     = 0.01f
                        });
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(44, this.position + new Vector2((float)(-Game1.tileSize / 4), 0.0f), this.color * 0.66f, 10, false, 100f, 0, -1, -1f, -1, 0)
                        {
                            interval = 70f,
                            delayBeforeAnimationStart = 0,
                            holdLastFrame             = true,
                            alphaFade = 0.01f
                        });
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(44, this.position + new Vector2(0.0f, (float)(Game1.tileSize / 4)), this.color * 0.66f, 10, false, 100f, 0, -1, -1f, -1, 0)
                        {
                            interval = 70f,
                            delayBeforeAnimationStart = 100,
                            holdLastFrame             = true,
                            alphaFade = 0.01f
                        });
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(44, this.position + new Vector2((float)(Game1.tileSize / 4), 0.0f), this.color * 0.66f, 10, false, 100f, 0, -1, -1f, -1, 0)
                        {
                            interval = 70f,
                            delayBeforeAnimationStart = 200,
                            holdLastFrame             = true,
                            alphaFade = 0.01f
                        });
                    }
                }
            }
            return(num1);
        }
Ejemplo n.º 10
0
        // Token: 0x06000C3E RID: 3134 RVA: 0x000F34F8 File Offset: 0x000F16F8
        public override void behaviorAtGameTick(GameTime time)
        {
            if (this.wagTimer > 0)
            {
                this.wagTimer -= (int)time.ElapsedGameTime.TotalMilliseconds;
            }
            switch (base.FacingDirection)
            {
            case 0:
                if (this.facePosition.X > 0f)
                {
                    this.facePosition.X = this.facePosition.X - 2f;
                }
                else if (this.facePosition.X < 0f)
                {
                    this.facePosition.X = this.facePosition.X + 2f;
                }
                if (this.facePosition.Y > (float)(-(float)Game1.pixelZoom * 2))
                {
                    this.facePosition.Y = this.facePosition.Y - 2f;
                }
                break;

            case 1:
                if (this.facePosition.X < (float)(Game1.pixelZoom * 2))
                {
                    this.facePosition.X = this.facePosition.X + 2f;
                }
                if (this.facePosition.Y < 0f)
                {
                    this.facePosition.Y = this.facePosition.Y + 2f;
                }
                break;

            case 2:
                if (this.facePosition.X > 0f)
                {
                    this.facePosition.X = this.facePosition.X - 2f;
                }
                else if (this.facePosition.X < 0f)
                {
                    this.facePosition.X = this.facePosition.X + 2f;
                }
                if (this.facePosition.Y < 0f)
                {
                    this.facePosition.Y = this.facePosition.Y + 2f;
                }
                break;

            case 3:
                if (this.facePosition.X > (float)(-(float)Game1.pixelZoom * 2))
                {
                    this.facePosition.X = this.facePosition.X - 2f;
                }
                if (this.facePosition.Y < 0f)
                {
                    this.facePosition.Y = this.facePosition.Y + 2f;
                }
                break;
            }
            if (this.ageUntilFullGrown <= 0)
            {
                this.readyToMate -= time.ElapsedGameTime.Milliseconds;
            }
            else
            {
                this.ageUntilFullGrown -= time.ElapsedGameTime.Milliseconds;
            }
            if (this.mateToPursue != null)
            {
                if (this.readyToMate <= -35000)
                {
                    this.mateToPursue.doneMating();
                    this.doneMating();
                    return;
                }
                this.moveTowardOtherSlime(this.mateToPursue, false, time);
                if (this.mateToPursue.mateToAvoid == null && this.mateToPursue.mateToPursue != null && !this.mateToPursue.mateToPursue.Equals(this))
                {
                    this.doneMating();
                    return;
                }
                if (Vector2.Distance(base.getStandingPosition(), this.mateToPursue.getStandingPosition()) < (float)(this.GetBoundingBox().Width + 4))
                {
                    if (this.mateToPursue.mateToAvoid != null && this.mateToPursue.mateToAvoid.Equals(this))
                    {
                        this.mateToPursue.mateToAvoid     = null;
                        this.mateToPursue.matingCountdown = 2000;
                        this.mateToPursue.mateToPursue    = this;
                    }
                    this.matingCountdown -= time.ElapsedGameTime.Milliseconds;
                    if (this.currentLocation != null && this.matingCountdown <= 0 && this.mateToPursue != null && (!this.currentLocation.isOutdoors || Utility.getNumberOfCharactersInRadius(this.currentLocation, Utility.Vector2ToPoint(this.position), 1) <= 4))
                    {
                        this.mateWith(this.mateToPursue, this.currentLocation);
                        return;
                    }
                }
                else if (Vector2.Distance(base.getStandingPosition(), this.mateToPursue.getStandingPosition()) > (float)(GreenSlime.matingRange * 2))
                {
                    this.mateToPursue.mateToAvoid = null;
                    this.mateToPursue             = null;
                    return;
                }
            }
            else
            {
                if (this.mateToAvoid != null)
                {
                    this.moveTowardOtherSlime(this.mateToAvoid, true, time);
                    return;
                }
                if (this.readyToMate < 0 && this.cute)
                {
                    this.readyToMate = -1;
                    if (Game1.random.NextDouble() < 0.001)
                    {
                        GreenSlime mate = (GreenSlime)Utility.checkForCharacterWithinArea(base.GetType(), this.position, Game1.currentLocation, new Rectangle(base.getStandingX() - GreenSlime.matingRange, base.getStandingY() - GreenSlime.matingRange, GreenSlime.matingRange * 2, GreenSlime.matingRange * 2));
                        if (mate != null && mate.readyToMate <= 0 && !mate.cute)
                        {
                            this.matingCountdown         = 2000;
                            this.mateToPursue            = mate;
                            mate.mateToAvoid             = this;
                            this.addedSpeed              = 1;
                            this.mateToPursue.addedSpeed = 1;
                            return;
                        }
                    }
                }
                else if (!this.isGlowing)
                {
                    this.addedSpeed = 0;
                }
                this.yOffset = Math.Max(this.yOffset - (int)Math.Abs(this.xVelocity + this.yVelocity) / 2, -Game1.tileSize);
                base.behaviorAtGameTick(time);
                if (this.yOffset < 0)
                {
                    this.yOffset = Math.Min(0, this.yOffset + 4 + (int)((this.yOffset <= -Game1.tileSize) ? ((float)(-(float)this.yOffset) / 8f) : ((float)(-(float)this.yOffset) / 16f)));
                }
                this.timeSinceLastJump += time.ElapsedGameTime.Milliseconds;
                if (this.readyToJump != -1)
                {
                    this.Halt();
                    base.IsWalkingTowardPlayer = false;
                    this.readyToJump          -= time.ElapsedGameTime.Milliseconds;
                    this.sprite.CurrentFrame   = 16 + (800 - this.readyToJump) / 200;
                    if (this.readyToJump <= 0)
                    {
                        this.timeSinceLastJump     = this.timeSinceLastJump;
                        this.slipperiness          = 10;
                        base.IsWalkingTowardPlayer = true;
                        this.readyToJump           = -1;
                        if (Utility.isOnScreen(this.position, 128))
                        {
                            Game1.playSound("slime");
                        }
                        Vector2 trajectory = Utility.getAwayFromPlayerTrajectory(this.GetBoundingBox());
                        trajectory.X = -trajectory.X / 2f;
                        trajectory.Y = -trajectory.Y / 2f;
                        base.setTrajectory((int)trajectory.X, (int)trajectory.Y);
                        this.sprite.CurrentFrame = 1;
                        this.invincibleCountdown = 0;
                    }
                }
                else if (Game1.random.NextDouble() < 0.1 && !this.focusedOnFarmers)
                {
                    if (this.facingDirection == 0 || this.facingDirection == 2)
                    {
                        if (this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(3), Game1.viewport, false, 1, false, this))
                        {
                            this.position.X = this.position.X - (float)this.speed;
                        }
                        else if (!this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(1), Game1.viewport, false, 1, false, this))
                        {
                            this.position.X = this.position.X + (float)this.speed;
                        }
                    }
                    else if (this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(0), Game1.viewport, false, 1, false, this))
                    {
                        this.position.Y = this.position.Y - (float)this.speed;
                    }
                    else if (!this.leftDrift && !Game1.currentLocation.isCollidingPosition(this.nextPosition(2), Game1.viewport, false, 1, false, this))
                    {
                        this.position.Y = this.position.Y + (float)this.speed;
                    }
                    if (Game1.random.NextDouble() < 0.08)
                    {
                        this.leftDrift = !this.leftDrift;
                    }
                }
                else if (this.withinPlayerThreshold() && this.timeSinceLastJump > (this.focusedOnFarmers ? 1000 : 4000) && Game1.random.NextDouble() < 0.01)
                {
                    if (this.name.Equals("Frost Jelly") && Game1.random.NextDouble() < 0.25)
                    {
                        this.addedSpeed = 2;
                        base.startGlowing(Color.Cyan, false, 0.15f);
                    }
                    else
                    {
                        this.addedSpeed = 0;
                        base.stopGlowing();
                        this.readyToJump = 800;
                    }
                }
                if (Game1.random.NextDouble() < 0.01 && this.wagTimer <= 0)
                {
                    this.wagTimer = 992;
                }
                if (Math.Abs(this.xVelocity) >= 0.5f || Math.Abs(this.yVelocity) >= 0.5f)
                {
                    this.sprite.AnimateDown(time, 0, "");
                }
                else if (!this.position.Equals(this.lastPosition))
                {
                    this.animateTimer = 500;
                }
                if (this.animateTimer > 0 && this.readyToJump <= 0)
                {
                    this.animateTimer -= time.ElapsedGameTime.Milliseconds;
                    this.sprite.AnimateDown(time, 0, "");
                }
            }
        }