Esempio n. 1
0
        internal void MoveBall(RoomItem item, GameClient client, Point user)
        {
            try
            {
                item.ComeDirection = ComeDirection.GetComeDirection(user, item.Coordinate);

                if (item.ComeDirection != IComeDirection.Null)
                {
                    // item.ballMover = client;
                    new TaskFactory().StartNew(() => MoveBallProcess(item, client));
                }
            }
            catch
            {
            }
        }
Esempio n. 2
0
        internal void OnUserWalk(RoomUser user)
        {
            if (user == null)
            {
                return;
            }

            foreach (RoomItem ball in _balls.Values)
            {
                if (user.SetX == ball.X && user.SetY == ball.Y && user.GoalX == ball.X && user.GoalY == ball.Y &&
                    user.HandelingBallStatus == 0) // super chute.
                {
                    Point userPoint = new Point(user.X, user.Y);
                    ball.ExtraData    = "55";
                    ball.BallIsMoving = true;
                    ball.BallValue    = 1;
                    MoveBall(ball, user.GetClient(), userPoint);
                }
                else if (user.X == ball.X && user.Y == ball.Y && user.HandelingBallStatus == 0)
                {
                    Point userPoint = new Point(user.SetX, user.SetY);
                    ball.ExtraData    = "55";
                    ball.BallIsMoving = true;
                    ball.BallValue    = 1;
                    MoveBall(ball, user.GetClient(), userPoint);
                }
                else
                {
                    if (user.HandelingBallStatus == 0 && user.GoalX == ball.X && user.GoalY == ball.Y)
                    {
                        return;
                    }

                    if (user.SetX != ball.X || user.SetY != ball.Y || !user.IsWalking ||
                        (user.X == user.GoalX && user.Y == user.GoalY))
                    {
                        return;
                    }
                    user.HandelingBallStatus = 1;
                    IComeDirection comeDirection = ComeDirection.GetComeDirection(new Point(user.X, user.Y), ball.Coordinate);
                    if (comeDirection == IComeDirection.Null)
                    {
                        return;
                    }

                    int newX = user.SetX;
                    int newY = user.SetY;

                    if (!ball.GetRoom().GetGameMap().ValidTile2(user.SetX, user.SetY) ||
                        !ball.GetRoom().GetGameMap().ItemCanBePlacedHere(user.SetX, user.SetY))
                    {
                        comeDirection = ComeDirection.InverseDirections(_room, comeDirection, user.X, user.Y);
                        newX          = ball.X;
                        newY          = ball.Y;
                    }

                    ComeDirection.GetNewCoords(comeDirection, ref newX, ref newY);
                    ball.ExtraData = "11";
                    MoveBall(ball, user.GetClient(), newX, newY);
                }
            }
        }