Esempio n. 1
0
        public HistoricalFigure GenerateChild(FactionHandler.FactionArray factionArray, int familyPref)
        {
            HistoricalFigure littleBaby = new HistoricalFigure();

            littleBaby.gender = Mathf.RoundToInt(Random.Range(1, 3));
            if (littleBaby.gender == 1)
            {
                littleBaby.name = cultures[factionArray.culture].possibleFemaleNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].possibleFemaleNames.Count - 1))];
            }
            else if (littleBaby.gender == 2)
            {
                littleBaby.name = cultures[factionArray.culture].possibleMaleNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].possibleMaleNames.Count - 1))];
            }
            else if (littleBaby.gender == 3)
            {
                littleBaby.name = cultures[factionArray.culture].allNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].allNames.Count - 1))];
            }

            littleBaby.age              = 1;
            littleBaby.mind             = new PhysicalProperties.Mind();
            littleBaby.mind.personality = (PhysicalProperties.PersonalityType)Mathf.RoundToInt(Random.Range(0, System.Enum.GetNames(typeof(PhysicalProperties.PersonalityType)).Length - 1));
            littleBaby.factionID        = factionArray.factionID;
            littleBaby.familyID         = familyPref;
            littleBaby.name             = littleBaby.name + " " + cultures[factionArray.culture].surnames[littleBaby.familyID];
            return(littleBaby);
        }
        public void HandleInheritance(HistoricalFigure deadFigure)
        {
            int eldestAge = 0;
            HistoricalFigure possibleInheritor = null;

            foreach (HistoricalFigure f in FactionHandler.instance.factionArray[deadFigure.factionID].livingFigures)
            {
                if (f.age > eldestAge && f.familyID == deadFigure.familyID)
                {
                    possibleInheritor = f;
                    eldestAge         = f.age;
                }
            }
            if (possibleInheritor == null)
            {
                HistoricalFigure possibleFig = null;
                int possImp          = 10000;
                int lowestDomainSize = 10000;
                foreach (HistoricalFigure f in FactionHandler.instance.factionArray[deadFigure.factionID].livingFigures)
                {
                    if (f.importance < possImp && f.domainSize < lowestDomainSize)
                    {
                        lowestDomainSize = f.domainSize;
                        possImp          = f.importance;
                        possibleFig      = f;
                    }
                }

                possibleInheritor = possibleFig;
            }

            foreach (GameObject g in MapGeneration.instance.chunks)
            {
                if (g.GetComponent <ChunkData>().histOwner == deadFigure)
                {
                    if (possibleInheritor != null && (int)FactionHandler.instance.factionArray[deadFigure.factionID].factionType == 0)
                    {
                        g.GetComponent <ChunkData>().histOwner = possibleInheritor;
                        possibleInheritor.domainSize++;
                    }
                    else if (possibleInheritor != null && (int)FactionHandler.instance.factionArray[deadFigure.factionID].factionType == 1)
                    {
                        g.GetComponent <ChunkData>().magicOwner = possibleInheritor;
                        possibleInheritor.domainSize++;
                    }
                    else if ((int)FactionHandler.instance.factionArray[deadFigure.factionID].factionType == 0)
                    {
                        g.GetComponent <ChunkData>().faction.domain.Remove(g);
                        g.GetComponent <ChunkData>().faction   = FactionHandler.instance.factionArray[0];
                        g.GetComponent <ChunkData>().histOwner = null;
                    }
                    else if ((int)FactionHandler.instance.factionArray[deadFigure.factionID].factionType == 1)
                    {
                        g.GetComponent <ChunkData>().school.domain.Remove(g);
                        g.GetComponent <ChunkData>().school     = FactionHandler.instance.factionArray[0];
                        g.GetComponent <ChunkData>().magicOwner = null;
                    }
                }
            }

            foreach (FactionHandler.FactionArray f in FactionHandler.instance.factionArray)
            {
                if (f.leader == deadFigure && possibleInheritor != null)
                {
                    f.leader = possibleInheritor;
                }
                else if (f.leader == deadFigure)
                {
                    HistoricalFigure newFig = FigureHandler.instance.GenerateChild(FactionHandler.instance.factionArray[deadFigure.factionID], 0);
                    f.leader = newFig;
                }
            }
        }
Esempio n. 3
0
        public HistoricalFigure GenerateHistoricalFigure(FactionHandler.FactionArray factionArray, int agePref, int genderPref, int personPref, int familyPref)
        {
            HistoricalFigure newFigure = new HistoricalFigure();

            newFigure.factionID = factionArray.factionID;

            if (genderPref == 0)
            {
                newFigure.gender = Mathf.RoundToInt(Random.Range(1, 3));
            }
            else
            {
                newFigure.gender = genderPref;
            }

            if (newFigure.gender == 1)
            {
                newFigure.name = cultures[factionArray.culture].possibleFemaleNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].possibleFemaleNames.Count - 1))];
            }
            else if (newFigure.gender == 2)
            {
                newFigure.name = cultures[factionArray.culture].possibleMaleNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].possibleMaleNames.Count - 1))];
            }
            else if (newFigure.gender == 3)
            {
                newFigure.name = cultures[factionArray.culture].allNames[Mathf.RoundToInt(Random.Range(0, cultures[factionArray.culture].allNames.Count - 1))];
            }

            if (agePref == 0)
            {
                newFigure.age = Mathf.RoundToInt(Random.Range(16, 30));
            }
            else
            {
                newFigure.age = agePref;
            }

            if (personPref == 0)
            {
                newFigure.mind             = new PhysicalProperties.Mind();
                newFigure.mind.personality = (PhysicalProperties.PersonalityType)Mathf.RoundToInt(Random.Range(0, System.Enum.GetNames(typeof(PhysicalProperties.PersonalityType)).Length - 1));
            }
            else
            {
                newFigure.mind             = new PhysicalProperties.Mind();
                newFigure.mind.personality = (PhysicalProperties.PersonalityType)personPref - 1;
            }

            newFigure.importance = 0;

            if (familyPref == -1)
            {
                newFigure.familyID = Mathf.RoundToInt(Random.Range(1, cultures[factionArray.culture].surnames.Count - 1));
            }
            else
            {
                newFigure.familyID = familyPref;
            }
            newFigure.name = newFigure.name + " " + cultures[factionArray.culture].surnames[newFigure.familyID];
            historicalFigures.Add(newFigure);
            factionArray.relatedFigures.Add(newFigure);
            factionArray.livingFigures.Add(newFigure);

            return(newFigure);
        }