123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using MaidStatus.CsvData;
- using UnityEngine;
- using wf;
- namespace MaidStatus
- {
- public class YotogiClassSystem : IClassSystem<YotogiClass.Data>
- {
- public YotogiClassSystem(Status status)
- {
- this.status = status;
- this.classDatas_ = new SortedDictionary<int, ClassData<YotogiClass.Data>>();
- this.datas = new ReadOnlySortedDictionary<int, ClassData<YotogiClass.Data>>(this.classDatas_);
- this.oldClassDatas_ = new SortedDictionary<int, ClassData<YotogiClass.Data>>();
- this.oldDatas = new ReadOnlySortedDictionary<int, ClassData<YotogiClass.Data>>(this.oldClassDatas_);
- }
- public override ReadOnlySortedDictionary<int, ClassData<YotogiClass.Data>> datas { get; protected set; }
- public override ReadOnlySortedDictionary<int, ClassData<YotogiClass.Data>> oldDatas { get; protected set; }
- public override Status status { get; protected set; }
- public override ClassData<YotogiClass.Data> Add(YotogiClass.Data data, bool setOpenFlag, bool updateBonusStatus = true)
- {
- if (data != null)
- {
- if (!YotogiClass.IsEnabled(data.id))
- {
- Debug.LogError(string.Concat(new string[]
- {
- "メイド[",
- this.status.fullNameJpStyle,
- "]は夜伽クラス[",
- data.drawName,
- "]を覚えようとしましたが,有効ではないので覚えられません"
- }));
- return null;
- }
- if (!data.learnConditions.isLearnPossiblePersonal(this.status.personal))
- {
- Debug.LogError(string.Concat(new string[]
- {
- "メイド[",
- this.status.fullNameJpStyle,
- "]は夜伽クラス[",
- data.drawName,
- "]を覚えようとしましたが,現在の性格[",
- this.status.personal.drawName,
- "]では覚えられません"
- }));
- return null;
- }
- }
- ClassData<YotogiClass.Data> classData = null;
- if (data != null)
- {
- if (data.classType != AbstractClassData.ClassType.Old)
- {
- if (!this.classDatas_.ContainsKey(data.id))
- {
- classData = new ClassData<YotogiClass.Data>(new Action(this.status.UpdateClassBonusStatus));
- classData.levelLock = true;
- classData.data = data;
- classData.expSystem.SetExreienceList(new List<int>(data.experiences));
- this.classDatas_.Add(data.id, classData);
- }
- classData = this.classDatas_[data.id];
- if (data.classType == AbstractClassData.ClassType.Share && !this.oldClassDatas_.ContainsKey(classData.data.id))
- {
- this.oldClassDatas_.Add(classData.data.id, classData);
- }
- if (this.classDatas_.Count == 1)
- {
- this.status.ChangeYotogiClass(classData.data);
- }
- if (setOpenFlag)
- {
- GameMain.Instance.CharacterMgr.status.AddYotogiClassOpenFlag(data.id);
- }
- }
- else if (data.classType == AbstractClassData.ClassType.Old && !this.oldClassDatas_.ContainsKey(data.id))
- {
- classData = new ClassData<YotogiClass.Data>(new Action(this.status.UpdateClassBonusStatus));
- classData.levelLock = true;
- classData.data = data;
- classData.expSystem.SetExreienceList(new List<int>(data.experiences));
- this.oldClassDatas_.Add(data.id, classData);
- }
- if (updateBonusStatus)
- {
- this.status.UpdateClassBonusStatus();
- }
- }
- return classData;
- }
- public override void Remove(YotogiClass.Data data, bool updateBonusStatus = true)
- {
- if (data != null)
- {
- if (this.classDatas_.ContainsKey(data.id))
- {
- this.classDatas_.Remove(data.id);
- }
- if (this.oldClassDatas_.ContainsKey(data.id))
- {
- this.oldClassDatas_.Remove(data.id);
- }
- if (updateBonusStatus)
- {
- this.status.UpdateClassBonusStatus();
- }
- }
- if (this.status.selectedYotogiClass == null)
- {
- using (SortedDictionary<int, ClassData<YotogiClass.Data>>.Enumerator enumerator = this.classDatas_.GetEnumerator())
- {
- if (enumerator.MoveNext())
- {
- KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair = enumerator.Current;
- this.status.ChangeYotogiClass(keyValuePair.Value.data);
- }
- }
- }
- }
- public void Clear()
- {
- this.classDatas_.Clear();
- this.oldClassDatas_.Clear();
- }
- public override List<YotogiClass.Data> GetLearnPossibleClassDatas(bool unlearnedOnly, AbstractClassData.ClassType classTypeFlags)
- {
- return base.GetLearnPossibleClassDatas(unlearnedOnly, classTypeFlags);
- }
- public override YotogiClass.Data IdToClass(int id)
- {
- return (!YotogiClass.Contains(id)) ? null : YotogiClass.GetData(id);
- }
- public override void Serialize(BinaryWriter binary)
- {
- binary.Write((short)this.classDatas_.Count);
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair in this.classDatas_)
- {
- binary.Write(keyValuePair.Key);
- keyValuePair.Value.Serialize(binary);
- }
- binary.Write((short)this.oldClassDatas_.Count);
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair2 in this.oldClassDatas_)
- {
- binary.Write(keyValuePair2.Key);
- bool flag = !this.classDatas_.ContainsKey(keyValuePair2.Key);
- binary.Write(flag);
- if (flag)
- {
- keyValuePair2.Value.Serialize(binary);
- }
- }
- }
- public override void Deserialize(BinaryReader binary, int version)
- {
- Func<int, ClassData<YotogiClass.Data>> func = delegate(int classId)
- {
- YotogiClass.Data data2 = (!YotogiClass.Contains(classId)) ? null : YotogiClass.GetData(classId);
- ClassData<YotogiClass.Data> classData3 = new ClassData<YotogiClass.Data>(new Action(this.status.UpdateClassBonusStatus));
- classData3.levelLock = true;
- classData3.data = data2;
- if (data2 != null)
- {
- classData3.expSystem.SetExreienceList(new List<int>(data2.experiences));
- }
- classData3.Deserialize(binary, version);
- Action<SimpleExperienceSystem> onChangeLevelEvent = classData3.expSystem.onChangeLevelEvent;
- classData3.expSystem.onChangeLevelEvent = null;
- classData3.expSystem.Update();
- classData3.expSystem.onChangeLevelEvent = onChangeLevelEvent;
- return classData3;
- };
- this.classDatas_.Clear();
- int num = (int)binary.ReadInt16();
- for (int i = 0; i < num; i++)
- {
- int num2 = binary.ReadInt32();
- ClassData<YotogiClass.Data> classData = func(num2);
- if (YotogiClass.IsEnabled(num2) && classData.data.learnConditions.isLearnPossiblePersonal(this.status.personal))
- {
- this.classDatas_.Add(num2, classData);
- }
- }
- if (211 >= version)
- {
- return;
- }
- this.oldClassDatas_.Clear();
- num = (int)binary.ReadInt16();
- for (int j = 0; j < num; j++)
- {
- int num3 = binary.ReadInt32();
- bool flag = binary.ReadBoolean();
- if (flag)
- {
- ClassData<YotogiClass.Data> classData2 = func(num3);
- if (YotogiClass.IsEnabled(num3) && classData2.data.learnConditions.isLearnPossiblePersonal(this.status.personal))
- {
- this.oldClassDatas_.Add(num3, classData2);
- }
- }
- else if (YotogiClass.IsEnabled(num3) && this.classDatas_.ContainsKey(num3))
- {
- this.oldClassDatas_.Add(this.classDatas_[num3].data.id, this.classDatas_[num3]);
- }
- }
- Dictionary<int, ClassData<YotogiClass.Data>> dictionary = new Dictionary<int, ClassData<YotogiClass.Data>>();
- Dictionary<int, ClassData<YotogiClass.Data>> dictionary2 = new Dictionary<int, ClassData<YotogiClass.Data>>();
- Dictionary<int, ClassData<YotogiClass.Data>> dictionary3 = new Dictionary<int, ClassData<YotogiClass.Data>>();
- for (int k = 0; k < 2; k++)
- {
- SortedDictionary<int, ClassData<YotogiClass.Data>> sortedDictionary = (k != 0) ? this.oldClassDatas_ : this.classDatas_;
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair in sortedDictionary)
- {
- YotogiClass.Data data = keyValuePair.Value.data;
- AbstractClassData.ClassType classType = data.classType;
- if (classType == AbstractClassData.ClassType.New && !dictionary2.ContainsKey(data.id))
- {
- dictionary2.Add(data.id, keyValuePair.Value);
- }
- else if (classType == AbstractClassData.ClassType.Old && !dictionary3.ContainsKey(data.id))
- {
- dictionary3.Add(data.id, keyValuePair.Value);
- }
- else if (classType == AbstractClassData.ClassType.Share && !dictionary.ContainsKey(data.id))
- {
- dictionary.Add(data.id, keyValuePair.Value);
- }
- }
- }
- this.classDatas_.Clear();
- this.oldClassDatas_.Clear();
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair2 in dictionary)
- {
- this.classDatas_.Add(keyValuePair2.Key, keyValuePair2.Value);
- this.oldClassDatas_.Add(keyValuePair2.Key, keyValuePair2.Value);
- }
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair3 in dictionary2)
- {
- this.classDatas_.Add(keyValuePair3.Key, keyValuePair3.Value);
- }
- foreach (KeyValuePair<int, ClassData<YotogiClass.Data>> keyValuePair4 in dictionary3)
- {
- this.oldClassDatas_.Add(keyValuePair4.Key, keyValuePair4.Value);
- }
- }
- protected override List<YotogiClass.Data> GetAllBaseClassData()
- {
- return YotogiClass.GetAllDatas(true);
- }
- }
- }
|