public void ShowGameOver(int key = 0) { if (IsShowGameOver) { return; } IsShowGameOver = true; GameOverObj.SetActive(true); if (pcvr.bIsHardWare) { MyCOMDevice.GetInstance().ForceRestartComPort(); } switch (key) { case 0: XKGlobalData.GetInstance().PlayAudioGameOver(); Invoke("HiddenGameOver", 3f); //MakeServerShowGameOver(); break; default: Invoke("DelayLoadingGameMovie", 5f); break; } }
void DelayForceRestartComPort() { if (pcvr.bIsHardWare && MyCOMDevice.GetInstance() != null) { MyCOMDevice.GetInstance().ForceRestartComPort(); } }
public static MyCOMDevice GetInstance() { if (_Instance == null) { GameObject obj = new GameObject("_MyCOMDevice"); DontDestroyOnLoad(obj); _Instance = obj.AddComponent <MyCOMDevice>(); } return(_Instance); }
public static pcvr GetInstance() { if (_Instance == null) { _Instance = new pcvr(); XKOpenCGCamera.GetInstance(); MyCOMDevice.GetInstance(); } return(_Instance); }
public static MyCOMDevice GetInstance() { if (_Instance == null) { GameObject obj = new GameObject("_MyCOMDevice"); DontDestroyOnLoad(obj); _Instance = obj.AddComponent <MyCOMDevice>(); // if (pcvr.IsTestHardWare) { // TestComPort.GetInstance(); // } } return(_Instance); }
static public pcvr GetInstance() { if (Instance == null) { GameObject obj = new GameObject("_PCVR"); DontDestroyOnLoad(obj); Instance = obj.AddComponent <pcvr>(); Instance.mPcvrTXManage = obj.AddComponent <pcvrTXManage>(); if (bIsHardWare) { MyCOMDevice.GetInstance(); } } return(Instance); }
static public pcvr GetInstance() { if (Instance == null) { GameObject obj = new GameObject("_PCVR"); DontDestroyOnLoad(obj); Instance = obj.AddComponent <pcvr>(); ScreenLog.init(); if (bIsHardWare) { MyCOMDevice.GetInstance(); } if (HardWareTest.IsTestHardWare) { TestComPort.GetInstance(); } //ScreenLog.Log("open hid***********************"); } return(Instance); }
// Use this for initialization void Start() { _Instance = this; StartCoroutine(OpenComThread()); }
bool createPCVR() { MyCOMDevice.GetInstance(); openPCVRFlag = 1; return(true); }
/*void ClickPlayerYouMenBtEvent(ButtonState val) * { * if (val == ButtonState.UP) { * return; * } * IsCloseYouMenTiShi = true; * }*/ void Update() { if (PlayerController.GetInstance().timmerstar < 5.0f) { //Debug.Log("11111111111111111111111111111111111111111111"); //gzkun void CloseAllQiNang() if (!SetPanel.IsOpenSetPanel) { pcvr.m_IsOpneForwardQinang = false; pcvr.m_IsOpneBehindQinang = false; pcvr.m_IsOpneLeftQinang = false; pcvr.m_IsOpneRightQinang = false; } UpdateBeginDaojishi(); } else { if (pcvr.mGetPower > 0f) { IsCloseYouMenTiShi = true; } if (m_BeginDaojishi.enabled) { m_BeginDaojishi.enabled = false; m_BeginDaojishiAudio.Stop(); } if (!IsCloseYouMenTiShi && !m_HasTishi) { m_YoumenTishi.enabled = true; UpdateYoumenTishi(); } else { m_HasTishi = true; m_YoumenTishi.enabled = false; m_YoumenTimmer = 0.0f; } if (m_pGameTime >= 0.0f && !m_Player.m_IsFinished) { UpdateJinduTiao(); UpdateGameTime(); } else { if (m_pGameTime <= 0.0f) { m_IsGameOver = true; TouBiInfoCtrl.IsCloseQiNang = true; } m_pScale.enabled = false; } if (m_Player.m_timmerFinished > 2.0f && !m_IsCongratulate) { if (m_Player.m_IsFinished) { m_Score = (int)(m_totalTime + chile * addChiLe - m_pGameTime); m_JiluRecord = ReadGameInfo.GetInstance().ReadGameRecord(); if (m_JiluRecord == 0 || m_Score < m_JiluRecord) { if (!m_NewRecordAudio.isPlaying) { m_NewRecordAudio.Play(); } m_CongratulateJiemian.SetActive(true); ReadGameInfo.GetInstance().WriteGameRecord(m_Score); } else { if (!m_FinishiAudio.isPlaying) { m_FinishiAudio.Play(); } m_FinishiJiemian.SetActive(true); } m_JiluObj.SetActive(true); UpdateMyScore(); UpdateRecord(); } else { if (!m_GameOverAudio.isPlaying) { m_GameOverAudio.Play(); } m_OverJiemian.SetActive(true); } m_IsCongratulate = true; m_JindutiaoObj.SetActive(false); m_daojishiObj.SetActive(false); m_biaodituObj.SetActive(false); } if (m_IsCongratulate) { m_CongratulateTimmer += Time.deltaTime; } if (m_CongratulateTimmer > 1.0f) { if (m_Player.m_IsFinished) { if (m_Score < m_JiluRecord || m_JiluRecord == 0) { if (!m_NewRecordHitAudio.isPlaying && !m_HasPlay) { m_HasPlay = true; m_NewRecordHitAudio.Play(); } m_CongratulateZitiObj.SetActive(true); } else { m_FinishiZitiObj.SetActive(true); } } else { m_OverZitiObj.SetActive(true); } } if (m_Player.m_IsFinished && m_CongratulateTimmer > 1.2f && !m_HasShake) { m_HasShake = true; m_CameraShake.setCameraShakeImpulseValue(); } if (m_CongratulateTimmer > 5.0f) { if (pcvr.bIsHardWare) { MyCOMDevice.GetInstance().ForceRestartComPort(); } XkGameCtrl.IsLoadingLevel = true; LoadMovieLevel(); } } }
/// <summary> /// 检测获取的IO信息是否错误. /// </summary> public bool CheckGetMsgInfoIsError(byte[] buffer) { if (!MyCOMDevice.GetInstance().IsFindDeviceDt) { return(true); } bool isErrorMsg = false; if (buffer[0] != ReadHead_1) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> readHead01_buffer_00 was wrong! head01 " + buffer[0].ToString("X2")); } if (buffer[1] != ReadHead_2) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> readHead02_buffer_01 was wrong! head02 " + buffer[1].ToString("X2")); } if (buffer[58] != EndRead_1) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> readEnd01_buffer_58 was wrong! end01 " + buffer[58].ToString("X2")); } if (buffer[59] != EndRead_2) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> readEnd02_buffer_59 was wrong! end02 " + buffer[59].ToString("X2")); } if (IsJiaoYanHid) { if (buffer[45] == 0xff || buffer[45] == 0x00 || (buffer[45] & 0x10) != 0x10) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> buffer_45 was wrong! val " + buffer[45].ToString("X2")); } } //校验位1 位号6~55的疑惑校验值、初始校验异或值为0x38,不包含53自身 byte jiaoYanVal = 0x38; for (int i = 6; i <= 51; i++) { if (i != 53) { jiaoYanVal ^= buffer[i]; } } if (jiaoYanVal != buffer[53]) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> jiaoYanVal01_buffer_53 was wrong! key " + buffer[53].ToString("X2")); } //数据校验位2 数据位5~49的异或值、初始异或值为0x95,不包23自身 jiaoYanVal = 0x95; for (int i = 5; i <= 49; i++) { if (i != 23) { jiaoYanVal ^= buffer[i]; } } if (jiaoYanVal != buffer[23]) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> jiaoYanVal02_buffer_23 was wrong! key " + buffer[23].ToString("X2")); } //全包校验 异或初值0x36、0~59都包含, 不包55自身 jiaoYanVal = 0x36; for (int i = 0; i <= 59; i++) { if (i != 55) { jiaoYanVal ^= buffer[i]; } } if (jiaoYanVal != buffer[55]) { isErrorMsg = true; Debug.LogWarning("CheckGetMsgInfo -> jiaoYanValQuanBao_buffer_55 was wrong! key " + buffer[55].ToString("X2")); } if (isErrorMsg) { string readInfo = ""; for (int i = 0; i < buffer.Length; i++) { readInfo += buffer[i].ToString("X2") + " "; } Debug.LogWarning("readMsg: " + readInfo); } return(isErrorMsg); }
/// <summary> /// 发送串口数据信息. /// </summary> void SendMessage() { if (!MyCOMDevice.GetInstance().IsFindDeviceDt) { return; } int writeCount = MyCOMDevice.ComThreadClass.WriteCountLock; if (WriteMsgCount == writeCount) { return; } WriteMsgCount = writeCount; int bufLenWrite = MyCOMDevice.ComThreadClass.BufLenWrite; byte[] buffer = new byte[bufLenWrite]; for (int i = 5; i < (bufLenWrite - 2); i++) { buffer[i] = (byte)Random.Range(0x00, 0xff); } buffer[0] = WriteHead_1; buffer[1] = WriteHead_2; //buffer[bufLenWrite - 2] = WriteEnd_1; //buffer[bufLenWrite - 1] = WriteEnd_2; buffer[bufLenWrite - 3] = WriteEnd_1; buffer[bufLenWrite - 2] = WriteEnd_2; //减币控制. if (!IsCleanHidCoinArray[0] && !IsCleanHidCoinArray[1] && !IsCleanHidCoinArray[2] && !IsCleanHidCoinArray[3]) { buffer[4] = 0x00; } else { if (IsCleanHidCoinArray[0] || IsCleanHidCoinArray[1]) { buffer[4] = 0x04; if (IsCleanHidCoinArray[0] && IsCleanHidCoinArray[1]) { buffer[2] = 0x11; } else if (IsCleanHidCoinArray[0]) { buffer[2] = 0x01; } else if (IsCleanHidCoinArray[1]) { buffer[2] = 0x10; } } if (IsCleanHidCoinArray[2] || IsCleanHidCoinArray[3]) { buffer[4] = 0x04; if (IsCleanHidCoinArray[2] && IsCleanHidCoinArray[3]) { buffer[3] = 0x11; } else if (IsCleanHidCoinArray[2]) { buffer[3] = 0x01; } else if (IsCleanHidCoinArray[3]) { buffer[3] = 0x10; } } } //加密芯片校验控制. if (IsJiaoYanHid) { //校验允许1 buffer[29] = 0x42; //校验允许2 buffer[31] = 0x12; //密码指示---由第3、5、8位确定 buffer[33] = mJiaMiPWDCmd[JiaMiPWDCmdIndex].Cmd; //密码1 buffer[34] = JiaoYanMiMa[mJiaMiPWDCmd[JiaMiPWDCmdIndex].Index01]; //密码2 buffer[38] = JiaoYanMiMa[mJiaMiPWDCmd[JiaMiPWDCmdIndex].Index02]; //密码3 buffer[45] = JiaoYanMiMa[mJiaMiPWDCmd[JiaMiPWDCmdIndex].Index03]; //加密运算标记(指示数据1、2、3)---位6、3、2 buffer[37] = mJiaMiDtCmd[JiaMiDtCmdIndex].Cmd; //加密校验数据1 buffer[40] = JiaoYanDt[mJiaMiDtCmd[JiaMiDtCmdIndex].Index01]; //加密校验数据2 buffer[41] = JiaoYanDt[mJiaMiDtCmd[JiaMiDtCmdIndex].Index02]; //加密校验数据3 buffer[35] = JiaoYanDt[mJiaMiDtCmd[JiaMiDtCmdIndex].Index03]; if (IsJiaoYanJiaMiCoreDt) { Debug.Log("buffer_29 " + buffer[29].ToString("X2") + ", buffer_31 " + buffer[31].ToString("X2")); Debug.Log("miMa:: buffer_33 " + buffer[33].ToString("X2") + ", buffer_34 " + buffer[34].ToString("X2") + ", buffer_38 " + buffer[38].ToString("X2") + ", buffer_45 " + buffer[45].ToString("X2") + ", JiaMiPWDCmdIndex " + JiaMiPWDCmdIndex); Debug.Log("dtVal:: buffer_37 " + buffer[37].ToString("X2") + ", buffer_40 " + buffer[40].ToString("X2") + ", buffer_41 " + buffer[41].ToString("X2") + ", buffer_35 " + buffer[35].ToString("X2") + ", JiaMiDtCmdIndex " + JiaMiDtCmdIndex); } } else { //不进行加密芯片校验. buffer[29] = 0x00; buffer[31] = 0x00; buffer[33] = 0x00; buffer[37] = 0x00; } //彩票打印控制. buffer[19] = (byte)CaiPiaoPrintCmdVal[(int)CaiPiaoJi.Num01]; buffer[20] = (byte)CaiPiaoPrintCmdVal[(int)CaiPiaoJi.Num02]; //灯1控制 LedData ledDt = new LedData(LedIndexEnum.Led01, buffer[13], buffer[12], 0x02, 0x04, 0x40, 0x08); SetLedInfo(out buffer[13], out buffer[12], ledDt); //灯2控制 ledDt = new LedData(LedIndexEnum.Led02, buffer[27], buffer[15], 0x04, 0x10, 0x40, 0x08); SetLedInfo(out buffer[27], out buffer[15], ledDt); //灯3控制 ledDt = new LedData(LedIndexEnum.Led03, buffer[14], buffer[16], 0x04, 0x10, 0x04, 0x10); SetLedInfo(out buffer[14], out buffer[16], ledDt); //灯4控制 ledDt = new LedData(LedIndexEnum.Led04, buffer[6], buffer[17], 0x04, 0x10, 0x04, 0x10); SetLedInfo(out buffer[6], out buffer[17], ledDt); //灯5控制 ledDt = new LedData(LedIndexEnum.Led05, buffer[11], buffer[7], 0x04, 0x40, 0x80, 0x04); SetLedInfo(out buffer[11], out buffer[7], ledDt); //灯6控制 ledDt = new LedData(LedIndexEnum.Led06, buffer[24], buffer[10], 0x02, 0x10, 0x04, 0x40); SetLedInfo(out buffer[24], out buffer[10], ledDt); //灯7控制 ledDt = new LedData(LedIndexEnum.Led07, buffer[30], buffer[8], 0x40, 0x10, 0x20, 0x10); SetLedInfo(out buffer[30], out buffer[8], ledDt); //灯8控制 ledDt = new LedData(LedIndexEnum.Led08, buffer[9], buffer[5], 0x02, 0x20, 0x20, 0x10); SetLedInfo(out buffer[9], out buffer[5], ledDt); //灯9控制 SetLedState(LedIndexEnum.Led09, buffer[21], out buffer[21]); //灯10控制 SetLedState(LedIndexEnum.Led10, buffer[21], out buffer[21]); //灯11控制 SetLedState(LedIndexEnum.Led11, buffer[21], out buffer[21]); //灯12控制 SetLedState(LedIndexEnum.Led12, buffer[21], out buffer[21]); //灯13控制 SetLedState(LedIndexEnum.Led13, buffer[21], out buffer[21]); //灯14控制 SetLedState(LedIndexEnum.Led14, buffer[21], out buffer[21]); //灯15控制 SetLedState(LedIndexEnum.Led15, buffer[21], out buffer[21]); //灯16控制 SetLedState(LedIndexEnum.Led16, buffer[21], out buffer[21]); //灯17控制 SetLedState(LedIndexEnum.Led17, buffer[22], out buffer[22]); //灯18控制 SetLedState(LedIndexEnum.Led18, buffer[22], out buffer[22]); //灯19控制 SetLedState(LedIndexEnum.Led19, buffer[22], out buffer[22]); //灯20控制 SetLedState(LedIndexEnum.Led20, buffer[22], out buffer[22]); //灯21控制 SetLedState(LedIndexEnum.Led21, buffer[22], out buffer[22]); //灯22控制 SetLedState(LedIndexEnum.Led22, buffer[22], out buffer[22]); //灯23控制 SetLedState(LedIndexEnum.Led23, buffer[22], out buffer[22]); //灯24控制 SetLedState(LedIndexEnum.Led24, buffer[22], out buffer[22]); //灯25控制 SetLedState(LedIndexEnum.Led25, buffer[26], out buffer[26]); //灯26控制 SetLedState(LedIndexEnum.Led26, buffer[26], out buffer[26]); //灯27控制 SetLedState(LedIndexEnum.Led27, buffer[26], out buffer[26]); //灯28控制 SetLedState(LedIndexEnum.Led28, buffer[26], out buffer[26]); //灯29控制 SetLedState(LedIndexEnum.Led29, buffer[26], out buffer[26]); //灯30控制 SetLedState(LedIndexEnum.Led30, buffer[26], out buffer[26]); //灯31控制 SetLedState(LedIndexEnum.Led31, buffer[26], out buffer[26]); //灯32控制 SetLedState(LedIndexEnum.Led32, buffer[26], out buffer[26]); //Led灯总控. SetLedZongKongInfo(out buffer[18], buffer[18]); //继电器控制. buffer[23] = GetJiDianQiCmd(); //数据校验位 26~44的异或校验、起始值为0x58(不包含自身) 第一步. buffer[32] = 0x58; for (int i = 26; i <= 44; i++) { if (i == 32) { continue; } buffer[32] ^= buffer[i]; } //校验位,2~45的异或校验、起始值为0x85(不包含自身) 第二步. buffer[25] = 0x85; for (int i = 2; i <= 45; i++) { if (i == 25) { continue; } buffer[25] ^= buffer[i]; } //数据校验 3~49的数据异或、异或初始值为0xba(不包含自身) 最后一步. buffer[46] = 0xba; for (int i = 3; i <= 49; i++) { if (i == 46) { continue; } buffer[46] ^= buffer[i]; } buffer[bufLenWrite - 1] = (byte)(TestSendDt % 256); //test TestSendDt++; //test MyCOMDevice.ComThreadClass.WriteByteMsg = buffer; }