This commit is contained in:
muqing 2024-08-25 17:55:05 +08:00
commit c78af315c6
14 changed files with 1265 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored Normal file
View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

BIN
.vscode.zip Normal file

Binary file not shown.

82
Chouka.cs Normal file
View File

@ -0,0 +1,82 @@

namespace Debug;
public class ChouKa
{
// 10 20 30 50 60 70 80 90
int currentsize = 0;
int baodinum = 70; //第一次保底80 往后就用随机数80 ~ 90
int waisize = 0; //歪的几率 第一次肯定不歪
string[] putong = ["1", "2", "3"];//普通物品
string[] waile = ["薄荷", "铁锈会员10天"];// 设置歪的物品
string baozan = "name";//设置本次UP池 精品 只能有一个
//创建随机数生成器
private readonly Random random = new();
public ChouKa()
{
// 清除控制台屏幕
Console.Clear();
do
{
Console.WriteLine("请输入抽卡次数 1-10/0返回主页");
var input = Console.ReadLine(); // 这一行会读取用户的输入
if (int.TryParse(input, out int number))
{
if (number == 0)
{
break;
}
if (number > 0 && number < 11)
{
for (int i = 0; i < number; i++)
{
Start();
}
}
}
} while (true);
// Console.WriteLine("退出抽卡系统,请按任意键结束");
// 清除控制台屏幕
Console.Clear();
}
public void Start()
{
// 生成一个1到100之间的随机数
var randomNumber = 0;
do
{
randomNumber = random.Next(1, 101); // 生成1到100之间的随机数
// Console.WriteLine(randomNumber + " " + random.NextDouble());
// 如果生成的数大于70则有一定概率重新生成
if (randomNumber > baodinum && random.NextDouble() > currentsize / 100)
{
randomNumber = -1; // 使用-1作为标记表示需要重新生成
}
} while (randomNumber == -1); // 如果标记为-1则重新生成
currentsize++;
if (randomNumber < baodinum && currentsize < baodinum)
{
Console.Write(" 普通:" + putong[new Random().Next(0, putong.Length)] + " ");//普通抽卡结果
}
else
{
int v = random.Next(0, 6);
// 判断是否歪
if (v < waisize)
{
int v1 = new Random().Next(0, waile.Length);
Console.Write(" 歪了:" + waile[v1] + " ");
waisize--;
}
else
{
Console.Write(" 精品:" + baozan + " ");
waisize = new Random().Next(0, 6);
baodinum = random.Next(80, 91);
currentsize = 0;
}
}
}
}

14
Debug.csproj Normal file
View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NAudio" Version="2.2.1" />
</ItemGroup>
</Project>

