using System; using System.Collections.Generic; using System.IO; public class SimpleExperienceSystem : IExperienceSystem { public SimpleExperienceSystem() { } public SimpleExperienceSystem(List need_exp_list) { this.SetExreienceList(need_exp_list); } protected SimpleExperienceSystem(SimpleExperienceSystem other) : base(other) { this.need_exp_list_ = new List(other.need_exp_list_); } public void SetExreienceList(List need_exp_list) { if (need_exp_list == null || need_exp_list.Count <= 0) { this.need_exp_list_ = null; this.Update(); return; } this.need_exp_list_ = need_exp_list; NDebug.Assert(0 < this.need_exp_list_.Count, "There is no element."); this.Update(); } public override int GetMaxLevel() { return (this.need_exp_list_ != null) ? this.need_exp_list_.Count : 0; } protected override int GetNeedExp(int level) { if (this.need_exp_list_ == null) { return 0; } return this.need_exp_list_[level - 1]; } public override void Serialize(BinaryWriter binary) { base.Serialize(binary); } public override void Update() { int level_ = this.level_; base.Update(); if (level_ != this.level_ && this.onChangeLevelEvent != null) { this.onChangeLevelEvent(this); } } public void SerializeAll(BinaryWriter binary) { this.Serialize(binary); if (this.need_exp_list_ == null) { int value = 0; binary.Write(value); } else { binary.Write(this.need_exp_list_.Count); for (int i = 0; i < this.need_exp_list_.Count; i++) { binary.Write(this.need_exp_list_[i]); } } } public void DeserializeAll(BinaryReader binary, int version) { this.Deserialize(binary, version); int num = binary.ReadInt32(); if (num <= 0) { this.need_exp_list_ = null; } else { if (this.need_exp_list_ == null) { this.need_exp_list_ = new List(); } this.need_exp_list_.Clear(); for (int i = 0; i < num; i++) { this.need_exp_list_.Add(binary.ReadInt32()); } } } public override object Clone() { return new SimpleExperienceSystem(this); } public Action onChangeLevelEvent; protected List need_exp_list_; }