Ejemplo n.º 1
0
 // Hall mode - Watcher Mode
 public AoDisplay(string sv, int room, ushort uid,
     string name, bool record, bool msglog)
 {
     InitializeComponent();
     Init();
     mzi = null; mvisi = null;
     VW.Cyvi vi = new VW.Cyvi(this);
     visiThread = new Thread(delegate()
     {
         int port = Base.NetworkCode.HALL_PORT + room;
         vi.Init();
         mvisi = new XIVisi(uid, name, 0, vi, sv, room, record, msglog, true, this);
         mvisi.RunAsync();
     });
     visiThread.Start();
     yhTV = new OI.AoTV(this);
     tvDict = new Dictionary<string, OI.Television>();
 }
Ejemplo n.º 2
0
 // Hall mode - Gamer mode
 public AoDisplay(string sv, string nick, int ava,
     bool record, bool msglog, int mode, int level, string[] trainer, int team)
 {
     InitializeComponent();
     var ass = System.Reflection.Assembly.GetExecutingAssembly().GetName();
     ResetGameTitle(ass.Name + " v" + ass.Version);
     Init();
     mzi = null; mvisi = null;
     visiThread = new Thread(delegate()
     {
         int port = Base.NetworkCode.HALL_PORT;
         mzi = new ZI(nick, ava, sv, port, team, mode, level, trainer, record, msglog, this);
         mzi.StartHall();
     });
     visiThread.Start();
     yhTV = new OI.AoTV(this);
     tvDict = new Dictionary<string, OI.Television>();
 }
Ejemplo n.º 3
0
Archivo: ZI.cs Proyecto: palome06/psd48
        public void StartHall()
        {
            VW.Cyvi cyvi = new VW.Cyvi(AD);
            VI = cyvi; VI.Init(); VI.SetInGame(false);

            TcpClient client = null;
            try { client = new TcpClient(server, port); }
            catch (SocketException) { cyvi.ReportNoServer(server); return; }
            NetworkStream tcpStream = client.GetStream();
            string trainerjoin = (this.trainer != null && trainer.Length > 0) ? ("," + string.Join(",", trainer)) : "";
            int version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision;
            Base.VW.WHelper.SentByteLine(tcpStream, "C0CO," + name + "," + avatar + ","
                + teamCode + "," + selCode + "," + levelCode + "," + version + trainerjoin);
            Thread msgThread = new Thread(delegate()
            {
                try
                {
                    string readLine = VI.RequestTalk(uid);
                    while (readLine != null)
                    {
                        lock (tcpStream)
                            Base.VW.WHelper.SentByteLine(tcpStream, "C0TK," + uid + "," + readLine);
                        readLine = VI.RequestTalk(uid);
                    }
                }
                catch (System.IO.IOException) { }
            });
            bool done = false;
            while (!done)
            {
                string line = Base.VW.WHelper.ReadByteLine(tcpStream);
                if (line.StartsWith("C0XV,"))
                {
                    cyvi.ReportWrongVersion(line.Substring("C0XV,".Length));
                    return;
                }
                if (line.StartsWith("C0CN,"))
                {
                    uid = ushort.Parse(line.Substring("C1CO,".Length));
                    cyvi.SetNick(1, name, avatar);
                }
                else if (line.StartsWith("C1RM,"))
                {
                    string[] splits = line.Split(',');
                    room = int.Parse(splits[1]);
                    int pos = 2;
                    for (int i = 2; i < splits.Length; i += 3)
                    {
                        IchiPlayer ip = new IchiPlayer()
                        {
                            Uid = ushort.Parse(splits[i]),
                            Name = splits[i + 1],
                            Avatar = int.Parse(splits[i + 2])
                        };
                        roomMates.Add(ip);
                        if (ip.Uid != uid)
                            cyvi.SetNick(pos++, ip.Name, ip.Avatar);
                    }
                    cyvi.SetRoom(room);
                    msgThread.Start();
                }
                else if (line.StartsWith("C1NW,"))
                {
                    string[] splits = line.Split(',');
                    IchiPlayer ip = new IchiPlayer()
                    {
                        Uid = ushort.Parse(splits[1]),
                        Name = splits[2],
                        Avatar = int.Parse(splits[3])
                    };
                    roomMates.Add(ip);
                    if (ip.Uid != uid)
                        cyvi.SetNick(roomMates.Count, ip.Name, ip.Avatar);
                }
                else if (line.StartsWith("C1LV,"))
                {
                    ushort ut = ushort.Parse(line.Substring("C1LV,".Length));
                    for (int idx = 0; idx < roomMates.Count; ++idx)
                    {
                        IchiPlayer ip = roomMates[idx];
                        if (ip.Uid == ut)
                        {
                            roomMates.RemoveAt(idx);
                            break;
                        }
                    }
                    int pos = 2;
                    foreach (IchiPlayer ip in roomMates)
                    {
                        if (ip.Uid != uid)
                            cyvi.SetNick(pos++, ip.Name, ip.Avatar);
                    }
                    while (pos <= 6)
                        cyvi.SetNick(pos++, "", 0);
                }
                else if (line.StartsWith("C1SA,"))
                {
                    Base.VW.WHelper.SentByteLine(tcpStream, "C1ST," + uid);
                    VI.SetInGame(true);
                    XV = new XIVisi(uid, name, teamCode, VI, server,
                        room, record, msglog, false, AD);
                    XV.RunAsync();
                    //client.Close();
                    done = true;
                }
                else if (line.StartsWith("C1TK,"))
                {
                    int idx = line.IndexOf(',', "C1TK,".Length);
                    string nick = Algo.Substring(line, "C1TK,".Length, idx);
                    string content = Algo.Substring(line, idx + 1, -1);
                    VI.Chat(content, nick);
                }
            }
            if (msgThread != null && msgThread.IsAlive)
                msgThread.Abort();
        }
