新增说话&控制台新增功能

This commit is contained in:
ZouJin 2023-01-26 23:15:37 +08:00
parent 2babad03a2
commit 02009313ab
22 changed files with 236 additions and 53 deletions

View File

@ -49,7 +49,7 @@ namespace VPet_Simulator.Core
ToolBar = new ToolBar(this);
ToolBar.Visibility = Visibility.Collapsed;
UIGrid.Children.Add(ToolBar);
MsgBar = new MessageBar();
MsgBar = new MessageBar(this);
MsgBar.Visibility = Visibility.Collapsed;
UIGrid.Children.Add(MsgBar);
Core.TouchEvent.Add(new TouchArea(Core.Graph.GraphConfig.TouchHeadLocate, Core.Graph.GraphConfig.TouchHeadSize, DisplayTouchHead));
@ -71,10 +71,6 @@ namespace VPet_Simulator.Core
MoveTimer.AutoReset = false;
}
public void Say(string text)
{
MsgBar.Show(Core.Save.Name, text);
}
private void MoveTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
string str = DisplayType.ToString();
@ -131,11 +127,18 @@ namespace VPet_Simulator.Core
rasetype = -1;
DisplayRaising();
}
else if (SmartMove)
else
{
MoveTimer.AutoReset = true;
SmartMoveTimer.Stop();
SmartMoveTimer.Start();
//if (MsgBar.Visibility == Visibility.Visible)
//{
// MsgBar.ForceClose();
//}
if (SmartMove)
{
MoveTimer.AutoReset = true;
SmartMoveTimer.Stop();
SmartMoveTimer.Start();
}
}
}

View File

