Exemple #1
0
 public GameEvent(string name, bool storyEvent, string description, float probability, Dictionary<TerrainType, sbyte> terrainWeights, TimeWeights timeWeight, StateWeights stateWeight, List<Reaction> reactions)
 {
     Name = name;
     Description = description;
     BaseProbability = Probability = probability;
     StoryEvent = storyEvent;
     TerrainWeights = terrainWeights;
     TimeWeight = timeWeight;
     StateWeight = stateWeight;
     Reactions = reactions;
 }
Exemple #2
0
    public void Read(SymBinaryReader reader)
    {
        Name = reader.ReadString();
        StoryEvent = reader.ReadBoolean();
        Description = reader.ReadString();
        BaseProbability = Probability = reader.ReadSingle();

        byte terrainsCount = (byte)(System.Enum.GetNames(typeof(TerrainType)).Length - 1);
        TerrainWeights = new Dictionary<TerrainType, sbyte>(terrainsCount);
        byte weightsCount = reader.ReadByte();
        for (byte i = 0; i < weightsCount; ++i)
            TerrainWeights.Add((TerrainType)(1 << i), reader.ReadSByte());
        for (byte i = weightsCount; i < terrainsCount; ++i)
            TerrainWeights.Add((TerrainType)(1 << i), 0);

        TimeWeight = new GameEvent.TimeWeights
        (
             reader.ReadSByte(),
             reader.ReadSByte()
        );

        StateWeight = new GameEvent.StateWeights();
        //

        byte reactionCount = reader.ReadByte();
        Reactions = new List<GameEvent.Reaction>(reactionCount);
        for (byte i = 0; i < reactionCount; ++i)
        {
            string reacDesc = reader.ReadString();

            byte resultCount = reader.ReadByte();
            List<GameEvent.Reaction.Result> results = new List<GameEvent.Reaction.Result>(resultCount);
            for (byte j = 0; j < resultCount; ++j)
                results.Add(new GameEvent.Reaction.Result
                (
                     reader.ReadString(),
                    reader.ReadSingle()
                ));

            Reactions.Add(new GameEvent.Reaction(reacDesc, results));
        }
    }