void GenerateSpriteCharacters(GeneratedBaseCharacter character, ClassLabel classLabel) { var pattern = "{0} => {1}"; var generatedAClassLabels = new[] { generatedCommonClassLabel, generatedAClassLabel }; var generatedSClassLabels = new[] { generatedSClassLabel, generatedAClassLabel }; var realHeadSpriteLoc = string.Empty; var realEyeSpriteLoc = string.Empty; var realMouthSpriteLoc = string.Empty; var realBodySpriteLoc = string.Empty; var realArmSpriteLoc = string.Empty; var realLegSpriteLoc = string.Empty; if (classLabel == ClassLabel.B || classLabel == ClassLabel.C) { realHeadSpriteLoc = string.Format(headSpriteLoc, generatedCommonClassLabel); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedCommonClassLabel); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedCommonClassLabel); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedCommonClassLabel); realArmSpriteLoc = string.Format(armSpriteLoc, generatedCommonClassLabel); realLegSpriteLoc = string.Format(legSpriteLoc, generatedCommonClassLabel); } else if (classLabel == ClassLabel.A) { var rIndex = Random.Range(0, generatedAClassLabels.Length); realHeadSpriteLoc = string.Format(headSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedAClassLabels[rIndex]); realArmSpriteLoc = string.Format(armSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realLegSpriteLoc = string.Format(legSpriteLoc, generatedAClassLabels[rIndex]); } else { var rIndex = Random.Range(0, generatedSClassLabels.Length); realHeadSpriteLoc = string.Format(headSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedSClassLabels[rIndex]); realArmSpriteLoc = string.Format(armSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realLegSpriteLoc = string.Format(legSpriteLoc, generatedSClassLabels[rIndex]); } countOfHeadSprite = spriteHelper.Count(realHeadSpriteLoc); countOfEyeSprite = spriteHelper.Count(realEyeSpriteLoc); countOfMouthSprite = spriteHelper.Count(realMouthSpriteLoc); countOfBodySprite = spriteHelper.Count(realBodySpriteLoc); countOfLegSprite = spriteHelper.Count(realLegSpriteLoc) / 2; var headIndex = Random.Range(0, countOfHeadSprite); var eyeIndex = Random.Range(0, countOfEyeSprite); var mouthIndex = Random.Range(0, countOfMouthSprite); var bodyIndex = Random.Range(0, countOfBodySprite); var legIndex = Random.Range(0, countOfLegSprite); var headSprite = spriteHelper.Get(string.Format(pattern, realHeadSpriteLoc, headIndex)); var eyeSprite = spriteHelper.Get(string.Format(pattern, realEyeSpriteLoc, eyeIndex)); var mouthSprite = spriteHelper.Get(string.Format(pattern, realMouthSpriteLoc, mouthIndex)); var bodySprite = spriteHelper.Get(string.Format(pattern, realBodySpriteLoc, bodyIndex)); var leftArmSprite = spriteHelper.Get(string.Format(pattern, realArmSpriteLoc, "l_" + bodyIndex)); var rightArmSprite = spriteHelper.Get(string.Format(pattern, realArmSpriteLoc, "r_" + bodyIndex)); var leftLegSprite = spriteHelper.Get(string.Format(pattern, realLegSpriteLoc, "l_" + legIndex)); var rightLegSprite = spriteHelper.Get(string.Format(pattern, realLegSpriteLoc, "r_" + legIndex)); // var instanceOfBaseCharacter = Instantiate<GeneratedBaseCharacter>(generatedBaseCharacterPrefab, Vector3.zero, Quaternion.identity); // _generatedCharaters.Add(instanceOfBaseCharacter); var characterElements = character.elements; var characterEyes = characterElements.eye; var characterMouth = characterElements.mouth; characterElements.head.sprite = headSprite; characterEyes.sprite = eyeSprite; characterMouth.sprite = mouthSprite; characterElements.body.sprite = bodySprite; characterElements.leftArm.sprite = leftArmSprite; characterElements.rightArm.sprite = rightArmSprite; characterElements.leftLeg.sprite = leftLegSprite; characterElements.rightLeg.sprite = rightLegSprite; // transform eyes and mouth according to pivot of Y // range of mouth var rangeYOfMouth = Random.Range(.2f, .6f); var mouthPosition = characterMouth.transform.localPosition; mouthPosition.y = rangeYOfMouth; characterMouth.transform.localPosition = mouthPosition; // range of eyes var rangeYOfEyes = Random.Range(1f, 1.3f); var eyesPosition = characterEyes.transform.localPosition; eyesPosition.y = rangeYOfEyes; characterEyes.transform.localPosition = eyesPosition; }