C# を使用することで、プログラムの主要な機能を完成させることでコードの平和を手に入れることができましたが、レンガの壁にぶつかり、何をすべきかを何時間も探しました。
私のプログラムは部分クラスで書かれています。リスト、画像リストをシャッフルしたいのですが、部分クラス内から静的メソッドを呼び出すことができないようです? Randomize a List<T>からメソッドを密猟しましたが、それはまさに私がやりたいことです。シャッフル メソッドがあることに気付くかもしれませんが、そのメソッドはリストではなく配列をシャッフルします。対象のメソッドのみを展開して、すべてのコードを折りたたんで追加しました。内部に shuffle メソッドを含む新しいクラスを作成しようとしましたが、部分クラスの場合は呼び出しがうまくいきませんでした。不要なコードがあまりないことを願っています。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace MemoryMortalKombatStyle
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
//generate random number
Random r = new Random();
//int for matching panels loop in matching method
int v = 0;
//Counts how many times the music stop/start buttin has been clicked
int musicCount = 0;
//timer counter for starting and stopping timer
int time = 1;
//First picture to be compared against next clicked
int myPBox1;
//Second picture to be compared against first
int myPBox2;
//counts the number of clicks events occured during play
int mouseClicks = 0;
//create image list for easy
List<Image> imagesEasy;
//create image list for hard1
List<Image> imagesHard1;
//create image list for hard2
List<Image> imagesHard2;
//List for final images picked to be used in the pictureBoxes on easy mode
List<Image> imagesFinalEasy;
//List for final images picked to be used in the pictureBoxes hard mode
List<Image> imagesFinalHard;
//create array to pick numbers 1-54 for the images to be chosen for the game
int[] picSlotArray = new int[8];
//Array to hold what pictures the user has mached
int[] picsMatched = new int[16];
//an array for the eight pictures already picked to be stored but now shuffeled in an array
int[] randArrayEightEasy = new int[8];
//an array for the eight pictures already picked to be stored but now shuffeled in an array
int[] randArrayEightHard = new int[8];
//array containing all panels that match
int[] matchedPanels = new int[16];
//the pics picked for easy doubled up twice into one array
int[] randArraySixteenEasy = new int[16];
//the pics picked for hard doubles up twice into one array
int[] randArraySixteenHard = new int[16];
//random array of 16 from 0-15 including 0 & 15
int[] randArray1616 = new int[16];
//Array for pictureBoxes
PictureBox[] myPics = new PictureBox[16];
//Array for panels
Panel[] myPanels = new Panel[16];
private void Form2_Load(object sender, EventArgs e)...
private void InitialiseMyPics()...
private void InitialisePanels()...
private void Theme()...
private void ImageListEasy()...
private void ImageListHard1()...
private void ImageListHard2()...
private void ImageListEasyFinal()...
private void ImageListHardFinal()
{
imagesFinalHard = new List<Image>();
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[0])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[1])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[2])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[3])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[4])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[5])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[6])]);
imagesFinalHard.Add(imagesHard1[(randArraySixteenHard[7])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[0])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[1])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[2])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[3])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[4])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[5])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[6])]);
imagesFinalHard.Add(imagesHard2[(randArraySixteenHard[7])]);
}
private void Randoms()...
private void ShuffleEasy()...
//need to some how shuffle the hardFinalList
private void ShuffleHard()...
private void SetImagesEasy()...
private void SetImagesHard()...
private void ArrayEightTwiceEasy()...
private void ArrayEightTwiceHard()...
private void Tags()...
private void TagsHard1()...
private void TagsHard2()...
private void Names1()...
private void Names2()...
private void Compare()...
private void MatchedPics()...
private void CheckForFinished()...
private void HidePanels()...
private void ShowPanels()...
private void DisableAllPanles()...
private void EnablePanels()...
{
private void HidePictureBoxes()...
private void RevealPictureBoxes()...
private void ShowPics()...
private void panel2_Click_1(object sender, EventArgs e)...
private void button6_Click(object sender, EventArgs e)...
private void button7_Click(object sender, EventArgs e)...
private void New_Game_Click(object sender, EventArgs e)...
private void timer1_Tick_1(object sender, EventArgs e)...
private void Music_Stop_Click(object sender, EventArgs e)...
private void button1_Click(object sender, EventArgs e)
{
ImageListHard1();
ImageListHard2();
Randoms();
ArrayEightTwiceHard();
ShuffleHard();
TagsHard1();
ImageListHardFinal();
//Shuffle Needs to be called here when button is clicked
SetImagesHard();
HidePictureBoxes();
}
}
}