private GameSettings currentSettings; //被挑战的临时游戏设置与此变量无关 public PokemonLobbyClient(IPAddress serverAddress, int serverPort) : base(new TcpMessageClient(serverAddress, serverPort)) { roomLock = new object(); LobbyService.Register(this); EnterSucceed = (user) => { user.Quited += () => { lock (roomLock) { battleClient = null; battleHost = null; challengingPms = null; if (User.State == UserState.Battling || User.State == UserState.Watching) ChangeState(UserState.Normal); }; }; switch (user.Role) { case Room.UserRole.Player: User.State = UserState.Aggressive; break; case Room.UserRole.Spectator: User.State = UserState.Watching; break; } }; }
void LoadDLL() { clients.Clear(); string[] plugins = Directory.GetFiles(Environment.CurrentDirectory, "*.dll"); foreach (string akt in plugins) { Assembly assembly = Assembly.LoadFile(akt); foreach (Type aktType in assembly.GetTypes()) { if (aktType.GetInterface("IBattleClient") != null) { IBattleClient instance = Activator.CreateInstance(aktType) as IBattleClient; clients.Add(instance.ClientName, instance); //aktType.InvokeMember("InitPlugin", BindingFlags.Default | BindingFlags.InvokeMethod, null, instance, new object[] { core }); } } } lstClients.DataSource = null; lstClients.DataSource = clients.Keys.ToList(); }
public Player(IBattleClient BC) { PlayerClient = BC; ExecRunning = false; ExecSTW = new Stopwatch(); }
public bool AcceptChallenge(int challenger, PokemonCustomInfo[] pokemons) { if (pokemons != null && pokemons.Length > 0) lock (roomLock) if (battleClient == null) { SendMessage(ACCEPT_CHALLENGE, challenger); //假如对方房间还没设好怎么办...测试了似乎没问题? battleClient = new SingleClient(challenger, currentSettings); StartGame(pokemons); challengingPms = null; return true; } return false; }
private void OnChallengeAccepted(int userId) { lock (roomLock) { ChallengeAccepted(GetUser(userId)); SingleHost s = new SingleHost(User.Id, currentSettings);/////////// battleHost = s; battleClient = s; StartGame(challengingPms); challengingPms = null; } }