mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
互动提示心情和体力数量
This commit is contained in:
parent
8b9351def3
commit
4438a902a2
@ -1,17 +1,22 @@
|
||||
<pu:ContentControlX x:Class="VPet_Simulator.Core.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:VPet_Simulator.Core"
|
||||
mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="250">
|
||||
<Viewbox>
|
||||
<Grid x:Name="MainGrid" Width="500" MouseLeftButtonDown="MainGrid_MouseLeftButtonDown"
|
||||
x:FieldModifier="public" MouseLeftButtonUp="MainGrid_MouseLeftButtonUp"
|
||||
MouseRightButtonDown="MainGrid_MouseRightButtonDown" MouseMove="MainGrid_MouseWave">
|
||||
<MediaElement x:Name="VoicePlayer" LoadedBehavior="Manual" UnloadedBehavior="Stop" />
|
||||
<Grid x:Name="MainGrid" Width="500" MouseLeftButtonDown="MainGrid_MouseLeftButtonDown" x:FieldModifier="public"
|
||||
MouseLeftButtonUp="MainGrid_MouseLeftButtonUp" MouseRightButtonDown="MainGrid_MouseRightButtonDown"
|
||||
MouseMove="MainGrid_MouseWave">
|
||||
<MediaElement x:Name="VoicePlayer" LoadedBehavior="Manual" UnloadedBehavior="Stop" x:FieldModifier="public" />
|
||||
<Grid x:Name="UIGrid_Back" x:FieldModifier="public" VerticalAlignment="Top" Width="500" />
|
||||
<Border x:Name="PetGrid" Height="500" VerticalAlignment="Top" Width="500" />
|
||||
<Border x:Name="PetGrid2" Height="500" VerticalAlignment="Top" Width="500" />
|
||||
<Grid x:Name="UIGrid" x:FieldModifier="public" VerticalAlignment="Top" Width="500" />
|
||||
<Label x:Name="LabelDisplay" HorizontalAlignment="Center" VerticalAlignment="Center" Content="内容显示如下"
|
||||
FontSize="30" Background="{DynamicResource DARKPrimaryTransA}"
|
||||
Foreground="{DynamicResource DARKPrimaryText}" pu:LabelHelper.CornerRadius="15"
|
||||
pu:LabelHelper.ShadowColor="{DynamicResource ShadowColor}" pu:ShadowHelper.Opacity="0.8"
|
||||
x:FieldModifier="public" Margin="0,300,0,0" Padding="15,7" Visibility="Collapsed" />
|
||||
</Grid>
|
||||
</Viewbox>
|
||||
</pu:ContentControlX>
|
||||
|
@ -64,7 +64,7 @@ namespace VPet_Simulator.Core
|
||||
MsgBar = new MessageBar(this);
|
||||
MsgBar.Visibility = Visibility.Collapsed;
|
||||
UIGrid.Children.Add(MsgBar);
|
||||
|
||||
labeldisplaytimer.Elapsed += Labledisplaytimer_Elapsed;
|
||||
|
||||
if (loadtouchevent)
|
||||
{
|
||||
@ -97,6 +97,28 @@ namespace VPet_Simulator.Core
|
||||
MoveTimer.Elapsed += MoveTimer_Elapsed;
|
||||
SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed;
|
||||
}
|
||||
|
||||
private void Labledisplaytimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (--labeldisplaycount <= 0)
|
||||
{
|
||||
labeldisplaytimer.Enabled = false;
|
||||
labeldisplaychangenum1 = 0;
|
||||
labeldisplaychangenum2 = 0;
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LabelDisplay.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
}
|
||||
else if (labeldisplaycount < 50)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LabelDisplay.Opacity = labeldisplaycount / 50;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动加载触摸事件
|
||||
/// </summary>
|
||||
|
@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using static VPet_Simulator.Core.GraphCore;
|
||||
|
||||
using Panuon.WPF.UI;
|
||||
namespace VPet_Simulator.Core
|
||||
{
|
||||
public partial class Main
|
||||
@ -120,6 +121,7 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
Core.Save.StrengthChange(-2);
|
||||
Core.Save.FeelingChange(1);
|
||||
LabelDisplayShowChangeNumber("体力-{1} 心情+{2}", 2, 1, tostr1: "f0", tostr2: "f0");
|
||||
}
|
||||
if (DisplayType == GraphType.Touch_Head_A_Start)
|
||||
return;
|
||||
@ -149,6 +151,7 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
Core.Save.StrengthChange(-2);
|
||||
Core.Save.FeelingChange(1);
|
||||
LabelDisplayShowChangeNumber("体力-{1} 心情+{2}",2,1,tostr1:"f0", tostr2: "f0");
|
||||
}
|
||||
if (DisplayType == GraphType.Touch_Body_A_Start)
|
||||
return;
|
||||
|
@ -58,7 +58,62 @@ namespace VPet_Simulator.Core
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int labeldisplaycount = 100;
|
||||
int labeldisplayhash = 0;
|
||||
Timer labeldisplaytimer = new Timer(10)
|
||||
{
|
||||
AutoReset = true,
|
||||
};
|
||||
double labeldisplaychangenum1 = 0;
|
||||
double labeldisplaychangenum2 = 0;
|
||||
/// <summary>
|
||||
/// 显示消息弹窗Label
|
||||
/// </summary>
|
||||
/// <param name="text">文本</param>
|
||||
/// <param name="time">持续时间</param>
|
||||
public void LabelDisplayShow(string text, int time = 2000)
|
||||
{
|
||||
labeldisplayhash = text.GetHashCode();
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LabelDisplay.Content = text;
|
||||
LabelDisplay.Opacity = 1;
|
||||
LabelDisplay.Visibility = Visibility.Visible;
|
||||
labeldisplaycount = time / 10;
|
||||
labeldisplaytimer.Start();
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示消息弹窗Lable,自动统计数值变化
|
||||
/// </summary>
|
||||
/// <param name="text">文本</param>
|
||||
/// <param name="changenum1">变化值1</param>
|
||||
/// <param name="changenum2">变化值2</param>
|
||||
/// <param name="time">持续时间</param>
|
||||
/// <param name="tostr1">转换方法1</param>
|
||||
/// <param name="tostr2">转换方法2</param>
|
||||
public void LabelDisplayShowChangeNumber(string text, double changenum1, double changenum2 = 0, int time = 2000, string tostr1 = "f2", string tostr2 = "f2")
|
||||
{
|
||||
if (labeldisplayhash == text.GetHashCode())
|
||||
{
|
||||
labeldisplaychangenum1 += changenum1;
|
||||
labeldisplaychangenum2 += changenum2;
|
||||
}
|
||||
else
|
||||
{
|
||||
labeldisplaychangenum1 = changenum1;
|
||||
labeldisplaychangenum2 = changenum2;
|
||||
labeldisplayhash = text.GetHashCode();
|
||||
}
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LabelDisplay.Content = text.Replace("{1}", labeldisplaychangenum1.ToString(tostr1)).Replace("{2}", labeldisplaychangenum2.ToString(tostr2));
|
||||
LabelDisplay.Opacity = 1;
|
||||
LabelDisplay.Visibility = Visibility.Visible;
|
||||
labeldisplaycount = time / 10;
|
||||
labeldisplaytimer.Start();
|
||||
});
|
||||
}
|
||||
public void Saying(GraphCore.Helper.SayType type)
|
||||
{
|
||||
Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type));
|
||||
|
@ -5,7 +5,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<pucore:SharedResourceDictionary Source="/Panuon.WPF.UI;component/Control.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
<DrawingBrush x:Key="ProgressBarForeground" Viewport="0,0,8,22" ViewportUnits="Absolute" Stretch="None"
|
||||
TileMode="Tile">
|
||||
<DrawingBrush.RelativeTransform>
|
||||
|
@ -76,8 +76,8 @@
|
||||
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.11.10, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.11.11\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.12.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.12.1\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
|
@ -2,5 +2,5 @@
|
||||
<packages>
|
||||
<package id="LinePutScript" version="1.8.2" targetFramework="net462" />
|
||||
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.11.11" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.12.1" targetFramework="net462" />
|
||||
</packages>
|
@ -94,8 +94,8 @@
|
||||
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.11.10, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.11.11\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.12.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.12.1\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
@ -2,5 +2,5 @@
|
||||
<packages>
|
||||
<package id="LinePutScript" version="1.8.2" targetFramework="net462" />
|
||||
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.11.11" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.12.1" targetFramework="net462" />
|
||||
</packages>
|
@ -87,8 +87,8 @@
|
||||
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.11.10, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.11.11\lib\net48\Panuon.WPF.UI.dll</HintPath>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.12.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.12.1\lib\net48\Panuon.WPF.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
|
@ -6,5 +6,5 @@
|
||||
<package id="LinePutScript" version="1.8.2" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||
<package id="Panuon.WPF" version="1.0.1" targetFramework="net48" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.11.11" targetFramework="net48" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.12.1" targetFramework="net48" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user