public override void DoAction(IEventArgs args) { if (honors != null) { IList <FreeData> fds = new List <FreeData>(); Contexts contexts = (Contexts)args.GameContext; foreach (PlayerEntity player in contexts.player.GetEntities()) { fds.Add((FreeData)player.freeData.FreeData); } foreach (PlayerHonorAction.PlayerHonor ph in honors) { ph.SetHonor(args, Sharpen.Collections.ToArray(fds, new FreeData[0])); } IDictionary <int, IList <PlayerHonorAction.PlayerHonor> > map = new Dictionary <int, IList <PlayerHonorAction.PlayerHonor> >(); foreach (PlayerHonorAction.PlayerHonor ph_1 in honors) { foreach (int id in ph_1.GetIds()) { if (!map.ContainsKey(id)) { map[id] = new List <PlayerHonorAction.PlayerHonor>(); } map[id].Add(ph_1); } } foreach (PlayerEntity player in contexts.player.GetEntities()) { int id_1 = (int)player.playerInfo.PlayerId; FreeData fd = (FreeData)player.freeData.FreeData; Reset(fd); fd.GetParameters().AddPara(new IntPara("honorCount", 0)); if (map.ContainsKey(id_1)) { IList <string> list1 = new List <string>(); IList <string> list2 = new List <string>(); IList <string> list3 = new List <string>(); PlayerHonorAction.PlayerHonor[] phs = Optimize(map[id_1]); for (int i = 0; i < MyMath.Min(max, phs.Length); i++) { fd.GetParameters().AddPara(new BoolPara("is" + StringUtil.GetPascalString(phs[i].name), true)); list1.Add(phs[i].img1); list2.Add(phs[i].img2); list3.Add(phs[i].img3); } fd.GetParameters().AddPara(new IntPara("honorCount", list1.Count)); AddHornorPara(fd, list1, "honors1"); AddHornorPara(fd, list2, "honors2"); AddHornorPara(fd, list3, "honors3"); } } } }
private void Reset(FreeData fd) { foreach (PlayerHonorAction.PlayerHonor ph in honors) { fd.GetParameters().AddPara(new BoolPara("is" + StringUtil.GetPascalString(ph.name), false)); } }
public override TestValue GetCaseValue(IEventArgs args) { TestValue tv = new TestValue(); FreeData fd = (FreeData)args.GetUnit(UnitTestConstant.Tester); if (fd != null) { IPara para = fd.GetParameters().Get(field); if (para != null) { tv.AddField(field, para.GetValue().ToString()); } } return(tv); }
private void AddHornorPara(FreeData fd, IList <string> list, string name) { fd.GetParameters().AddPara(new StringPara(name, StringUtil.GetStringFromStrings(list, StringMultiAction.FIELD_SPLITER))); }