示例#1
0
文件: Sequence.cs 项目: corefan/urho
		public Sequence (params FiniteTimeAction[] actions) : base ()
		{

			Actions = new FiniteTimeAction[2];

			var prev = actions [0];

			// Can't call base(duration) because we need to calculate duration here
			float combinedDuration = 0.0f;
			foreach (FiniteTimeAction action in actions)
			{
				combinedDuration += action.Duration;
			}
			Duration = combinedDuration;

			if (actions.Length == 1)
			{
				InitSequence (prev, new ExtraAction ());
			}
			else
			{
				// Basically what we are doing here is creating a whole bunch of 
				// nested Sequences from the actions.
				for (int i = 1; i < actions.Length - 1; i++)
				{
					prev = new Sequence (prev, actions [i]);
				}

				InitSequence (prev, actions [actions.Length - 1]);
			}

		}
示例#2
0
文件: Sequence.cs 项目: corefan/urho
		public SequenceState (Sequence action, Node target)
			: base (action, target)
		{ 
			actionSequences = action.Actions;
			hasInfiniteAction = (actionSequences [0] is RepeatForever) || (actionSequences [1] is RepeatForever);
			split = actionSequences [0].Duration / Duration;
			last = -1;

		}
示例#3
0
文件: Node.cs 项目: Zamir7/urho
        /// <summary>
        /// Runs an Action that can be awaited.
        /// </summary>
        /// <param name="action">A FiniteTimeAction.</param>
        public Task<ActionState> RunActionsAsync(FiniteTimeAction action)
        {
            var tcs = new TaskCompletionSource<ActionState>();

            ActionState state = null;
            var completion = new CallFunc(() => tcs.TrySetResult(state));

            var asyncAction = new Sequence(action, completion);

            state = Application.Current.ActionManager.AddAction(asyncAction, this);
            return tcs.Task;
        }
示例#4
0
文件: Spawn.cs 项目: Zamir7/urho
		private void InitSpawn (FiniteTimeAction action1, FiniteTimeAction action2)
		{
			Debug.Assert (action1 != null);
			Debug.Assert (action2 != null);

			float d1 = action1.Duration;
			float d2 = action2.Duration;

			ActionOne = action1;
			ActionTwo = action2;

			if (d1 > d2)
			{
				ActionTwo = new Sequence (action2, new DelayTime (d1 - d2));
			}
			else if (d1 < d2)
			{
				ActionOne = new Sequence (action1, new DelayTime (d2 - d1));
			}
		}
示例#5
0
文件: Parallel.cs 项目: Zamir7/urho
		public Parallel (params FiniteTimeAction[] actions) : base ()
		{
			// Can't call base(duration) because max action duration needs to be determined here
			float maxDuration = 0.0f;
			foreach (FiniteTimeAction action in actions)
			{
				if (action.Duration > maxDuration)
				{
					maxDuration = action.Duration;
				}
			}
			Duration = maxDuration;

			Actions = actions;

			for (int i = 0; i < Actions.Length; i++)
			{
				var actionDuration = Actions [i].Duration;
				if (actionDuration < Duration)
				{
					Actions [i] = new Sequence (Actions [i], new DelayTime (Duration - actionDuration));
				}
			}
		}