Ejemplo n.º 4
0
Archivo: ZI.cs Proyecto: palome06/psd48
        public void ResumeHall()
        {
            VW.Cyvi cyvi = new VW.Cyvi(AD);
            VI = cyvi; VI.Init(); VI.SetInGame(true);

            TcpClient client = new TcpClient(server, port);
            NetworkStream tcpStream = client.GetStream();
            Base.VW.WHelper.SentByteLine(tcpStream, "C4CO," + name + "," + room);

            bool done = false;
            while (!done)
            {
                string line = Base.VW.WHelper.ReadByteLine(tcpStream);
                if (line.StartsWith("C4RM,0"))
                {
                    done = true;
                    System.Windows.MessageBox.Show("重连被拒绝.");
                }
                else if (line.StartsWith("C4RM,")) // Reconnection case
                {
                    string[] parts = line.Split(',');
                    ushort centerUid = ushort.Parse(parts[1]); // AUid
                    ushort subUid = ushort.Parse(parts[2]); // Uid
                    int roomNumber = int.Parse(parts[3]);
                    string nick = parts[4];
                    string passcode = parts[5];
                    // start new connection...
                    VI.SetInGame(true);
                    cyvi.SetRoom(roomNumber);
                    XV = XIVisi.CreateInResumeHall(centerUid, subUid, name, VI,
                        server, roomNumber, passcode, record, msglog, AD);
                    XV.RunAsync();
                    done = true;
                }
            }
        }
Ejemplo n.º 5
0
 // Direct mode
 public AoDisplay(string sv, string nick, int ava, bool watch,
     bool record, bool msglog, int room, int team)
 {
     InitializeComponent();
     Init();
     mzi = null; mvisi = null;
     visiThread = new Thread(delegate()
     {
         int port = Base.NetworkCode.DIR_PORT + room;
         if (port >= 65535)
             port = Base.NetworkCode.DIR_PORT;
         mvisi = XIVisi.CreateInDirectConnect(sv, port, nick,
             ava, team, record, watch, msglog, this);
         mvisi.RunAsync();
     });
     visiThread.Start();
     yhTV = new OI.AoTV(this);
     tvDict = new Dictionary<string, OI.Television>();
 }
Ejemplo n.º 6
0
 // Reconnection mode
 public AoDisplay(string nick, string sv, int room, bool record, bool msglog)
 {
     InitializeComponent();
     var ass = System.Reflection.Assembly.GetExecutingAssembly().GetName();
     ResetGameTitle(ass.Name + " v" + ass.Version);
     Init();
     mzi = null; mvisi = null;
     visiThread = new Thread(delegate()
     {
         int port = Base.NetworkCode.HALL_PORT;
         mzi = ZI.CreateResumeHall(nick, sv, port, record, msglog, room, this);
         mzi.ResumeHall();
     });
     visiThread.Start();
     yhTV = new OI.AoTV(this);
     tvDict = new Dictionary<string, OI.Television>();
 }
Ejemplo n.º 7
0
 // Replay mode
 public AoDisplay(string fileName)
 {
     InitializeComponent();
     Init();
     mzi = null; mvisi = null;
     yfSpeeder.Visibility = Visibility.Visible;
     visiThread = new Thread(delegate()
     {
         mvisi = new XIVisi(fileName, this);
         mvisi.RunAsync();
     });
     visiThread.Start();
     yhTV = new OI.AoTV(this);
     tvDict = new Dictionary<string, OI.Television>();
 }
Ejemplo n.º 8
0
 public ZeroDisplay(XIVisi xiv)
 {
     this.xiv = xiv;
     this.tuple = xiv.Tuple;
 }