Пример #1
0
        public void onUserwalk(RoomUser User, RoomItem ball)
        {
            if (User == null)
            {
                return;
            }

            if (ball == null)
            {
                return;
            }

            var Height = room.GetGameMap().SqAbsoluteHeight(User.SetX, User.SetY);

            foreach (ThreeDCoord tile in ball.GetAffectedTiles.Values)
            {
                if (ball.GetZ != Height)
                {
                    ball.SetHeight(Height);
                }
            }

            if (User.SetX == ball.GetX && User.SetY == ball.GetY && (ball._iBallValue == 5 || ball._iBallValue == 6)) // start the second game ball... inversing:
            {
            }

            else if (User.SetX == ball.GetX && User.SetY == ball.GetY && User.GoalX == ball.GetX && User.GoalY == ball.GetY && User.handelingBallStatus == 0) // super chute.
            {
                Point userPoint = new Point(User.X, User.Y);
                ball.ExtraData    = "55";
                ball.ballIsMoving = true;
                ball._iBallValue  = 1;
                ball.ballMover    = User;
                MoveBall(ball, User.GetClient(), userPoint);
            }
            else if (User.SetX == ball.GetX && User.SetY == ball.GetY && User.GoalX == ball.GetX && User.GoalY == ball.GetY && User.handelingBallStatus == 1) // super chute quando para de andar
            {
                User.handelingBallStatus = 0;
                ComeDirection _comeDirection = _ComeDirection.GetComeDirection(new Point(User.X, User.Y), ball.Coordinate);
                if (_comeDirection != ComeDirection.NULL)
                {
                    int NewX = User.SetX;
                    int NewY = User.SetY;

                    _ComeDirection.GetNewCoords(_comeDirection, ref NewX, ref NewY);
                    if (ball.GetRoom().GetGameMap().ValidTile(NewX, NewY))
                    {
                        Point userPoint = new Point(User.X, User.Y);
                        //ball.ExtraData = "55";
                        ball.ballIsMoving = true;
                        ball._iBallValue  = 6;
                        ball.ballMover    = User;
                        MoveBall(ball, User.GetClient(), userPoint);
                    }
                }
            }
            else if (User.X == ball.GetX && User.Y == ball.GetY && User.handelingBallStatus == 0)
            {
                Point userPoint = new Point(User.SetX, User.SetY);
                ball.ExtraData    = "55";
                ball.ballIsMoving = true;
                ball._iBallValue  = 1;
                ball.ballMover    = User;
                MoveBall(ball, User.GetClient(), userPoint);
            }
            else
            {
                if (User.handelingBallStatus == 0 && User.GoalX == ball.GetX && User.GoalY == ball.GetY)
                {
                    return;
                }

                if (User.SetX == ball.GetX && User.SetY == ball.GetY && User.IsWalking && (User.X != User.GoalX || User.Y != User.GoalY))
                {
                    User.handelingBallStatus = 1;
                    ComeDirection _comeDirection = _ComeDirection.GetComeDirection(new Point(User.X, User.Y), ball.Coordinate);
                    if (_comeDirection != ComeDirection.NULL)
                    {
                        int NewX = User.SetX;
                        int NewY = User.SetY;

                        _ComeDirection.GetNewCoords(_comeDirection, ref NewX, ref NewY);

                        if (!room.GetGameMap().itemCanBePlacedHere(NewX, NewY) && User.handelingBallStatus == 1)
                        {
                            ball.comeDirection = _ComeDirection.InverseDirections(room, ball.comeDirection, NewX, NewY);
                            NewX           = User.X;
                            NewY           = User.Y;
                            ball.ExtraData = "11";
                            MoveBall(ball, User, NewX, NewY);
                        }
                        else if (room.GetGameMap().SquareHasUsers(NewX, NewY) && User.handelingBallStatus == 1)
                        {
                            ball.comeDirection = _ComeDirection.InverseDirections(room, ball.comeDirection, NewX, NewY);
                            NewX           = User.X;
                            NewY           = User.Y;
                            ball.ExtraData = "11";
                            MoveBall(ball, User, NewX, NewY);
                        }
                        else if (ball.GetRoom().GetGameMap().ValidTile(NewX, NewY, true))
                        {
                            ball.ExtraData = "11";
                            MoveBall(ball, User, NewX, NewY);
                        }
                        else
                        {
                            ball.comeDirection = _ComeDirection.InverseDirections(room, ball.comeDirection, NewX, NewY);
                            NewX           = User.X;
                            NewY           = User.Y;
                            ball.ExtraData = "11";
                            MoveBall(ball, User, NewX, NewY);
                        }
                    }
                }
            }
        }
