Beispiel #1
0
    public void SendLocalOpt(FrameOpt opt)
    {
        ByteBuffer byteBuffer = new ByteBuffer();

        byteBuffer.AddInt(1);
        string jsonStr = JsonConvert.SerializeObject(opt);

        byteBuffer.AddString(jsonStr);

        GameMain.GetInstance().netManager.Send(byteBuffer);
    }
Beispiel #2
0
    public void MainTick(object sender, ElapsedEventArgs e)
    {
        LogicFrame frame = new LogicFrame(FrameIdx++);

        foreach (var kv in plyLastFrameInfo)
        {
            if (FrameIdx - kv.Value > 50)
            {
                //掉线
                isDiaoxian = true;
            }
            else
            {
                isDiaoxian = false;
            }
        }

        foreach (var kv in NowOpts)
        {
            if (kv.Value.Count == 0)
            {
                FrameOpt emptyOpt = new FrameOpt();
                emptyOpt.actorId    = kv.Key;
                emptyOpt.optType    = eOptType.MVOE;
                emptyOpt.optContent = "0,0";
                frame.frameOpts.Add(emptyOpt);

                if (isDiaoxian)
                {
                    //伪造回家包
                }
            }
            else
            {
                frame.frameOpts.Add(kv.Value[0]);
            }
            kv.Value.Clear();
        }

        FrameList.AddLast(new LinkedListNode <LogicFrame>(frame));
        frame.dtime = (int)TickInteval;

        //LinkedListNode<LogicFrame> node = FrameList.Last;
        //Debug.Log("svr frame:" + frame.frameIdx);

        string     ret        = JsonConvert.SerializeObject(frame);
        ByteBuffer byteBuffer = new ByteBuffer();

        byteBuffer.AddInt((int)eNetMsgType.FRAME);
        byteBuffer.AddString(ret);
        FakeSendMsg(byteBuffer);
    }