-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWorldManager.cs
64 lines (53 loc) · 1.77 KB
/
WorldManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhirlpoolCore.Game;
namespace WhirlpoolCore
{
static class WorldManager
{
public static Dictionary<String, Room> Channels;
public static Dictionary<String, User> Players;
//public static Dictionary<int, GameItem> GameItems;
public static void InitializeWorld()
{
Channels = new Dictionary<String, Room>();
Players = new Dictionary<String, User>();
}
public static void AddUserToWorld(String PlayerId)
{
if (Players.ContainsKey(PlayerId))
{
Receiver.Disconnect(PlayerId);
}
Players.Add(PlayerId, new User());
}
public static void JoinRoom(String ChannelId, String PlayerId)
{
if (!Channels.ContainsKey(ChannelId))
{
Channels.Add(ChannelId, new Room(ChannelId, 30));
}
if (Players[PlayerId].IsInRoom)
{
Channels[Players[PlayerId].CurrentChannel].RemoveUser(PlayerId);
}
Channels[ChannelId].Users.Add(PlayerId);
Players[PlayerId].CurrentChannel = ChannelId;
foreach (String Channel in Channels.Keys)
{
Console.WriteLine(">> " + Channel + ":");
foreach (String Player in Channels[Channel].Users)
{
Console.WriteLine(" > " + Player);
}
}
}
public static void RemoveUserFromWorld(String PlayerId)
{
Channels[Players[PlayerId].CurrentChannel].RemoveUser(PlayerId);
Players.Remove(PlayerId);
}
}
}