Beispiel #1
0
    private void CreateParents()
    {
        #region variables
        GeneCodeManagement manageCode    = new GeneCodeManagement();
        SpriteManagement   manageSprite  = new SpriteManagement();
        List <ChibiGenes>  parentGenes   = new List <ChibiGenes>();
        List <Chibi>       parents       = new List <Chibi>();
        SpriteSelector     selector      = currentParent.GetComponent <SpriteSelector>();
        string             eyeSpriteName = selector.faceEyesRenderer.sprite.name;
        string             gender        = eyeSpriteName.Substring(eyeSpriteName.Length - 1);
        bool isMale;
        List <SpriteSelector> selectors = new List <SpriteSelector>
        {
            parent1.GetComponent <SpriteSelector>(),
            parent2.GetComponent <SpriteSelector>(),
            parent3.GetComponent <SpriteSelector>(),
            parent4.GetComponent <SpriteSelector>(),
            parent5.GetComponent <SpriteSelector>(),
            parent6.GetComponent <SpriteSelector>()
        };
        #endregion

        // Get sample parent caracteristics from Parents.cs (genetic code)
        if (gender.Equals("A"))
        {
            for (int i = 0; i < Parents.FATHER_GENES.Count; i++)
            {
                parentGenes.Add(Parents.FATHER_GENES[i]);
            }

            isMale = true;
        }
        else
        {
            for (int i = 0; i < Parents.MOTHER_GENES.Count; i++)
            {
                parentGenes.Add(Parents.MOTHER_GENES[i]);
            }

            isMale = false;
        }

        // Create Chibi objects
        for (int j = 0; j < parentGenes.Count; j++)
        {
            string genderSpritename = manageCode.GetSpritenameFromGeneCode("gender", parentGenes[j].Gender, isMale);
            int    skinIndex        = manageCode.GetIndexFromGeneCode("skin", parentGenes[j].SkinColor, isMale);
            int    eyesIndex        = manageCode.GetIndexFromGeneCode("eyes", parentGenes[j].EyesColor, isMale);
            Color  hairColor        = manageCode.GetColorFromGeneCode(parentGenes[j].HairColor);
            int    mouthIndex       = manageCode.GetIndexFromGeneCode("mouth", parentGenes[j].Mouth, isMale);
            parents.Add(new Chibi(skinIndex, eyesIndex, -1, -1, -1, hairColor, mouthIndex));
        }

        // Set those characteristics
        for (int i = 0; i < selectors.Count; i++)
        {
            manageSprite.SetSpriteFromChibiObject(selectors[i], isMale, parents[i]);
        }
    }
Beispiel #2
0
 private void GetSpriteNames(List <GenePair> genePairList)
 {
     genderCode       = genePairList[4].ConcatenateGenePairs();
     isMale           = manageCode.IsMale(genderCode);
     genderSpritename = manageCode.GetSpritenameFromGeneCode("gender", genderCode, isMale);
     skinCode         = genePairList[0].ConcatenateGenePairs();
     skinIndex        = manageCode.GetIndexFromGeneCode("skin", skinCode, isMale);
     eyesCode         = genePairList[1].ConcatenateGenePairs();
     eyesIndex        = manageCode.GetIndexFromGeneCode("eyes", eyesCode, isMale);
     hairCode         = genePairList[2].ConcatenateGenePairs();
     hairColor        = manageCode.GetColorFromGeneCode(hairCode);
     mouthCode        = genePairList[3].ConcatenateGenePairs();
     mouthIndex       = manageCode.GetIndexFromGeneCode("mouth", mouthCode, isMale);
 }