public static UdpPB Instance() { // 如果类的实例不存在则创建,否则直接返回 if (singleInstance == null) { singleInstance = new UdpPB(); } return(singleInstance); }
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"); }
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; }
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); } } }
void Send_BattleReady() { UdpPB.Instance().SendBattleReady(NetGlobal.Instance().userUid, BattleData.Instance.battleID); }
void OnDestroy() { BattleData.Instance.ClearData(); UdpPB.Instance().Destory(); instance = null; }
void SendGameOver() { UdpPB.Instance().SendGameOver(BattleData.Instance.battleID); }
void OnApplicationQuit() { MarsTcp.Instance.EndClient(); UdpPB.Instance().Destory(); }