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);
    }
Exemple #4
0
    public void SetContent()
    {
        #region Variables
        int             geneNumber    = sourceChildGenes.transform.childCount;
        SpriteSelector  childSelector = child.GetComponent <SpriteSelector>();
        List <GenePair> genePairList  = new List <GenePair>();
        Chibi           childToDisplay;
        Child           childToSave;
        string          firstGene = null;
        #endregion

        // Display genes
        for (int i = 0; i < geneNumber; i++)
        {
            string currentGene = sourceChildGenes.transform.GetChild(i).GetComponentInChildren <Text>().text;
            destChildGenes.transform.GetChild(i).GetComponentInChildren <Text>().text = currentGene;

            if ((i % 2) == 0)
            {
                firstGene = currentGene;
            }
            else
            {
                genePairList.Add(new GenePair(firstGene, currentGene));
            }
        }

        // Get sprites name
        GetSpriteNames(genePairList);

        // Prepare Child object for child saving
        childToSave = new Child(gameManager.GetParents(), skinCode, eyesCode, hairCode, mouthCode, genderCode);
        gameManager.SetChild(childToSave);

        // Set sprite
        childToDisplay = new Chibi(skinIndex, eyesIndex, -1, -1, -1, hairColor, mouthIndex);
        manageSprite.SetSpriteFromChibiObject(childSelector, isMale, childToDisplay);
    }