@ -53,10 +53,12 @@ namespace VPet_Simulator.Core
Display(GraphCore.GraphType.Crawl_Right_C_End, EndAction);
return true;
case GraphType.Fall_Left_B_Loop:
Display(GraphCore.GraphType.Fall_Left_C_End, EndAction);
Display(GraphCore.GraphType.Fall_Left_C_End,
() => Display(GraphCore.GraphType.Climb_Up_Left, EndAction));
return true;
case GraphType.Fall_Right_B_Loop:
Display(GraphCore.GraphType.Fall_Right_C_End, EndAction);
Display(GraphCore.GraphType.Fall_Right_C_End,
() => Display(GraphCore.GraphType.Climb_Up_Right, EndAction));
return true;
case GraphType.Walk_Left_B_Loop:
Display(GraphCore.GraphType.Walk_Left_C_End, EndAction);
@ -97,7 +99,6 @@ namespace VPet_Simulator.Core
ig2.IsContinue = true;
return;
}
Core.Graph.RndGraph.Clear();
Display(GraphCore.GraphType.Touch_Head_A_Start, () =>
Display(GraphCore.GraphType.Touch_Head_B_Loop, () =>
Display(GraphCore.GraphType.Touch_Head_C_End, DisplayNomal
@ -111,7 +112,6 @@ namespace VPet_Simulator.Core
{
looptimes = 0;
CountNomal = 0;
Core.Graph.RndGraph.Clear();
Display(GraphCore.GraphType.Boring_A_Start, DisplayBoringing);
}
/// <summary>
@ -132,7 +132,6 @@ namespace VPet_Simulator.Core
{
looptimes = 0;
CountNomal = 0;
Core.Graph.RndGraph.Clear();
Display(GraphCore.GraphType.Squat_A_Start, DisplaySquating);
}
/// <summary>
@ -152,7 +151,6 @@ namespace VPet_Simulator.Core
{
looptimes = 0;
CountNomal = 0;
Core.Graph.RndGraph.Clear();
if (force)
Display(GraphCore.GraphType.Sleep_A_Start, DisplaySleepingForce);
else
@ -969,9 +967,10 @@ namespace VPet_Simulator.Core
/// </summary>
/// <param name="Type">动画类型</param>
/// <param name="EndAction">动画结束后操作</param>
public void Display(GraphType Type, Action EndAction = null)//, bool StoreRnd = false)
/// <param name="storernd">是否储存随机数字典</param>
public void Display(GraphType Type, Action EndAction = null, bool storernd = false)
{
Display(Core.Graph.FindGraph(Type, Core.Save.Mode), EndAction);
Display(Core.Graph.FindGraph(Type, Core.Save.Mode, storernd), EndAction);
}
bool petgridcrlf = true;
/// <summary>

View File

@ -17,13 +17,25 @@ namespace VPet_Simulator.Core
public const int LoopMax = 10;
public const int LoopMid = 7;
public const int LoopMin = 5;
public const int TreeRND = 4;
public const int TreeRND = 5;
public Timer EventTimer = new Timer(15000)
{
AutoReset = true,
Enabled = true
};
public void Say(string text)
{
Display(GraphCore.GraphType.Say_A_Start, () =>
{
Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text));
Saying();
});
}
public void Saying()
{
Display(GraphCore.GraphType.Say_B_Loop, Saying);
}
private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
@ -13,6 +14,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Timer = System.Timers.Timer;
namespace VPet_Simulator.Core
{
@ -21,12 +23,14 @@ namespace VPet_Simulator.Core
/// </summary>
public partial class MessageBar : UserControl, IDisposable
{
public MessageBar()
Main m;
public MessageBar(Main m)
{
InitializeComponent();
EndTimer.Elapsed += EndTimer_Elapsed;
ShowTimer.Elapsed += ShowTimer_Elapsed;
CloseTimer.Elapsed += CloseTimer_Elapsed;
this.m = m;
}
private void CloseTimer_Elapsed(object sender, ElapsedEventArgs e)
@ -35,7 +39,8 @@ namespace VPet_Simulator.Core
{
Dispatcher.Invoke(() => this.Visibility = Visibility.Collapsed);
EndAction?.Invoke();
}else
}
else
{
Dispatcher.Invoke(() => Opacity -= 0.02);
}
@ -50,6 +55,11 @@ namespace VPet_Simulator.Core
}
else
{
Task.Run(() =>
{
Thread.Sleep(timeleft * 50);
m.Display(GraphCore.GraphType.Say_C_End, m.DisplayNomal);
});
ShowTimer.Stop();
EndTimer.Start();
}
@ -65,9 +75,14 @@ namespace VPet_Simulator.Core
}
public Timer EndTimer = new Timer() { Interval = 100 };
public Timer ShowTimer = new Timer() { Interval = 20 };
public Timer ShowTimer = new Timer() { Interval = 40 };
public Timer CloseTimer = new Timer() { Interval = 10 };
int timeleft;
/// <summary>
/// 显示消息
/// </summary>
/// <param name="name">名字</param>
/// <param name="text">内容</param>
public void Show(string name, string text)
{
TText.Text = "";
@ -94,11 +109,17 @@ namespace VPet_Simulator.Core
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
EndTimer.Stop(); ShowTimer.Stop();CloseTimer.Close();
ForceClose();
}
/// <summary>
/// 强制关闭
/// </summary>
public void ForceClose()
{
EndTimer.Stop(); ShowTimer.Stop(); CloseTimer.Close();
this.Visibility = Visibility.Collapsed;
EndAction?.Invoke();
}
public void Dispose()
{
EndTimer.Dispose();

View File

@ -177,6 +177,30 @@ namespace VPet_Simulator.Core
/// 睡觉 (结束)
/// </summary>
Sleep_C_End,
/// <summary>
/// 说话 (开始)
/// </summary>
Say_A_Start,
/// <summary>
/// 说话 (循环)
/// </summary>
Say_B_Loop,
/// <summary>
/// 说话 (结束)
/// </summary>
Say_C_End,
/// <summary>
/// 待机 (开始) (自动保持一致性)
/// </summary>
Idel_A_Start,
/// <summary>
/// 待机 (循环) (自动保持一致性)
/// </summary>
Idel_B_Loop,
/// <summary>
/// 待机 (结束) (自动保持一致性)
/// </summary>
Idel_C_End,
}
///// <summary> loop 应该被取缔
///// 动画类型默认设置 前文本|是否循环|是否常用
@ -265,9 +289,9 @@ namespace VPet_Simulator.Core
/// </summary>
/// <param name="type">动画类型</param>
/// <param name="mode">状态类型,找不到就找相同动画类型</param>
///// <param name="storernd">是否储存随机数字典</param>
/// <param name="storernd">是否储存随机数字典</param>
/// <returns></returns>
public IGraph FindGraph(GraphType type, Save.ModeType mode)//
public IGraph FindGraph(GraphType type, Save.ModeType mode, bool storernd = false)
{
if (Graphs.ContainsKey(type))
{
@ -276,18 +300,18 @@ namespace VPet_Simulator.Core
{
if (list.Count == 1)
return list[0];
//if (storernd)
// if (RndGraph.TryGetValue(list.Count, out int index))
// {
// return list[index];
// }
// else
// {
// index = Function.Rnd.Next(list.Count);
// RndGraph.Add(list.Count, index);
// return list[index];
// }
//else
if (storernd)
if (RndGraph.TryGetValue(list.Count, out int index))
{
return list[index];
}
else
{
index = Function.Rnd.Next(list.Count);
RndGraph.Add(list.Count, index);
return list[index];
}
else
return list[Function.Rnd.Next(list.Count)];
}
else
@ -382,7 +406,7 @@ namespace VPet_Simulator.Core
/// </summary>
public double LocateClimbTop;
/// <summary>
/// 初始化设置
/// </summary>

View File

@ -170,7 +170,7 @@ namespace VPet_Simulator.Core
public void Run(Action EndAction = null)
{
//先显示该图层
parent.Dispatcher.Invoke(Visible);
parent.Dispatcher.BeginInvoke(Visible);
//然后等待帧时间毫秒
Thread.Sleep(Time);
//判断是否要下一步
@ -186,8 +186,8 @@ namespace VPet_Simulator.Core
}
else
{
//parent.endwilldo = () => parent.Dispatcher.Invoke(Hidden);
//parent.Dispatcher.Invoke(Hidden);
//parent.endwilldo = () => parent.Dispatcher.BeginInvoke(Hidden);
//parent.Dispatcher.BeginInvoke(Hidden);
parent.PlayState = false;
if (parent.DoEndAction)
EndAction?.Invoke();//运行结束动画时事件
@ -197,20 +197,20 @@ namespace VPet_Simulator.Core
Task.Run(() =>
{
Thread.Sleep(25);
parent.Dispatcher.Invoke(Hidden);
parent.Dispatcher.BeginInvoke(Hidden);
});
return;
}
//要下一步,现在就隐藏图层
//隐藏该图层
parent.Dispatcher.Invoke(Hidden);
parent.Dispatcher.BeginInvoke(Hidden);
parent.Animations[parent.nowid].Run(EndAction);
return;
}
else
{
parent.IsContinue = false;
//parent.Dispatcher.Invoke(Hidden);
//parent.Dispatcher.BeginInvoke(Hidden);
if (parent.DoEndAction)
EndAction?.Invoke();//运行结束动画时事件
parent.StopAction?.Invoke();
@ -218,7 +218,7 @@ namespace VPet_Simulator.Core
Task.Run(() =>
{
Thread.Sleep(25);
parent.Dispatcher.Invoke(Hidden);
parent.Dispatcher.BeginInvoke(Hidden);
});
}
}

View File

@ -11,5 +11,44 @@
<ListBox x:Name="GraphListBox" Margin="0,20,0,0" MouseDoubleClick="GraphListBox_MouseDoubleClick" />
</Grid>
</TabItem>
<TabItem Header="显示逻辑">
<Grid>
<Label Background="{x:Null}" Content="双击运行显示效果" />
<Label x:Name="LabelSuccess" Background="{x:Null}" Content="" HorizontalAlignment="Right" />
<ListBox x:Name="DisplayListBox" Margin="0,20,0,0" MouseDoubleClick="DisplayListBox_MouseDoubleClick">
<ListBoxItem Content="DisplayNomal" />
<ListBoxItem Content="DisplayTouchHead" />
<ListBoxItem Content="DisplayBoring" />
<ListBoxItem Content="DisplaySquat" />
<ListBoxItem Content="DisplaySquating" />
<ListBoxItem Content="DisplaySleep" />
<ListBoxItem Content="DisplaySleeping" />
<ListBoxItem Content="DisplaySleepingForce" />
<ListBoxItem Content="DisplayRaised" />
<ListBoxItem Content="DisplayFalled_Left" />
<ListBoxItem Content="DisplayFalled_Right" />
<ListBoxItem Content="DisplayWalk_Left" />
<ListBoxItem Content="DisplayWalk_Right" />
<ListBoxItem Content="DisplayCrawl_Left" />
<ListBoxItem Content="DisplayCrawl_Right" />
<ListBoxItem Content="DisplayClimb_Left_UP" />
<ListBoxItem Content="DisplayClimb_Left_DOWN" />
<ListBoxItem Content="DisplayClimb_Right_UP" />
<ListBoxItem Content="DisplayClimb_Right_DOWN" />
<ListBoxItem Content="DisplayClimb_Top_Right" />
<ListBoxItem Content="DisplayClimb_Top_Left" />
<ListBoxItem Content="DisplayFall_Left" />
<ListBoxItem Content="DisplayFall_Right" />
</ListBox>
</Grid>
</TabItem>
<TabItem Header="说话">
<Grid>
<Label Background="{x:Null}" Content="输入要说的话,按说话键发送" />
<TextBox x:Name="SayTextBox" TextWrapping="Wrap" Text="在这里输入要说话的内容" VerticalAlignment="Top"
Margin="5,25,5,0" Height="60" AcceptsReturn="True" VerticalContentAlignment="Top" />
<Button VerticalAlignment="Bottom" Content="说话" Click="Say_Click" />
</Grid>
</TabItem>
</TabControl>
</Window>

View File

@ -29,7 +29,7 @@ namespace VPet_Simulator.Windows
{
GraphListBox.Items.Add(v);
}
}
public void DisplayLoop(GraphType graphType)
{
@ -42,5 +42,89 @@ namespace VPet_Simulator.Windows
LabelNowPlay.Content = $"当前正在播放: {GraphListBox.SelectedItem}";
DisplayLoop((GraphType)Enum.Parse(typeof(GraphType), (string)GraphListBox.SelectedItem));
}
private void DisplayListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (DisplayListBox.SelectedItem == null)
return;
LabelSuccess.Content = $"当前正在运行: {(string)((ListBoxItem)DisplayListBox.SelectedItem).Content}";
switch ((string)((ListBoxItem)DisplayListBox.SelectedItem).Content)
{
case "DisplayNomal":
mw.Main.DisplayNomal();
break;
case "DisplayTouchHead":
mw.Main.DisplayTouchHead();
break;
case "DisplayBoring":
mw.Main.DisplayBoring();
break;
case "DisplaySquat":
mw.Main.DisplaySquat();
break;
case "DisplaySquating":
mw.Main.DisplaySquating();
break;
case "DisplaySleep":
mw.Main.DisplaySleep();
break;
case "DisplaySleeping":
mw.Main.DisplaySleeping();
break;
case "DisplaySleepingForce":
mw.Main.DisplaySleepingForce();
break;
case "DisplayRaised":
mw.Main.DisplayRaised();
break;
case "DisplayFalled_Left":
mw.Main.DisplayFalled_Left();
break;
case "DisplayFalled_Right":
mw.Main.DisplayFalled_Right();
break;
case "DisplayWalk_Left":
mw.Main.DisplayWalk_Left();
break;
case "DisplayWalk_Right":
mw.Main.DisplayWalk_Right();
break;
case "DisplayCrawl_Left":
mw.Main.DisplayCrawl_Left();
break;
case "DisplayCrawl_Right":
mw.Main.DisplayCrawl_Right();
break;
case "DisplayClimb_Left_UP":
mw.Main.DisplayClimb_Left_UP();
break;
case "DisplayClimb_Left_DOWN":
mw.Main.DisplayClimb_Left_DOWN();
break;
case "DisplayClimb_Right_UP":
mw.Main.DisplayClimb_Right_UP();
break;
case "DisplayClimb_Right_DOWN":
mw.Main.DisplayClimb_Right_DOWN();
break;
case "DisplayClimb_Top_Right":
mw.Main.DisplayClimb_Top_Right();
break;
case "DisplayClimb_Top_Left":
mw.Main.DisplayClimb_Top_Left();
break;
case "DisplayFall_Left":
mw.Main.DisplayFall_Left();
break;
case "DisplayFall_Right":
mw.Main.DisplayFall_Right();
break;
}
}
private void Say_Click(object sender, RoutedEventArgs e)
{
mw.Main.Say(SayTextBox.Text);
}
}
}

