Ejemplo n.º 1
0
        private void AutoMove(Settings settings, int horizontal, int vertical, Stopwatch t, MyItem item)
        {
            try
            {
                if (item.IsDestroyed)
                {
                    item.IsMoving = false;
                    return;
                }

                if (settings.AutoMove && this.Game.WorldEntered)
                {
                    if (t.ElapsedMilliseconds < settings.AutoMoveInterval)
                    {
                        if (false == item.MoveRelative(new Vector {
                            X = horizontal, Y = vertical
                        }, Vector.Zero))
                        {
                            Vector newPos = this.GetRandomPosition();
                            item.MoveAbsolute(newPos, Vector.Zero);
                        }

                        this.fiber.Schedule(() => this.AutoMove(settings, horizontal, vertical, t, item), settings.SendInterval);
                    }
                    else
                    {
                        item.IsMoving = false;
                        this.fiber.Schedule(() => this.AutoMoveStart(item), settings.SendInterval);
                    }
                }
                else
                {
                    item.IsMoving = false;
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The auto move.
        /// </summary>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <param name="horizontal">
        /// The horizontal.
        /// </param>
        /// <param name="vertical">
        /// The vertical.
        /// </param>
        /// <param name="t">
        /// The stop watch.
        /// </param>
        /// <param name="item">
        /// The mmo item.
        /// </param>
        private void AutoMove(Settings settings, int horizontal, int vertical, Stopwatch t, MyItem item)
        {
            try
            {
                if (item.IsDestroyed)
                {
                    item.IsMoving = false;
                    return;
                }

                if (settings.AutoMove && this.Game.State == GameState.WorldEntered)
                {
                    if (t.ElapsedMilliseconds < settings.AutoMoveInterval)
                    {
                        if (false == item.MoveRelative(new float[] { horizontal, vertical }, null))
                        {
                            float[] newPos = this.GetRandomPosition();
                            item.MoveAbsolute(newPos, null);
                        }

                        this.fiber.Schedule(() => this.AutoMove(settings, horizontal, vertical, t, item), settings.SendInterval);
                    }
                    else
                    {
                        item.IsMoving = false;
                        this.fiber.Schedule(() => this.AutoMoveStart(item), settings.SendInterval);
                    }
                }
                else
                {
                    item.IsMoving = false;
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }