I made this code to randomly select a hue for a given pet. I have two questions regarding this code. I realize that there may be a function for this built in already but I still wanted to try to make my own.
1. I feel like this is far to much code to accomplish what I want and I don't feel like this is the best way to create "random" percentage chances. ( I know there is a random double command and also a random list command. I had issues teaching myself how to use these commands.)
2. I can make this a stand alone function and just call the function rather than including this code in every mobile file correct?
1. I feel like this is far to much code to accomplish what I want and I don't feel like this is the best way to create "random" percentage chances. ( I know there is a random double command and also a random list command. I had issues teaching myself how to use these commands.)
2. I can make this a stand alone function and just call the function rather than including this code in every mobile file correct?
Code:
//Random Color Selection
int hueNum = Utility.RandomMinMax(0, 12);
switch (hueNum) //Selects Color Category
{
case 0: //Purple Category
case 1:
int purNum = Utility.RandomMinMax(0, 8);
switch (purNum)
{
case 0:
case 1:
this.Hue = 0xA33;
break;
case 2:
case 3:
this.Hue = 0xA24;
break;
case 4:
case 5:
this.Hue = 0xA3C;
break;
case 6:
case 7:
this.Hue = 0xA30;
break;
case 8:
this.Hue = 0x77F;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 2: //Blue Category
case 3:
int bluNum = Utility.RandomMinMax(0, 8);
switch (bluNum)
{
case 0:
case 1:
this.Hue = 0xA13;
break;
case 2:
case 3:
this.Hue = 0x7BB;
break;
case 4:
case 5:
this.Hue = 0x4F1;
break;
case 6:
case 7:
this.Hue = 0x57;
break;
case 8:
this.Hue = 0x77C;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 4: //Pink Category
case 5:
int pinNum = Utility.RandomMinMax(0, 8);
switch (pinNum)
{
case 0:
case 1:
this.Hue = 0x78A;
break;
case 2:
case 3:
this.Hue = 0x1C;
break;
case 4:
case 5:
this.Hue = 0x80;
break;
case 6:
case 7:
this.Hue = 0x78B;
break;
case 8:
this.Hue = 0x503;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 6: //Yellow Category
case 7:
int yelNum = Utility.RandomMinMax(0, 8);
switch (yelNum)
{
case 0:
case 1:
this.Hue = 0x4EB;
break;
case 2:
case 3:
this.Hue = 0x4EC;
break;
case 4:
case 5:
this.Hue = 0x550;
break;
case 6:
case 7:
this.Hue = 0xAA1;
break;
case 8:
this.Hue = 0x496;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 8: //Green Category
case 9:
int grnNum = Utility.RandomMinMax(0, 8);
switch (grnNum)
{
case 0:
case 1:
this.Hue = 0x5B4;
break;
case 2:
case 3:
this.Hue = 0x4E;
break;
case 4:
case 5:
this.Hue = 0x110;
break;
case 6:
case 7:
this.Hue = 0x506;
break;
case 8:
this.Hue = 0x77B;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 10: //Red Category
case 11:
int redNum = Utility.RandomMinMax(0, 8);
switch (redNum)
{
case 0:
case 1:
this.Hue = 0x7AC;
break;
case 2:
case 3:
this.Hue = 0x21;
break;
case 4:
case 5:
this.Hue = 0xE8;
break;
case 6:
case 7:
this.Hue = 0x494;
break;
case 8:
this.Hue = 0x780;
break;
default:
this.Hue = 0x422;
break;
}
break;
case 12: //2-Tone !!Rare!! Category
int rareNum = Utility.RandomMinMax(0, 5);
switch (rareNum)
{
case 0:
this.Hue = 0x795;
break;
case 1:
this.Hue = 0x503;
break;
case 2:
this.Hue = 0x508;
break;
case 3:
this.Hue = 0x509;
break;
case 4:
this.Hue = 0xAA9;
break;
case 5:
this.Hue = 0xAA8;
break;
default:
this.Hue = 0x422;
break;
}
break;
default:
this.Hue = 0x422;
break;
}