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