예제 #1
0
        internal static void PcWalkCheck(Player player, float startX, float startY, Point[] movePos)
        {
            if (!Settings.CheckCollision)
            {
                ClientPacketHandler.send_PCMoveTo(player, movePos.ToArray());
                return;
            }

            //ConsoleUtils.Write(ConsoleMsgType.Debug, "[Debug Move] startX: {0} ; startY: {1} ; Points: {2}\n", startX, startY, movePos.Length);
            //for (int i = 0; i < movePos.Length; i++)
            //	ConsoleUtils.Write(ConsoleMsgType.Debug, "--> MovePos[{0}]: ( {1}, {2} )\n", i, (int)movePos[i].X, (int)movePos[i].Y);

            List <Point> moves = new List <Point>();
            int          mapX = 10; int mapY = 3;
            bool         endOfTest = false;

            for (int i = 0; i < movePos.Length; i++)
            {
                int fromX, fromY;
                if (i == 0)
                {
                    fromX = (int)startX; fromY = (int)startY;
                }
                else
                {
                    fromX = (int)movePos[i - 1].X; fromY = (int)movePos[i - 1].Y;
                }

                Map m = Maps[mapX][mapY];

                for (int j = 0; j < m.Collisions.Length; j++)
                {
                    if (Geometry.DoIntersect(new Point(fromX, fromY), movePos[i], m.Collisions[j].P1, m.Collisions[j].P2))
                    {
                        //ConsoleUtils.Write(ConsoleMsgType.Debug, "Intersects with ({0}, {1}) ({2}, {3})!\n", (int)m.Collisions[j].P1.X, (int)m.Collisions[j].P1.Y, (int)m.Collisions[j].P2.X, (int)m.Collisions[j].P2.Y);
                        endOfTest = true;
                        break;
                    }
                }

                if (endOfTest)
                {
                    break;
                }
                else
                {
                    //ConsoleUtils.Write(ConsoleMsgType.Debug, "OK! ( {0}, {1} )\n", movePos[i].X, movePos[i].Y);
                    moves.Add(movePos[i]);
                }
            }

            //Console.Write("End of Move Process\n");

            ClientPacketHandler.send_PCMoveTo(player, moves.ToArray());
        }
예제 #2
0
        internal void Update()
        {
            lock (this)
            {
                // Note : This method is not really good
                int movSpd    = 10;
                int deltaTime = (Environment.TickCount);
                deltaTime -= this.LastUpdate;

                float toX = this.Position.X + (new Random().Next(-movSpd * deltaTime, movSpd * deltaTime) / 1000);
                float toY = this.Position.Y + (new Random().Next(-movSpd * deltaTime, movSpd * deltaTime) / 1000);

                this.LastUpdate = Environment.TickCount;

                ClientPacketHandler.send_PCMoveTo(this, new Point(toX, toY));
            }
        }