Exemplo n.º 1
0
    void ini()
    {
        for (int i = 0; i < 4; i++)
        {
            roomPlayers[i] = null;
        }
        if (gameObject != null)
        {
            ES_quit();
        }
        MonoBehaviour.DestroyImmediate(gameObject);
        if (mode == 2)
        {
            createWindow(Program.I().remaster_tagRoom);
        }
        else
        {
            createWindow(Program.I().remaster_room);
        }
        lazyRoom = gameObject.GetComponent <lazyRoom>();
        fixScreenProblem();
        superScrollView = gameObject.GetComponentInChildren <UIselectableList>();
        superScrollView.selectedAction = onSelected;
        superScrollView.install();
        printFile();
        superScrollView.selectedString = Config.Get("deckInUse", "");
        superScrollView.toTop();
        if (mode == 0)
        {
            UIHelper.trySetLableText(gameObject, "Rname_", InterString.Get("单局房间"));
        }
        if (mode == 1)
        {
            UIHelper.trySetLableText(gameObject, "Rname_", InterString.Get("比赛房间"));
        }
        if (mode == 2)
        {
            UIHelper.trySetLableText(gameObject, "Rname_", InterString.Get("双打房间"));
        }

        UIHelper.trySetLableText(gameObject, "description_", "");
        for (int i = 0; i < 4; i++)
        {
            realPlayers[i] = UIHelper.getByName <lazyPlayer>(gameObject, i.ToString());
        }

        for (int i = 0; i < 4; i++)
        {
            realPlayers[i].ini();
            realPlayers[i].onKick           = OnKick;
            realPlayers[i].onPrepareChanged = onPrepareChanged;
        }

        UIHelper.shiftButton(startButton(), false);
        UIHelper.registUIEventTriggerForClick(startButton().gameObject, listenerForClicked);
        UIHelper.registUIEventTriggerForClick(exitButton().gameObject, listenerForClicked);
        UIHelper.registUIEventTriggerForClick(duelistButton().gameObject, listenerForClicked);
        UIHelper.registUIEventTriggerForClick(observerButton().gameObject, listenerForClicked);
        UIHelper.registUIEventTriggerForClick(readyButton().gameObject, listenerForClicked);
        realize();
        superScrollView.refreshForOneFrame();
    }
Exemplo n.º 2
0
 public void StocMessage_WaitingSide(BinaryReader r)
 {
     sideWaitingObserver = true;
     RMSshow_none(InterString.Get("请耐心等待双方玩家更换副卡组。"));
 }
Exemplo n.º 3
0
 void onNew()
 {
     RMSshow_input("onNew", InterString.Get("请输入要创建的卡组名"), UIHelper.getTimeString());
 }
