Пример #1
0
 public BasicProjectile(int damageToFarmer, int parentSheetIndex, int bouncesTillDestruct, int tailLength, float rotationVelocity, float xVelocity, float yVelocity, Vector2 startingPosition, string collisionSound, string firingSound, bool explode, bool damagesMonsters = false, Character firer = null, bool spriteFromObjectSheet = false, BasicProjectile.onCollisionBehavior collisionBehavior = null)
 {
     this.damageToFarmer        = damageToFarmer;
     this.currentTileSheetIndex = parentSheetIndex;
     this.bouncesLeft           = bouncesTillDestruct;
     this.tailLength            = tailLength;
     this.rotationVelocity      = rotationVelocity;
     this.xVelocity             = xVelocity;
     this.yVelocity             = yVelocity;
     this.position = startingPosition;
     if (firingSound != null && !firingSound.Equals(""))
     {
         Game1.playSound(firingSound);
     }
     this.explode               = explode;
     this.collisionSound        = collisionSound;
     this.damagesMonsters       = damagesMonsters;
     this.theOneWhoFiredMe      = firer;
     this.spriteFromObjectSheet = spriteFromObjectSheet;
     this.collisionBehavior     = collisionBehavior;
 }
Пример #2
0
        public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.indexOfMenuItemView = this.initialParentTileIndex;
            who.usingSlingshot       = false;
            who.canReleaseTool       = true;
            who.usingTool            = false;
            who.canMove = true;
            if (this.attachments[0] != null)
            {
                StardewValley.Object @object = (StardewValley.Object) this.attachments[0].getOne();
                StardewValley.Object expr_54 = this.attachments[0];
                int num = expr_54.Stack;
                expr_54.Stack = num - 1;
                if (this.attachments[0].Stack <= 0)
                {
                    this.attachments[0] = null;
                }
                int num2 = Game1.getOldMouseX() + Game1.viewport.X;
                int num3 = Game1.getOldMouseY() + Game1.viewport.Y;
                if (this.startedWithGamePad)
                {
                    Point expr_107 = Utility.Vector2ToPoint(Game1.player.getStandingPosition() + new Vector2(Game1.oldPadState.ThumbSticks.Left.X, -Game1.oldPadState.ThumbSticks.Left.Y) * (float)Game1.tileSize * 4f);
                    num2 = expr_107.X;
                    num3 = expr_107.Y;
                }
                int     arg_195_0           = Math.Min(20, (int)Vector2.Distance(new Vector2((float)who.getStandingX(), (float)(who.getStandingY() - Game1.tileSize)), new Vector2((float)num2, (float)num3)) / 20);
                Vector2 velocityTowardPoint = Utility.getVelocityTowardPoint(new Point(who.getStandingX(), who.getStandingY() + Game1.tileSize), new Vector2((float)num2, (float)(num3 + Game1.tileSize)), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                if (arg_195_0 > 4 && !this.canPlaySound)
                {
                    int num4 = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = null;
                    string collisionSound = "hammer";
                    float  num5           = 1f;
                    if (this.initialParentTileIndex == 33)
                    {
                        num5 = 2f;
                    }
                    else if (this.initialParentTileIndex == 34)
                    {
                        num5 = 4f;
                    }
                    num = @object.ParentSheetIndex;
                    switch (num)
                    {
                    case 378:
                    {
                        num4 = 10;
                        StardewValley.Object expr_270 = @object;
                        num = expr_270.ParentSheetIndex;
                        expr_270.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 379:
                    case 381:
                    case 383:
                    case 385:
                    case 387:
                    case 389:
                        break;

                    case 380:
                    {
                        num4 = 20;
                        StardewValley.Object expr_288 = @object;
                        num = expr_288.ParentSheetIndex;
                        expr_288.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 382:
                    {
                        num4 = 15;
                        StardewValley.Object expr_2B8 = @object;
                        num = expr_2B8.ParentSheetIndex;
                        expr_2B8.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 384:
                    {
                        num4 = 30;
                        StardewValley.Object expr_2A0 = @object;
                        num = expr_2A0.ParentSheetIndex;
                        expr_2A0.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 386:
                    {
                        num4 = 50;
                        StardewValley.Object expr_2D0 = @object;
                        num = expr_2D0.ParentSheetIndex;
                        expr_2D0.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 388:
                    {
                        num4 = 2;
                        StardewValley.Object expr_23B = @object;
                        num = expr_23B.ParentSheetIndex;
                        expr_23B.ParentSheetIndex = num + 1;
                        break;
                    }

                    case 390:
                    {
                        num4 = 5;
                        StardewValley.Object expr_255 = @object;
                        num = expr_255.ParentSheetIndex;
                        expr_255.ParentSheetIndex = num + 1;
                        break;
                    }

                    default:
                        if (num == 441)
                        {
                            num4 = 20;
                            collisionBehavior = new BasicProjectile.onCollisionBehavior(BasicProjectile.explodeOnImpact);
                            collisionSound    = "explosion";
                        }
                        break;
                    }
                    num = @object.category;
                    if (num == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    location.projectiles.Add(new BasicProjectile((int)(num5 * (float)(num4 + Game1.random.Next(-(num4 / 2), num4 + 2)) * (1f + who.attackIncreaseModifier)), @object.ParentSheetIndex, 0, 0, (float)(3.1415926535897931 / (double)(64f + (float)Game1.random.Next(-63, 64))), -velocityTowardPoint.X, -velocityTowardPoint.Y, new Vector2((float)(who.getStandingX() - 16), (float)(who.getStandingY() - Game1.tileSize - 8)), collisionSound, "", false, true, who, true, collisionBehavior)
                    {
                        ignoreLocationCollision = (Game1.currentLocation.currentEvent != null)
                    });
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254", new object[0]));
            }
            this.canPlaySound = true;
            who.Halt();
        }
        /// <summary>Fires a projectile.</summary>
        public void Fire(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.IndexOfMenuItemView = this.InitialParentTileIndex;

            if (this.attachments[0] == null)
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
                return;
            }

            if (this.GetPullBackRange(x, y, who) <= 4 || this.baseCanPlaySound.GetValue())
            {
                return;
            }
            this.didFire            = true;
            this.lastShotProjectile = this.attachments[0];
            SObject one = (SObject)this.attachments[0].getOne();

            if (!this.config.InfiniteAmmo)
            {
                --this.attachments[0].Stack;
            }
            if (this.attachments[0].Stack <= 0 && !this.Reload())
            {
                this.attachments[0] = null;
            }

            int num5 = 1;

            BasicProjectile.onCollisionBehavior collisionBehavior = null;
            string collisionSound = "hammer";
            float  num6           = 1f;

            if (this.InitialParentTileIndex == 33)
            {
                num6 = 2f;
            }
            else if (this.InitialParentTileIndex == 34)
            {
                num6 = 4f;
            }
            switch (one.ParentSheetIndex)
            {
            case 378:
                num5 = 10;
                ++one.ParentSheetIndex;
                break;

            case 380:
                num5 = 20;
                ++one.ParentSheetIndex;
                break;

            case 382:
                num5 = 15;
                ++one.ParentSheetIndex;
                break;

            case 384:
                num5 = 30;
                ++one.ParentSheetIndex;
                break;

            case 386:
                num5 = 50;
                ++one.ParentSheetIndex;
                break;

            case 388:
                num5 = 2;
                ++one.ParentSheetIndex;
                break;

            case 390:
                num5 = 5;
                ++one.ParentSheetIndex;
                break;

            case 441:
                num5 = 20;
                collisionBehavior = BasicProjectile.explodeOnImpact;
                collisionSound    = "explosion";
                break;
            }

            if (one.Category == -5)
            {
                collisionSound = "slimedead";
            }

            Vector2 velocity = this.GetDirection() * (15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier);

            BasicProjectile basicProjectile = new BasicProjectile(
                (int)((double)num6 * (num5 + Game1.random.Next(-(num5 / 2), num5 + 2)) *
                      (1.0 + who.attackIncreaseModifier)), one.ParentSheetIndex, 0, 0,
                (float)(Math.PI / (64.0 + Game1.random.Next(-63, 64))), velocity.X, velocity.Y,
                this.GetStartProjectilePosition(who), collisionSound, "", false, true, location, who, true,
                collisionBehavior);

            basicProjectile.IgnoreLocationCollision = Game1.currentLocation.currentEvent != null;

            location.projectiles.Add(basicProjectile);
        }
Пример #4
0
        public override bool onRelease(GameLocation location, int x, int y, Farmer who)
        {
            usingBow[who] = false;

            if (this.attachments[0] != null)
            {
                StardewValley.Object one = (StardewValley.Object) this.attachments[0].getOne();
                --this.attachments[0].Stack;
                if (this.attachments[0].Stack <= 0)
                {
                    this.attachments[0] = (StardewValley.Object)null;
                }
                int x1 = this.AimingAt.X;
                int y1 = this.AimingAt.Y;
                //int num1 = Math.Min(20, (int)Vector2.Distance(new Vector2((float)who.getStandingX(), (float)(who.getStandingY() - 64)), new Vector2((float)x1, (float)y1)) / 20);
                Vector2 velocityTowardPoint = Utility.getVelocityTowardPoint(new Point(who.getStandingX(), who.getStandingY() + 64), new Vector2((float)x1, (float)(y1 + 64)), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                //int num2 = 4;
                int heldLen = UseTime.Value;
                velocityTowardPoint *= heldLen / 100f;

                //if (num1 > num2 && !this.canPlaySound)
                {
                    int num3 = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = (BasicProjectile.onCollisionBehavior)null;
                    string collisionSound = "hammer";
                    float  num4           = 2;
                    switch (one.ParentSheetIndex)
                    {
                    case 378:
                        num3 = 10;
                        ++one.ParentSheetIndex;
                        break;

                    case 380:
                        num3 = 20;
                        ++one.ParentSheetIndex;
                        break;

                    case 382:
                        num3 = 15;
                        ++one.ParentSheetIndex;
                        break;

                    case 384:
                        num3 = 30;
                        ++one.ParentSheetIndex;
                        break;

                    case 386:
                        num3 = 50;
                        ++one.ParentSheetIndex;
                        break;

                    case 388:
                        num3 = 2;
                        ++one.ParentSheetIndex;
                        break;

                    case 390:
                        num3 = 5;
                        ++one.ParentSheetIndex;
                        break;

                    case 441:
                        num3 = 20;
                        collisionBehavior = new BasicProjectile.onCollisionBehavior(BasicProjectile.explodeOnImpact);
                        collisionSound    = "explosion";
                        break;
                    }
                    if (one.Category == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    NetCollection <Projectile> projectiles     = location.projectiles;
                    BasicProjectile            basicProjectile = new BasicProjectile((int)((double)num4 * (double)(num3 + Game1.random.Next(-(num3 / 2), num3 + 2)) * (1.0 + (double)who.attackIncreaseModifier)), one.ParentSheetIndex, 0, 0, (float)(Math.PI / (64.0 + (double)Game1.random.Next(-63, 64))), velocityTowardPoint.X, velocityTowardPoint.Y, new Vector2((float)(who.getStandingX() - 16), (float)(who.getStandingY() - 64 - 8)), collisionSound, "", false, true, location, (Character)who, true, collisionBehavior);
                    basicProjectile.IgnoreLocationCollision = Game1.currentLocation.currentEvent != null;
                    projectiles.Add((Projectile)basicProjectile);
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
            }
            return(true);
        }
Пример #5
0
 public AbigailProjectile(int damageToFarmer, int ParentSheetIndex, int bouncesTillDestruct, int tailLength, float rotationVelocity, float xVelocity, float yVelocity, Vector2 startingPosition, string collisionSound, string firingSound, bool explode, bool damagesMonsters = false, GameLocation location = null, Character firer = null, bool spriteFromObjectSheet = false, BasicProjectile.onCollisionBehavior collisionBehavior = null) : base(damageToFarmer, ParentSheetIndex, bouncesTillDestruct, tailLength, rotationVelocity, xVelocity, yVelocity, startingPosition, collisionSound, firingSound, explode, true, location, firer, true, null)
 {
     IgnoreLocationCollision = true;
     myCollisionSound        = collisionSound;
     myExplode = explode;
 }
Пример #6
0
        public BossProjectile(int damageToFarmer, int parentSheetIndex, int bouncesTillDestruct, int tailLength, float rotationVelocity, float xVelocity, float yVelocity, Vector2 startingPosition, string collisionSound, string firingSound, bool explode, bool damagesMonsters = false, GameLocation location = null, Character firer = null, bool spriteFromObjectSheet = false, BasicProjectile.onCollisionBehavior collisionBehavior = null, int debuff = -1, bool pullIn = false) : base(damageToFarmer, parentSheetIndex, bouncesTillDestruct, tailLength, rotationVelocity, xVelocity, yVelocity, startingPosition, collisionSound, firingSound, explode, damagesMonsters, location, firer, spriteFromObjectSheet, collisionBehavior)
        {
            this.debuff           = debuff;
            this.startingPosition = startingPosition;

            this.pullPlayerIn = pullIn;
        }
Пример #7
0
        public virtual void PerformFire(GameLocation location, Farmer who)
        {
            if (attachments[0] != null)
            {
                updateAimPos();
                int     mouseX          = aimPos.X;
                int     mouseY          = aimPos.Y;
                int     backArmDistance = GetBackArmDistance(who);
                Vector2 shoot_origin    = GetShootOrigin(who);
                Vector2 v = Utility.getVelocityTowardPoint(GetShootOrigin(who), AdjustForHeight(new Vector2(mouseX, mouseY)), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                if (backArmDistance > 4 && !canPlaySound)
                {
                    Object ammunition = (Object)attachments[0].getOne();
                    attachments[0].Stack--;
                    if (attachments[0].Stack <= 0)
                    {
                        attachments[0] = null;
                    }
                    int damage = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = null;
                    string collisionSound = "hammer";
                    float  damageMod      = 1f;
                    if (base.InitialParentTileIndex == 33)
                    {
                        damageMod = 2f;
                    }
                    else if (base.InitialParentTileIndex == 34)
                    {
                        damageMod = 4f;
                    }
                    switch (ammunition.ParentSheetIndex)
                    {
                    case 388:
                        damage = 2;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 390:
                        damage = 5;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 378:
                        damage = 10;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 380:
                        damage = 20;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 384:
                        damage = 30;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 382:
                        damage = 15;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 386:
                        damage = 50;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 441:
                        damage            = 20;
                        collisionBehavior = BasicProjectile.explodeOnImpact;
                        collisionSound    = "explosion";
                        break;
                    }
                    int category = ammunition.Category;
                    if (category == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    if (!Game1.options.useLegacySlingshotFiring)
                    {
                        v.X *= -1f;
                        v.Y *= -1f;
                    }
                    location.projectiles.Add(new BasicProjectile((int)(damageMod * (float)(damage + Game1.random.Next(-(damage / 2), damage + 2)) * (1f + who.attackIncreaseModifier)), ammunition.ParentSheetIndex, 0, 0, (float)(Math.PI / (double)(64f + (float)Game1.random.Next(-63, 64))), 0f - v.X, 0f - v.Y, shoot_origin - new Vector2(32f, 32f), collisionSound, "", explode: false, damagesMonsters: true, location, who, spriteFromObjectSheet: true, collisionBehavior)
                    {
                        IgnoreLocationCollision = (Game1.currentLocation.currentEvent != null || Game1.currentMinigame != null)
                    });
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
            }
            canPlaySound = true;
        }
Пример #8
0
        public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            base.IndexOfMenuItemView = base.InitialParentTileIndex;
            if (attachments[0] != null)
            {
                updateAimPos();
                int     mouseX = aimPos.X;
                int     mouseY = aimPos.Y;
                int     num    = Math.Min(20, (int)Vector2.Distance(new Vector2(who.getStandingX(), who.getStandingY() - 64), new Vector2(mouseX, mouseY)) / 20);
                Vector2 v      = Utility.getVelocityTowardPoint(new Point(who.getStandingX(), who.getStandingY() + 64), new Vector2(mouseX, mouseY + 64), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                if (num > 4 && !canPlaySound)
                {
                    Object ammunition = (Object)attachments[0].getOne();
                    attachments[0].Stack--;
                    if (attachments[0].Stack <= 0)
                    {
                        attachments[0] = null;
                    }
                    int damage = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = null;
                    string collisionSound = "hammer";
                    float  damageMod      = 1f;
                    if (base.InitialParentTileIndex == 33)
                    {
                        damageMod = 2f;
                    }
                    else if (base.InitialParentTileIndex == 34)
                    {
                        damageMod = 4f;
                    }
                    switch (ammunition.ParentSheetIndex)
                    {
                    case 388:
                        damage = 2;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 390:
                        damage = 5;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 378:
                        damage = 10;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 380:
                        damage = 20;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 384:
                        damage = 30;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 382:
                        damage = 15;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 386:
                        damage = 50;
                        ammunition.ParentSheetIndex++;
                        break;

                    case 441:
                        damage            = 20;
                        collisionBehavior = BasicProjectile.explodeOnImpact;
                        collisionSound    = "explosion";
                        break;
                    }
                    int category = ammunition.Category;
                    if (category == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    location.projectiles.Add(new BasicProjectile((int)(damageMod * (float)(damage + Game1.random.Next(-(damage / 2), damage + 2)) * (1f + who.attackIncreaseModifier)), ammunition.ParentSheetIndex, 0, 0, (float)(Math.PI / (double)(64f + (float)Game1.random.Next(-63, 64))), 0f - v.X, 0f - v.Y, new Vector2(who.getStandingX() - 16, who.getStandingY() - 64 - 8), collisionSound, "", explode: false, damagesMonsters: true, location, who, spriteFromObjectSheet: true, collisionBehavior)
                    {
                        IgnoreLocationCollision = (Game1.currentLocation.currentEvent != null)
                    });
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
            }
            canPlaySound = true;
            finish();
        }
Пример #9
0
        public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.indexOfMenuItemView = this.initialParentTileIndex;
            who.usingSlingshot       = false;
            who.canReleaseTool       = true;
            who.usingTool            = false;
            who.canMove = true;
            if (this.attachments[0] != null)
            {
                StardewValley.Object one = (StardewValley.Object) this.attachments[0].getOne();
                --this.attachments[0].Stack;
                if (this.attachments[0].Stack <= 0)
                {
                    this.attachments[0] = (StardewValley.Object)null;
                }
                int num1 = Game1.getOldMouseX() + Game1.viewport.X;
                int num2 = Game1.getOldMouseY() + Game1.viewport.Y;
                if (this.startedWithGamePad)
                {
                    Point point = Utility.Vector2ToPoint(Game1.player.getStandingPosition() + new Vector2(Game1.oldPadState.ThumbSticks.Left.X, -Game1.oldPadState.ThumbSticks.Left.Y) * (float)Game1.tileSize * 4f);
                    num1 = point.X;
                    num2 = point.Y;
                }
                int     num3 = Math.Min(20, (int)Vector2.Distance(new Vector2((float)who.getStandingX(), (float)(who.getStandingY() - Game1.tileSize)), new Vector2((float)num1, (float)num2)) / 20);
                Vector2 velocityTowardPoint = Utility.getVelocityTowardPoint(new Point(who.getStandingX(), who.getStandingY() + Game1.tileSize), new Vector2((float)num1, (float)(num2 + Game1.tileSize)), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                int     num4 = 4;
                if (num3 > num4 && !this.canPlaySound)
                {
                    int num5 = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = (BasicProjectile.onCollisionBehavior)null;
                    string collisionSound = "hammer";
                    float  num6           = 1f;
                    if (this.initialParentTileIndex == 33)
                    {
                        num6 = 2f;
                    }
                    else if (this.initialParentTileIndex == 34)
                    {
                        num6 = 4f;
                    }
                    switch (one.ParentSheetIndex)
                    {
                    case 378:
                        num5 = 10;
                        ++one.ParentSheetIndex;
                        break;

                    case 380:
                        num5 = 20;
                        ++one.ParentSheetIndex;
                        break;

                    case 382:
                        num5 = 15;
                        ++one.ParentSheetIndex;
                        break;

                    case 384:
                        num5 = 30;
                        ++one.ParentSheetIndex;
                        break;

                    case 386:
                        num5 = 50;
                        ++one.ParentSheetIndex;
                        break;

                    case 388:
                        num5 = 2;
                        ++one.ParentSheetIndex;
                        break;

                    case 390:
                        num5 = 5;
                        ++one.ParentSheetIndex;
                        break;

                    case 441:
                        num5 = 20;
                        collisionBehavior = new BasicProjectile.onCollisionBehavior(BasicProjectile.explodeOnImpact);
                        collisionSound    = "explosion";
                        break;
                    }
                    if (one.category == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    List <Projectile> projectiles     = location.projectiles;
                    BasicProjectile   basicProjectile = new BasicProjectile((int)((double)num6 * (double)(num5 + Game1.random.Next(-(num5 / 2), num5 + 2)) * (1.0 + (double)who.attackIncreaseModifier)), one.ParentSheetIndex, 0, 0, (float)(Math.PI / (64.0 + (double)Game1.random.Next(-63, 64))), -velocityTowardPoint.X, -velocityTowardPoint.Y, new Vector2((float)(who.getStandingX() - 16), (float)(who.getStandingY() - Game1.tileSize - 8)), collisionSound, "", false, true, (Character)who, true, collisionBehavior);
                    int num7 = Game1.currentLocation.currentEvent != null ? 1 : 0;
                    basicProjectile.ignoreLocationCollision = num7 != 0;
                    projectiles.Add((Projectile)basicProjectile);
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
            }
            this.canPlaySound = true;
            who.Halt();
        }
 public IndicatorProjectile(int v1, int v2, int v3, int v4, float v5, float v6, float v7, Vector2 vector2, string v8, string v9, bool v10, bool v11, GameLocation currentLocation, Farmer player, bool v12, BasicProjectile.onCollisionBehavior p) : base(v1, v2, v3, v4, v5, v6, v7, vector2, v8, v9, v10, v11, currentLocation, player, v12, p)
 {
 }
Пример #11
0
        public static bool PerformFire_Prefix(Slingshot __instance, ref GameLocation location, ref Farmer who)
        {
            if (__instance != null &&
                (__instance.hasEnchantmentOfType <Enchantments.PreservingEnchantment>() ||
                 __instance.hasEnchantmentOfType <SwiftEnchantment>()))
            {
                AccessTools.FieldRef <Slingshot, NetPoint> aimPos       = AccessTools.FieldRefAccess <Slingshot, NetPoint>("aimPos");
                AccessTools.FieldRef <Slingshot, bool>     canPlaySound = AccessTools.FieldRefAccess <Slingshot, bool>("canPlaySound");
                var updateAimPosMethod = typeof(Slingshot).GetMethod("updateAimPos", BindingFlags.NonPublic | BindingFlags.Instance);

                if (__instance.attachments[0] != null)
                {
                    updateAimPosMethod.Invoke(__instance, null);
                    int     mouseX          = aimPos(__instance).X;
                    int     mouseY          = aimPos(__instance).Y;
                    int     backArmDistance = __instance.GetBackArmDistance(who);
                    Vector2 shoot_origin    = __instance.GetShootOrigin(who);
                    Vector2 v = Utility.getVelocityTowardPoint(__instance.GetShootOrigin(who), __instance.AdjustForHeight(new Vector2(mouseX, mouseY)), (15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                    if (backArmDistance > 4 && !canPlaySound(__instance))
                    {
                        StardewValley.Object ammunition = (StardewValley.Object)__instance.attachments[0].getOne();
                        if (__instance.hasEnchantmentOfType <Enchantments.PreservingEnchantment>() && Game1.random.NextDouble() < 0.5)
                        {
                            __instance.attachments[0].Stack--;
                        }

                        if (__instance.attachments[0].Stack <= 0)
                        {
                            __instance.attachments[0] = null;
                        }

                        int damage = 1;
                        BasicProjectile.onCollisionBehavior collisionBehavior = null;
                        string collisionSound = "hammer";

                        float damageMod = 1f;
                        if (__instance.InitialParentTileIndex == 33)
                        {
                            damageMod = 2f;
                        }
                        else if (__instance.InitialParentTileIndex == 34)
                        {
                            damageMod = 3f;                                                                         //new damage
                        }
                        else if (__instance.InitialParentTileIndex == ModEntry.Instance.config.InfinitySlingshotId) //Infinity Sling
                        {
                            damageMod = 4f;
                        }

                        switch (ammunition.ParentSheetIndex)
                        {
                        case 388:
                            damage = 2;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 390:
                            damage = 5;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 378:
                            damage = 10;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 380:
                            damage = 20;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 384:
                            damage = 30;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 382:
                            damage = 15;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 386:
                            damage = 50;
                            ammunition.ParentSheetIndex++;
                            break;

                        case 441:
                            damage            = 20;
                            collisionBehavior = BasicProjectile.explodeOnImpact;
                            collisionSound    = "explosion";
                            break;
                        }

                        if (ammunition.Category == -5)
                        {
                            collisionSound = "slimedead";
                        }

                        if (!Game1.options.useLegacySlingshotFiring)
                        {
                            v.X *= -1f;
                            v.Y *= -1f;
                        }

                        if (__instance.hasEnchantmentOfType <SwiftEnchantment>())
                        {
                            v.X *= 2;
                            v.Y *= 2;
                        }

                        BasicProjectile projectile = new BasicProjectile(
                            (int)(damageMod * (damage + Game1.random.Next(-(damage / 2), damage + 2)) * (1f + who.attackIncreaseModifier)),
                            ammunition.ParentSheetIndex,
                            0,
                            0,
                            (float)(Math.PI / (64f + Game1.random.Next(-63, 64))),
                            0f - v.X,
                            0f - v.Y,
                            shoot_origin - new Vector2(32f, 32f),
                            collisionSound,
                            "",
                            explode: false,
                            damagesMonsters: true,
                            location,
                            who,
                            spriteFromObjectSheet: true,
                            collisionBehavior)
                        {
                            IgnoreLocationCollision = (Game1.currentLocation.currentEvent != null || Game1.currentMinigame != null)
                        };

                        location.projectiles.Add(projectile);
                    }
                }
                else
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
                }
                canPlaySound(__instance) = true;
                return(false);
            }
            else
            {
                return(true);
            }
        }