コード例 #1
0
        public bool mine(Game game, ItemStack stack, int xTile, int yTile, int distance, World.TileDepth tileDepth)
        {
            int del = delay;

            Tile.Material mat = game.currentWorld.getTileObjectNoCheck(xTile, yTile, tileDepth).material;

            if (mat == Tile.Material.furniture)
            {
                del = 20;
            }
            int power = getPower(mat);

            if (power <= 0)
            {
                return(false);
            }
            game.inventory.t++;
            if (game.inventory.t >= del && distance <= reach)
            {
                game.inventory.t = 0;
                Tile tile = game.currentWorld.getTileObject(xTile, yTile, tileDepth);
                if (tile.index != Tile.TileAir.index)
                {
                    SoundEffectPlayer.playSoundWithRandomPitch(SoundEffectPlayer.SoundTink);
                    int m = ((int)game.currentWorld.getCrackNoCheck(xTile, yTile));
                    if (m == 0)
                    {
                        game.inventory.t = 0;
                    }
                    int n   = m + power;
                    int max = (Tile.getTileObject(tile.index)).toughness;
                    if (n > max)
                    {
                        n = max;
                    }
                    game.currentWorld.setCrackNoCheck(xTile, yTile, (byte)n);

                    if (n == max)
                    {
                        if (game.currentWorld.mineTile(xTile, yTile, this, tileDepth))
                        {
                            game.currentWorld.setCrackNoCheck(xTile, yTile, 0);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
 public int getPower(Tile.Material material)
 {
     return(Game.instance.inventory.applyMiningPowerModifier(powers[(int)material]));
 }