// リストからパイロットを検索 public Pilot Item(string Index) { Pilot p = colPilots[Index]; if (p?.Alive ?? false) { return(p); } // IDで見つからなければ名称で検索 var pname = Index; foreach (Pilot currentP in AlivePilots) { p = currentP; if ((p.Data.Name ?? "") == (pname ?? "")) { if (p.Alive) { return(p); } } } // それでも見つからなければ愛称で検索 foreach (Pilot currentP in AlivePilots) { p = currentP; if ((p.Data.Nickname ?? "") == (pname ?? "")) { if (p.Alive) { return(p); } } } return(null); }
// パイロットを追加 public Pilot Add(string pname, int plevel, string pparty, string gid = null) { Pilot AddRet = default; string key; int i; var new_pilot = new Pilot(SRC, SRC.PDList.Item(pname)); new_pilot.Level = plevel; new_pilot.Party = pparty; new_pilot.FullRecover(); new_pilot.Alive = true; new_pilot.Unit = null; if (string.IsNullOrEmpty(gid)) { // グループIDが指定されていない場合 if (Strings.InStr(new_pilot.Name, "(ザコ)") == 0 && Strings.InStr(new_pilot.Name, "(汎用)") == 0) { key = new_pilot.Name; if (SRC.PList.IsDefined2(key)) { var p = SRC.PList.Item2(key); if ((p.ID ?? "") == (key ?? "")) { // 一度作成されたパイロットを復活させる場合 if (!p.Alive) { p.Level = plevel; p.Party = pparty; p.FullRecover(); p.Alive = true; return(p); } GUI.ErrorMessage(key + "というパイロットは既に登録されています"); return(null); } } } else { i = colPilots.Count; do { i = (i + 1); key = new_pilot.Name + "_" + SrcFormatter.Format(i); }while (SRC.PList.IsDefined2(key)); } } else { // グループIDが指定されている場合 key = gid; i = 1; while (SRC.PList.IsDefined2(key)) { i = (i + 1); key = gid + ":" + SrcFormatter.Format(i); } } new_pilot.ID = key; colPilots.Add(new_pilot, key); return(new_pilot); }
// イベントコマンド SetRelation で設定した値を返す public int Relation(Pilot t) { return(Expression.GetValueAsLong("関係:" + Name + ":" + t.Name)); }