Ejemplo n.º 1
0
        public virtual void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.lastUser = who;
            short seed = (short)Game1.random.Next((int)short.MinValue, 32768);

            if (Game1.IsClient && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                ToolDescription indexFromTool = ToolFactory.getIndexFromTool(this);
                Game1.client.sendMessage((byte)7, new object[7]
                {
                    (object)indexFromTool.index,
                    (object)indexFromTool.upgradeLevel,
                    (object)(short)x,
                    (object)(short)y,
                    (object)location.name,
                    (object)(byte)who.FacingDirection,
                    (object)seed
                });
            }
            else if (Game1.IsServer && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                MultiplayerUtility.broadcastToolAction(this, x, y, location.name, (byte)who.FacingDirection, seed, who.uniqueMultiplayerID);
            }
            if (this.isHeavyHitter() && !(this is MeleeWeapon))
            {
                Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 4.0), (float)(100 + Game1.random.Next(50)));
                location.damageMonster(new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), this.upgradeLevel + 1, (this.upgradeLevel + 1) * 3, false, who);
            }
            if (!(this is MeleeWeapon) || who.UsingTool && Game1.mouseClickPolling < 50 && ((this as MeleeWeapon).type != 1 && (this as MeleeWeapon).initialParentTileIndex != 47) && (MeleeWeapon.timedHitTimer <= 0 && who.FarmerSprite.indexInCurrentAnimation == 5 && (double)who.FarmerSprite.timer < (double)who.FarmerSprite.interval / 4.0))
            {
                return;
            }
            if ((this as MeleeWeapon).type == 2 && (this as MeleeWeapon).isOnSpecial)
            {
                (this as MeleeWeapon).doClubFunction(who);
            }
            else
            {
                if (who.FarmerSprite.indexInCurrentAnimation <= 0)
                {
                    return;
                }
                MeleeWeapon.timedHitTimer = 500;
            }
        }
Ejemplo n.º 2
0
        // Token: 0x060007B1 RID: 1969 RVA: 0x000A8560 File Offset: 0x000A6760
        public virtual void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.lastUser = who;
            short seed = (short)Game1.random.Next(-32768, 32768);

            if (Game1.IsClient && who.Equals(Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                ToolDescription t = ToolFactory.getIndexFromTool(this);
                Game1.client.sendMessage(7, new object[]
                {
                    t.index,
                    t.upgradeLevel,
                    (short)x,
                    (short)y,
                    location.name,
                    (byte)who.FacingDirection,
                    seed
                });
            }
            else if (Game1.IsServer && who.Equals(Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                MultiplayerUtility.broadcastToolAction(this, x, y, location.name, (byte)who.FacingDirection, seed, who.uniqueMultiplayerID);
            }
            if (this.isHeavyHitter() && !(this is MeleeWeapon))
            {
                Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 4.0), (float)(100 + Game1.random.Next(50)));
                location.damageMonster(new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), this.upgradeLevel + 1, (this.upgradeLevel + 1) * 3, false, who);
            }
            if (this is MeleeWeapon && (!who.UsingTool || Game1.mouseClickPolling >= 50 || (this as MeleeWeapon).type == 1 || (this as MeleeWeapon).initialParentTileIndex == 47 || MeleeWeapon.timedHitTimer > 0 || who.FarmerSprite.indexInCurrentAnimation != 5 || who.FarmerSprite.timer >= who.FarmerSprite.interval / 4f))
            {
                if ((this as MeleeWeapon).type == 2 && (this as MeleeWeapon).isOnSpecial)
                {
                    (this as MeleeWeapon).doClubFunction(who);
                    return;
                }
                if (who.FarmerSprite.indexInCurrentAnimation > 0)
                {
                    MeleeWeapon.timedHitTimer = 500;
                }
            }
        }