2025-06-26 15:55:03 +09:00
|
|
|
|
using System;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2025-05-26 18:06:25 +09:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2025-06-26 15:55:03 +09:00
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class ResourceInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
public string resource_name;
|
|
|
|
|
|
public int capacity;
|
|
|
|
|
|
public float speed_factor;
|
|
|
|
|
|
public int? breakdown_interval;
|
|
|
|
|
|
public int? repair_time;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class ResourceStatus
|
|
|
|
|
|
{
|
|
|
|
|
|
public string resource_name;
|
|
|
|
|
|
public int requesters;
|
|
|
|
|
|
public int claimers;
|
|
|
|
|
|
public int available;
|
|
|
|
|
|
public int capacity;
|
2025-07-15 17:35:53 +09:00
|
|
|
|
public int original_capacity;
|
2025-06-26 15:55:03 +09:00
|
|
|
|
public float utilization;
|
|
|
|
|
|
public float occupancy;
|
|
|
|
|
|
public int broken_units;
|
|
|
|
|
|
public float speed_factor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-05 17:54:18 +09:00
|
|
|
|
public class SimulationModelResource : SimulationModel
|
2025-05-26 18:06:25 +09:00
|
|
|
|
{
|
2025-06-26 15:55:03 +09:00
|
|
|
|
ResourceInfo info;
|
|
|
|
|
|
ResourceStatus currentStatus;
|
|
|
|
|
|
|
|
|
|
|
|
private void Message_Initialized(ResourceInfo data)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.info = data;
|
|
|
|
|
|
|
|
|
|
|
|
this.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Message_Status_Updted(ResourceStatus data)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.currentStatus = data;
|
2025-07-15 17:35:53 +09:00
|
|
|
|
SetBubble($"{data.claimers}/{data.original_capacity}");
|
2025-06-26 15:55:03 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-24 17:02:07 +09:00
|
|
|
|
public override void GetData(string data)
|
2025-05-26 18:06:25 +09:00
|
|
|
|
{
|
2025-06-26 15:55:03 +09:00
|
|
|
|
var message = JsonConvert.DeserializeObject<BaseJson>(data);
|
|
|
|
|
|
|
|
|
|
|
|
switch (message._event)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "resource_initialized":
|
|
|
|
|
|
Message_Initialized(message.data.ToObject<ResourceInfo>());
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
case "resource_status_update":
|
|
|
|
|
|
Message_Status_Updted(message.data.ToObject<ResourceStatus>());
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
2025-07-15 17:35:53 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-06-26 15:55:03 +09:00
|
|
|
|
|
2025-07-15 17:35:53 +09:00
|
|
|
|
public override void SetBubble(object data)
|
|
|
|
|
|
{
|
|
|
|
|
|
string msg = data.ToString();
|
2025-06-26 15:55:03 +09:00
|
|
|
|
|
2025-07-15 17:35:53 +09:00
|
|
|
|
if (currentBubble == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
currentBubble = Instantiate(bubbleUIPrefab, FindAnyObjectByType<Canvas_Bubble>().transform);
|
|
|
|
|
|
currentBubble.target = DataBubbleSocket;
|
|
|
|
|
|
currentBubble.worldOffset = new Vector3(0, 2.0f, 0); // <20>ʿ信 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2025-06-26 15:55:03 +09:00
|
|
|
|
}
|
2025-07-15 17:35:53 +09:00
|
|
|
|
// <20>ؽ<EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
currentBubble.SetMessage(msg);
|
2025-05-26 18:06:25 +09:00
|
|
|
|
}
|
2025-06-26 15:55:03 +09:00
|
|
|
|
}
|