View File

@ -42,8 +42,8 @@ namespace VPet_Simulator.Windows
ZoomSlider.Maximum = 3;
}
ZoomSlider.Value = mw.Set.ZoomLevel * 2;
this.Width = 400 * ZoomSlider.Value;
this.Height = 450 * ZoomSlider.Value;
this.Width = 400 * Math.Sqrt(ZoomSlider.Value);
this.Height = 450 * Math.Sqrt(ZoomSlider.Value);
sDesktopAlignment.IsChecked = mw.Set.EnableFunction;
CalSlider.Value = mw.Set.LogicInterval;
@ -440,8 +440,8 @@ namespace VPet_Simulator.Windows
private void ZoomSlider_MouseUp(object sender, MouseButtonEventArgs e)
{
mw.SetZoomLevel(ZoomSlider.Value / 2);
this.Width = 400 * ZoomSlider.Value;
this.Height = 450 * ZoomSlider.Value;
this.Width = 400 * Math.Sqrt(ZoomSlider.Value);
this.Height = 450 * Math.Sqrt(ZoomSlider.Value);
}
private void PressLengthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
@ -535,6 +535,6 @@ namespace VPet_Simulator.Windows
mw.Main.SetMoveMode(mw.Set.AllowMove, mw.Set.SmartMove, mw.Set.SmartMoveInterval * 1000);
}
}
}

