Пример #1
0
        public void Start()
        {
            MS2.PlayerBossPos pos2 = ms2.GetPlayerAndBossLocation();
            Console.WriteLine(pos2.px + ", " + pos2.py);
            Thread.Sleep(2000);



            //            System.Threading.Thread.Sleep(2000);
            //ms2.WalkRel(5,5);
            //ms2.WalkTo(230,587);
            //ms2.WalkTo(198,612);
            //return;
            for (;;)
            {
                switch (currentPhase)
                {
                case Phase.WalkAcrossBridge:
                    WalkBridge();
                    break;

                case Phase.First:
                    FirstPhase();
                    break;

                case Phase.Second:

                    break;

                default:
                    break;
                }
            }
        }
Пример #2
0
        public void walkAroundBoss()
        {
            int    offset      = 20;
            float  radians     = 0;
            Thread attackt     = new Thread(Attack);
            bool   notincorner = true;
            bool   direction   = false;

            attackt.Start();
            Stopwatch sw = new Stopwatch();

            sw.Start();
            MS2.PlayerBossPos posprev = new MS2.PlayerBossPos();
            while (notincorner)
            {
                MS2.PlayerBossPos pos = ms2.GetPlayerAndBossLocation();
                if (pos.by < 415 && false)
                {
                    Console.WriteLine("Second Phase " + pos.by);
                    ms2.StopMoving();
                    currentPhase = Phase.Second;
                    break;
                }

                if (OnFire())
                {
                    Point p = getClosestFairy(pos.px, pos.py);
                    ms2.WalkTowards(pos.px, pos.py, p.X, p.Y, 3);
                    if (inHole(pos.px, pos.py))
                    {
                        ms2.WalkTowards(pos.px, pos.py, pos.px, pos.py - 1, 0);
                        Thread.Sleep(100);
                        ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                        Thread.Sleep(100);
                        ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    }
                    continue;
                }
                else if (pos.px <= 265)
                {
                    ms2.WalkTowards(pos.px, pos.py, pos.px + 1, pos.py, 0);
                    Thread.Sleep(250);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    continue;
                }
                else if (pos.py >= 550)
                {
                    ms2.WalkTowards(pos.px, pos.py, pos.px, pos.py - 1, 0);
                    Thread.Sleep(250);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                    Thread.Sleep(100);
                    ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    continue;
                }
                else if (posprev.px == pos.px && pos.py == posprev.py)
                {
                    if (inHole(pos.px, pos.py))
                    {
                        ms2.WalkTowards(pos.px, pos.py, pos.px, pos.py - 1, 0);
                        Thread.Sleep(100);
                        ms2.input.SendKey(Keys.RightAlt, KeyState.Down);
                        Thread.Sleep(100);
                        ms2.input.SendKey(Keys.RightAlt, KeyState.Up);
                    }
                    continue;
                }

                int targetx = 0, targety = 0;
                int mag = GetMag(pos.px, pos.py, pos.bx, pos.by);
                Console.WriteLine("pr " + mag);
                if (mag > 40)
                {
                    float rad = (float)(Math.Atan((pos.by - pos.py) / (pos.bx - pos.py)) + Math.PI / 2);

                    targetx = (int)(Math.Cos(rad) * mag * .75f + pos.bx);
                    targety = (int)(Math.Sin(rad) * mag * .75f + pos.by);
                }
                else
                {
                    targetx = (int)(Math.Cos(radians) * offset + pos.bx);
                    targety = (int)(Math.Sin(radians) * offset + pos.by);
                }

                if (targetx > 413)
                {
                    direction = !direction;
                    targetx   = 413;
                }
                if (targety > 522)
                {
                    direction = !direction;
                    targety   = 522;
                }
                if (targetx < 275)
                {
                    direction = !direction;
                    targetx   = 275;
                }
                if (targety < 437)
                {
                    direction = !direction;
                    targety   = 437;
                }
                ms2.WalkTowards(pos.px, pos.py, targetx, targety, 0);

                radians = (float)(sw.ElapsedMilliseconds / 1000f * Math.PI / 3 * (direction?1:-1));
                //Console.WriteLine("rad "+radians/Math.PI);
                //Thread.Sleep(10);
                posprev = pos;
            }

            attackt.Interrupt();
        }