Skip to content

Commit

Permalink
登録した時の時間を取得
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagata Yuto committed Oct 24, 2019
1 parent 78d0cbf commit d882004
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
74 changes: 69 additions & 5 deletions Assets/Script/CleanDataList.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,97 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

[System.Serializable]
/// <summary>
/// 掃除場所のデータと掃除していない時間のデータを保持するクラス
/// </summary>
public class CleanPlaceData
{
[SerializeField] string place;
public string Place { get { return place; }private set { place = value; } }
DateTime time;
[SerializeField] SEDataTime seDate;
[SerializeField] string dateData;
public string DateData { get { return dateData; } }
public DateTime Time { get { return time; } }

public CleanPlaceData(string place)
{
this.place = place;
this.time = DateTime.Now;
seDate = new SEDataTime(time);
dateData = seDate.EntryDate();
}
}
[System.Serializable]
public class SEDataTime{
[SerializeField] int year;
[SerializeField] int month;
[SerializeField] int day;
[SerializeField] int hour;
[SerializeField] int minute;
[SerializeField] int second;

public SEDataTime(DateTime time)
{
this.year = time.Year;
this.month = time.Month;
this.day = time.Day;
this.hour = time.Hour;
this.minute = time.Minute;
this.second = time.Second;
}

public string EntryDate()
{
return this.year + "" + this.month + "" + this.day + "" + this.hour + "" + this.minute + "" + this.second + "";
}
}

/// <summary>
/// 掃除場所のデータを保持するクラス
/// </summary>
[System.Serializable]
public class CleanDataList
{

/// <summary>
/// 場所のデータ
/// </summary>
public List<string> placeList = new List<string>();
public List<CleanPlaceData> placeDataList = new List<CleanPlaceData>();


/// <summary>
/// 場所のデータの追加
/// </summary>
/// <param name="placename"></param>
public void AddPlaceList(string placename)
{
placeList.Add(placename);
//var data = new CleanPlaceData();
//placeDataList.Add(placename);
placeDataList.Add(new CleanPlaceData(placename));
}

/*public void AddPlaceList(CleanPlaceData data)
{
}*/

/// <summary>
/// 場所のデータの取得
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public string GetPlaceData(int index)
{
return placeList[index];
return placeDataList[index].Place;
}

public string GetDateData(int index)
{
return placeDataList[index].DateData;
}

/// <summary>
Expand All @@ -38,9 +100,11 @@ public string GetPlaceData(int index)
/// <param name="index"></param>
public void RemoveData(int index)
{
if (placeList.Count > index)
if (placeDataList.Count > index)
{
placeList.RemoveAt(index);
placeDataList.RemoveAt(index);
}
}


}
5 changes: 3 additions & 2 deletions Assets/Script/Main_UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ void InitInputFieldText()
void DisplayData()
{
layoutTextList.ResetText();
for (int i = 0; i < cleanDataList.placeList.Count; i++)
for (int i = 0; i < cleanDataList.placeDataList.Count; i++)
{
layoutTextList.AddText(cleanDataList.placeList[i]);
layoutTextList.AddText(cleanDataList.GetPlaceData(i) +
cleanDataList.GetDateData(i));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/cleanPlaceData.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"placeList":["1"]}
{"placeDataList":[{"place":"daigo","seDate":{"year":2019,"month":10,"day":24,"hour":17,"minute":51,"second":6},"dateData":""},{"place":"daigogo","seDate":{"year":2019,"month":10,"day":24,"hour":17,"minute":52,"second":8},"dateData":""},{"place":"daigogogo","seDate":{"year":2019,"month":10,"day":24,"hour":18,"minute":2,"second":22},"dateData":"2019年10月24日18時2分22秒"},{"place":"12","seDate":{"year":2019,"month":10,"day":24,"hour":18,"minute":10,"second":52},"dateData":"2019年10月24日18時10分52秒"},{"place":"daigo","seDate":{"year":2019,"month":10,"day":24,"hour":18,"minute":12,"second":19},"dateData":"2019年10月24日18時12分19秒"}]}

0 comments on commit d882004

Please sign in to comment.