99 lines
3.6 KiB
C#
99 lines
3.6 KiB
C#
using Simulator.Data;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UVC.UI.Window.PropertyWindow;
|
|
|
|
public class PlayProperty : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private PropertyWindow propertyWindow;
|
|
int lineIndex = 0;
|
|
|
|
private void Start()
|
|
{
|
|
PlayerPropertyDataBase.Instance.onPlay += InitPlayProperty;
|
|
PlayerPropertyDataBase.Instance.data.onDataUpdated += UpdateProperty;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (PlayerPropertyDataBase.Instance != null)
|
|
{
|
|
PlayerPropertyDataBase.Instance.onPlay -= InitPlayProperty;
|
|
if (PlayerPropertyDataBase.Instance.data != null)
|
|
PlayerPropertyDataBase.Instance.data.onDataUpdated -= UpdateProperty;
|
|
}
|
|
}
|
|
public void InitPlayProperty(PlayPropertyData data)
|
|
{
|
|
lineIndex = 0;
|
|
List<IPropertyEntry> entries = new List<IPropertyEntry>
|
|
{
|
|
new ConstStringProperty("progress_State","시뮬레이션 상태",data.simulation_State),
|
|
CreateCostPolicy_Constant(data),
|
|
CreateCostPolicy_Constant2(data)
|
|
};
|
|
|
|
propertyWindow.LoadMixedProperties(entries);
|
|
}
|
|
|
|
public void UpdateProperty(PlayPropertyData data)
|
|
{
|
|
propertyWindow.ApplyExternalValue("progress_State", $"{data.simulation_State}");
|
|
propertyWindow.ApplyExternalValue("title_Generate", $"{data.total_Generate}개");
|
|
propertyWindow.ApplyExternalValue("total_Use", $"{data.total_Use}개");
|
|
propertyWindow.ApplyExternalValue("agv_Total", $"{data.agv_Total}개");
|
|
propertyWindow.ApplyExternalValue("agv_Moving", $"{data.agv_Moving}개");
|
|
propertyWindow.ApplyExternalValue("agv_Idle", $"{data.agv_Idle}개");
|
|
propertyWindow.ApplyExternalValue("agv_Loading", $"{data.agv_Loading}개");
|
|
}
|
|
|
|
private PropertyGroup CreateCostPolicy_Constant(PlayPropertyData data)
|
|
{
|
|
var group = new PropertyGroup("group_total", "", isExpanded: true,isMargin:true);
|
|
group.AddItems(new IPropertyItem[]
|
|
{
|
|
new ConstStringProperty("title_Generate", "생산량", "",istitle:true)
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("total_Generate", "총 생산량", $"{data.total_Generate}개")
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("total_Use", "총 소비량", $"{data.total_Use}개")
|
|
{
|
|
},
|
|
});
|
|
return group;
|
|
}
|
|
|
|
private PropertyGroup CreateCostPolicy_Constant2(PlayPropertyData data)
|
|
{
|
|
var group = new PropertyGroup("group_AGV", "", isExpanded: true, isMargin: true);
|
|
group.AddItems(new IPropertyItem[]
|
|
{
|
|
new ConstStringProperty("title_AGV", "AGV현황", "",istitle:true)
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("agv_Total", "총 AGV", $"{data.agv_Total}개")
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("agv_Moving", "운송 중", $"{data.agv_Moving}개")
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("agv_Idle", "대기 중", $"{data.agv_Idle}개")
|
|
{
|
|
},
|
|
new SeperationLine($"line{lineIndex++}",""),
|
|
new ConstStringProperty("agv_Loading", "로딩/언로딩", $"{data.agv_Loading}개")
|
|
{
|
|
},
|
|
});
|
|
return group;
|
|
}
|
|
}
|