Beispiel #1
0
        public ReputationState GetReputation(string characterName)
        {
            ReputationState rep = null;

            if (!CharacterReputation.TryGetValue(characterName, out rep))
            {
                rep = GetNewRepForCharacter(characterName);
                CharacterReputation.Add(characterName, rep);
                Player.Get.AvatarActions.ReceiveAction(AvatarAction.NpcReputationChange, WorldClock.AdjustedRealTime);
            }
            return(rep);
        }
Beispiel #2
0
        public void AddExperience(int experience, string flagSet)
        {
            int currentExperience = 0;

            if (!ExperienceByFlagset.TryGetValue(flagSet, out currentExperience))
            {
                ExperienceByFlagset.Add(flagSet, 0);
            }
            ExperienceByFlagset [flagSet] = currentExperience + experience;

            Player.Get.AvatarActions.ReceiveAction(AvatarAction.SkillExperienceGain, WorldClock.AdjustedRealTime);
            //credentials will be handled by Skills
        }
Beispiel #3
0
        public void InitDbValue()
        {
            var rType = GetType();
            var ps    = rType.GetProperties();

            foreach (var info in ps)
            {
                ExtendedAttribute extended = ExtendedAttribute.GetAttribute(info);
                if (extended != null)
                {
                    continue;
                }
                ExcludeFieldAttribute exclude = ExcludeFieldAttribute.GetAttribute(info);
                if (exclude != null)
                {
                    continue;
                }
                RefFieldAttribute refField = RefFieldAttribute.GetAttribute(info);
                if (refField != null)
                {
                    continue;
                }
                _dbvalue.Add(info.Name, info.GetValue(this, null));
            }
        }
Beispiel #4
0
 public void SetLastCredentials(string flagset, int credentials)
 {
     if (!LastCredentialsByFlagset.ContainsKey(flagset))
     {
         LastCredentialsByFlagset.Add(flagset, credentials);
     }
     else
     {
         LastCredentialsByFlagset [flagset] = credentials;
     }
     Player.Get.AvatarActions.ReceiveAction(AvatarAction.SkillCredentialsGain, WorldClock.AdjustedRealTime);
 }
    static void Main(string[] args)
    {
        SDictionary <string, string> b = new SDictionary <string, string>();

        b.Add("foo", "bar");

        System.IO.MemoryStream memStream = new System.IO.MemoryStream();
        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
        f.Serialize(memStream, b);
        memStream.Position = 0;

        b = f.Deserialize(memStream) as SDictionary <string, string>;
    }
Beispiel #6
0
 private static void StringAddGUI <TValue>(SDictionary <string, TValue> dict, ref string toAdd, GetNew <TValue> getNew)
 {
     EditorGUILayout.LabelField("New:", GUILayout.Width(45));
     toAdd = EditorGUILayout.TextField(toAdd);
     if (GUILayout.Button(new GUIContent("Add"), GUILayout.Width(45)))
     {
         if (!string.IsNullOrWhiteSpace(toAdd) && !dict.ContainsKey(toAdd))
         {
             dict.Add(toAdd, getNew());
         }
         toAdd = string.Empty;
         GUIUtility.keyboardControl = 0;
     }
 }
Beispiel #7
0
 public void FinishSpeech(string characterName)
 {
     if (FinishedByCharacters.ContainsKey(characterName))
     {
         int numTimes = FinishedByCharacters [characterName] + 1;
         FinishedByCharacters [characterName] = numTimes;
     }
     else
     {
         FinishedByCharacters.Add(characterName, 1);
     }
     NumTimesCompleted++;
     NumUsers--;
 }
Beispiel #8
0
 public void StartSpeech(string characterName)
 {
     if (StartedByCharacters.ContainsKey(characterName))
     {
         int numTimes = StartedByCharacters [characterName] + 1;
         StartedByCharacters [characterName] = numTimes;
     }
     else
     {
         StartedByCharacters.Add(characterName, 1);
     }
     NumTimesStarted++;
     NumUsers++;
 }
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            SDictionary <object, object> sdict = new SDictionary <object, object>();

            List <object> keys   = (List <object>)info.GetValue("keys", typeof(List <object>));
            List <object> values = (List <object>)info.GetValue("values", typeof(List <object>));

            for (int i = 0; i < keys.Count; i++)
            {
                sdict.Add(keys[i], i < values.Count ? values[i] : default);
            }

            obj = sdict;
            return(obj);
        }
Beispiel #10
0
        public void Load()
        {
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var files = Directory.GetFiles(dir);

            foreach (var file in files)
            {
                if (!File.Exists(file))
                {
                    continue;
                }
                var lines = File.ReadAllLines(file);
                foreach (var line in lines)
                {
                    // 주석 라인 처리
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    var columns = line.Split(';');
                    if (columns.Length < 2)
                    {
                        continue;
                    }

                    var answer = columns[0].Trim();
                    var desc   = columns[1].Trim();

                    var selections = answer.Split(':');
                    if (selections.Length == 1)
                    {
                        // 주관식 문제
                        Dictionary.Add(new Question(answer, desc));
                    }
                    else
                    {
                        // 답안 지정 객관식 문제
                        SDictionary.Add(new SelectableQuestion(selections.ToList(), desc));
                    }
                }
            }
        }
Beispiel #11
0
        public void CopyFrom(WISaveState saveState)
        {
            CanEnterInventory = saveState.CanEnterInventory;
            CanBeCarried      = saveState.CanBeCarried;
            CanBeDropped      = saveState.CanBeDropped;
            UnloadWhenStacked = saveState.UnloadWhenStacked;
            LastState         = saveState.LastState;
            if (Scripts == null)
            {
                Scripts = new SDictionary <string, string>();
            }
            else
            {
                Scripts.Clear();
            }
            var scriptsEnum = saveState.Scripts.GetEnumerator();

            while (scriptsEnum.MoveNext())
            {
                Scripts.Add(scriptsEnum.Current.Key, scriptsEnum.Current.Value);
            }
        }
Beispiel #12
0
 private static void EnumAddGUI <TKey, TValue>(this SDictionary <TKey, TValue> dict, GetNew <TValue> getNew) where TKey : System.Enum
 {
     if (EditorGUILayout.DropdownButton(new GUIContent("+"), FocusType.Keyboard))
     {
         GenericMenu menu = new GenericMenu();
         foreach (var t in EnumUtils.GetValues <TKey>())
         {
             if (!dict.ContainsKey(t))
             {
                 menu.AddItem(new GUIContent(t.ToString()), false, (obj) => dict.Add((TKey)obj, getNew()), t);
             }
         }
         menu.ShowAsContext();
     }
 }