public void Add(int type, int value, bool isMerge = true) { if (!this.achives.ContainsKey(type.ToString())) { return; } LocalData localData = this.achives[type.ToString()]; if (isMerge) { localData.value += value; } else { localData.value = value; } this.achives[type.ToString()] = localData; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); GlobalEventHandle.EmitRefreshAchiveHandle(type); DotManager.GetInstance().CheckAchiev(); if (localData.status != -1) { return; } TAchive tAchive = Configs.Configs.TAchives[localData.key.ToString()]; if (localData.value >= tAchive.Value) { localData.status = -2; } this.achives[type.ToString()] = localData; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); GlobalEventHandle.EmitRefreshAchiveHandle(type); }
public void Update(int type) { if (!this.achives.ContainsKey(type.ToString())) { return; } LocalData localData = this.achives[type.ToString()]; if (localData.status != -3) { return; } TAchive tAchive = Configs.Configs.TAchives[localData.key.ToString()]; if (tAchive.Next == 0) { return; } TAchive tAchive2 = Configs.Configs.TAchives[tAchive.Next.ToString()]; if (localData.value >= tAchive2.Value) { localData.status = -2; localData.key = tAchive2.ID; } else { localData.status = -1; localData.key = tAchive2.ID; } this.achives[type.ToString()] = localData; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); }
public void Reset() { this.tasks.Clear(); foreach (KeyValuePair <string, TTask> current in Configs.Configs.TTasks) { LocalData localData = this.GetLocalData(current.Value.ID); localData.type = -1; localData.key = current.Value.ID; localData.status = -1; localData.value = 0; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); } this.Read(); }
private void Read() { tasks.Clear(); List <TTask> list = new List <TTask>(); foreach (KeyValuePair <string, TTask> current in Configs.Configs.TTasks) { bool flag = false; using (List <TTask> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { if (enumerator2.Current.ID == current.Value.ID) { flag = true; break; } } } if (!flag) { list.Add(current.Value); } } List <TTask> arg_A7_0 = list; Comparison <TTask> arg_A7_1; if ((arg_A7_1 = TaskData.__c.__9__13_0) == null) { arg_A7_1 = (TaskData.__c.__9__13_0 = new Comparison <TTask>(TaskData.__c.__9._Read_b__13_0)); } arg_A7_0.Sort(arg_A7_1); foreach (TTask current2 in list) { LocalData localData = this.GetLocalData(current2.ID); if (localData.type == 0) { localData.type = -1; localData.key = current2.ID; localData.status = -1; localData.value = 0; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); } this.tasks.Add(current2.ID.ToString(), localData); } }
public bool Finish(int type) { if (!this.achives.ContainsKey(type.ToString())) { return(false); } LocalData localData = this.achives[type.ToString()]; if (localData.status != -2) { return(false); } TAchive tAchive = Configs.Configs.TAchives[localData.key.ToString()]; if (tAchive.Next == 0) { localData.status = -3; } else { TAchive tAchive2 = Configs.Configs.TAchives[tAchive.Next.ToString()]; if (localData.value >= tAchive2.Value) { localData.status = -2; localData.key = tAchive2.ID; } else { localData.status = -1; localData.key = tAchive2.ID; } } this.achives[type.ToString()] = localData; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); DotManager.GetInstance().CheckAchiev(); return(true); }
private LocalData ConvertLocalData(string str) { LocalData result = default(LocalData); if (str.Equals("nil")) { result.type = 0; result.key = 0; result.status = 0; result.value = 0; } else { string[] array = str.Split(new char[] { ',' }); result.type = int.Parse(array[0]); result.value = int.Parse(array[1]); result.key = int.Parse(array[2]); result.status = int.Parse(array[3]); } return(result); }
public bool Finish(int type) { if (!this.tasks.ContainsKey(type.ToString())) { return(false); } LocalData localData = this.tasks[type.ToString()]; if (localData.status != -2) { return(false); } TTask tTask = Configs.Configs.TTasks[localData.key.ToString()]; if (localData.value < tTask.Value) { return(false); } localData.status = -3; this.tasks[type.ToString()] = localData; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); DotManager.GetInstance().CheckTask(); return(true); }
private void Read() { achives.Clear(); List <TAchive> list = new List <TAchive>(); foreach (KeyValuePair <string, TAchive> current in Configs.Configs.TAchives) { bool flag = false; using (List <TAchive> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { if (enumerator2.Current.Type == current.Value.Type) { flag = true; break; } } } if (!flag) { list.Add(current.Value); } } List <TAchive> arg_A7_0 = list; Comparison <TAchive> arg_A7_1; if ((arg_A7_1 = AchiveData.__c.__9__12_0) == null) { arg_A7_1 = (AchiveData.__c.__9__12_0 = new Comparison <TAchive>(AchiveData.__c.__9._Read_b__12_0)); } arg_A7_0.Sort(arg_A7_1); foreach (TAchive current2 in list) { LocalData localData = this.GetLocalData(current2.Type); if (localData.type == 0) { Dictionary <int, int> dictionary = new Dictionary <int, int> { { 1, 1 }, { 2, 0 }, { 3, 0 }, { 4, 0 }, { 5, 0 }, { 6, 0 } }; localData.type = current2.Type; localData.key = current2.ID; localData.status = -1; localData.value = dictionary[current2.Type]; this.SetLocalData(localData.type, localData.value, localData.key, localData.status); } else { this.Update(localData.type); } this.achives.Add(current2.Type.ToString(), localData); } }