Exemplo n.º 1
0
 public static UdpPB Instance()
 {
     // 如果类的实例不存在则创建,否则直接返回
     if (singleInstance == null)
     {
         singleInstance = new UdpPB();
     }
     return(singleInstance);
 }
Exemplo n.º 2
0
    void Start()
    {
        UdpPB.Instance().StartClientUdp();
        UdpPB.Instance().mes_battle_start     = Message_Battle_Start;
        UdpPB.Instance().mes_frame_operation  = Message_Frame_Operation;
        UdpPB.Instance().mes_delta_frame_data = Message_Delta_Frame_Data;
        UdpPB.Instance().mes_down_game_over   = Message_Down_Game_Over;

        isBattleStart = false;
        StartCoroutine("WaitInitData");
    }
Exemplo n.º 3
0
    public void Destory()
    {
        singleInstance = null;

        if (_upd != null)
        {
            _upd.EndClientUdp();
            _upd = null;
        }

        mes_frame_operation  = null;
        mes_delta_frame_data = null;
        mes_down_game_over   = null;
    }
Exemplo n.º 4
0
    public void AddNewFrameData(int _frameID, AllPlayerOperation _op)
    {
        dic_frameDate [_frameID] = _op;
        for (int i = maxFrameID + 1; i < _frameID; i++)
        {
            lackFrame.Add(i);
            Debug.Log("缺失 :" + i);
        }
        maxFrameID = _frameID;

        //发送缺失帧数据
        if (lackFrame.Count > 0)
        {
            if (lackFrame.Count > maxSendNum)
            {
                List <int> sendList = lackFrame.GetRange(0, maxSendNum);
                UdpPB.Instance().SendDeltaFrames(selfOperation.battleID, sendList);
            }
            else
            {
                UdpPB.Instance().SendDeltaFrames(selfOperation.battleID, lackFrame);
            }
        }
    }
Exemplo n.º 5
0
 void Send_BattleReady()
 {
     UdpPB.Instance().SendBattleReady(NetGlobal.Instance().userUid, BattleData.Instance.battleID);
 }
Exemplo n.º 6
0
 void OnDestroy()
 {
     BattleData.Instance.ClearData();
     UdpPB.Instance().Destory();
     instance = null;
 }
Exemplo n.º 7
0
 void SendGameOver()
 {
     UdpPB.Instance().SendGameOver(BattleData.Instance.battleID);
 }
Exemplo n.º 8
0
 void OnApplicationQuit()
 {
     MarsTcp.Instance.EndClient();
     UdpPB.Instance().Destory();
 }