Пример #2
0
        public void MoveBallProcess(RoomItem item)
        {
            int tryes = 0;
            int newX  = item.Coordinate.X;
            int newY  = item.Coordinate.Y;
            int resetX;
            int resetY;

            foreach (RoomItem gate in room.GetRoomItemHandler().mFloorItems.Values)
            {
                if (gate.GetBaseItem().InteractionType == InteractionType.footballgoalred || gate.GetBaseItem().InteractionType == InteractionType.footballgoalgreen || gate.GetBaseItem().InteractionType == InteractionType.footballgoalblue || gate.GetBaseItem().InteractionType == InteractionType.footballgoalyellow)
                {
                    foreach (ThreeDCoord tile in gate.GetAffectedTiles.Values)
                    {
                        if (item.Coordinate == tile.SquareBehind(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, true))
                        {
                            item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                        }

                        else if (item.Coordinate == tile.LeftSide(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, true))
                        {
                            item._iBallValue   = 1;
                            item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                        }

                        else if (item.Coordinate == tile.RightSide(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, true))
                        {
                            item._iBallValue   = 1;
                            item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                        }

                        else if (item.Coordinate == tile.UpLeftSide(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, false, true))
                        {
                            item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                        }

                        else if (item.Coordinate == tile.UpRightSide(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, false, false, true))
                        {
                            item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                        }

                        // Two tiles

                        if (item.Coordinate == tile.SquareBehindTwoTiles(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, true))
                        {
                            item.ExtraData   = "11";
                            item._iBallValue = 6;
                        }

                        else if (item.Coordinate == tile.LeftSideTwoTiles(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, true))
                        {
                            item.ExtraData   = "11";
                            item._iBallValue = 6;
                        }

                        else if (item.Coordinate == tile.RightSideTwoTiles(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, true))
                        {
                            item.ExtraData   = "11";
                            item._iBallValue = 6;
                        }

                        else if (item.Coordinate == tile.UpLeftSideTwoTiles(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, false, true))
                        {
                            item.ExtraData   = "11";
                            item._iBallValue = 6;
                        }

                        else if (item.Coordinate == tile.UpRightSideTwoTiles(gate.Rot) && item.comeDirection == GetComeDirection(gate.Rot, false, false, false, false, true))
                        {
                            item.ExtraData   = "11";
                            item._iBallValue = 6;
                        }
                    }
                }
            }

            while (tryes < 3)
            {
                if (room == null)
                {
                    return;
                }

                var Height = room.GetGameMap().SqAbsoluteHeight(newX, newY);

                foreach (ThreeDCoord tile in item.GetAffectedTiles.Values)
                {
                    if (item.GetZ != Height)
                    {
                        item.SetHeight(Height);
                    }
                }

                if (room.GetGameMap() == null)
                {
                    room.FixGameMap();
                    if (room.GetGameMap() == null)
                    {
                        return;
                    }
                }

                if (item.comeDirection == ComeDirection.NULL)
                {
                    item.ballIsMoving = false;
                    break;
                }

                resetX = newX;
                resetY = newY;

                _ComeDirection.GetNewCoords(item.comeDirection, ref newX, ref newY);

                if (room.GetGameMap().SquareHasUsers(newX, newY) && tryes == 1 && (item._iBallValue == 2 || item._iBallValue == 3)) // se chuta ela no quadrado da frente, e ela volta, ela atravessa o usuario
                {
                }
                else if (!room.GetGameMap().itemCanBePlacedHere(newX, newY) || room.GetGameMap().SquareHasUsers(newX, newY)) // start the second game ball... inversing:
                {
                    item.comeDirection = _ComeDirection.InverseDirections(room, item.comeDirection, newX, newY);
                    newX = resetX;
                    newY = resetY;
                    tryes++;
                    if (tryes > 2)
                    {
                        item.ballIsMoving = false;
                    }
                    continue;
                }

                if (MoveBall(item, item.ballMover, newX, newY))
                {
                    item.ballIsMoving = false;
                    break;
                }

                int Number = 11;
                int.TryParse(item.ExtraData, out Number);
                if (Number > 11)
                {
                    item.ExtraData = (int.Parse(item.ExtraData) - 11).ToString();
                }
                item.ExtraData = "11";
                item._iBallValue++;

                if (item._iBallValue > 2)
                {
                    item.ballIsMoving = false;
                    item._iBallValue  = 1;
                    item.ballMover    = null;
                }
                break;
            }
        }