View File

@ -12,11 +12,12 @@
Margin="10,0,0,0" />
<pu:FormGroup Header="类型:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="需要反馈的类型" HeaderWidth="Auto">
<ComboBox x:Name="tType" SelectedIndex="3">
<ComboBox x:Name="tType" SelectedIndex="4">
<ComboBoxItem>游戏内报错</ComboBoxItem>
<ComboBoxItem>逻辑计算错误</ComboBoxItem>
<ComboBoxItem>数值设计不合理</ComboBoxItem>
<ComboBoxItem>玩法与功能建议</ComboBoxItem>
<ComboBoxItem>游玩心得分享</ComboBoxItem>
</ComboBox>
</pu:FormGroup>
<pu:FormGroup Header="描述:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
@ -26,7 +27,7 @@
</pu:FormGroup>
<pu:FormGroup Header="内容:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="详细内容信息">
<TextBox x:Name="tContent" pu:TextBoxHelper.Watermark="详细描述&#13;eg:如何触发这个报错" AcceptsReturn="True"
<TextBox x:Name="tContent" pu:TextBoxHelper.Watermark="详细描述&#13;eg:报错详细信息" AcceptsReturn="True"
MaxHeight="172" HorizontalScrollBarVisibility="Auto" />
</pu:FormGroup>
<pu:FormGroup Header="提交:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB