當前位置: 首頁>>代碼示例>>C#>>正文


C# Angle.Between方法代碼示例

本文整理匯總了C#中System.Angle.Between方法的典型用法代碼示例。如果您正苦於以下問題:C# Angle.Between方法的具體用法?C# Angle.Between怎麽用?C# Angle.Between使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Angle的用法示例。


在下文中一共展示了Angle.Between方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AI

		public override void AI()
		{
			NPC npc = Main.npc[octopus];
			if (!npc.active || npc.type != mod.NPCType("Octopus"))
			{
				return;
			}
			projectile.timeLeft = 2;
			Player player = Main.player[npc.target];
			projectile.position = npc.Center;
			Vector2 offset = player.Center - projectile.position;
			float distance = offset.Length() + 32f;
			Angle currAngle = new Angle(projectile.rotation);
			Angle angleToPlayer = new Angle((float)Math.Atan2(offset.Y, offset.X));
			Angle min = new Angle(minAngle);
			Angle max = new Angle(maxAngle);
			Angle limit = new Angle((minAngle + maxAngle) / 2f);
			if (limit.Between(min, max))
			{
				limit = limit.Opposite();
			}
			Angle buffer = new Angle(angleBuffer);
			if (angleToPlayer.Between(min - buffer, max + buffer))
			{
				if (currAngle.Between(max, limit))
				{
					angleSpeed -= maxAngleSpeed / 10f;
				}
				else if (currAngle.Between(limit, min))
				{
					angleSpeed += maxAngleSpeed / 10f;
				}
				else if (currAngle.ClockwiseFrom(angleToPlayer))
				{
					angleSpeed += maxAngleSpeed / 10f;
				}
				else
				{
					angleSpeed -= maxAngleSpeed / 10f;
				}
				if (length > maxLength)
				{
					lengthSpeed -= maxLengthSpeed / 10f;
				}
				else if (length < minLength)
				{
					lengthSpeed += maxLengthSpeed / 10f;
				}
				else if (distance > length)
				{
					lengthSpeed += maxLengthSpeed / 10f;
				}
				else if (distance < length)
				{
					lengthSpeed -= maxLengthSpeed / 10f;
				}
			}
			else
			{
				if (currAngle.Between(max, limit))
				{
					angleSpeed -= maxAngleSpeed / 10f;
				}
				else if (currAngle.Between(limit, min))
				{
					angleSpeed += maxAngleSpeed / 10f;
				}
				else if (angleSpeed > 0f)
				{
					angleSpeed += maxAngleSpeed / 20f;
				}
				else if (angleSpeed < 0f)
				{
					angleSpeed -= maxAngleSpeed / 20f;
				}
				else
				{
					angleSpeed = maxAngleSpeed / 20f;
				}
				if (length > minLength)
				{
					lengthSpeed -= maxLengthSpeed / 10f;
				}
				else
				{
					lengthSpeed += maxLengthSpeed / 10f;
				}
			}
			if (angleSpeed > maxAngleSpeed)
			{
				angleSpeed = maxAngleSpeed;
			}
			else if (angleSpeed < -maxAngleSpeed)
			{
				angleSpeed = -maxAngleSpeed;
			}
			if (lengthSpeed > maxLengthSpeed)
			{
				lengthSpeed = maxLengthSpeed;
			}
//.........這裏部分代碼省略.........
開發者ID:DrakoGlyph,項目名稱:tModLoader,代碼行數:101,代碼來源:OctopusArm.cs


注:本文中的System.Angle.Between方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。