2024-03-22 17:03:01 +08:00
|
|
|
|
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;
|
2024-04-08 21:04:47 +08:00
|
|
|
|
using System.Timers;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
using System.Windows.Forms;
|
2024-04-02 23:14:34 +08:00
|
|
|
|
using CDSAE3_Lian_Lian_Kan.Boards;
|
2024-04-18 08:38:59 +08:00
|
|
|
|
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
|
2024-04-08 21:04:47 +08:00
|
|
|
|
using CDSAE3_Lian_Lian_Kan.Properties;
|
2024-04-18 08:38:59 +08:00
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
using static CDSAE3_Lian_Lian_Kan.Etcs;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
namespace CDSAE3_Lian_Lian_Kan.Forms
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public partial class Leisure_Mode : Form, IGameMode
|
|
|
|
|
{
|
2024-04-19 10:00:37 +08:00
|
|
|
|
GameControl gameControl;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
public Leisure_Mode()
|
|
|
|
|
{
|
2024-04-18 08:38:59 +08:00
|
|
|
|
Etcs.gameModeForm = this;
|
2024-04-19 10:00:37 +08:00
|
|
|
|
Etcs.current_block_theme = Theme.fruit;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
InitializeComponent();
|
2024-04-18 08:38:59 +08:00
|
|
|
|
upper_search.Item_Init(Resources.search, (70, 70), Color.FromArgb(253, 161, 60));
|
2024-03-22 17:03:01 +08:00
|
|
|
|
time.Text = (left_time / 60).ToString().PadLeft(2, '0') + ":" + (left_time % 60).ToString().PadLeft(2, '0');
|
2024-04-08 21:04:47 +08:00
|
|
|
|
upper_search_ori_position = upper_search.Location;
|
|
|
|
|
timer = new System.Timers.Timer(1000);
|
|
|
|
|
timer.Elapsed += Timer_Tick;
|
2024-04-18 08:38:59 +08:00
|
|
|
|
timer.Enabled = false;
|
2024-04-19 10:00:37 +08:00
|
|
|
|
gameControl = new GameControl((t) => t++);
|
|
|
|
|
game_Panel.Controls.Add(gameControl);
|
|
|
|
|
gameControl.Dock = DockStyle.Fill;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
System.Timers.Timer timer;
|
2024-04-08 21:04:47 +08:00
|
|
|
|
int hundred_up_timer = 0;
|
|
|
|
|
Point upper_search_ori_position;
|
2024-04-02 21:57:04 +08:00
|
|
|
|
int left_time = Etcs.left_time;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
bool is_pause = true;
|
|
|
|
|
int cur_score = 0;
|
|
|
|
|
int factor_val = 1;
|
|
|
|
|
int current_base = 0;
|
2024-03-29 14:18:38 +08:00
|
|
|
|
int search_left_time = 0;
|
|
|
|
|
bool search_mode = false;
|
2024-04-02 21:57:04 +08:00
|
|
|
|
Dictionary<int, double> decrease_per_level = Etcs.decrease_per_level;
|
2024-03-22 17:03:01 +08:00
|
|
|
|
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'));
|
2024-04-18 08:38:59 +08:00
|
|
|
|
if (search_mode)
|
2024-03-29 14:18:38 +08:00
|
|
|
|
{
|
|
|
|
|
search_left_time--;
|
|
|
|
|
if (search_left_time < 0)
|
|
|
|
|
{
|
|
|
|
|
search_mode = false;
|
|
|
|
|
gameControl.Search_Handler(this, new SearchEventArgs { set_search = false });
|
2024-04-08 21:04:47 +08:00
|
|
|
|
BeginInvoke(() => upper_search.set_progress(0));
|
2024-04-18 08:38:59 +08:00
|
|
|
|
BeginInvoke(() => upper_search.Visible = false);
|
2024-03-29 14:18:38 +08:00
|
|
|
|
}
|
2024-04-18 08:38:59 +08:00
|
|
|
|
SuspendLayout();
|
2024-04-08 21:04:47 +08:00
|
|
|
|
BeginInvoke(() => upper_search.Location = new Point(upper_search_ori_position.X, upper_search_ori_position.Y + (int)(70 * (1 - ((search_left_time - hundred_up_timer * 0.1) / Etcs.search_left_time)))));
|
|
|
|
|
BeginInvoke(() => upper_search.set_progress(70 - upper_search.Location.Y + upper_search_ori_position.Y));
|
2024-04-18 08:38:59 +08:00
|
|
|
|
ResumeLayout();
|
2024-03-29 14:18:38 +08:00
|
|
|
|
}
|
2024-03-22 17:03:01 +08:00
|
|
|
|
if (current_base <= 0)
|
|
|
|
|
{
|
2024-03-29 14:18:38 +08:00
|
|
|
|
if (factor_val > 1)
|
2024-03-22 17:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
current_base = 100;
|
|
|
|
|
factor_val--;
|
|
|
|
|
BeginInvoke(() => factor.Text = "x" + factor_val.ToString());
|
|
|
|
|
BeginInvoke(() => energy_bar.Value = current_base);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
current_base -= (int)decrease_per_level[factor_val];
|
|
|
|
|
if (current_base < 0)
|
|
|
|
|
current_base = 0;
|
|
|
|
|
BeginInvoke(() => energy_bar.Value = current_base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (left_time < 0)
|
|
|
|
|
{
|
|
|
|
|
timer.Enabled = false;
|
2024-04-19 10:00:37 +08:00
|
|
|
|
Finished_Handler(this, new FinishArgs { finishType = FinishArgs.FinishType.Time_out });
|
2024-03-22 17:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
if (is_pause) { timer.Enabled = false; }
|
|
|
|
|
}
|
|
|
|
|
public void De_pause(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (is_pause)
|
|
|
|
|
Sp_button_Click(sender, e);
|
|
|
|
|
}
|
2024-04-18 08:38:59 +08:00
|
|
|
|
public void Do_pause(object sender,EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!is_pause)
|
|
|
|
|
Sp_button_Click(sender, e);
|
|
|
|
|
}
|
2024-03-22 17:03:01 +08:00
|
|
|
|
|
2024-04-19 10:00:37 +08:00
|
|
|
|
public void Score_Change(object sender, ChangeScoreArgs e)
|
2024-03-22 17:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
cur_score += e.score * factor_val;
|
|
|
|
|
current_base += e.score;
|
2024-03-29 14:18:38 +08:00
|
|
|
|
while (current_base > 100)
|
2024-03-22 17:03:01 +08:00
|
|
|
|
{
|
2024-03-29 14:18:38 +08:00
|
|
|
|
if (factor_val >= 10)
|
2024-03-22 17:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
factor_val = 10;
|
|
|
|
|
current_base = 100;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
current_base -= 100;
|
|
|
|
|
factor_val++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-29 14:18:38 +08:00
|
|
|
|
BeginInvoke(() => factor.Text = "x" + factor_val.ToString());
|
2024-03-22 17:03:01 +08:00
|
|
|
|
BeginInvoke(() => energy_bar.Value = current_base);
|
|
|
|
|
BeginInvoke(() => score.Text = cur_score.ToString());
|
|
|
|
|
}
|
|
|
|
|
public void Sp_button_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (is_pause)
|
|
|
|
|
{
|
|
|
|
|
sp_button.Image = Properties.Resources.pause;
|
|
|
|
|
is_pause = false;
|
|
|
|
|
timer.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sp_button.Image = Properties.Resources.play_buttton;
|
|
|
|
|
is_pause = true;
|
|
|
|
|
timer.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Finished_Handler(object sender, FinishArgs e)
|
|
|
|
|
{
|
2024-04-18 08:38:59 +08:00
|
|
|
|
BeginInvoke(() =>
|
2024-03-22 17:03:01 +08:00
|
|
|
|
{
|
2024-04-18 08:38:59 +08:00
|
|
|
|
timer.Close();
|
2024-04-19 10:00:37 +08:00
|
|
|
|
switch (e.finishType)
|
2024-04-18 08:38:59 +08:00
|
|
|
|
{
|
2024-04-19 10:00:37 +08:00
|
|
|
|
case FinishArgs.FinishType.All_done:
|
2024-04-18 08:38:59 +08:00
|
|
|
|
Do_pause(this, new EventArgs());
|
|
|
|
|
Form form = new FinishedMessageBox(cur_score, Etcs.left_time - left_time);
|
|
|
|
|
form.FormClosed += ((sender, args) => {
|
|
|
|
|
Dispose();
|
|
|
|
|
Close();
|
2024-04-19 10:00:37 +08:00
|
|
|
|
Etcs.form?.change_form(charts, false, null, null); });
|
2024-04-18 08:38:59 +08:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
break;
|
2024-04-19 10:00:37 +08:00
|
|
|
|
case FinishArgs.FinishType.Time_out:
|
2024-04-18 08:38:59 +08:00
|
|
|
|
Thread thread = new Thread(() => MessageBox.Show("时间到!"));
|
|
|
|
|
thread.Start();
|
|
|
|
|
back_Click(this, new EventArgs());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-03-22 17:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void back_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
2024-04-02 21:57:04 +08:00
|
|
|
|
Close();
|
2024-03-22 17:03:01 +08:00
|
|
|
|
timer.Close();
|
2024-04-18 08:38:59 +08:00
|
|
|
|
Etcs.gameMenuForm!.playFormToMenu();
|
2024-03-22 17:03:01 +08:00
|
|
|
|
}
|
2024-03-29 14:18:38 +08:00
|
|
|
|
|
|
|
|
|
private void exchange_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() => gameControl.Exchange_Handler(this, new EventArgs()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void search_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-04-18 08:38:59 +08:00
|
|
|
|
gameControl.Search_Handler(this, new SearchEventArgs { set_search = true });
|
2024-03-29 14:18:38 +08:00
|
|
|
|
search_mode = true;
|
2024-04-02 21:57:04 +08:00
|
|
|
|
search_left_time = Etcs.search_left_time;
|
2024-04-18 08:38:59 +08:00
|
|
|
|
upper_search.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetTheme()
|
|
|
|
|
{
|
|
|
|
|
Etcs.ThemeInfo themeInfo = Etcs.currentThemeInfo;
|
|
|
|
|
BackColor = Color.FromArgb(themeInfo.ThemeColor![0], themeInfo.ThemeColor[1], themeInfo.ThemeColor[2]);
|
2024-04-19 10:00:37 +08:00
|
|
|
|
//gameControl.BackColor = BackColor;
|
2024-04-18 08:38:59 +08:00
|
|
|
|
//gameControl.BackgroundImage = (Image)res_Manager.GetObject(themeInfo.PictureName!, Etcs.res_Culture)!;
|
|
|
|
|
if (themeInfo.PlayPanelUsePicture)
|
|
|
|
|
{
|
|
|
|
|
if (themeInfo.PlayPanelPictureIsOutPicture)
|
|
|
|
|
BackgroundImage = new Bitmap(themeInfo.PlayPanelPictureName!);
|
|
|
|
|
else
|
|
|
|
|
BackgroundImage = (Image)res_Manager.GetObject(themeInfo.PictureName!, Etcs.res_Culture)!;
|
|
|
|
|
}
|
2024-03-29 14:18:38 +08:00
|
|
|
|
}
|
2024-04-19 10:00:37 +08:00
|
|
|
|
|
|
|
|
|
public void GetGift_Handler(object sender, GiftArgs e){ }
|
|
|
|
|
|
|
|
|
|
public void TogglePause()
|
|
|
|
|
{
|
|
|
|
|
Sp_button_Click(this, new EventArgs());
|
|
|
|
|
}
|
2024-03-22 17:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|