25
Debug.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Debug", "Debug.csproj", "{50C9FAAA-6ECF-4CFC-991A-1FF8BDA1816C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{50C9FAAA-6ECF-4CFC-991A-1FF8BDA1816C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50C9FAAA-6ECF-4CFC-991A-1FF8BDA1816C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50C9FAAA-6ECF-4CFC-991A-1FF8BDA1816C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50C9FAAA-6ECF-4CFC-991A-1FF8BDA1816C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {75A149FC-155B-4A84-A968-B40C51A2D237}
EndGlobalSection
EndGlobal

20
Debug.xsd Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Project">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyGroup">
<xs:complexType>
<xs:sequence>
<xs:element name="OutputType" type="xs:string" />
<xs:element name="TargetFramework" type="xs:string" />
<xs:element name="ImplicitUsings" type="xs:string" />
<xs:element name="Nullable" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Sdk" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>

204
Mod.cs Normal file
View File

@ -0,0 +1,204 @@
using Debug;
using Microsoft.VisualBasic;
using Microsoft.Win32;
/// <summary>
/// 模组搜索引擎操作
/// </summary>
public class Mod
{
private static DateTime StartTime;
/// <summary>
/// 结束时间
/// </summary>
private static void EndTime()
{
Console.WriteLine("结束" + (DateTime.Now - StartTime).TotalMilliseconds + "ms");
}
private readonly bool Isdot = true;
private readonly List<string> ExcludeFile = [
"Android", "androidword", "Java",
"Linux", "linuxword", "Mac",
"Windows", "Windows 10", "Steam",
"Genshin Impact Game", "Godot", "Gradle",
"WeGame", "Mental Omega", "WeGameApps",
"ramboplayGame", "QQ", "QQWORD","Microsoft SDKs","Creator","editors","AndroidSDK","SDK","Pr","PR","PS","Ps","WE",
"androidstudioword","xshell7"
];
public string FileDir = string.Empty;
public Mod()
{
Console.Clear();
var SearchMode = 1;
do
{
Program.printfLine("输入 1.默认搜索 2.只执行steam搜索 3.只执行全盘搜索 0.返回主页");
var v = Console.ReadLine();
if (int.TryParse(v, out int i))
{
SearchMode = i;
if (SearchMode == 0)
{
Console.Clear();
break;
}
// StartTime = DateTime.Now;
if (SearchMode == 1 || SearchMode == 2)
{
steam();//先看看steam中有没有安装铁锈战争
//steam中没有安装铁锈战争扫全盘
}
if (SearchMode == 1 || SearchMode == 3)
{
if (FileDir == string.Empty)
{
init();
}
}
if (!string.IsNullOrEmpty(FileDir))
{
Program.printfLine("找到了:" + FileDir);
}
}
} while (true);
}
private void steam()
{
var steamPath = GetSteamInstallPath();
if (!string.IsNullOrEmpty(steamPath))
{
string v = Path.Combine(steamPath, "steamapps\\common\\Rusted Warfare");
// Program.printfLine("找到了:" + v);
if (Directory.Exists(v))
{
FileDir = v;
// EndTime();
}
}
}
private void init()
{
var allDrives = DriveInfo.GetDrives();
foreach (var d in allDrives)
{
Console.WriteLine();
if (d.IsReady == true)
{
var name = d.Name;
if (ExcludeFile.Contains(name))
{
continue;
}
if (name.Equals("C:\\"))
{
FileSearch(name);
}
else
{
if (Directory.Exists(name + "/Rusted Warfare"))
{
EndTime();
break;
}
else
{
FileSearch(name);
}
}
}
}
}
public bool IsSearch = true;
private void FileSearch(string path)
{
try
{
foreach (var file in Directory.EnumerateDirectories(path))
{
if (!IsSearch)
{
return;
}
var name = Path.GetFileName(file);
if (Isdot && name.StartsWith("."))
{
continue;
}
if (ExcludeFile.Contains(name))
{
continue;
}
if (name.Equals("Rusted Warfare"))
{
FileDir = file;
EndTime();
break;
}
else
{
FileSearch(file);
}
}
}
catch (UnauthorizedAccessException)
{
Console.WriteLine($"Access denied for: {path}");
}
catch (Exception ex)
{
Console.WriteLine($"Error accessing directory '{path}': {ex.Message}");
}
}
private static string GetSteamInstallPath()
{
var installPath = GetInstallPathFromKey(@"Software\Valve\Steam");
if (string.IsNullOrEmpty(installPath))
{
installPath = GetInstallPathFromKey(@"SOFTWARE\Wow6432Node\Valve\Steam");
}
return installPath;
string GetInstallPathFromKey(string subKey)
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(subKey))
{
if (key != null)
{
object path = key.GetValue("InstallPath");
if (path != null)
{
return (string)path;
}
}
}
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey))
{
if (key != null)
{
var path = key.GetValue("InstallPath");
if (path != null)
{
return (string)path;
}
}
}
return string.Empty;
}
}
}

217
ModelingMusic/Music.cs Normal file
View File

