internal static IComeDirection InverseDirections(Room room, IComeDirection comeWith, int x, int y) { try { switch (comeWith) { case IComeDirection.Up: return(IComeDirection.Down); case IComeDirection.UpRight: if (room.GetGameMap().StaticModel.SqState[x][y] == SquareState.Blocked) { return(room.GetGameMap().StaticModel.SqState[x + 1][y] == SquareState.Blocked ? IComeDirection.DownRight : IComeDirection.UpLeft); } return(IComeDirection.DownRight); case IComeDirection.Right: return(IComeDirection.Left); case IComeDirection.DownRight: if (room.GetGameMap().StaticModel.SqState[x][y] == SquareState.Blocked) { return(room.GetGameMap().StaticModel.SqState[x + 1][y] == SquareState.Blocked ? IComeDirection.UpRight : IComeDirection.DownLeft); } return(IComeDirection.UpRight); case IComeDirection.Down: return(IComeDirection.Up); case IComeDirection.DownLeft: return(room.GetGameMap().Model.MapSizeX - 1 <= x ? IComeDirection.DownRight : IComeDirection.UpLeft); case IComeDirection.Left: return(IComeDirection.Right); case IComeDirection.UpLeft: return(room.GetGameMap().Model.MapSizeX - 1 <= x ? IComeDirection.UpRight : IComeDirection.DownLeft); } return(IComeDirection.Null); } catch { return(IComeDirection.Null); } }
internal static void GetNewCoords(IComeDirection comeWith, ref int newX, ref int newY) { try { switch (comeWith) { case IComeDirection.Up: newY++; break; case IComeDirection.UpRight: newX--; newY++; break; case IComeDirection.Right: newX--; break; case IComeDirection.DownRight: newX--; newY--; break; case IComeDirection.Down: newY--; break; case IComeDirection.DownLeft: newX++; newY--; break; case IComeDirection.Left: newX++; break; case IComeDirection.UpLeft: newX++; newY++; break; } } catch { } }
internal static void GetNewCoords(IComeDirection comeWith, ref int newX, ref int newY) { try { switch (comeWith) { case IComeDirection.Up: newY++; break; case IComeDirection.UpRight: newX--; newY++; break; case IComeDirection.Right: newX--; break; case IComeDirection.DownRight: newX--; newY--; break; case IComeDirection.Down: newY--; break; case IComeDirection.DownLeft: newX++; newY--; break; case IComeDirection.Left: newX++; break; case IComeDirection.UpLeft: newX++; newY++; break; } } catch { } }
internal static IComeDirection GetInverseDirectionEasy(IComeDirection comeWith) { IComeDirection result; try { switch (comeWith) { case IComeDirection.Up: result = IComeDirection.Down; break; case IComeDirection.UpRight: result = IComeDirection.DownLeft; break; case IComeDirection.Right: result = IComeDirection.Left; break; case IComeDirection.DownRight: result = IComeDirection.UpLeft; break; case IComeDirection.Down: result = IComeDirection.Up; break; case IComeDirection.DownLeft: result = IComeDirection.UpRight; break; case IComeDirection.Left: result = IComeDirection.Right; break; default: result = comeWith == IComeDirection.UpLeft ? IComeDirection.DownRight : IComeDirection.Null; break; } } catch { result = IComeDirection.Null; } return(result); }
internal static IComeDirection GetInverseDirectionEasy(IComeDirection comeWith) { IComeDirection result; try { switch (comeWith) { case IComeDirection.Up: result = IComeDirection.Down; break; case IComeDirection.UpRight: result = IComeDirection.DownLeft; break; case IComeDirection.Right: result = IComeDirection.Left; break; case IComeDirection.DownRight: result = IComeDirection.UpLeft; break; case IComeDirection.Down: result = IComeDirection.Up; break; case IComeDirection.DownLeft: result = IComeDirection.UpRight; break; case IComeDirection.Left: result = IComeDirection.Right; break; default: result = comeWith == IComeDirection.UpLeft ? IComeDirection.DownRight : IComeDirection.Null; break; } } catch { result = IComeDirection.Null; } return result; }
internal static IComeDirection InverseDirections(Room room, IComeDirection comeWith, int x, int y) { try { switch (comeWith) { case IComeDirection.Up: return IComeDirection.Down; case IComeDirection.UpRight: if (room.GetGameMap().StaticModel.SqState[x][y] == SquareState.Blocked) return room.GetGameMap().StaticModel.SqState[x + 1][y] == SquareState.Blocked ? IComeDirection.DownRight : IComeDirection.UpLeft; return IComeDirection.DownRight; case IComeDirection.Right: return IComeDirection.Left; case IComeDirection.DownRight: if (room.GetGameMap().StaticModel.SqState[x][y] == SquareState.Blocked) return room.GetGameMap().StaticModel.SqState[x + 1][y] == SquareState.Blocked ? IComeDirection.UpRight : IComeDirection.DownLeft; return IComeDirection.UpRight; case IComeDirection.Down: return IComeDirection.Up; case IComeDirection.DownLeft: return room.GetGameMap().Model.MapSizeX - 1 <= x ? IComeDirection.DownRight : IComeDirection.UpLeft; case IComeDirection.Left: return IComeDirection.Right; case IComeDirection.UpLeft: return room.GetGameMap().Model.MapSizeX - 1 <= x ? IComeDirection.UpRight : IComeDirection.DownLeft; } return IComeDirection.Null; } catch { return IComeDirection.Null; } }
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); } } }
internal void OnUserWalk(RoomUser User) { if (User == null) { return; } foreach (Item ball in _balls.Values) { if (ball == null) { return; } //If user position is same as ball position AND The goal Y is the same as Ball y position SHOOT! 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.BallTryGoThrough = 0; ball.Shoot = true; ball.ballIsMoving = true; ball.ballMover = User.GetClient(); MoveBall(ball, User.GetClient(), userPoint); } //if user position is same as ball //shoot! SHOOT! 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.BallTryGoThrough = 0; ball.Shoot = true; ball.ballIsMoving = true; ball.ballMover = User.GetClient(); MoveBall(ball, User.GetClient(), userPoint); } else { //if user goal is same as ball position 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; IComeDirection _comeDirection = ComeDirection.GetComeDirection(new Point(User.X, User.Y), ball.Coordinate); if (_comeDirection != IComeDirection.Null) { int NewX = User.SetX; int NewY = User.SetY; ComeDirection.GetNewCoords(_comeDirection, ref NewX, ref NewY); if (ball.GetRoom().GetGameMap().ValidTile(NewX, NewY)) { ball.ExtraData = "11"; ball.ballMover = User.GetClient(); MoveBall(ball, User.GetClient(), NewX, NewY); } } } } } }