コード例 #1
0
    void GetActions()
    {
        foreach (GameObject _event in EventManager.Instance.GeneralEventList)
        {
            foreach (Action action in _event.GetComponent <ActionListController>().actions)
            {
                if (action.tag == "Action" && _event.name != "night")
                {
                    TimeTableData data = new TimeTableData();
                    data.action = action;

                    switch (_event.name)
                    {
                    case "morning":
                        data.morning = true;
                        break;

                    case "day":
                        data.day = true;
                        break;

                    case "evening":
                        data.evening = true;
                        break;
                    }

                    ChangeTimeTable(data);
                }
            }
        }
    }
コード例 #2
0
        public TimeTableData Deserialize(JObject jsonAsJObject)
        {
            var timeTableData = new TimeTableData()
            {
                LastUpdate = jsonAsJObject.Value <DateTime>("lastUpdate"),
                StopTimes  = new List <StopTime>()
            };

            var stopTimeList = jsonAsJObject.Value <JArray>("stopTimes");

            if (!stopTimeList.HasValues)
            {
                return(timeTableData);
            }

            foreach (var stopTime in stopTimeList.Children <JObject>())
            {
                var stopTimeToAdd = new StopTime()
                {
                    RouteId           = stopTime.Value <int>("routeId"),
                    TripId            = stopTime.Value <int>("tripId"),
                    AgencyId          = stopTime.Value <int>("agencyId"),
                    TopologyVersionId = stopTime.Value <int>("topologyVersionId"),
                    ArrivalTime       = stopTime.Value <DateTime>("arrivalTime"),
                    DepartureTime     = stopTime.Value <DateTime>("departureTime"),
                    StopId            = stopTime.Value <int>("stopId"),
                    StopSequence      = stopTime.Value <int>("stopSequence"),
                    Date           = stopTime.Value <DateTime>("date"),
                    BusServiceName = stopTime.Value <string>("busServiceName"),
                    Order          = stopTime.Value <int>("order")
                };

                timeTableData.StopTimes.Add(stopTimeToAdd);
            }

            var firstStopTime = timeTableData.StopTimes.FirstOrDefault();

            timeTableData.RouteId = firstStopTime.RouteId;
            timeTableData.Date    = firstStopTime.Date;

            return(timeTableData);
        }
コード例 #3
0
    void ChangeTimeTable(TimeTableData data)
    {
        TimeTableData timecheck = timetable.Find(x => x.action == data.action);

        if (timecheck == null && data.action.VerifyActionRequirements(true))
        {
            timetable.Add(data);
        }
        else if (timecheck != null)
        {
            if (data.morning)
            {
                timecheck.morning = true;
            }
            if (data.day)
            {
                timecheck.day = true;
            }
            if (data.evening)
            {
                timecheck.evening = true;
            }
        }
    }
コード例 #4
0
ファイル: TimeTable.cs プロジェクト: TetsuOtter/LimExpTIMSPI
    private async void CnvCSVtoClass(List<string> FileContentList)
    {
      bool IsTimeTableEditing = false;
      bool IsOptDataEditing = false;
      TimeTableData TTD = new TimeTableData();
      TTList = new List<TimeTableData>();
      if (FileContentList == default || FileContentList == null)
      {
        UsefulFunc.MsgBxShow("ファイル内容の読み取りに失敗しました。", "Error");
        return;
      }
      foreach (string ContLine in FileContentList)
      {
        if (ContLine == null) continue;
        string Content = ContLine.Replace(" ", string.Empty);
        string[] RowData = ContLine.Split(',');
        if (RowData[0] == string.Empty) continue;//空行なら無視
        if (RowData[0].StartsWith("//")) continue;//"//"ならコメント
        if (RowData[0].StartsWith(";")) continue;//";"ならコメント
        if (RowData[0].StartsWith("#")) continue;//"#"ならコメント
        if (IsTimeTableEditing)
        {
          if (IsOptDataEditing)
          {
            switch (RowData[0])
            {
              case "TRTimeTableOPEOF":
                IsOptDataEditing = false;
                break;
              case "SlowPoint":
                try
                {
                  SlowPointData SPD = new SlowPointData() { LimitSpeed = double.Parse(RowData[1]) };
                  SPD.NoticeStartPoint = double.Parse(RowData[2]);
                  SPD.LimitStartPoint = double.Parse(RowData[3]);
                  SPD.EndPoint = double.Parse(RowData[4]);
                  TTD.SlowPointList.Add(SPD);
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("徐行警告機能の位置設定記述が正しくありません。\n" + e.Message, "SlowPoint Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                  return;
                }
                break;
              case "AirSec":
                try
                {
                  TTD.AirSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("エアセクション警告機能の位置設定記述が正しくありません。\n" + e.Message, "AirSection Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "ACDCChange":
                try
                {
                  TTD.ACDCSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("交直切換警告機能の位置設定記述が正しくありません。\n" + e.Message, "AC-DC Section Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "ACACSec":
                try
                {
                  TTD.ACACSecList.Add(new SectionData()
                  {
                    NoticeStartPoint = double.Parse(RowData[1]),
                    EndPoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("交交セクション警告機能の位置設定記述が正しくありません。\n" + e.Message, "AC-AC Section Location Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "RadioCH":
                try
                {
                  TTD.RCHChangePList.Add(new RadioCHChangingData()
                  {
                    ChangeTo = RowData[1],
                    ChangePoint = double.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("無線チャンネル自動切換機能の設定記述が正しくありません。\n" + e.Message, "Radio Channel Changing Function Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
              case "LineColorChange":
                try
                {
                  TTD.LineColorList.Add(new LineColorChangingData()
                  {
                    ColorTo = StrToSCB(RowData[1]),
                    StaID = int.Parse(RowData[2])
                  });
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("進行線色変更機能の設定記述が正しくありません。\n" + e.Message, "Line Color Changing Function Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                }
                break;
            }
          }
          else
          {
            switch (RowData[0])
            {
              case "TRTimeTableOP100":
                IsOptDataEditing = true;
                break;
              case "TRTimeTableEOF":
                IsTimeTableEditing = false;
                TTList.Add(TTD);
                break;
              default://各駅設定
                StaInfo SI = new StaInfo();
                try
                {
                  int c = 0;
                  SI.StaName = RowData[c++];
                  try
                  {
                    SI.StaLocation = double.Parse(RowData[c++]);
                  }
                  catch (Exception e)
                  {
                    UsefulFunc.MsgBxShow("駅位置の設定記述が正しくありません。\n" + e.Message, "Station Location Parsing Error");
                    DecidedTTData = null;
                    InsertedICInfo = null;
                    return;
                  }
                  SI.RunMM = RowData[c++].ToNarrow();
                  SI.RunSS = RowData[c++].ToNarrow();
                  SI.ArrHH = RowData[c++].ToWide();
                  SI.ArrMM = RowData[c++].ToWide();
                  SI.ArrSS = RowData[c++].ToNarrow();
                  SI.ArrSymbol = RowData[c++];
                  SI.IsPass = RowData[c++] == "1";
                  SI.DepHH = RowData[c++].ToWide();
                  SI.DepMM = RowData[c++].ToWide();
                  SI.DepSS = RowData[c++].ToNarrow();
                  SI.DepSymbol = RowData[c++];
                  SI.TrackName = RowData[c++];
                  SI.RuninLim = RowData[c++].ToNarrow();
                  SI.RunoutLim = RowData[c++].ToNarrow();
                  int StaWorkIndex = c++;
                  if (RowData[StaWorkIndex] != string.Empty)
                  {
                    try
                    {
                      SI.StaWork = (StaWorkEnum)int.Parse(RowData[StaWorkIndex]);
                    }
                    catch (Exception e)
                    {
                      UsefulFunc.MsgBxShow("駅仕業の設定記述が正しくありません。\n" + e.Message, "StationWork Parsing Error");
                      DecidedTTData = null;
                      InsertedICInfo = null;
                      return;
                    }
                  }
                  SI.DispColor = StrToSCB(RowData[c++]);
                  if (SI.ArrSS == string.Empty) SI.ArrSS = "0";
                  if (SI.DepSS == string.Empty) SI.DepSS = "0";
                  TTD.TTList.Add(SI);
                }
                catch (Exception e)
                {
                  UsefulFunc.MsgBxShow("駅の設定記述が正しくありません。\n" + e.Message, "StationData Parsing Error");
                  DecidedTTData = null;
                  InsertedICInfo = null;
                  return;
                }

                break;
            }
          }
        }
        else
        {
          switch (RowData[0])
          {
            case "TRTimeTable100":
              if (RowData.Length >= 8)
              {
                TTD = new TimeTableData();
                TTD.TrainNum = RowData[1].ToWide();
                TTD.PTrainNum = RowData[2].ToWide();
                TTD.IsPassDefault = RowData[3] == "1";
                TTD.IsDirectionLeft = RowData[4] == "1";
                TTD.RadioNum = RowData[5] == string.Empty ? "-" : RowData[5].ToNarrow();
                TTD.LineColor = StrToSCB(RowData[6]);
                TTD.LastStation = RowData[7];
                IsTimeTableEditing = true;
                TTD.LineColorList.Add(new LineColorChangingData() { ColorTo = TTD.LineColor, StaID = 0 });
              }
              else
              {
                UsefulFunc.MsgBxShow("時刻表設定のヘッダー行形式が正しくありません。", "IC File Error");
                DecidedTTData = null;
                InsertedICInfo = null;
                return;
              }
              break;
            case "TRTimeTableIC100":
              if (RowData.Length >= 6)
              {
                InsertedICInfo = new ICSettingInfo();
                InsertedICInfo.OfficeName = RowData[1];
                InsertedICInfo.WorkNumber = RowData[2].ToWide();
                InsertedICInfo.EffectedDateYY = RowData[3].ToNarrow();
                InsertedICInfo.EffectedDateMM = RowData[4].ToNarrow();
                InsertedICInfo.EffectedDateDD = RowData[5].ToNarrow();
              }
              else
              {
                UsefulFunc.MsgBxShow("IC情報設定の形式が正しくありません。", "IC File Error");
                DecidedTTData = null;
                InsertedICInfo = null;
                return;
              }
              break;
          }
        }
      }
      if (IsTimeTableEditing || IsOptDataEditing)
      {
        UsefulFunc.MsgBxShow("行路ICカードファイルの設定が終了していません。\nEOF記述を追加してください。", "EOF Not Found Error");
        DecidedTTData = null;
        InsertedICInfo = null;
        return;
      }
      switch (TTList.Count)
      {
        case 0:
          DecidedTTData = null;
          break;
        case 1:
          TimeTablesPicked(0);
          break;
        default:
          await Task.Delay(100 * TTList.Count);
          ManyTTDataInput?.Invoke(null, null);
          break;
      }
    }