Megacity demo game for UOS
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

40 行
1.3 KiB

using Unity.Entities;
using Unity.MegaCity.Gameplay;
using Unity.MegaCity.UI;
using Unity.NetCode;
using static Unity.Entities.SystemAPI;
namespace Unity.Megacity.UI
{
/// <summary>
/// Update the notification UI
/// </summary>
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
public partial struct UpdateNotification : ISystem
{
private EntityQuery m_LocalPlayerQuery;
private int m_CurrentKills;
public void OnCreate(ref SystemState state)
{
m_LocalPlayerQuery = state.GetEntityQuery(ComponentType.ReadOnly<GhostOwnerIsLocal>());
state.RequireForUpdate(m_LocalPlayerQuery);
m_CurrentKills = 0;
}
public void OnUpdate(ref SystemState state)
{
if (HUD.Instance == null)
return;
foreach (var playerAspect in Query<PlayerScoreAspect>().WithAll<GhostOwnerIsLocal>())
{
if(playerAspect.Kills > m_CurrentKills)
{
m_CurrentKills = playerAspect.Kills;
var message = $"You Killed\n{playerAspect.Killed}";
HUD.Instance.Notification.Message(message);
}
}
}
}
}