Soccer.cs

Twister

New Member
May 24, 2015
29
1
Hello DevBest,

I fixing the football on Plusemu and I fixe the distance at 4 cases when you shoot but they are not the move of the ball:

Screen:

My Method
PHP:
public void OnUserWalk(RoomUser User)
        {
            if (User == null)
                return;

            foreach (Item item in this._balls.Values.ToList())
            {
                int NewX = 0;
                int NewY = 0;
                int differenceX = User.X - item.GetX;
                int differenceY = User.Y - item.GetY;

                if (differenceX == 0 && differenceY == 0)
                {
                    if (User.RotBody == 4)
                    {
                        NewX = User.X;
                        NewY = User.Y + 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 6)
                    {
                        NewX = User.X - 4;
                        NewY = User.Y;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 0)
                    {
                        NewX = User.X;
                        NewY = User.Y - 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 2)
                    {
                        NewX = User.X + 4;
                        NewY = User.Y;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 1)
                    {
                        NewX = User.X + 4;
                        NewY = User.Y - 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 7)
                    {
                        NewX = User.X - 4;
                        NewY = User.Y - 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 3)
                    {
                        NewX = User.X + 4;
                        NewY = User.Y + 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;

                    }
                    else if (User.RotBody == 5)
                    {
                        NewX = User.X - 4;
                        NewY = User.Y + 4;
                        item.ExtraData = "55";
                        item.BallIsMoving = true;
                        item.BallValue = 1;
                    }

                    if (!this._room.GetRoomItemHandler().CheckPosItem(User.GetClient(), item, NewX, NewY, item.Rotation, false, false))
                    {
                        if (User.RotBody == 0)
                        {
                            NewX = User.X;
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 2)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y;
                        }
                        else if (User.RotBody == 4)
                        {
                            NewX = User.X;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 6)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y;
                        }
                        else if (User.RotBody == 5)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 3)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 7)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 1)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y + 1;
                        }
                    }
                }
                else if (differenceX <= 1 && differenceX >= -1 && differenceY <= -1 && differenceY >= 1 && VerifyBall(User, item.Coordinate.X, item.Coordinate.Y))//VERYFIC BALL CHECAR SI ESTA EN DIRECCION ASIA LA PELOTA
                {
                    NewX = differenceX * -1;
                    NewY = differenceY * -1;

                    NewX = NewX + item.GetX;
                    NewY = NewY + item.GetY;
                }

                if (item.GetRoom().GetGameMap().ValidTile(NewX, NewY))
                {
                    MoveBall(item, User.GetClient(), NewX, NewY);
                }
            }
        }

Thanks you
Have a good day
 

Users who are viewing this thread

Top