Step 2

Datum: 22/11/2014 23:46:46

Staženo: 257x

Popis:


Hodnocení: 3.0/10 (57 hlasy)

Download file:cs

Příkazy:

Kód:

using System.Windows.Forms;
using Phoenix.WorldData;

namespace Phoenix.Scripts.DP.Skills
{
    public static class Walking
    {
        public static bool Step(int x, int y)
        {
            if (x > 0)
                return StepDirection(2, 34);
            if (x < 0)
                return StepDirection(6, 36);
            if (y > 0)
                return StepDirection(4, 35);
            if (y < 0)
                return StepDirection(0, 33);
            return false;
        }

        private static bool StepDirection(byte direction, int key)
        {
            if (World.Player.Direction != direction)
                StepWait(key);
            return StepWait(key);
        }

        private static bool StepWait(int key)
        {
            using (StepWaiter sw = new StepWaiter())
            {
                UO.Press((Keys)key);
                sw.Wait(2000);
                UO.Wait(250);
                return sw.Result;
            }
        }

        private class StepWaiter : ServerMessageWaiter
        {
            public StepWaiter() : base(0x21, 0x22) { }
            public bool Result { get; private set; }
            protected override CallbackResult EventHandler(byte[] data, CallbackResult prevResult)
            {
                Result = data[0] == 0x22;
                return base.EventHandler(data, prevResult);
            }
        }
    }
}
Zde ještě není žádný komentář.

Nový komentář