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


C# Game.TryGetItem方法代码示例

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


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

示例1: HandleEventItemSubscribed

        /// <summary>
        /// The handle event item subscribed.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemSubscribed(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            var position = (float[])eventData[(byte)ParameterCode.Position];
            var cameraId = (byte)eventData[(byte)ParameterCode.InterestAreaId];
            float[] rotation = eventData.Contains((byte)ParameterCode.Rotation) ? (float[])eventData[(byte)ParameterCode.Rotation] : null;

            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                if (item.IsMine)
                {
                    item.AddSubscribedInterestArea(cameraId);
                    item.AddVisibleInterestArea(cameraId);
                }
                else
                {
                    var revision = (int)eventData[(byte)ParameterCode.PropertiesRevision];
                    if (revision == item.PropertyRevision)
                    {
                        item.AddSubscribedInterestArea(cameraId);
                        item.AddVisibleInterestArea(cameraId);
                    }
                    else
                    {
                        item.AddSubscribedInterestArea(cameraId);
                        item.GetProperties();
                    }

                    item.SetPositions(position, position, rotation, rotation);
                }
            }
            else
            {
                item = new ForeignItem(itemId, itemType, game);
                item.SetPositions(position, position, rotation, rotation);
                game.AddItem(item);

                item.AddSubscribedInterestArea(cameraId);
                item.GetProperties();
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:52,代码来源:WorldEntered.cs

示例2: HandleEventItemUnsubscribed

        /// <summary>
        /// The handle event item unsubscribed.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemUnsubscribed(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            var cameraId = (byte)eventData[(byte)ParameterCode.InterestAreaId];

            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                if (item.RemoveSubscribedInterestArea(cameraId))
                {
                    item.RemoveVisibleInterestArea(cameraId);
                }
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:24,代码来源:WorldEntered.cs

示例3: HandleEventItemMoved

 /// <summary>
 /// The handle event item moved.
 /// </summary>
 /// <param name="game">
 /// The mmo game.
 /// </param>
 /// <param name="eventData">
 /// The event data.
 /// </param>
 private static void HandleEventItemMoved(Game game, IDictionary eventData)
 {
     var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
     var itemId = (string)eventData[(byte)ParameterCode.ItemId];
     Item item;
     if (game.TryGetItem(itemType, itemId, out item))
     {
         if (item.IsMine == false)
         {
             var position = (float[])eventData[(byte)ParameterCode.Position];
             var oldPosition = (float[])eventData[(byte)ParameterCode.OldPosition];
             float[] rotation = eventData.Contains((byte)ParameterCode.Rotation) ? (float[])eventData[(byte)ParameterCode.Rotation] : null;
             float[] oldRotation = eventData.Contains((byte)ParameterCode.OldRotation) ? (float[])eventData[(byte)ParameterCode.OldRotation] : null;
             item.SetPositions(position, oldPosition, rotation, oldRotation);
         }
     }
 }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:26,代码来源:WorldEntered.cs

示例4: HandleEventItemPropertiesSet

        /// <summary>
        /// The handle event item properties set.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemPropertiesSet(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                item.PropertyRevision = (int)eventData[(byte)ParameterCode.PropertiesRevision];

                if (item.IsMine == false)
                {
                    var propertiesSet = (Hashtable)eventData[(byte)ParameterCode.PropertiesSet];

                    if (propertiesSet.ContainsKey(Item.PropertyKeyColor))
                    {
                        item.SetColor((int)propertiesSet[Item.PropertyKeyColor]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyText))
                    {
                        item.SetText((string)propertiesSet[Item.PropertyKeyText]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyViewDistanceEnter))
                    {
                        var viewDistanceEnter = (float[])propertiesSet[Item.PropertyKeyViewDistanceEnter];
                        item.SetInterestAreaViewDistance(viewDistanceEnter, (float[])propertiesSet[Item.PropertyKeyViewDistanceExit]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyInterestAreaAttached))
                    {
                        item.SetInterestAreaAttached((bool)propertiesSet[Item.PropertyKeyInterestAreaAttached]);
                    }
                }
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:45,代码来源:WorldEntered.cs

示例5: HandleEventItemDestroyed

        /// <summary>
        /// The handle event item destroyed.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemDestroyed(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];

            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                item.IsDestroyed = game.RemoveItem(item);
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:20,代码来源:WorldEntered.cs

示例6: HandleEventItemPropertiesSet

        /// <summary>
        /// The handle event item properties set.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemPropertiesSet(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                item.PropertyRevision = (int)eventData[(byte)ParameterCode.PropertiesRevision];

                if (item.IsMine == false)
                {
                    var propertiesSet = (Hashtable)eventData[(byte)ParameterCode.PropertiesSet];

                    if (propertiesSet.ContainsKey(Item.PropertyKeyColor))
                    {
                        item.SetColor((int)propertiesSet[Item.PropertyKeyColor]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyText))
                    {
                        item.SetText((string)propertiesSet[Item.PropertyKeyText]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyViewDistanceEnter))
                    {
                        var viewDistanceEnter = (float[])propertiesSet[Item.PropertyKeyViewDistanceEnter];
                        item.SetInterestAreaViewDistance(viewDistanceEnter, (float[])propertiesSet[Item.PropertyKeyViewDistanceExit]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyInterestAreaAttached))
                    {
                        item.SetInterestAreaAttached((bool)propertiesSet[Item.PropertyKeyInterestAreaAttached]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyServerAddress))
                    {
                        item.SetServerAddress((string)propertiesSet[Item.PropertyKeyServerAddress]);
                    }

                    if (propertiesSet.ContainsKey(Item.PropertyKeyAnimation))
                    {
                        string animation = (string)propertiesSet[Item.PropertyKeyAnimation];
                        byte wrap = (byte)propertiesSet[Item.PropertyKeyAnimationWrap];
                        float speed = (float)propertiesSet[Item.PropertyKeyAnimationSpeed];
                        int layer = (int)propertiesSet[Item.PropertyKeyAnimationLayer];
                        byte action = (byte)propertiesSet[Item.PropertyKeyAnimationAction];

                        item.SetAnimation(animation, (AnimationAction)action, wrap, speed);

                        game.Listener.OnItemAnimate(game, item, animation, (AnimationAction)action, wrap, speed, layer);
                    }
                }
            }
        }
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:63,代码来源:WorldEntered.cs

