mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
All multirooms implemented!
This commit is contained in:
parent
2b59ba1be9
commit
e9dc4157b0
6 changed files with 151 additions and 47 deletions
|
@ -307,27 +307,20 @@ namespace HISP.Game
|
|||
{
|
||||
|
||||
string message = Messages.MultiroomPlayersParticipating;
|
||||
if(id != null) // Special type
|
||||
|
||||
Multiroom room = Multiroom.GetMultiroom(user.X, user.Y);
|
||||
room.Join(user);
|
||||
|
||||
foreach (User userOnTile in room.JoinedUsers)
|
||||
{
|
||||
foreach (User userOnTile in GameServer.GetUsersOnSpecialTileCode("MULTIROOM-" + id))
|
||||
{
|
||||
if (userOnTile.Id == user.Id)
|
||||
continue;
|
||||
message += Messages.FormatMultiroomParticipent(userOnTile.Username);
|
||||
}
|
||||
message += Messages.R1;
|
||||
}
|
||||
else if(id == null) // Generic
|
||||
{
|
||||
foreach (User userOnTile in GameServer.GetUsersAt(user.X, user.Y, true, true))
|
||||
{
|
||||
if (userOnTile.Id == user.Id)
|
||||
continue;
|
||||
message += Messages.FormatMultiroomParticipent(userOnTile.Username);
|
||||
}
|
||||
message += Messages.R1;
|
||||
if (userOnTile.Id == user.Id)
|
||||
continue;
|
||||
|
||||
message += Messages.FormatMultiroomParticipent(userOnTile.Username);
|
||||
}
|
||||
|
||||
message += Messages.R1;
|
||||
|
||||
if(id == null) // Generic
|
||||
{
|
||||
// Do nothing
|
||||
|
|
91
Horse Isle Server/HorseIsleServer/Game/Multiroom.cs
Normal file
91
Horse Isle Server/HorseIsleServer/Game/Multiroom.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
public class Multiroom
|
||||
{
|
||||
public static List<Multiroom> Multirooms = new List<Multiroom>();
|
||||
public static Multiroom GetMultiroom(int x, int y)
|
||||
{
|
||||
foreach (Multiroom multiroom in Multirooms)
|
||||
if(multiroom.x == x && multiroom.y == y)
|
||||
return multiroom;
|
||||
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
public static bool IsMultiRoomAt(int x, int y)
|
||||
{
|
||||
foreach (Multiroom multiroom in Multirooms)
|
||||
if (multiroom.x == x && multiroom.y == y)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void LeaveAllMultirooms(User user)
|
||||
{
|
||||
foreach (Multiroom room in Multirooms)
|
||||
room.Leave(user);
|
||||
}
|
||||
|
||||
public static void CreateMultirooms()
|
||||
{
|
||||
Logger.InfoPrint("Creating Multirooms...");
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles)
|
||||
{
|
||||
if (tile.Code != null)
|
||||
{
|
||||
if (tile.Code.StartsWith("MULTIROOM"))
|
||||
{
|
||||
Logger.DebugPrint("Created Multiroom @ " + tile.X.ToString() + "," + tile.Y.ToString());
|
||||
new Multiroom(tile.X, tile.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Multiroom(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
Multirooms.Add(this);
|
||||
}
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public List<User> JoinedUsers = new List<User>();
|
||||
|
||||
public void Join(User user)
|
||||
{
|
||||
if (!JoinedUsers.Contains(user))
|
||||
{
|
||||
Logger.DebugPrint(user.Username + " Joined multiroom @ " + x.ToString() + "," + y.ToString());
|
||||
JoinedUsers.Add(user);
|
||||
|
||||
foreach (User joinedUser in JoinedUsers)
|
||||
if (joinedUser.Id != user.Id)
|
||||
GameServer.UpdateArea(joinedUser.LoggedinClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Leave(User user)
|
||||
{
|
||||
|
||||
if(JoinedUsers.Contains(user))
|
||||
{
|
||||
Logger.DebugPrint(user.Username + " Left multiroom @ " + x.ToString() + "," + y.ToString());
|
||||
JoinedUsers.Remove(user);
|
||||
}
|
||||
|
||||
foreach (User joinedUser in JoinedUsers)
|
||||
GameServer.UpdateArea(joinedUser.LoggedinClient);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue