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


C# GameLiving.StartAttack方法代码示例

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


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

示例1: TryToUseStyle

		/// <summary>
		/// Tries to queue a new style in the player's style queue.
		/// Takes care of all conditions like setting backup styles and
		/// canceling styles if the style was queued already.
		/// </summary>
		/// <param name="living">The living to execute the style</param>
		/// <param name="style">The style to execute</param>
		public static void TryToUseStyle(GameLiving living, Style style)
		{
			//First thing in processors, lock the objects you modify
			//This way it makes sure the objects are not modified by
			//several different threads at the same time!
			GamePlayer player = living as GamePlayer;
			lock (living)
			{
				//Dead players can't use styles
				if (!living.IsAlive)
				{
					if (player != null)
						player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.CantCombatMode"), eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
					
					return;
				}
				if (living.IsDisarmed)
				{
					if(living is GamePlayer) (living as GamePlayer).Out.SendMessage("You are disarmed and cannot attack!", eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
					return;
				}
				//Can't use styles with range weapon
				if (living.ActiveWeaponSlot == GameLiving.eActiveWeaponSlot.Distance)
				{
					if (player != null)
						player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.CantMeleeCombat"), eChatType.CT_YouHit, eChatLoc.CL_SystemWindow);
					return;
				}

				//Put player into attack state before setting the styles
				//Changing the attack state clears out the styles...
				if (living.AttackState == false)
				{
					living.StartAttack(player.TargetObject);
				}

				if (living.TargetObject == null)
				{
					if (player != null)
						player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.MustHaveTarget"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					return;
				}

				InventoryItem weapon = (style.WeaponTypeRequirement == (int)eObjectType.Shield) ? living.Inventory.GetItem(eInventorySlot.LeftHandWeapon) : living.AttackWeapon;
				//				if (weapon == null) return;	// no weapon = no style
				if (!CheckWeaponType(style, living, weapon))
				{
					if (player != null)
					{
						if (style.WeaponTypeRequirement == Style.SpecialWeaponType.DualWield)
							player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.DualWielding"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
						else
							player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.StyleRequires", style.GetRequiredWeaponName()), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					}
					return;
				}

				if (player != null) //Do mob use endurance?
				{
					int fatCost = CalculateEnduranceCost(player, style, weapon.SPD_ABS);
					if (player.Endurance < fatCost)
					{
						player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.Fatigued"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
						return;
					}
				}

				if (player != null)
				{
					Style preRequireStyle = null;
					if (style.OpeningRequirementType == Style.eOpening.Offensive && style.AttackResultRequirement == Style.eAttackResult.Style)
						preRequireStyle = SkillBase.GetStyleByID(style.OpeningRequirementValue, player.CharacterClass.ID);

					//We have not set any primary style yet?
					if (player.NextCombatStyle == null)
					{
						if (preRequireStyle != null)
						{
							AttackData lastAD = (AttackData)living.TempProperties.getProperty<object>(GameLiving.LAST_ATTACK_DATA, null);
							if (lastAD == null
							|| lastAD.AttackResult != GameLiving.eAttackResult.HitStyle
							|| lastAD.Style == null
							|| lastAD.Style.ID != style.OpeningRequirementValue)
							{
								player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.PerformStyleBefore", preRequireStyle.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
								return;
							}
						}

						player.NextCombatStyle = style;
						player.NextCombatBackupStyle = null;
						player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "StyleProcessor.TryToUseStyle.PreparePerform", style.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);

//.........这里部分代码省略.........
开发者ID:boscorillium,项目名称:dol,代码行数:101,代码来源:StyleProcessor.cs


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