@ -0,0 +1,217 @@
using System.Diagnostics;
namespace Debug.ModelingMusic;
public class Music
{
//选择的模式
public static int mode = 0;
public Music()
{
Console.Clear();
do
{
Program.printfLine("模拟音游 1.0 by ");
Program.printfLine("1.启动 2.测试下落 3.指定字符串 4.随机指定字符串下落 5.扬声器节奏 0.退出");
var v = Console.ReadLine();
if (int.TryParse(v, out int i))
{
mode = i;
if (i == 0)
{
//退出程序
Environment.Exit(0);
return;
}
Init().GetAwaiter().GetResult(); // 启动
return;
}
} while (true);
}
private int consoleWidth = 0, consoleHeight = 0;
private async Task Init()
{
Console.CursorVisible = false; // 隐藏光标
Console.Clear();
Program.printf("加载资源中");
// 获取控制台的大小
consoleWidth = Console.WindowWidth;
consoleHeight = Console.WindowHeight - 1;
for (int i = 0; i < 3; i++)
{
Program.printf("·");
await Task.Delay(300);
}
Console.WriteLine();
Program.printfLine("加载完成");
await Task.Delay(500);
Console.Clear();
setCharArry();
switch (mode)
{//默认模式
case 1:
new Thread(MusicDebug.Default).Start();
break;
case 2:
new Thread(MusicDebug.DebugDefault).Start();
break;
case 3:
case 4:
{
Console.CursorVisible = true; // 隐藏光标
Console.WriteLine("请输入字符串");
string? v = Console.ReadLine();
//string转成char[]
char[] ch = v!.ToCharArray();
if (mode == 3)
{
//指定字符串模式
new Thread(() => MusicDebug.DesignateDown(ch)).Start();
}
else
{
//随机指定字符串下落
new Thread(() => MusicDebug.DesignateRandmoDown(ch)).Start();
}
break;
}
case 5:
new Thread(MusicDebug.MusicRhythm).Start();
//MusicDebug.();
break;
default:
break;
}
Console.CursorVisible = false; // 隐藏光标
new Thread(PrintCharArray).Start();
// 等待用户按下任意键后退出
// Console.ReadKey();
}
/// <summary>
/// 随机字符下落
/// </summary>
private static readonly Random random = new();
//常量
public const char ShowChar = ' ';
//Y,X
public static readonly Point[,] chars = new Point[10, 30];
public static void Down(char a)
{
// 随机生成字符出现的初始位置
// 设置光标位置
ConsoleColor Color = ConsoleColor.White;
int v = random.Next(0, 2);
switch (v)
{
case 0:
Color = ConsoleColor.Red;
break;
case 1:
Color = ConsoleColor.Blue;
break;
}
// 让字符从初始位置下落
int x = random.Next(0, chars.GetLength(1));
for (int y = 0; y < chars.GetLength(0); y++) // 注意这里使用consoleHeight
{
// 移动到下一行
chars[y, x].Char = a;
if (y > 0)
{
chars[y - 1, x].Char = ShowChar;
}
chars[y, x].Color = Color;
Thread.Sleep(random.Next(60, 120)); // 控制字符下落速度
}
Thread.Sleep(50);
chars[chars.GetLength(0) - 1, x].Char = ShowChar;
}
private static long item = 0;
// 定义一个方法来打印二维字符数组
public static void PrintCharArray()
{
var stopwatch = new Stopwatch();
int frameCount = 0;
double totalTime = 0;
int i; int j;
var a = chars.GetLength(0);
var b = chars.GetLength(1);
while (true)
{
stopwatch.Restart();
Console.Clear(); Console.SetCursorPosition(0, 0);
for (i = 0; i < a; i++)
{
for (j = 0; j < b; j++)
{
Console.ForegroundColor = chars[i, j].Color;
Console.Write($" {chars[i, j].Char} ");
item++;
if (item > 100000)
{
GC.Collect(); item = 0;
}
}
Console.WriteLine();
}
switch (new Random().Next(0, 2))
{
case 0:
Console.ForegroundColor = ConsoleColor.Red;
break;
case 1:
Console.ForegroundColor = ConsoleColor.Blue;
break;
}
for (i = 0; i < b; i++)
{
Console.Write("---");
}
Console.ResetColor();
Console.SetCursorPosition(0, 1);// 设定光标位置到第二行
// 停止计时并计算本帧的处理时间
stopwatch.Stop();
double elapsedMilliseconds = stopwatch.Elapsed.TotalMilliseconds;
totalTime += elapsedMilliseconds;
frameCount++;
// 计算帧率
double fps = frameCount / (totalTime / 1000.0);
Console.WriteLine($" {fps:0} FPS");
// 保持每秒约16.67ms即大约60 FPS的间隔
// Thread.Sleep(Math.Max(0, 60 - (int)elapsedMilliseconds));
//死方法 不知道为什么 控制台限制60 帧这样闪烁不会太严重
Thread.Sleep(100);
}
}
private void setCharArry()
{
for (int i = 0; i < chars.GetLength(0); i++)
{
for (int j = 0; j < chars.GetLength(1); j++)
{
chars[i, j] = new Point(); // 初始化每个元素
}
// Console.WriteLine();
}
}
}

