Beispiel #1
0
 public static void Unregister(this IStepableEvent stepEvent, IStepable stepable)
 {
     stepEvent.PreStep     -= stepable.PreStep;
     stepEvent.PostStep    -= stepable.PostStep;
     stepEvent.Step        -= stepable.Step;
     stepEvent.PhysicsStep -= stepable.PhysicsStep;
 }
Beispiel #2
0
        /// <summary>
        /// perform enqueued task (i.e. calculating image)
        /// </summary>
        public void DoWork()
        {
            models.Progress.IsProcessing = true;

            Debug.Assert(currentWork != null);

            // advance the first stepable
            if (currentWork.HasStep())
            {
                currentWork.NextStep();
            }

            if (!currentWork.HasStep())
            {
                // remove this element
                currentWork = null;
                if (!HasWork())
                {
                    models.Progress.IsProcessing = false;
                }
            }
            else
            {
                // report progress
                models.Progress.What     = currentWork.GetDescription();
                models.Progress.Progress = (float)currentWork.CurrentStep() / currentWork.GetNumSteps();
            }
        }
Beispiel #3
0
    public void StepGround(IStepable stepable)
    {
        GravityValue = 0;
        RectTransform pt = gameObject.transform as RectTransform;

        Vector2 stepPosition = stepable.CalcStepPoint(pt as RectTransform);

        pt.position = stepPosition;
        MoveVector  = stepable.CalcMoveVector(pt, MaxSpeed);
    }
Beispiel #4
0
        /// <summary>
        /// true if DoWork should be called to perform some work
        /// </summary>
        /// <returns></returns>
        public bool HasWork()
        {
            if (currentWork != null)
            {
                return(true);
            }

            // check if the other controllers have something
            foreach (var ctrl in imageController)
            {
                currentWork = ctrl.GetWork();
                if (currentWork != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #5
0
 public void RemoveSteppable(IStepable steppable) => this.Unregister(steppable);
Beispiel #6
0
 public void AddSteppable(IStepable steppable) => this.Register(steppable);
Beispiel #7
0
 /// <summary>
 ///     Удалить обьект из мира.
 /// </summary>
 /// <param name="obj">Удаляемый обьект.</param>
 public void RemoveObject(IStepable obj)
 {
     currentWorld.Remove(obj);
 }
Beispiel #8
0
 /// <summary>
 ///     Добавить новый обьект в текущий мир.
 /// </summary>
 /// <param name="obj">Добавляемый обьект.</param>
 public void AddObject(IStepable obj)
 {
     currentWorld.Add(obj);
 }
Beispiel #9
0
 public static void Unregister(this IStepable stepable, IStepableEvent stepEvent) => stepEvent.Unregister(stepable);