Esempio n. 1
0
    internal override void Apply(Dictionary <Role, Character> involvedCharacters)
    {
        Character HolderCharacter;

        if (!involvedCharacters.TryGetValue(Holder, out HolderCharacter))
        {
            return;                                                              //unbound role
        }
        Character RecipientCharacter;

        if (!involvedCharacters.TryGetValue(Recipient, out RecipientCharacter))
        {
            return;
        }
        RelationshipArray relationships;

        if (!HolderCharacter.m_relationships.TryGetValue(RecipientCharacter, out relationships))
        {
            relationships = new RelationshipArray();
            HolderCharacter.m_relationships.Add(RecipientCharacter, relationships);
        }
        if (status && !relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Add(relationship);
        }
        else if (!status && relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Remove(relationship);
        }
    }
Esempio n. 2
0
    internal override void VirtualApply(ref WorldModel targetModel, Dictionary <Role, Character> involvedCharacters, float likelyhood)
    {
        Character OpinionHolderChar;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderChar))
        {
            return;                                                                       //unbound role
        }
        Character RelationshipHolderChar;

        if (!involvedCharacters.TryGetValue(RelationshipHolder, out RelationshipHolderChar))
        {
            return;
        }
        Character RelationshipRecipientChar;

        if (!involvedCharacters.TryGetValue(RelationshipRecipient, out RelationshipRecipientChar))
        {
            return;
        }
        CharModel OpinionHolderModel;

        if (!targetModel.Characters.TryGetValue(OpinionHolderChar, out OpinionHolderModel))//no previous model
        {
            OpinionHolderModel = new CharModel(OpinionHolderChar);
            targetModel.Characters.Add(OpinionHolderChar, OpinionHolderModel);
        }
        OpinionModel opinions;

        if (!OpinionHolderModel.opinions.TryGetValue(RelationshipHolderChar, out opinions))
        {
            opinions = new OpinionModel();
            OpinionHolderModel.opinions.Add(RelationshipHolderChar, opinions);
        }
        RelationshipArray relationships;

        if (!opinions.relationships.TryGetValue(RelationshipRecipientChar, out relationships))//no previous relationship modeled for the recipient
        {
            relationships = new RelationshipArray();
        }
        if (RelationshipStatus && !relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Add(relationship);
        }
        else if (!RelationshipStatus && relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Remove(relationship);
        }
    }
Esempio n. 3
0
    internal override void Apply(Dictionary <Role, Character> involvedCharacters)
    {
        Character OpinionHolderCharacter;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderCharacter))
        {
            return;
        }
        Character RelationshipHolderChar;

        if (!involvedCharacters.TryGetValue(RelationshipHolder, out RelationshipHolderChar))
        {
            return;
        }
        Character RelationshipRecipientChar;

        if (!involvedCharacters.TryGetValue(RelationshipRecipient, out RelationshipRecipientChar))
        {
            return;
        }
        CharModel RelationshipHolderModel;

        if (!OpinionHolderCharacter.worldModel.Characters.TryGetValue(RelationshipHolderChar, out RelationshipHolderModel))
        {
            RelationshipHolderModel = new CharModel(RelationshipHolderChar);
            OpinionHolderCharacter.worldModel.Characters.Add(RelationshipHolderChar, RelationshipHolderModel);
        }
        RelationshipArray relationshipArray;

        if (!RelationshipHolderModel.Relationships.TryGetValue(RelationshipRecipientChar, out relationshipArray))
        {
            relationshipArray = new RelationshipArray();
            RelationshipHolderModel.Relationships.Add(RelationshipRecipientChar, relationshipArray);
        }
        if (RelationshipStatus && !relationshipArray.relationships.Contains(relationship))
        {
            relationshipArray.relationships.Add(relationship);
        }
        else if (!RelationshipStatus && relationshipArray.relationships.Contains((relationship)))
        {
            relationshipArray.relationships.Remove(relationship);
        }
    }