Exemplo n.º 4
0
 public override void ES_RMS(string hashCode, List <messageSystemValue> result)
 {
     base.ES_RMS(hashCode, result);
     if (hashCode == "onRename")
     {
         try
         {
             if (opYRP)
             {
                 System.IO.File.Move("replay/" + superScrollView.selectedString, "replay/" + result[0].value + ".yrp");
             }
             else
             {
                 System.IO.File.Move("replay/" + superScrollView.selectedString + ".yrp3d", "replay/" + result[0].value + ".yrp3d");
             }
             printFile();
             RMSshow_none(InterString.Get("重命名成功。"));
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onDelete")
     {
         if (result[0].value == "yes")
         {
             try
             {
                 if (File.Exists("replay/" + superScrollView.selectedString + ".yrp3d"))
                 {
                     System.IO.File.Delete("replay/" + superScrollView.selectedString + ".yrp3d");
                     RMSshow_none(InterString.Get("[?]已经被删除。", superScrollView.selectedString));
                     printFile();
                 }
                 if (File.Exists("replay/" + superScrollView.selectedString))
                 {
                     System.IO.File.Delete("replay/" + superScrollView.selectedString);
                     RMSshow_none(InterString.Get("[?]已经被删除。", superScrollView.selectedString));
                     printFile();
                 }
             }
             catch (Exception)
             {
             }
         }
     }
     if (hashCode == "onValue")
     {
         if (result[0].value == "yes")
         {
             FileInfo[] fileInfos = (new DirectoryInfo("replay")).GetFiles();
             for (int i = 0; i < fileInfos.Length; i++)
             {
                 if (fileInfos[i].Name.Length == 21)
                 {
                     if (fileInfos[i].Name[2] == '-')
                     {
                         if (fileInfos[i].Name[5] == '「')
                         {
                             if (fileInfos[i].Name[8] == ':')
                             {
                                 try
                                 {
                                     File.Delete("replay/" + fileInfos[i].Name);
                                 }
                                 catch (Exception)
                                 {
                                 }
                             }
                         }
                     }
                 }
             }
             RMSshow_none(InterString.Get("清理完毕。"));
             printFile();
         }
     }
 }
Exemplo n.º 5
0
    void realize()
    {
        string description = "";

        if (mode == 0)
        {
            description += InterString.Get("单局模式");
        }
        if (mode == 1)
        {
            description += InterString.Get("比赛模式");
        }
        if (mode == 2)
        {
            description += InterString.Get("双打模式");
        }
        if (Program.I().ocgcore.MasterRule == 4)
        {
            description += InterString.Get("/新大师规则") + "\r\n";
        }
        else
        {
            description += InterString.Get("/大师规则[?]", Program.I().ocgcore.MasterRule.ToString()) + "\r\n";
        }
        description += InterString.Get("禁限卡表:[?]", YGOSharp.BanlistManager.GetName(lflist)) + "\r\n";
        if (rule == 0)
        {
            description += InterString.Get("(OCG卡池)") + "\r\n";
        }
        if (rule == 1)
        {
            description += InterString.Get("(TCG卡池)") + "\r\n";
        }
        if (rule == 2)
        {
            description += InterString.Get("(混合卡池)") + "\r\n";
        }
        if (no_check_deck)
        {
            description += InterString.Get("*不检查卡组") + "\r\n";
        }
        if (no_shuffle_deck)
        {
            description += InterString.Get("*不洗牌") + "\r\n";
        }
        description += InterString.Get("LP:[?]", start_lp.ToString()) + " ";
        description += InterString.Get("手牌:[?]", start_hand.ToString()) + " \r\n";
        description += InterString.Get("抽卡:[?]", draw_count.ToString()) + " ";
        description += InterString.Get("时间:[?]", time_limit.ToString()) + "\r\n";
        description += InterString.Get("观战者人数:[?]", countOfObserver.ToString());
        UIHelper.trySetLableText(gameObject, "description_", description);
        Program.I().ocgcore.name_0 = "---";
        Program.I().ocgcore.name_1 = "---";
        Program.I().ocgcore.name_0_tag = "---";
        Program.I().ocgcore.name_1_tag = "---";
        for (int i = 0; i < 4; i++)
        {
            realPlayers[i] = UIHelper.getByName <lazyPlayer>(gameObject, i.ToString());
            if (roomPlayers[i] == null)
            {
                realPlayers[i].SetNotNull(false);
            }
            else
            {
                realPlayers[i].SetNotNull(true);
                realPlayers[i].setName(roomPlayers[i].name);
                realPlayers[i].SetIFcanKick(is_host && (i != selftype));
                realPlayers[i].setIfMe(i == selftype);
                realPlayers[i].setIfprepared(roomPlayers[i].prep);
                if (mode != 2)
                {
                    if (i == 0)
                    {
                        Program.I().ocgcore.name_0 = roomPlayers[i].name;
                    }
                    if (i == 1)
                    {
                        Program.I().ocgcore.name_1 = roomPlayers[i].name;
                    }
                    Program.I().ocgcore.name_0_tag = "---";
                    Program.I().ocgcore.name_1_tag = "---";
                }
                else
                {
                    if (i == 0)
                    {
                        Program.I().ocgcore.name_0 = roomPlayers[i].name;
                    }
                    if (i == 1)
                    {
                        Program.I().ocgcore.name_0_tag = roomPlayers[i].name;
                    }
                    if (i == 2)
                    {
                        Program.I().ocgcore.name_1 = roomPlayers[i].name;
                    }
                    if (i == 3)
                    {
                        Program.I().ocgcore.name_1_tag = roomPlayers[i].name;
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
 public override void ES_RMS(string hashCode, List <messageSystemValue> result)
 {
     base.ES_RMS(hashCode, result);
     if (hashCode == "deckManager_returnAction")
     {
         if (result[0].value == "yes")
         {
             if (Program.I().deckManager.onSave())
             {
                 Program.I().shiftToServant(Program.I().selectDeck);
             }
         }
         if (result[0].value == "no")
         {
             Program.I().shiftToServant(Program.I().selectDeck);
         }
     }
     if (hashCode == "onNew")
     {
         try
         {
             File.Create("deck/" + result[0].value + ".ydk").Close();
             RMSshow_none(InterString.Get("「[?]」创建完毕。", result[0].value));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onDispose")
     {
         if (result[0].value == "yes")
         {
             try
             {
                 File.Delete("deck/" + superScrollView.selectedString + ".ydk");
                 RMSshow_none(InterString.Get("「[?]」删除完毕。", superScrollView.selectedString));
                 printFile();
             }
             catch (Exception)
             {
                 RMSshow_none(InterString.Get("非法删除!"));
             }
         }
     }
     if (hashCode == "onCopy")
     {
         try
         {
             File.Copy("deck/" + superScrollView.selectedString + ".ydk", "deck/" + result[0].value + ".ydk");
             RMSshow_none(InterString.Get("「[?]」复制完毕。", superScrollView.selectedString));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onRename")
     {
         try
         {
             File.Move("deck/" + superScrollView.selectedString + ".ydk", "deck/" + result[0].value + ".ydk");
             RMSshow_none(InterString.Get("「[?]」重命名完毕。", superScrollView.selectedString));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
 }
Exemplo n.º 7
0
 public override void ES_RMS(string hashCode, List <messageSystemValue> result)
 {
     base.ES_RMS(hashCode, result);
     if (hashCode == "deckManager_returnAction")
     {
         if (result[0].value == "yes")
         {
             if (Program.I().deckManager.onSave())
             {
                 Program.I().shiftToServant(Program.I().selectDeck);
             }
         }
         if (result[0].value == "no")
         {
             Program.I().shiftToServant(Program.I().selectDeck);
         }
     }
     if (hashCode == "onNew")
     {
         try
         {
             File.Create("Assets/essential/deck/" + result[0].value + ".ydk").Close();
             RMSshow_none(InterString.Get("「[?]」创建完毕。", result[0].value));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onDispose")
     {
         if (result[0].value == "yes")
         {
             try
             {
                 File.Delete("Assets/essential/deck/" + superScrollView.selectedString + ".ydk");
                 RMSshow_none(InterString.Get("「[?]」删除完毕。", superScrollView.selectedString));
                 printFile();
             }
             catch (Exception)
             {
                 RMSshow_none(InterString.Get("非法删除!"));
             }
         }
     }
     if (hashCode == "onCopy")
     {
         try
         {
             File.Copy("Assets/essential/deck/" + superScrollView.selectedString + ".ydk", "Assets/essential/deck/" + result[0].value + ".ydk");
             RMSshow_none(InterString.Get("「[?]」复制完毕。", superScrollView.selectedString));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onRename")
     {
         try
         {
             File.Move("Assets/essential/deck/" + superScrollView.selectedString + ".ydk", "Assets/essential/deck/" + result[0].value + ".ydk");
             RMSshow_none(InterString.Get("「[?]」重命名完毕。", superScrollView.selectedString));
             superScrollView.selectedString = result[0].value;
             printFile();
         }
         catch (Exception)
         {
             RMSshow_none(InterString.Get("非法输入!请检查输入的文件名。"));
         }
     }
     if (hashCode == "onCode")
     {
         if (result[0].value != "")
         {
             try
             {
                 YGOSharp.Deck deck;
                 if (!DeckManager.FromBase64toCodedDeck(result[0].value, out deck))
                 {
                     RMSshow_none(InterString.Get("卡组代码无效。"));
                     return;
                 }
                 string value = "#created by ygopro2\r\n#main\r\n";
                 for (int i = 0; i < deck.Main.Count; i++)
                 {
                     value += deck.Main[i].ToString() + "\r\n";
                 }
                 value += "#extra\r\n";
                 for (int i = 0; i < deck.Extra.Count; i++)
                 {
                     value += deck.Extra[i].ToString() + "\r\n";
                 }
                 value += "!side\r\n";
                 for (int i = 0; i < deck.Side.Count; i++)
                 {
                     value += deck.Side[i].ToString() + "\r\n";
                 }
                 System.IO.File.WriteAllText("Assets/essential/deck/" + superScrollView.selectedString + ".ydk", value, System.Text.Encoding.UTF8);
                 printSelected();
                 RMSshow_none(InterString.Get("卡组代码加载成功。"));
             }
             catch (Exception)
             {
                 RMSshow_none(InterString.Get("卡组代码加载失败。"));
             }
         }
     }
 }
Exemplo n.º 8
0
    public void StocMessage_ErrorMsg(BinaryReader r)
    {
        int msg  = r.ReadByte();
        int code = 0;

        switch (msg)
        {
        case 1:
            r.ReadByte();
            r.ReadByte();
            r.ReadByte();
            code = r.ReadInt32();
            switch (code)
            {
            case 0:
                RMSshow_onlyYes("", GameStringManager.get_unsafe(1403), null);
                break;

            case 1:
                RMSshow_onlyYes("", GameStringManager.get_unsafe(1404), null);
                break;

            case 2:
                RMSshow_onlyYes("", GameStringManager.get_unsafe(1405), null);
                break;
            }
            break;

        case 2:
            r.ReadByte();
            r.ReadByte();
            r.ReadByte();
            code = r.ReadInt32();
            int flag = code >> 28;
            code = code & 0xFFFFFFF;
            switch (flag)
            {
            case 1:         // DECKERROR_LFLIST
                RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(数量不符合禁限卡表)"), null);
                break;

            case 2:         // DECKERROR_OCGONLY
                RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(OCG独有卡,不能在当前设置使用)"), null);
                break;

            case 3:         // DECKERROR_TCGONLY
                RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(TCG独有卡,不能在当前设置使用)"), null);
                break;

            case 4:         // DECKERROR_UNKNOWNCARD
                if (code < 100000000)
                {
                    RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(服务器无法识别此卡,可能是服务器未更新)"), null);
                }
                else
                {
                    RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(服务器无法识别此卡,可能是服务器不支持先行卡或此先行卡已正式更新)"), null);
                }
                break;

            case 5:         // DECKERROR_CARDCOUNT
                RMSshow_onlyYes("", InterString.Get("卡组非法,请检查:[?]", YGOSharp.CardsManager.Get(code).Name) + "\r\n" + InterString.Get("(数量过多)"), null);
                break;

            case 6:         // DECKERROR_MAINCOUNT
                RMSshow_onlyYes("", InterString.Get("主卡组数量应为40-60张"), null);
                break;

            case 7:         // DECKERROR_EXTRACOUNT
                RMSshow_onlyYes("", InterString.Get("额外卡组数量应为0-15张"), null);
                break;

            case 8:         // DECKERROR_SIDECOUNT
                RMSshow_onlyYes("", InterString.Get("副卡组数量应为0-15"), null);
                break;

            default:
                RMSshow_onlyYes("", GameStringManager.get_unsafe(1406), null);
                break;
            }
            break;

        case 3:
            RMSshow_onlyYes("", InterString.Get("更换副卡组失败,请检查卡片张数是否一致。"), null);
            break;

        case 4:
            r.ReadByte();
            r.ReadByte();
            r.ReadByte();
            code = r.ReadInt32();
            //string hexOutput = "0x"+String.Format("{0:X}", code);
            //Program.I().selectServer.set_version(hexOutput);
            //RMSshow_none(InterString.Get("你输入的版本号和服务器不一致,[7CFC00]YGOPro2已经智能切换版本号[-],请重新连接。"));
            break;

        default:
            break;
        }
    }
Exemplo n.º 9
0
 public override void preFrameFunction()
 {
     base.preFrameFunction();
     Menu.checkCommend();
     if (Program.noAccess && !msgPermissionShowed)
     {
         msgPermissionShowed = true;
         Program.PrintToChat(InterString.Get("[b][FF0000]NO ACCESS!! NO ACCESS!! NO ACCESS!![-][/b]") + "\n" + InterString.Get("访问程序目录出错,软件大部分功能将无法使用。@n请将 YGOPro2 安装到其他文件夹,或以管理员身份运行。"));
     }
     else if (upurl != "" && !msgUpdateShowed)
     {
         msgUpdateShowed = true;
         RMSshow_yesOrNo("update", InterString.Get("[b]发现更新![/b]") + "\n" + uptxt + "\n" + InterString.Get("是否打开下载页面?"),
                         new messageSystemValue {
             value = "1", hint = "yes"
         }, new messageSystemValue {
             value = "0", hint = "no"
         });
     }
 }
Exemplo n.º 10
0
 public static void gugugu()
 {
     PrintToChat(InterString.Get("非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。"));
 }
Exemplo n.º 11
0
 public PrecyOcg()
 {
     error        = InterString.Get("Error occurred! @nError occurred! @nError occurred! @nError occurred! @nError occurred! @nError occurred! @nYGOPro1旧版的录像崩溃了!您可以选择使用永不崩溃的新版录像。");
     ygopro       = new Percy.smallYgopro(receiveHandler, cardHandler, chatHandler);
     ygopro.m_log = (a) => { Program.DEBUGLOG(a); };
 }
Exemplo n.º 12
0
    public static void preFrameFunction()
    {
        if (datas.Count > 0)
        {
            if (Monitor.TryEnter(datas))
            {
                for (int i = 0; i < datas.Count; i++)
                {
                    try
                    {
                        MemoryStream memoryStream = new MemoryStream(datas[i]);
                        BinaryReader r            = new BinaryReader(memoryStream);
                        var          ms           = (StocMessage)(r.ReadByte());
                        switch (ms)
                        {
                        case StocMessage.GameMsg:
                            Program.I().room.StocMessage_GameMsg(r);
                            break;

                        case StocMessage.ErrorMsg:
                            Program.I().room.StocMessage_ErrorMsg(r);
                            break;

                        case StocMessage.SelectHand:
                            Program.I().room.StocMessage_SelectHand(r);
                            break;

                        case StocMessage.SelectTp:
                            Program.I().room.StocMessage_SelectTp(r);
                            break;

                        case StocMessage.HandResult:
                            Program.I().room.StocMessage_HandResult(r);
                            break;

                        case StocMessage.TpResult:
                            Program.I().room.StocMessage_TpResult(r);
                            break;

                        case StocMessage.ChangeSide:
                            Program.I().room.StocMessage_ChangeSide(r);
                            TcpHelper.SaveRecord();
                            break;

                        case StocMessage.WaitingSide:
                            Program.I().room.StocMessage_WaitingSide(r);
                            TcpHelper.SaveRecord();
                            break;

                        case StocMessage.CreateGame:
                            Program.I().room.StocMessage_CreateGame(r);
                            break;

                        case StocMessage.JoinGame:
                            Program.I().room.StocMessage_JoinGame(r);
                            break;

                        case StocMessage.TypeChange:
                            Program.I().room.StocMessage_TypeChange(r);
                            break;

                        case StocMessage.LeaveGame:
                            Program.I().room.StocMessage_LeaveGame(r);
                            break;

                        case StocMessage.DuelStart:
                            Program.I().room.StocMessage_DuelStart(r);
                            break;

                        case StocMessage.DuelEnd:
                            Program.I().room.StocMessage_DuelEnd(r);
                            TcpHelper.SaveRecord();
                            break;

                        case StocMessage.Replay:
                            Program.I().room.StocMessage_Replay(r);
                            TcpHelper.SaveRecord();
                            break;

                        case StocMessage.TimeLimit:
                            Program.I().ocgcore.StocMessage_TimeLimit(r);
                            break;

                        case StocMessage.Chat:
                            Program.I().room.StocMessage_Chat(r);
                            break;

                        case StocMessage.HsPlayerEnter:
                            Program.I().room.StocMessage_HsPlayerEnter(r);
                            break;

                        case StocMessage.HsPlayerChange:
                            Program.I().room.StocMessage_HsPlayerChange(r);
                            break;

                        case StocMessage.HsWatchChange:
                            Program.I().room.StocMessage_HsWatchChange(r);
                            break;

                        case YGOSharp.Network.Enums.StocMessage.RoomList:
                            ((Room)Program.I().room).StocMessage_RoomList(r);
                            break;

                        default:
                            break;
                        }
                    }
                    catch (System.Exception e)
                    {
                        // Program.DEBUGLOG(e);
                    }
                }
                datas.Clear();
                Monitor.Exit(datas);
            }
        }
        if (onDisConnected == true)
        {
            onDisConnected = false;
            Program.I().ocgcore.returnServant = Program.I().selectServer;
            if (TcpHelper.tcpClient != null)
            {
                if (TcpHelper.tcpClient.Connected)
                {
                    tcpClient.Client.Shutdown(0);
                    tcpClient.Close();
                }
            }

            tcpClient = null;
            if (Program.I().ocgcore.isShowed == false)
            {
                if (Program.I().menu.isShowed == false)
                {
                    Program.I().shiftToServant(Program.I().selectServer);
                }
                if (!roomListChecking)
                {
                    Program.I().cardDescription.RMSshow_none(InterString.Get("连接被断开。"));
                }
            }
            else
            {
                Program.I().cardDescription.RMSshow_none(InterString.Get("对方离开游戏,您现在可以截图。"));
                Program.I().ocgcore.forceMSquit();
            }
        }
    }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     s = InterString.Get("等待对方行动中");
 }