Using C# I am one peace of code from finishing main functionality of my program but have hit a brick wall and have searched for hours what to do.
My program is written in a partial class. I want to shuffle a list, an image list to be but I cant seem call a static method from within my partial class? I poached the method from Randomize a List<T> and it is exactly what I want to do. You may notice I have a shuffle method, but that method shuffles an array, not a list. I have added all my code as collapsed with only the methods of interest expanded. I tried creating a new class with the shuffle method inside but had no luck calling if in my partial class: I hope that isn't to much unnecessary code.
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();
}
}
}