Exemple #1
0
    private void SetSprites()
    {
        SpriteManagement   spriteManagement   = new SpriteManagement();
        GeneCodeManagement geneCodeManagement = new GeneCodeManagement();
        SpriteSelector     selector;
        bool  isMale;
        Chibi chibi;

        // Child
        selector = child.GetComponent <SpriteSelector>();
        isMale   = geneCodeManagement.IsMale(childGenes.Gender);
        chibi    = geneCodeManagement.GetChibiFromChild(childGenes, isMale);

        spriteManagement.SetSpriteFromChibiObject(selector, isMale, chibi);

        //Father
        selector = father.GetComponent <SpriteSelector>();
        isMale   = geneCodeManagement.IsMale(fatherGenes.Gender);
        chibi    = geneCodeManagement.GetChibiFromChibiGenes(fatherGenes, isMale);

        spriteManagement.SetSpriteFromChibiObject(selector, isMale, chibi);

        //Mother
        selector = mother.GetComponent <SpriteSelector>();
        isMale   = geneCodeManagement.IsMale(motherGenes.Gender);
        chibi    = geneCodeManagement.GetChibiFromChibiGenes(motherGenes, isMale);

        spriteManagement.SetSpriteFromChibiObject(selector, isMale, chibi);
    }
Exemple #2
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]);
        }
    }
    private void DisplayChild(Child child, GameObject childObject)
    {
        SpriteManagement   spriteManagement   = new SpriteManagement();
        GeneCodeManagement geneCodeManagement = new GeneCodeManagement();
        SpriteSelector     childSelector      = childObject.GetComponent <SpriteSelector>();
        bool  isMale = geneCodeManagement.IsMale(child.Gender);
        Chibi chibi  = geneCodeManagement.GetChibiFromChild(child, isMale);

        spriteManagement.SetSpriteFromChibiObject(childSelector, isMale, chibi);
    }