Esempio n. 4
0
    internal override void VirtualApply(ref WorldModel targetModel, Dictionary <Role, Character> involvedCharacters, float likelyhood)
    {
        Character HolderChar;
        Character RecipientChar;

        if (!involvedCharacters.TryGetValue(Holder, out HolderChar))
        {
            return;                                                         //unbound role
        }
        if (!involvedCharacters.TryGetValue(Recipient, out RecipientChar))
        {
            return;                                                               //unbound role
        }
        CharModel HolderModel;

        if (!targetModel.Characters.TryGetValue(HolderChar, out HolderModel)) //no previous model of the holder
        {
            HolderModel = new CharModel(HolderChar);                          //assuming no relationship
        }
        RelationshipArray relationshipModel;

        if (!HolderModel.Relationships.TryGetValue(RecipientChar, out relationshipModel))//no known relationship with the recipient
        {
            relationshipModel = new RelationshipArray();
            HolderModel.Relationships.Add(RecipientChar, relationshipModel);
        }
        //There are only two cases I can think of at the moment
        if (status && !relationshipModel.relationships.Contains(relationship))
        {
            relationshipModel.relationships.Add(relationship);
        }
        else if (!status && relationshipModel.relationships.Contains(relationship))
        {
            relationshipModel.relationships.Remove(relationship);
        }
    }
 static int SortByID(RelationshipArray rel1, RelationshipArray rel2)
 {
     return(rel1.relID.CompareTo(rel2.relID));
 }
            //public RelationshipArray[] relationships;

            public RelationshipArray CallRelationshipArray(int factID)
            {
                RelationshipArray relArray = relationships[factID];

                return(relArray);
            }
        public void StartUpGame()
        {
            for (int i = 1; i <= System.Enum.GetNames(typeof(PixelType)).Length * 2 - 2; i++)
            {
                FactionArray newFaction = new FactionArray();
                if (i <= System.Enum.GetNames(typeof(PixelType)).Length - 1)
                {
                    newFaction.primaryElementAssociation = (PixelType)i;
                }
                else
                {
                    newFaction.primaryElementAssociation = (PixelType)i - System.Enum.GetNames(typeof(PixelType)).Length;
                }
                int secondaryTemp = Mathf.RoundToInt(Random.Range(1, System.Enum.GetNames(typeof(PixelType)).Length - 1));
                if (secondaryTemp != i)
                {
                    newFaction.secondaryElementAssociation = (PixelType)secondaryTemp;
                }
                else
                {
                    newFaction.secondaryElementAssociation = (PixelType)Mathf.RoundToInt(Random.Range(1, System.Enum.GetNames(typeof(PixelType)).Length - 1));
                }
                newFaction.factionType = (FactionType)1;
                newFaction.factionName = "School of " + newFaction.primaryElementAssociation + " and " + newFaction.secondaryElementAssociation;
                newFaction.factionID   = factionArray.Count;

                newFaction.culture = 4;

                int schoolType = Random.Range(1, 100);
                if (schoolType <= 50)
                {
                    newFaction.schoolType   = (SchoolType)0;
                    newFaction.genHostility = -25f;
                    newFaction.baseStrength = 150;
                }
                else
                {
                    newFaction.schoolType   = (SchoolType)1;
                    newFaction.genHostility = 75f;
                }

                Vector2 newVector2 = GenerateStartCoords();

                newFaction.startTileX = Mathf.RoundToInt(newVector2.x);
                newFaction.startTileY = Mathf.RoundToInt(newVector2.y);

                factionArray.Add(newFaction);
            }

            foreach (FactionArray p in factionArray)
            {
                GameObject[] actors;
                actors = GameObject.FindGameObjectsWithTag("Actor");

                foreach (GameObject g in actors)
                {
                    if (g.GetComponent <CharacterData>().factionID == p.factionID)
                    {
                        g.GetComponent <CharacterData>().factionArray = p;
                        p.members.Add(g);
                    }
                }

                foreach (FactionArray f in factionArray)
                {
                    if (f.factionID != p.factionID)
                    {
                        RelationshipArray relArray = new RelationshipArray();
                        relArray.relationshipNum = 0 - f.genHostility - p.genHostility;
                        relArray.relName         = f.factionName;
                        relArray.relID           = f.factionID;
                        p.relationships.Add(relArray);
                    }
                    else
                    {
                        RelationshipArray relArray = new RelationshipArray();
                        relArray.relationshipNum = 100;
                        relArray.relName         = f.factionName;
                        relArray.relID           = f.factionID;
                        p.relationships.Add(relArray);
                    }
                }
                p.SortRelationShips();
            }

            hasSetUp = true;
            MapGeneration.instance.LayDownFactions();
        }