// Constructor 1#: Used for Hall setting public XIVisi(ushort uid, string name, int teamCode, Base.VW.IVI vi, string server, int room, bool record, bool logmsg, bool watcher, AoDisplay ad) { this.auid = uid; this.name = name; this.VI = vi as VW.Cyvi; hopeTeam = teamCode; this.server = server; this.Room = room; this.port = Base.NetworkCode.HALL_PORT + room; this.ad = ad; VW.Bywi bywi = new VW.Bywi(server, port, name, avatar, hopeTeam, uid, this); Log = new ClLog(); Log.Start(auid, record, logmsg, 0); bywi.Log = Log; CommonConstruct(); //if (VI is VW.Ayvi) // (VI as VW.Ayvi).Log = Log; WI = bywi; if (!bywi.StartConnect(watcher)) (vi as VW.Cyvi).ReportFlashQuitError(); if (watcher) Uid = bywi.Uid; VI.Cout(uid, watcher ? "您开始旁观~" : "游戏开始咯~"); isReplay = false; }
private ZI(string name, string server, int port, bool record, bool msglog, int room, AoDisplay ad) { this.name = name; this.server = server; this.port = port; // selCode and pkgCode pending this.record = record; this.msglog = msglog; roomMates = new List<IchiPlayer>(); this.room = room; AD = ad; }
public ZI(string name, int avatar, string server, int port, int teamCode, int selCode, int levelCode, string[] trainer, bool record, bool msglog, AoDisplay ad) { this.name = name; this.avatar = avatar; this.server = server; this.port = port; this.teamCode = teamCode; this.selCode = selCode; this.levelCode = levelCode; this.trainer = trainer; this.record = record; this.msglog = msglog; roomMates = new List<IchiPlayer>(); AD = ad; XV = null; LoginDoor = null; }
// Constructor 3#: Used for Replay mode public XIVisi(string fileName, AoDisplay ad) { VI = new VW.Cyvi(ad); VI.Init(); VI.SetInGame(true); VW.Eywi eywi = new VW.Eywi(fileName); WI = eywi; this.ad = ad; Log = new ClLog(); Log.Start(Uid, false, false, 0); CommonConstruct(); this.auid = eywi.Uid; isReplay = true; }
public AoMix(AoDisplay ad) { this.AD = ad; }
public static ZI CreateResumeHall(string name, string server, int port, bool record, bool msglog, int room, AoDisplay ad) { return new ZI(name, server, port, record, msglog, room, ad); }
public bool StartWatchHall() { TcpClient client = null; try { client = new TcpClient(server, port); } catch (SocketException) { return false; } NetworkStream tcpStream = client.GetStream(); Base.VW.WHelper.SentByteLine(tcpStream, "C0QI," + name); while (true) { string line = Base.VW.WHelper.ReadByteLine(tcpStream); if (line.StartsWith("C0QJ,")) { string[] splits = line.Split(','); uid = ushort.Parse(splits[1]); List<int> crooms = new List<int>(); for (int i = 2; i < splits.Length; ++i) crooms.Add(int.Parse(splits[i])); if (crooms.Count > 0) { if (LoginDoor != null) LoginDoor.Dispatcher.BeginInvoke((Action)(() => { LoginDoor.ReportRoom(crooms); })); do { int gr = LoginDoor.DecidedRoom; if (gr != 0 && crooms.Contains(gr)) { Base.VW.WHelper.SentByteLine(tcpStream, "C0QS," + gr); break; } Thread.Sleep(500); } while (true); } else { LoginDoor.ReportWatchFail(0); return false; } } else if (line.StartsWith("C1SQ,")) { room = ushort.Parse(line.Substring("C1SQ,".Length)); if (room != 0) { LoginDoor.Dispatcher.BeginInvoke((Action)(() => { AoDisplay a0d = new AoDisplay(server, room, uid, name, record, msglog); LoginDoor.Close(); a0d.Show(); })); return true; } else { LoginDoor.ReportWatchFail(1); client.Close(); return false; } } } }
public static XIVisi CreateInResumeHall(ushort newUid, ushort oldUid, string name, Base.VW.IVI vi, string server, int room, string passCode, bool record, bool msglog, AoDisplay ad) { return new XIVisi(newUid, oldUid, name, vi, server, room, passCode, record, msglog, ad); }
public static XIVisi CreateInDirectConnect(string server, int port, string name, int avatar, int hopeTeam, bool record, bool watcher, bool msglog, AoDisplay ad) { return new XIVisi(server, port, name, avatar, hopeTeam, record, watcher, msglog, ad); }
// Constructor 4#: Used for ResumeHall // passCode is the password for a settled room private XIVisi(ushort newUid, ushort oldUid, string name, Base.VW.IVI vi, string server, int room, string passCode, bool record, bool msglog, AoDisplay ad) { this.auid = newUid; this.name = name; this.VI = vi as VW.Cyvi; this.server = server; this.Room = room; this.port = Base.NetworkCode.HALL_PORT + room; this.ad = ad; VW.Bywi bywi = new VW.Bywi(server, port, name, avatar, hopeTeam = 0, newUid, this); Log = new ClLog(); Log.Start(auid, record, msglog, 0); bywi.Log = Log; VI.Log = Log; WI = bywi; CommonConstruct(); bywi.StartConnectResume(oldUid, passCode); // After that, Uid get updated. this.Uid = bywi.Uid; VI.Cout(Uid, "游戏继续啦~"); isReplay = false; }
// Constructor 2#: Used for Direct Connection private XIVisi(string server, int port, string name, int avatar, int hopeTeam, bool record, bool watcher, bool msglog, AoDisplay ad) { this.server = server; this.port = port; this.name = name; this.avatar = avatar; this.hopeTeam = hopeTeam; VI = new VW.Cyvi(ad); VI.Init(); VI.SetInGame(true); VW.Bywi bywi = new VW.Bywi(server, port, name, avatar, hopeTeam, 0, this); WI = bywi; this.ad = ad; Log = new ClLog(); Log.Start(Uid, record, msglog, 0); CommonConstruct(); if (!bywi.StartConnectDirect(watcher, VI)) { VI.Cout(Uid, "咦,您是不是掉线或者连错人了:-("); auid = 0; return; } VI.Cout(Uid, watcher ? "您开始旁观~" : "游戏开始咯~"); this.auid = bywi.Uid; if (watcher) Uid = bywi.Uid; bywi.Log = Log; VI.Log = Log; WI.Send("C2ST," + Uid, Uid, 0); isReplay = false; }