183
ModelingMusic/MusicDebug.cs Normal file
View File

@ -0,0 +1,183 @@
using NAudio.Wave;
namespace Debug.ModelingMusic;
public class MusicDebug
{
/// <summary>
/// 默认模式
/// </summary>
public static void Default()
{
do
{
var keyInfo = Console.ReadKey(true);
// // 输出按下的键的信息,这里只是为了演示
if (keyInfo.Key == ConsoleKey.Escape)
{
Console.Clear();
//关闭程序
Environment.Exit(0);
break;
}
char keyChar = keyInfo.KeyChar;
if ((keyChar >= 'A' && keyChar <= 'Z') || (keyChar >= 'a' && keyChar <= 'z'))
{
new Thread(() => Music.Down(keyChar)).Start();
}
} while (true);
}
/// <summary>
/// 随机下落测试模式
/// </summary>
public static void DebugDefault()
{
Console.Clear();
Console.CursorVisible = false; // 隐藏光标
var random = new Random();
while (true)
{
//随机生成 a-z和A-Z
var ch = (char)(random.Next(26) + 65);
new Thread(() => Music.Down(ch)).Start();
//随机暂停
Thread.Sleep(random.Next(1000));
}
}
/// <summary>
/// 指定下落字符串
/// </summary>
public static void DesignateDown(char[] ch)
{
Console.Clear();
var random = new Random();
while (true)
{
for (int v = 0; v < ch.Length; v++)
{
new Thread(() => Music.Down(ch[v])).Start();
//随机暂停
Thread.Sleep(random.Next(1000));
}
}
}
/// <summary>
/// 随机指定下落字符串
/// </summary>
public static void DesignateRandmoDown(char[] ch)
{
Console.Clear();
var random = new Random();
while (true)
{
int v = random.Next(0, ch.Length);
new Thread(() => Music.Down(ch[v])).Start();
//随机暂停
Thread.Sleep(random.Next(600));
}
}
public static void MusicRhythm()
{
WasapiLoopbackCapture cap = new WasapiLoopbackCapture();
cap.DataAvailable += (sender, e) =>
{
float[] allSamples = Enumerable
.Range(0, e.BytesRecorded / 4)
.Select(i => BitConverter.ToSingle(e.Buffer, i * 4))
.ToArray();
int channelCount = cap.WaveFormat.Channels;
float[][] channelSamples = Enumerable
.Range(0, channelCount)
.Select(channel => Enumerable
.Range(0, allSamples.Length / channelCount)
.Select(i => allSamples[channel + i * channelCount])
.ToArray())
.ToArray();
float[] averageSamples = Enumerable
.Range(0, allSamples.Length / channelCount)
.Select(index => Enumerable
.Range(0, channelCount)
.Select(channel => channelSamples[channel][index])
.Average())
.ToArray();
float rmsVolume = CalculateRMS(averageSamples);
//Console.Clear();
DrawVolumeBar(rmsVolume);
//Console.WriteLine($"RMS Volume: {rmsVolume}");
Thread.Sleep(100);
};
cap.StartRecording();
Console.ReadKey();
}
static float CalculateRMS(float[] samples)
{
if (samples.Length == 0) return 0;
float sumOfSquares = samples.Sum(sample => sample * sample);
return (float)Math.Sqrt(sumOfSquares / samples.Length);
}
static void DrawVolumeBar(float rmsVolume)
{
// Console.Write(rmsVolume);
int barLength = Music.chars.GetLength(1); // 控制条长度
int filledLength = Math.Min((int)(rmsVolume * 1000), barLength);
//Console.WriteLine($"[{bar}]");
// 在数组的最后一行Y=9绘制音量条
for (int x = 0; x < Music.chars.GetLength(1); x++)
{
Music.chars[9, x].Color = ConsoleColor.DarkCyan;
if (x < filledLength)
{
Music.chars[9, x].Char = '#'; // 绘制音量条
}
else
{
Music.chars[9, x].Char = Music.ShowChar;
}
}
}
public static void MusicRhythm(FileInfo file)
{
// 创建一个 WasapiLoopbackCapture 对象来捕获系统音频输出
using (var capture = new WasapiLoopbackCapture())
{
// 创建一个 WaveFileWriter 用于保存捕获的音频到文件
using (var writer = new WaveFileWriter(file.FullName, capture.WaveFormat))
{
// 订阅 DataAvailable 事件,处理捕获到的音频数据
capture.DataAvailable += (s, e) =>
{
// 将捕获的音频数据写入文件
writer.Write(e.Buffer, 0, e.BytesRecorded);
};
// 启动音频捕获
capture.StartRecording();
Console.WriteLine("正在捕获音频... 按任意键停止。");
Console.ReadKey();
// 停止音频捕获
capture.StopRecording();
}
}
}
}

