当前位置: 首页>>代码示例>>C#>>正文


C# HostData.Except方法代码示例

本文整理汇总了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;
                    }
                }
    }
开发者ID:Collegiennes,项目名称:picoBattle,代码行数:43,代码来源:OverlayUI.cs


注:本文中的UnityEngine.HostData.Except方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。