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


C# GamePlayer.SendDoorUpdate方法代码示例

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


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

示例1: UpdatePlayerDoors

		/// <summary>
		/// Send Game Doors Depening on last refresh time.
		/// </summary>
		/// <param name="player"></param>
		/// <param name="nowTicks"></param>
		private static void UpdatePlayerDoors(GamePlayer player, long nowTicks)
		{
			// Get All Game Doors in Range
			var doors = player.GetDoorsInRadius(WorldMgr.OBJ_UPDATE_DISTANCE).Cast<IDoor>().OfType<GameObject>().Where(o => o.IsVisibleTo(player)).ToArray();
			
			try
			{
				// Clean Cache
				foreach (var objEntry in player.Client.GameObjectUpdateArray)
				{
					var objKey = objEntry.Key;
					GameObject obj = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);
					// We have a Door in cache that is not in vincinity
					if (obj is IDoor && !doors.Contains(obj) && (nowTicks - objEntry.Value) >= GetPlayerItemUpdateInterval)
					{
						long dummy;
						player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while Cleaning Doors cache for Player : {0}, Exception : {1}", player.Name, e);
			}
			
			try
			{
				// Now Send remaining doors
				foreach (IDoor ldoor in doors)
				{
					IDoor door = ldoor;
					
					// Get last update time
					long lastUpdate;
					if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple<ushort, ushort>(((GameObject)door).CurrentRegionID, (ushort)door.ObjectID), out lastUpdate))
					{
						// This Door Needs Update
						if ((nowTicks - lastUpdate) >= GetPlayerItemUpdateInterval)
						{
							player.SendDoorUpdate(door);
						}
					}
					else
					{
						// Not in cache, Door entering in range, sending update will add it to cache.
						player.SendDoorUpdate(door);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while updating Doors for Player : {0}, Exception : {1}", player.Name, e);
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:61,代码来源:WorldUpdateThread.cs

示例2: GetExamineMessages

        public override IList GetExamineMessages(GamePlayer player)
        {
            /*
             * You select the Keep Gate. It belongs to your realm.
             * You target [the Keep Gate]
             *
             * You select the Keep Gate. It belongs to an enemy realm and can be attacked!
             * You target [the Keep Gate]
             *
             * You select the Postern Door. It belongs to an enemy realm!
             * You target [the Postern Door]
             */

            IList list = base.GetExamineMessages(player);
            string text = "You select the " + Name + ".";
            if (!GameServer.KeepManager.IsEnemy(this, player))
            {
                text = text + " It belongs to your realm.";
            }
            else
            {
                if (IsAttackableDoor)
                {
                    text = text + " It belongs to an enemy realm and can be attacked!";
                }
                else
                {
                    text = text + " It belongs to an enemy realm!";
                }
            }

            list.Add(text);

            ChatUtil.SendDebugMessage(player, "Health = " + Health);

            if (IsAttackableDoor)
            {
                // Attempt to fix issue where some players see door as closed when it should be broken open
                // if you target a door it will re-broadcast it's state

                if (Health <= 0 && State != eDoorState.Open)
                {
                    State = eDoorState.Open;
                    BroadcastDoorStatus();
                }
                else if (State == eDoorState.Open)
                {
                    player.SendDoorUpdate(this, true);
                }
            }

            return list;
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:53,代码来源:GameKeepDoor.cs


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