Exemple #1
0
    public void runServer2(object[] keyFrame, object[] mapData, int start, int end)
    {
        ServerRunTime server = new ServerRunTime();

        server.init();
        string clientId  = "";
        int    teamIndex = 0;
        List <List <Dictionary <string, object> > > steps = new List <List <Dictionary <string, object> > >();
        int mapDataIndex = 0;

        for (int i = 0, len = keyFrame.Length + 1; i < len; i++)
        {
            if (keyFrame.Length > i)
            {
                object[] keyDatas = (object[])keyFrame[i];
                List <Dictionary <string, object> > keyFrameList = new List <Dictionary <string, object> >();
                steps.Add(keyFrameList);
                for (int j = 0, len2 = keyDatas.Length; j < len2; j++)
                {
                    List <object> list = new List <object>((object[])keyDatas[j]);
                    Dictionary <string, object> data = (Dictionary <string, object>)list[1];
                    string uid = null == list[2] ? "" : list[2].ToString();
                    string key = list[0].ToString();
                    server.netWork.receiveClient(key, uid, data);
                    keyFrameList.Add(new Dictionary <string, object> {
                        { "type", key },
                        { "data", data },
                        { "uid", uid }
                    });
                    if (key == ConfigConstant.NET_C_CREATE_USER && clientId == "")
                    {
                        clientId  = uid;
                        teamIndex = (int)data["teamIndex"];
                    }
                }
            }

            //server.nextFrame();
            //server.getData();
            if (server.stepIndex >= start && server.stepIndex <= end && false)
            {
                Dictionary <string, object> frameData = mapData[mapDataIndex] as Dictionary <string, object>;
                try {
                    Dictionary <string, object> equalInfo = ViewUtils.equal(server.getData(), frameData, "");
                    if (equalInfo.Count > 0)
                    {
                        this.logDebug(ViewUtils.toString(equalInfo));
                        break;
                    }
                } catch (Exception e) {
                    Debug.Log("sdfsdfsfd");
                }

                mapDataIndex++;
            }
        }

        this.logDebug("比较完毕");
        FightMain.instance.autoRunClient.startFight(keyFrame, clientId, teamIndex, ConfigConstant.MODE_WATCH);
    }
Exemple #2
0
 public void clearFight()
 {
     ResFactory.clear();
     Utils.clearObject(this.server);
     Utils.clearObject(this._selection);
     ResFactory.enable = true;
     this._selection   = null;
     this.server       = null;
 }
Exemple #3
0
    public void startFight()
    {
        this.lobby.hide();
        this.cc     = 2;
        this.isPlay = true;
//		Stage.inst.gameObject.SetActive (false);
        if (!this.isWatch)
        {
            if (FightMain.isLocal)
            {
                this.server = new ServerRunTime();
                this.server.init();
                if (FightMain.fightTest)
                {
                    this.addUser("0", 0, 0);
                    //if(FightMain.instance.mode == ConfigConstant.MODE_CHAOS) {
                    //    for(int i = 1, len = 11; i < len; i++) {
                    //        this.addUser("-" + i, i, i);
                    //    }
                    //}
                }
                else
                {
                    this.addUser(PlayerData.instance.uid, 0, 0);
                }
            }
            else
            {
                if (this.isTestMode)
                {
                    NetAdapter.sendStartMatch2();
                }
                else
                {
                    NetAdapter.sendStartMatch();
                }
            }
        }
    }