コード例 #1
0
				public LineScriptTimer(
					IPoint3D from, IPoint3D to, Map map, UberScriptItem scriptSpot, TriggerObject trigObject, TimeSpan delay)
					: base(TimeSpan.Zero, TimeSpan.Zero)
				{
					if (from.X == to.X && from.Y == to.Y)
					{
						throw new UberScriptException("LineScriptTimer cannot have same from and to point!");
					}

					Priority = TimerPriority.TenMS;

					From = from;
					To = to;
					Map = map;
					ScriptSpot = scriptSpot;
					DirectionVector = new Point3D(to.X - from.X, to.Y - from.Y, to.Z - from.Z);

					double magnitude =
						Math.Sqrt(
							DirectionVector.X * DirectionVector.X + DirectionVector.Y * DirectionVector.Y +
							DirectionVector.Z * DirectionVector.Z);

					NormalizedDirectionVectorX = DirectionVector.X / magnitude;
					NormalizedDirectionVectorY = DirectionVector.Y / magnitude;
					NormalizedDirectionVectorZ = DirectionVector.Z / magnitude;

					CurrentX = from.X;
					CurrentY = from.Y;
					CurrentZ = from.Z;

					TrigObj = trigObject;
					DelayPerTick = delay;
					LastExecuted = DateTime.UtcNow;
				}
コード例 #2
0
			public static void LINESCRIPT(
				TriggerObject trigObject, IPoint3D from, IPoint3D to, string scriptFile, TimeSpan delay, Map map)
			{
				if (from == null || to == null || scriptFile == null || map == null || map == Map.Internal)
				{
					return;
				}

				UberScriptItem scriptSpot = new UberScriptItem();
				XmlScript newScript = new XmlScript(scriptFile)
				{
					Name = "line"
				};

				scriptSpot.MoveToWorld(new Point3D(from), map);

				XmlAttach.AttachTo(scriptSpot, newScript);

				if (from.X == to.X && from.Y == to.Y)
				{
					newScript.Execute(trigObject, false);
					scriptSpot.Delete();
					return;
				}

				LineScriptTimer timer = new LineScriptTimer(from, to, map, scriptSpot, trigObject, delay);
				timer.Start();

				AllLineScriptTimers.Add(timer);
			}