本文整理汇总了C#中UnityEngine.HostData.Except方法的典型用法代码示例。如果您正苦于以下问题:C# HostData.Except方法的具体用法?C# HostData.Except怎么用?C# HostData.Except使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.HostData
的用法示例。
在下文中一共展示了HostData.Except方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStars
void UpdateStars(HostData[] newHosts, HostData[] oldHosts)
{
var addedHosts = newHosts.Except(oldHosts, HostDataEqualityComparer.Default);
var deletedHosts = oldHosts.Except(newHosts, HostDataEqualityComparer.Default);
if (addedHosts.Count() != 0 || deletedHosts.Count() != 0)
{
Debug.Log("Updated hosts : " + addedHosts.Count() + " new, " + deletedHosts.Count() + " deleted");
int i = 0;
foreach (var h in addedHosts)
Debug.Log("New host #" + i++ + " : guid = " + h.guid + ", ip = " + h.ip.Aggregate("", (a, b) => a + (a == "" ? "" : ".") + b) + ", comment = " + h.comment);
i = 0;
foreach (var h in deletedHosts)
Debug.Log("Deleted host #" + i++ + " : guid = " + h.guid + ", ip = " + h.ip.Aggregate("", (a, b) => a + (a == "" ? "" : ".") + b) + ", comment = " + h.comment);
}
Enemies.RemoveAll(x => deletedHosts.Any(y => x.HostData != null && y.guid == x.HostData.guid));
Enemies.AddRange(addedHosts.Select(x =>
new Enemy
{
HostData = x,
Location = Random.onUnitSphere * 400
}));
foreach (var h in newHosts)
foreach (var e in Enemies)
if (e.HostData != null && e.HostData.guid == h.guid)
{
float? newHue;
int parsedHue;
if (!int.TryParse(h.comment, out parsedHue))
newHue = null;
else
newHue = parsedHue;
if (e.Hue != newHue)
{
Debug.Log("Updated shield hue for host to " + newHue + " : guid = " + h.guid + ", ip = " + h.ip.Aggregate("", (a, b) => a + (a == "" ? "" : ".") + b));
e.Hue = newHue;
}
}
}