示例#1
0
        public MMovePacket(ushort clientId, MPosition lastPosition, MPosition destPosition, UInt32 moveType, UInt32 speedMove)
            : base(opcode, clientId)
        {
            LastPosition = lastPosition;

            MoveType  = moveType;
            SpeedMove = speedMove;

            Destiny = destPosition;
        }
示例#2
0
        private InterestRegions GetDataInterestRegion(List <Region> listInterestRegion)
        {
            InterestRegions dataInterest = new InterestRegions()
            {
                listRegion = new List <MPosition>()
            };

            foreach (var region in listInterestRegion)
            {
                MPosition data = new MPosition()
                {
                    x = region.x, y = region.y
                };
                dataInterest.listRegion.Add(data);
            }

            return(dataInterest);
        }
示例#3
0
        public void SingleAttack(ushort clientId, MPosition attackerPosition, MPosition targetPosition, MTarget target, short skilId)
        {
            var packet = new MSingleAttackPacket(clientId)
            {
                AttackCount      = AttackCount,
                AttackerPosition = attackerPosition,
                AttackerId       = clientId,

                Target         = target,
                TargetPosition = targetPosition,

                CurrentMp = -1,
                SkillId   = skilId,
                FlagLocal = 1,
                Motion    = 4,
            };

            Connection.Send(W2Marshal.GetBytes(packet));
        }
示例#4
0
        private InterestRegions GetDataInterestRegion(List<Region> listInterestRegion)
        {
            InterestRegions dataInterest = new InterestRegions() { listRegion = new List<MPosition>() };

            foreach (var region in listInterestRegion)
            {
                MPosition data = new MPosition() { x = region.x, y = region.y };
                dataInterest.listRegion.Add(data);
            }

            return dataInterest;
        }
示例#5
0
        public void Movement(ushort clientId, MPosition Current, MPosition Destiny, uint moveType, uint Speed)
        {
            var movement = new MMovePacket(clientId, Current, Destiny, moveType, Speed);

            Connection.Send(W2Marshal.GetBytes(movement));
        }
示例#6
0
 public static double GetDistance(MPosition pos1, MPosition pos2)
 {
     return(Math.Sqrt(Math.Pow(pos1.X - pos2.X, 2) + Math.Pow(pos1.Y - pos2.Y, 2)));
 }
        private static void MouseEventInvoke(NativeMethods.MOUSE_EVENT_RECORD record)
        {
            MButton mBtnCurrentState = MButton.None;

            if (record.dwButtonState >= 0 && record.dwButtonState <= 3)
            {
                mBtnCurrentState = (MButton)(2 * record.dwButtonState);
            }
            var phrases = new List <Phrase>();

            for (int i = 0; i < IntaractivePhrases.Count; i++)
            {
                var phrase = IntaractivePhrases[i];
                if (phrase != null)
                {
                    var tempPhrase = new Phrase(phrase.Pattern);

                    Phrase.FindInPosition(record.dwMousePosition.X, record.dwMousePosition.Y, ref tempPhrase);

                    if (tempPhrase.IsSuccess)
                    {
                        phrase.PosLeft = tempPhrase.PosLeft;
                        phrase.PosTop  = tempPhrase.PosTop;
                        phrase.Match   = tempPhrase.Match;
                        phrases.Add(phrase);
                    }
                    else
                    {
                        phrase.IsSuccess = false;
                    }
                }
            }

            //MouseMove
            if (!MPosition.Equals(record.dwMousePosition))
            {
                MPosition = record.dwMousePosition;
                PhraseEventSignal(PhraseEvents.MouseMove, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, mBtnCurrentState));
                #region Mouse Enter/Leave logic

                for (int i = 0; i < phrases.Count; i++)
                {
                    if (!phrases[i].IsMouseEnter)
                    {
                        phrases[i].MouseEventSignal(PhraseEvents.MouseEnter, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, mBtnCurrentState));
                    }
                }

                for (int i = 0; i < IntaractivePhrases.Count; i++)
                {
                    if (IntaractivePhrases[i] != null && !IntaractivePhrases[i].IsSuccess && IntaractivePhrases[i].IsMouseEnter)
                    {
                        IntaractivePhrases[i].MouseEventSignal(PhraseEvents.MouseLeave, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, mBtnCurrentState));
                    }
                }
                #endregion
            }

            //Left MouseDown
            if (MButtonPreState == MButton.None && (mBtnCurrentState & MButton.Left) == MButton.Left)
            {
                IsLeftMButtonDown = true;
                PhraseEventSignal(PhraseEvents.MouseDown, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Left));
            }

            //Right MouseDown
            if (MButtonPreState == MButton.None && (mBtnCurrentState & MButton.Right) == MButton.Right)
            {
                IsRightMButtonDown = true;
                PhraseEventSignal(PhraseEvents.MouseDown, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Right));
            }
            //Right MouseUp / MouseClick
            if ((MButtonPreState & MButton.Left) == MButton.Left && (mBtnCurrentState & MButton.Left) != MButton.Left)
            {
                PhraseEventSignal(PhraseEvents.MouseUp, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Left));
                if (IsLeftMButtonDown)
                {
                    PhraseEventSignal(PhraseEvents.MouseClick, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Left));
                    IsLeftMButtonDown = false;
                }
            }

            //Left MouseUp / MouseClick
            if ((MButtonPreState & MButton.Right) == MButton.Right && (mBtnCurrentState & MButton.Right) != MButton.Right)
            {
                PhraseEventSignal(PhraseEvents.MouseUp, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Left));
                if (IsRightMButtonDown)
                {
                    PhraseEventSignal(PhraseEvents.MouseClick, new ConsoleMouseEventArgs(MPosition.X, MPosition.Y, MButton.Left));
                    IsRightMButtonDown = false;
                }
            }
            MButtonPreState = mBtnCurrentState;

            void PhraseEventSignal(PhraseEvents eventName, ConsoleMouseEventArgs e)
            {
                for (int i = 0; i < phrases.Count; i++)
                {
                    phrases[i].MouseEventSignal(eventName, e);
                }
            }
        }