//buff更新 public void buffupdate() { bool bupd = true; List <BuffName> mbf = new List <BuffName>(magic.GetBuffList().Keys); List <BuffName> bf = new List <BuffName>(buffs.Keys); for (int i = 0; i < magic.GetBuffList().Count; ++i) { if (i < buffs.Count) { if (bf[i] != mbf[i]) { bupd = false; break; } } else { bupd = false; break; } } if (!bupd) { //删 for (int i = 0; i < buffGameObjectlist.Count; ++i) { GameObject.Destroy(buffGameObjectlist[i]); } buffGameObjectlist.Clear(); //修 buffs.Clear(); foreach (KeyValuePair <BuffName, int> child in magic.GetBuffList()) { buffs.Add(child.Key, child.Value); } //新建 bf = new List <BuffName>(buffs.Keys); List <int> bflevel = new List <int>(buffs.Values); for (buffCount = 0; buffCount < buffs.Count; ++buffCount) { GameObject buff = GameObject.Instantiate(buffPerb, buffLists.transform); buffGameObjectlist.Add(buff); buff.transform.localPosition = new Vector3(-200 + 100 * (buffCount % 5), -25 + 50 * (buffCount / 5), 0); string[] lines = bufftext.text.Split("\n"[0]); for (int i = 0; i < lines.Length; ++i) { string[] parts = lines[i].Split(" "[0]); if (parts[0] == bf[buffCount].ToString()) { foreach (Transform child in buff.transform) { if (child.name == "state") { child.GetComponentInChildren <Text>().text = parts[1]; } if (child.name == "bufflevel") { child.GetComponent <Text>().text = bflevel[buffCount].ToString(); } } break; } } } } }