View File

@ -0,0 +1,6 @@

namespace Debug.ModelingMusic;
public class MusicForm
{
}

23
ModelingMusic/Point.cs Normal file
View File

@ -0,0 +1,23 @@

namespace Debug.ModelingMusic;
public partial class Point
{
public ConsoleColor Color = Console.ForegroundColor;
public char Char = Music.ShowChar;
public Point()
{
int v = new Random().Next(0, 2);
switch (v)
{
case 0:
Color = ConsoleColor.Red;
break;
case 1:
Color = ConsoleColor.Blue;
break;
}
}
}

64
Program.cs Normal file
View File

@ -0,0 +1,64 @@

using System.Diagnostics;
using System.Runtime.InteropServices;
using Debug.ModelingMusic;
namespace Debug;
/// <summary>
/// 主程序入口 参考 https://blog.csdn.net/oscar999/article/details/141370223
/// 在VS Code的终端中使用dotnet build命令来编译项目。这将在项目目录中生成一个bin文件夹其中包含编译后的程序集。
/// 使用dotnet run命令来运行项目。这将编译项目如果尚未编译并运行编译后的程序。
/// </summary>
public class Program
{
public static void printf(object a)
{
Console.Write(a);
}
public static void printfLine(object a)
{
Console.WriteLine(a);
}
[DllImport("kernel32.dll")]
private static extern bool SetConsoleTitle(string title);
//开始计时
public static void Main(string[] args)
{
// 设置控制台标题为一个独特的字符串
SetConsoleTitle("Tools");
_ = new Program();
}
public Program()
{
do
{
printfLine("请选择你要执行的操作:"); printf(" 0.退出 ");
printf(" 1.抽拉 "); printf(" 2.铁锈位置搜索引擎 ");
Console.WriteLine();
var v = Console.ReadLine();
if (int.TryParse(v, out var i))
{
switch (i)
{
case 0:
Environment.Exit(0);
break;
case 1:
_ = new ChouKa();
break;
case 2:
_ = new Mod();
break;
case 3:
_ = new Music();
return;
default:
printfLine("还没有这个功能");
break;
}
}
} while (true);
}
}

1
README.md Normal file
View File

@ -0,0 +1 @@
# Debug