Ejemplo n.º 1
0
    public static void ParseEventsActions(string fileName)
    {
        var eventActionsNodule = XmlNodule.Load(fileName);

        foreach (var eventAction in eventActionsNodule)
        {
            var eventActionObject = new EventAction
            {
                Id                   = eventAction.Get("id").ToInt(),
                ActionName           = eventAction.Get("name").ToString(),
                AnimationName        = eventAction.Get("animationname").ToString(),
                Position             = eventAction.Get("position").ToVector3(),
                PersonalityModifiers = GetNodePersonalityModifiers(eventAction)
            };

            if (fileName.Equals("eventActions"))
            {
                EventActions.Add(eventActionObject.Id, eventActionObject);
            }
            else
            {
                EventReactions.Add(eventActionObject.Id, eventActionObject);
            }
        }
    }
Ejemplo n.º 2
0
    public static void ParseNormalActions()
    {
        var actions = XmlNodule.Load(ACTIONS);

        foreach (var action in actions)
        {
            var actionInstance = new NormalAction
            {
                Id                   = action.Get("actionId").ToInt(),
                Position             = action.Get("position").ToVector3(),
                ActionName           = action.Get("actionname").ToString(),
                AnimationName        = action.Get("animationname").ToString(),
                PersonalityModifiers = GetNodePersonalityModifiers(action)
            };

            foreach (var neighbour in action.Get("neighbours"))
            {
                if (neighbour.ToString() != "")
                {
                    actionInstance.NeighbourIds.Add(neighbour.ToInt());
                }
            }
            NormalActions.Add(actionInstance.Id, actionInstance);
        }
    }
Ejemplo n.º 3
0
    public static void ParsePersonalitiesXml(bool defaultValue, List <AvatarGenerator.Personality> personalities)
    {
        var pathToSettings = Application.dataPath + "\\Resources\\settings.xml";

        if (defaultValue)
        {
            personalities.Clear();
        }

        var personalityDict = personalities.ToDictionary(item => item.Name,
                                                         item => item.ToTuple());

        var settings = XmlNodule.Load(SETTINGS);

        foreach (var personality in settings.Get("personalities"))
        {
            if (defaultValue)
            {
                personalities.Add(ParsePersonality(personality));
            }
            else
            {
                personality.Get("minvalue").Set(personalityDict[personality.Get("name").ToString()].Item1);
                personality.Get("maxvalue").Set(personalityDict[personality.Get("name").ToString()].Item2);
            }
        }
        settings.Save(pathToSettings);
    }
Ejemplo n.º 4
0
    public static void ParseAll()
    {
        var settings = XmlNodule.Load(SETTINGS);

        ParseSpawnPoints(settings);
        ParseModelNames(settings);
    }
Ejemplo n.º 5
0
    public static void ParsePersons()
    {
        var personsxml = XmlNodule.Load(PERSONS);

        foreach (var person in personsxml)
        {
            var personalities   = person.Get("personalities");
            var personalityList =
                personalities.Select(
                    personality =>
                    new Tuple <int, int>(personality.Get("id").ToInt(), personality.Get("value").ToInt()))
                .ToList();

            ParsedPersons.Add(new Tuple <string, List <Tuple <int, int> > >(person.Get("prefabname").ToString(),
                                                                            personalityList));
        }
    }
Ejemplo n.º 6
0
    public static void ParseEvents()
    {
        var eventsNodule = XmlNodule.Load(EVENTS);

        foreach (var Event in eventsNodule)
        {
            var eventObject = new Event
            {
                Id                      = Event.Get("id").ToInt(),
                Name                    = Event.Get("name").ToString(),
                ModelName               = Event.Get("modelname").ToString(),
                IsPlayerControlled      = Event.Get("playercontrolled").ToBool(),
                TriggerKey              = Event.Get("triggerkey").ToString(),
                Radius                  = Event.Get("radius").ToInt(),
                AnimationName           = Event.Get("animationname").ToString(),
                Position                = Event.Get("position").ToVector3(),
                InterestLevel           = Event.Get("interestlevel").ToInt(),
                MaxAmountOfParticipants = Event.Get("maxamountofparticipants").ToInt()
            };

            var personalityMinimums = new List <Tuple <int, int> >();
            foreach (var minimum in Event.Get("personalityMinimums"))
            {
                var personalityId      = minimum.Get("id").ToInt();
                var personalityMinimum = minimum.Get("value").ToInt();
                var newMinimumTuple    = new Tuple <int, int>(personalityId, personalityMinimum);
                personalityMinimums.Add(newMinimumTuple);
            }
            eventObject.PersonalityMinimums = personalityMinimums;

            var npcActionIds        = Event.Get("NpcAnimationActions").Select(actionId => actionId.ToInt()).ToList();
            var associatedActionIds = Event.Get("associatedreactions").Select(actionId => actionId.ToInt()).ToList();
            eventObject.AssociatedActions = associatedActionIds;
            eventObject.NpcActionIds      = npcActionIds;

            if (eventObject.IsPlayerControlled)
            {
                PlayerEvents.Add(eventObject.Id, eventObject);
            }
            else
            {
                Events.Add(eventObject.Id, eventObject);
            }
        }
    }