示例7: HandleEventItemProperties

        /// <summary>
        /// The handle event item properties.
        /// </summary>
        /// <param name="game">
        /// The mmo game.
        /// </param>
        /// <param name="eventData">
        /// The event data.
        /// </param>
        private static void HandleEventItemProperties(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];

            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                item.PropertyRevision = (int)eventData[(byte)ParameterCode.PropertiesRevision];

                if (item.IsMine == false)
                {
                    var propertiesSet = (Hashtable)eventData[(byte)ParameterCode.PropertiesSet];

                    item.SetServerAddress((string)propertiesSet[Item.PropertyKeyServerAddress]);
                    item.SetColor((int)propertiesSet[Item.PropertyKeyColor]);
                    item.SetText((string)propertiesSet[Item.PropertyKeyText]);
                    item.SetInterestAreaAttached((bool)propertiesSet[Item.PropertyKeyInterestAreaAttached]);
                    item.SetInterestAreaViewDistance(
                        (float[])propertiesSet[Item.PropertyKeyViewDistanceEnter], (float[])propertiesSet[Item.PropertyKeyViewDistanceExit]);

                    item.MakeVisibleToSubscribedInterestAreas();
                }
            }
        }
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:34,代码来源:WorldEntered.cs

示例8: HandleEventItemChat

        /// <summary>
        /// The handle event item chat
        /// </summary>
        /// <param name="game">The mmo game</param>
        /// <param name="eventData">The event data</param>
        private static void HandleEventItemChat(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                if (item.IsMine == false)
                {
                    // Chat Group, not used for now
                    string[] group = (string[])eventData[(byte)ParameterCode.ChatGroup];
                    string message = (string)eventData[(byte)ParameterCode.ChatMessage];

                    game.Listener.OnReceivedChatMessage(game, item, group, message);
                }
            }
        }
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:22,代码来源:WorldEntered.cs

示例9: HandleEventItemAnimate

        /// <summary>
        /// The handle event item animate
        /// </summary>
        /// <param name="game">The mmo game</param>
        /// <param name="eventData">The event data</param>
        private static void HandleEventItemAnimate(Game game, IDictionary eventData)
        {
            var itemType = (byte)eventData[(byte)ParameterCode.ItemType];
            var itemId = (string)eventData[(byte)ParameterCode.ItemId];
            Item item;
            if (game.TryGetItem(itemType, itemId, out item))
            {
                if (item.IsMine == false)
                {
                    string animation = (string)eventData[(byte)ParameterCode.Animation];
                    byte wrap = (byte)eventData[(byte)ParameterCode.AnimationWrap];
                    float speed = (float)eventData[(byte)ParameterCode.AnimationSpeed];
                    int layer = (int)eventData[(byte)ParameterCode.AnimationLayer];
                    byte action = (byte)eventData[(byte)ParameterCode.AnimationAction];

                    AnimationAction animationAction = (AnimationAction)action;

                    item.SetAnimation(animation, animationAction, wrap, speed);
                }
            }
        }
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:26,代码来源:WorldEntered.cs


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