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


C# Hashtable.Remove方法代码示例

本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.Remove方法的具体用法?C# Hashtable.Remove怎么用?C# Hashtable.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExitGames.Client.Photon.Hashtable的用法示例。


在下文中一共展示了Hashtable.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeltaCompressionWrite

    /// <summary>
    /// Compares the new data with previously sent data and skips values that didn't change.
    /// </summary>
    /// <returns>True if anything has to be sent, false if nothing new or no data</returns>
    private bool DeltaCompressionWrite(PhotonView view, Hashtable data)
    {
        if (view.lastOnSerializeDataSent == null)
        {
            return true; // all has to be sent
        }

        // We can compress as we sent a full update previously (readers can re-use previous values)
        object[] lastData = view.lastOnSerializeDataSent;
        object[] currentContent = data[(byte)1] as object[];

        if (currentContent == null)
        {
            // no data to be sent
            return false;
        }

        if (lastData.Length != currentContent.Length)
        {
            // if new data isn't same length as before, we send the complete data-set uncompressed
            return true;
        }

        object[] compressedContent = new object[currentContent.Length];
        int compressedValues = 0;

        List<int> valuesThatAreChangedToNull = new List<int>();
        for (int index = 0; index < compressedContent.Length; index++)
        {
            object newObj = currentContent[index];
            object oldObj = lastData[index];
            if (this.ObjectIsSameWithInprecision(newObj, oldObj))
            {
                // compress (by using null, instead of value, which is same as before)
                compressedValues++;
                // compressedContent[index] is already null (initialized)
            }
            else
            {
                compressedContent[index] = currentContent[index];

                // value changed, we don't replace it with null
                // new value is null (like a compressed value): we have to mark it so it STAYS null instead of being replaced with previous value
                if (newObj == null)
                {
                    valuesThatAreChangedToNull.Add(index);
                }
            }
        }

        // Only send the list of compressed fields if we actually compressed 1 or more fields.
        if (compressedValues > 0)
        {
            data.Remove((byte)1); // remove the original data (we only send compressed data)

            if (compressedValues == currentContent.Length)
            {
                // all values are compressed to null, we have nothing to send
                return false;
            }

            data[(byte)2] = compressedContent; // current, compressted data is moved to key 2 to mark it as compressed
            if (valuesThatAreChangedToNull.Count > 0)
            {
                data[(byte)3] = valuesThatAreChangedToNull.ToArray(); // data that is actually null (not just cause we didn't want to send it)
            }
        }

        return true;    // some data was compressed but we need to send something
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:74,代码来源:NetworkingPeer.cs

示例2: InstantiateBots

    /// <summary>
    /// If the owner of the room, instantiates bots.
    /// </summary>
    /// <param name="teamsCount"></param>
    public void InstantiateBots(int[] teamsCount)
    {
        if (!botsIntantiated)
        {
            botsIntantiated = true;

            object owner;
            if (PhotonNetwork.player.customProperties.TryGetValue("Owner", out owner))
            {
                ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
                properties.Remove("Owner");
                PhotonNetwork.player.SetCustomProperties(properties);

                string ownerName = owner.ToString();
                if (ownerName == PhotonNetwork.player.name)
                {
                    networkLayer.InstantiateBots(teamsCount);
                }
            }
        }
    }
开发者ID:dearzhangle,项目名称:UNION-OpenSource-MOBA,代码行数:25,代码来源:MultiplayerRoomsManager.cs


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