画线 加声音
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
||||
namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
{
|
||||
partial class Audio_player
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
sp_Button = new PictureBox();
|
||||
last = new PictureBox();
|
||||
next = new PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)sp_Button).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)last).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)next).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// sp_Button
|
||||
//
|
||||
sp_Button.Image = Properties.Resources.pause;
|
||||
sp_Button.Location = new Point(368, 114);
|
||||
sp_Button.Name = "sp_Button";
|
||||
sp_Button.Size = new Size(70, 70);
|
||||
sp_Button.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
sp_Button.TabIndex = 0;
|
||||
sp_Button.TabStop = false;
|
||||
sp_Button.Click += sp_Button_Click;
|
||||
//
|
||||
// last
|
||||
//
|
||||
last.Image = Properties.Resources.last;
|
||||
last.Location = new Point(199, 114);
|
||||
last.Name = "last";
|
||||
last.Size = new Size(70, 70);
|
||||
last.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
last.TabIndex = 1;
|
||||
last.TabStop = false;
|
||||
last.Click += last_Click;
|
||||
//
|
||||
// next
|
||||
//
|
||||
next.Image = Properties.Resources.next;
|
||||
next.Location = new Point(536, 114);
|
||||
next.Name = "next";
|
||||
next.Size = new Size(70, 70);
|
||||
next.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
next.TabIndex = 2;
|
||||
next.TabStop = false;
|
||||
next.Click += next_Click;
|
||||
//
|
||||
// Audio_player
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(11F, 24F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.White;
|
||||
Controls.Add(next);
|
||||
Controls.Add(last);
|
||||
Controls.Add(sp_Button);
|
||||
Name = "Audio_player";
|
||||
Size = new Size(873, 323);
|
||||
((System.ComponentModel.ISupportInitialize)sp_Button).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)last).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)next).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox sp_Button;
|
||||
private PictureBox last;
|
||||
private PictureBox next;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using CDSAE3_Lian_Lian_Kan;
|
||||
using CDSAE3_Lian_Lian_Kan.Properties;
|
||||
using NAudio.Wave;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
{
|
||||
public partial class Audio_player : UserControl
|
||||
{
|
||||
public Audio_player()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
bool play_state = false;
|
||||
private void sp_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!play_state)
|
||||
play();
|
||||
else
|
||||
pause();
|
||||
play_state = !play_state;
|
||||
}
|
||||
private void play()
|
||||
{
|
||||
Settings.audio_Processer.resume_song();
|
||||
sp_Button.Image = Resources.pause;
|
||||
}
|
||||
private void pause()
|
||||
{
|
||||
Settings.audio_Processer.pause_song();
|
||||
sp_Button.Image = Resources.play_buttton;
|
||||
}
|
||||
|
||||
private void last_Click(object sender, EventArgs e)
|
||||
{
|
||||
Settings.audio_Processer.last_song();
|
||||
play();
|
||||
}
|
||||
|
||||
private void next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Settings.audio_Processer.next_song();
|
||||
play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -5,6 +5,7 @@ using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -13,10 +14,13 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
{
|
||||
public partial class GameControl : UserControl, IBeSelected
|
||||
public partial class GameControl : UserControl, IGameControl
|
||||
{
|
||||
Board board = new Board();
|
||||
IGameMode iGameMode;
|
||||
IGameMode? iGameMode;
|
||||
Queue<((int, int), Single_Block)> queue = new Queue<((int, int), Single_Block)>();//y,x
|
||||
bool do_search = false;
|
||||
List<Single_Block> hint_blocks = new List<Single_Block>();
|
||||
public GameControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -27,16 +31,7 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
}
|
||||
void playPanel_set()
|
||||
{
|
||||
int[,] bd;
|
||||
if (board.Bd == null)
|
||||
{
|
||||
board.make_board();
|
||||
bd = board.Bd ?? new int[0, 0];
|
||||
if (bd.Length == 0)
|
||||
throw new Exception("bd is null");
|
||||
}
|
||||
else
|
||||
bd = board.Bd;
|
||||
int[,] bd = board.Bd;
|
||||
playPanel_size_change();
|
||||
for (int i = 0; i < playPanel.RowCount; i++)
|
||||
for (int j = 0; j < playPanel.ColumnCount; j++)
|
||||
@@ -55,18 +50,128 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
Queue<((int, int), Single_Block)> queue = new Queue<((int, int), Single_Block)>();//y,x
|
||||
/// <summary>
|
||||
/// 由form和to两个点获取方向
|
||||
/// </summary>
|
||||
/// <param name="from">起始点</param>
|
||||
/// <param name="to">终点</param>
|
||||
/// <returns></returns>
|
||||
Settings.Direction get_Direction((int, int) from, (int, int) to) //x,y
|
||||
{
|
||||
if (from.Item1 == to.Item1)
|
||||
if (from.Item2 > to.Item2)
|
||||
return Settings.Direction.up;
|
||||
else
|
||||
return Settings.Direction.down;
|
||||
else
|
||||
if (from.Item1 > to.Item1)
|
||||
return Settings.Direction.left;
|
||||
else
|
||||
return Settings.Direction.right;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置单个点方向
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="direction"></param>
|
||||
/// <param name="blocks"></param>
|
||||
/// <param name="decrease"></param>
|
||||
/// <returns></returns>
|
||||
async Task set_PathAsync((int, int) point, Settings.Direction direction, List<Single_Block> blocks, int wait_time,bool is_hint)
|
||||
{
|
||||
|
||||
if (wait_time != 0)
|
||||
await Task.Delay(wait_time);
|
||||
Control? control = playPanel.GetControlFromPosition(point.Item1, point.Item2);
|
||||
if (control != null && control is Single_Block single_Block)
|
||||
{
|
||||
if (is_hint)
|
||||
single_Block.hint_path(direction);
|
||||
else
|
||||
single_Block.to_path(direction);
|
||||
blocks.Add(single_Block);
|
||||
}
|
||||
}
|
||||
async Task to_path((int, int) from, (int, int) to, bool include_end, Settings.Direction extra_Direction, List<Single_Block> blocks, int wait_time, bool is_hint)
|
||||
{
|
||||
var direction = get_Direction(from, to);
|
||||
switch (direction)
|
||||
{
|
||||
case Settings.Direction.up:
|
||||
for (int i = from.Item2 - 1; i != to.Item2; i--)
|
||||
await set_PathAsync((from.Item1, i), Settings.Direction.up_down, blocks, wait_time,is_hint);
|
||||
break;
|
||||
case Settings.Direction.down:
|
||||
for (int i = from.Item2 + 1; i != to.Item2; i++)
|
||||
await set_PathAsync((from.Item1, i), Settings.Direction.up_down, blocks, wait_time,is_hint);
|
||||
break;
|
||||
case Settings.Direction.right:
|
||||
for (int i = from.Item1 + 1; i != to.Item1; i++)
|
||||
await set_PathAsync((i, from.Item2), Settings.Direction.left_right, blocks, wait_time,is_hint);
|
||||
break;
|
||||
case Settings.Direction.left:
|
||||
for (int i = from.Item1 - 1; i != to.Item1; i--)
|
||||
await set_PathAsync((i, from.Item2), Settings.Direction.left_right, blocks, wait_time,is_hint);
|
||||
break;
|
||||
}
|
||||
if (include_end)
|
||||
{
|
||||
direction = ((int)direction & 3) > 0 ? (Settings.Direction)((int)direction << 2) : (Settings.Direction)((int)direction >> 2);
|
||||
direction = direction | extra_Direction;
|
||||
await set_PathAsync(to, direction, blocks, wait_time,is_hint);
|
||||
}
|
||||
}
|
||||
async Task path_drawerAsync(List<(int, int)> path, int wait_time, List<Single_Block> blocks, bool is_hint)
|
||||
{
|
||||
switch (path.Count)
|
||||
{
|
||||
case 2:
|
||||
await to_path(path[0], path[1], false, Settings.Direction.none, blocks, wait_time,is_hint);
|
||||
break;
|
||||
case 3:
|
||||
var extra_direction = get_Direction(path[1], path[2]);
|
||||
await to_path(path[0], path[1], true, extra_direction, blocks, wait_time,is_hint);
|
||||
await to_path(path[1], path[2], false, Settings.Direction.none, blocks, wait_time,is_hint);
|
||||
break;
|
||||
case 4:
|
||||
Settings.Direction extra_directionA = get_Direction(path[1], path[2]), extra_directionB = get_Direction(path[2], path[3]);
|
||||
await to_path(path[0], path[1], true, extra_directionA, blocks, wait_time,is_hint);
|
||||
await to_path(path[1], path[2], true, extra_directionB, blocks, wait_time,is_hint);
|
||||
await to_path(path[2], path[3], false, Settings.Direction.none, blocks, wait_time,is_hint);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
internal void set_tip()
|
||||
{
|
||||
if (queue.Count != 1)
|
||||
return;
|
||||
List<List<(int, int)>> paths = board.get_tip(queue.Peek().Item1);
|
||||
foreach (var path in paths)
|
||||
_ = path_drawerAsync(path, 0, hint_blocks,true);
|
||||
}
|
||||
internal void de_set_tip()
|
||||
{
|
||||
foreach (var control in hint_blocks)
|
||||
control.de_path();
|
||||
hint_blocks.Clear();
|
||||
}
|
||||
public void Selected_Handler(Single_Block sender, SelectedEventArgs e)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
iGameMode.De_pause(this, e);
|
||||
iGameMode?.De_pause(this, e);
|
||||
if (e.be_selected)
|
||||
{
|
||||
switch (queue.Count)
|
||||
{
|
||||
case 0:
|
||||
queue.Enqueue((e.position, sender));
|
||||
if (do_search)
|
||||
{
|
||||
de_set_tip();
|
||||
set_tip();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var (posa, sendera) = queue.Dequeue();
|
||||
@@ -74,15 +179,18 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
var (could, path) = board.test(posa, posb);
|
||||
if (could)
|
||||
{
|
||||
board.decrease(posa, posb);
|
||||
_ = Block_ClearAsync(path);
|
||||
while (queue.Count() > 0)
|
||||
queue.Dequeue();
|
||||
if (board.Bd is null) throw new Exception("No usable board. How come?");
|
||||
board.Bd[posa.Item2, posa.Item1] = -1;
|
||||
board.Bd[posb.Item2, posb.Item1] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_search)
|
||||
{
|
||||
de_set_tip();
|
||||
set_tip();
|
||||
}
|
||||
queue.Enqueue((e.position, sender));
|
||||
sendera.deselect();
|
||||
}
|
||||
@@ -97,86 +205,25 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
break;
|
||||
case 1:
|
||||
if (queue.Peek().Item1 == e.position)
|
||||
{
|
||||
queue.Dequeue();
|
||||
if (do_search)
|
||||
de_set_tip();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async Task Block_ClearAsync(List<(int, int)>? path)
|
||||
{
|
||||
List<Single_Block> paths = new List<Single_Block>();
|
||||
if (do_search == true)
|
||||
foreach (Single_Block single_Block in hint_blocks)
|
||||
single_Block.de_path();
|
||||
List<Single_Block> blocks = new List<Single_Block>();
|
||||
if (path == null)
|
||||
return;
|
||||
Func<(int, int), (int, int), Settings.Direction> get_Direction = ((int, int) from, (int, int) to) =>//x,y
|
||||
{
|
||||
if (from.Item1 == to.Item1)
|
||||
if (from.Item2 > to.Item2)
|
||||
return Settings.Direction.up;
|
||||
else
|
||||
return Settings.Direction.down;
|
||||
else
|
||||
if (from.Item1 > to.Item1)
|
||||
return Settings.Direction.left;
|
||||
else
|
||||
return Settings.Direction.right;
|
||||
};
|
||||
Func<(int, int), Settings.Direction, Task> set_Path = async ((int, int) point, Settings.Direction direction) =>
|
||||
{
|
||||
await Task.Delay(20);
|
||||
Control? control = playPanel.GetControlFromPosition(point.Item1, point.Item2);
|
||||
if (control != null && control is Single_Block single_Block)
|
||||
{
|
||||
single_Block.to_path(direction);
|
||||
paths.Add(single_Block);
|
||||
}
|
||||
};
|
||||
Func<(int, int), (int, int), bool, Settings.Direction, Task> to_path = async ((int, int) from, (int, int) to, bool include_end, Settings.Direction extra_Direction) =>
|
||||
{
|
||||
var direction = get_Direction(from, to);
|
||||
switch (direction)
|
||||
{
|
||||
case Settings.Direction.up:
|
||||
for (int i = from.Item2 - 1; i != to.Item2; i--)
|
||||
await set_Path((from.Item1, i), Settings.Direction.up_down);
|
||||
break;
|
||||
case Settings.Direction.down:
|
||||
for (int i = from.Item2 + 1; i != to.Item2; i++)
|
||||
await set_Path((from.Item1, i), Settings.Direction.up_down);
|
||||
break;
|
||||
case Settings.Direction.right:
|
||||
for (int i = from.Item1 + 1; i != to.Item1; i++)
|
||||
await set_Path((i, from.Item2), Settings.Direction.left_right);
|
||||
break;
|
||||
case Settings.Direction.left:
|
||||
for (int i = from.Item1 - 1; i != to.Item1; i--)
|
||||
await set_Path((i, from.Item2), Settings.Direction.left_right);
|
||||
break;
|
||||
}
|
||||
if (include_end)
|
||||
{
|
||||
direction = direction | extra_Direction;
|
||||
await set_Path(to, direction);
|
||||
}
|
||||
};
|
||||
switch (path.Count)
|
||||
{
|
||||
case 2:
|
||||
await to_path(path[0], path[1], false, 0);
|
||||
break;
|
||||
case 3:
|
||||
var extra_direction = get_Direction(path[1], path[2]);
|
||||
await to_path(path[0], path[1], true, extra_direction);
|
||||
await to_path(path[1], path[2], false, Settings.Direction.none);
|
||||
break;
|
||||
case 4:
|
||||
Settings.Direction extra_directionA = get_Direction(path[1], path[2]), extra_directionB = get_Direction(path[2], path[3]);
|
||||
await to_path(path[0], path[1], true, extra_directionA);
|
||||
await to_path(path[1], path[2], true, extra_directionB);
|
||||
await to_path(path[2], path[3], false, Settings.Direction.none);
|
||||
break;
|
||||
}
|
||||
await path_drawerAsync(path, 20, blocks, false);
|
||||
Control? controlA = playPanel.GetControlFromPosition(path[0].Item1, path[0].Item2), controlB = playPanel.GetControlFromPosition(path.Last().Item1, path.Last().Item2);
|
||||
if (controlA != null && controlB != null && controlA is Single_Block single_BlockA && controlB is Single_Block single_BlockB)
|
||||
{
|
||||
@@ -184,12 +231,11 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
single_BlockB.destroyAsync();
|
||||
}
|
||||
await Task.Delay(200);
|
||||
foreach (var control in paths)
|
||||
foreach (var control in blocks)
|
||||
control.de_path();
|
||||
iGameMode.Score_Add(this, new AddScoreArgs { score = (paths.Count + 2)*10 });
|
||||
iGameMode?.Score_Add(this, new AddScoreArgs { score = (blocks.Count + 2) * 10 });
|
||||
board.Total -= 2;
|
||||
}
|
||||
|
||||
void playPanel_size_change()
|
||||
{
|
||||
var (width, height) = board.size;
|
||||
@@ -202,5 +248,34 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
for (int i = 0; i < height + 1; i++)
|
||||
playPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
}
|
||||
public void Exchange_Handler(object? sender, EventArgs e)
|
||||
{
|
||||
board.remake_board();
|
||||
int[,] bd = board.Bd;
|
||||
for (int i = 0; i < bd.GetLength(0); i++)
|
||||
for (int j = 0; j < bd.GetLength(1); j++)
|
||||
if (bd[i, j] == -1)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
Control? control = playPanel.GetControlFromPosition(j, i);
|
||||
if (control != null && control is Single_Block single_Block)
|
||||
single_Block.Re_create(bd[i, j], null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void Search_Handler(object? sender, SearchEventArgs e)
|
||||
{
|
||||
if (e.set_search)
|
||||
{
|
||||
do_search = true;
|
||||
set_tip();
|
||||
}
|
||||
else
|
||||
{
|
||||
do_search = false;
|
||||
de_set_tip();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
{
|
||||
public interface IBeSelected
|
||||
public interface IGameControl
|
||||
{
|
||||
public void Selected_Handler(Single_Block sender, SelectedEventArgs e);
|
||||
public void Exchange_Handler(object? sender, EventArgs e);
|
||||
public void Search_Handler(object? sender, SearchEventArgs e);
|
||||
}
|
||||
public class SearchEventArgs:EventArgs
|
||||
{
|
||||
public bool set_search { get; set; } = false;//true : search
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
search.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
search.TabIndex = 9;
|
||||
search.TabStop = false;
|
||||
search.Click += search_Click;
|
||||
//
|
||||
// exchange
|
||||
//
|
||||
@@ -161,6 +162,7 @@
|
||||
exchange.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
exchange.TabIndex = 10;
|
||||
exchange.TabStop = false;
|
||||
exchange.Click += exchange_Click;
|
||||
//
|
||||
// Leisure_Mode
|
||||
//
|
||||
|
||||
@@ -29,15 +29,26 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
int cur_score = 0;
|
||||
int factor_val = 1;
|
||||
int current_base = 0;
|
||||
|
||||
int search_left_time = 0;
|
||||
bool search_mode = false;
|
||||
Dictionary<int, double> decrease_per_level = Settings.decrease_per_level;
|
||||
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
left_time--;
|
||||
BeginInvoke(() => time.Text = (left_time / 60).ToString().PadLeft(2, '0') + ":" + (left_time % 60).ToString().PadLeft(2, '0'));
|
||||
if(search_mode)
|
||||
{
|
||||
search_left_time--;
|
||||
if (search_left_time < 0)
|
||||
{
|
||||
search_mode = false;
|
||||
gameControl.Search_Handler(this, new SearchEventArgs { set_search = false });
|
||||
}
|
||||
}
|
||||
if (current_base <= 0)
|
||||
{
|
||||
if(factor_val>1)
|
||||
if (factor_val > 1)
|
||||
{
|
||||
current_base = 100;
|
||||
factor_val--;
|
||||
@@ -70,9 +81,9 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
{
|
||||
cur_score += e.score * factor_val;
|
||||
current_base += e.score;
|
||||
while(current_base>100)
|
||||
while (current_base > 100)
|
||||
{
|
||||
if(factor_val>=10)
|
||||
if (factor_val >= 10)
|
||||
{
|
||||
factor_val = 10;
|
||||
current_base = 100;
|
||||
@@ -83,7 +94,7 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
factor_val++;
|
||||
}
|
||||
}
|
||||
BeginInvoke(()=>factor.Text = "x" + factor_val.ToString());
|
||||
BeginInvoke(() => factor.Text = "x" + factor_val.ToString());
|
||||
BeginInvoke(() => energy_bar.Value = current_base);
|
||||
BeginInvoke(() => score.Text = cur_score.ToString());
|
||||
}
|
||||
@@ -123,5 +134,17 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
timer.Close();
|
||||
Settings.form?.change_form(new Leisure_Mode_MenuForm());
|
||||
}
|
||||
|
||||
private void exchange_Click(object sender, EventArgs e)
|
||||
{
|
||||
Task.Run(() => gameControl.Exchange_Handler(this, new EventArgs()));
|
||||
}
|
||||
|
||||
private void search_Click(object sender, EventArgs e)
|
||||
{
|
||||
gameControl.Search_Handler(this, new SearchEventArgs { set_search = true});
|
||||
search_mode = true;
|
||||
search_left_time = Settings.search_left_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
|
||||
public Leisure_Mode_MenuForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
Settings.audio_Processer.next_song();
|
||||
Settings.audio_Processer.resume_song();
|
||||
}
|
||||
|
||||
private void start_Game_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -79,13 +79,21 @@ namespace CDSAE3_Lian_Lian_Kan
|
||||
selected = false;
|
||||
BackColor = nor_color;
|
||||
}
|
||||
Settings.Direction direction = Settings.Direction.none;
|
||||
public void hint_path(Settings.Direction direction)
|
||||
{
|
||||
this.direction |= direction;
|
||||
Image_change(Settings.get_tip_direction_Image(this.direction));
|
||||
}
|
||||
public void to_path(Settings.Direction direction)
|
||||
{//TODO tube Image
|
||||
Image_change(Settings.get_block_Image(0));
|
||||
{
|
||||
Image_change(Settings.get_direction_Image(direction));
|
||||
direction = Settings.Direction.none;
|
||||
}
|
||||
public void de_path()
|
||||
{
|
||||
Image_change(Settings.trans_Image);
|
||||
direction = Settings.Direction.none;
|
||||
}
|
||||
System.Timers.Timer? timer = null;
|
||||
public void destroyAsync()
|
||||
@@ -98,7 +106,7 @@ namespace CDSAE3_Lian_Lian_Kan
|
||||
timer.Elapsed += Image_Clear;
|
||||
timer.Enabled = true;
|
||||
}
|
||||
Object locker = new object();
|
||||
object locker = new object();
|
||||
public void Image_Clear(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
timer?.Stop();
|
||||
@@ -116,9 +124,21 @@ namespace CDSAE3_Lian_Lian_Kan
|
||||
catch(Exception)
|
||||
{
|
||||
Image_change(new_image);
|
||||
//Console.WriteLine("test");
|
||||
}
|
||||
}
|
||||
public void Re_create(int image, Color? default_backColor, Color? select_Color, (int, int)? pos)
|
||||
{
|
||||
if (block_id == image)
|
||||
return;
|
||||
block_id = image;
|
||||
Image_change(Settings.get_block_Image(image));
|
||||
if (default_backColor != null)
|
||||
nor_color = (Color)default_backColor;
|
||||
if(select_Color != null)
|
||||
sel_color = (Color)select_Color;
|
||||
if (pos != null)
|
||||
position = ((int, int))pos;
|
||||
}
|
||||
public event SelectedEventHandler Selected;
|
||||
}
|
||||
public class SelectedEventArgs : EventArgs
|
||||
|
||||
Reference in New Issue
Block a user