public static CtrlForHardWare GetInstance()
 {
     if (Instance == null)
     {
         GameObject obj = new GameObject("_CtrlForHardWare");
         DontDestroyOnLoad(obj);
         Instance = obj.AddComponent <CtrlForHardWare>();
     }
     return(Instance);
 }
Exemplo n.º 2
0
    void Start()
    {
        int volumNum = Convert.ToInt32(ReadGameInfo.GetInstance().ReadVolumeNum());

        AudioListener.volume = volumNum * 0.1f;

        UpdateInsertCoin();

        CHEN = ReadGameInfo.GetInstance().ReadCHEN();
        if (CHEN == "EN")
        {
            chenNum = 5;
            if (Application.loadedLevel == 0)
            {
                Application.LoadLevel(0 + chenNum);
            }
        }
        else
        {
            chenNum = 0;
        }

        if (pcvr.bIsHardWare)
        {
            Screen.showCursor = false;
            Screen.SetResolution(1360, 768, true);
            PlayerController.inGame = false;
            pcvr.bZhendong          = false;
            pcvr.dianboState        = 0;
            //MyCOMDevice.ComThreadClass.IsLoadingLevel = false;
            Invoke("SetLoade", 0.1f);

            if (pcvr.GetInstance())
            {
                pcvr.GetInstance().gunShakeOpen = false;
            }
        }

        //Screen.showCursor = false;
        pcvr.GetInstance();
        CtrlForHardWare.GetInstance();
        Debug.Log("pcvr.CoinCurGame" + ReadGameInfo.GetInstance().ReadInsertCoinNum());
        m_MovieTex.loop = true;
        m_MovieTex.Play();

        if (m_Donghua)
        {
            m_Donghua.loop = true;
            m_Donghua.Play();
        }

        if (pcvr.bIsAutoMoveSelf)
        {
            autoTime = 6.0f;
        }
        else
        {
            GameMode = ReadGameInfo.GetInstance().ReadGameStarMode();
        }

        if (GameMode == "oper")
        {
            m_pMianfeiobject.SetActive(false);
            m_pToubiobject.SetActive(true);
            CoinNumSet = ReadGameInfo.GetInstance().ReadStarCoinNumSet();
            CoinNumSetTex.spriteName = CoinNumSet;
        }
        else
        {
            m_pMianfeiobject.SetActive(true);
            m_pToubiobject.SetActive(false);
        }

        ANQUANDAI = ReadGameInfo.GetInstance().ReadAnquandai();

        if (ANQUANDAI == "close" || pcvr.bIsAutoMoveSelf)
        {
            pcvr.openAanquandai = false;
            pcvr.GetInstance().p1AnquandaiOpen = true;
            pcvr.GetInstance().p2AnquandaiOpen = true;
        }
        else
        {
            pcvr.openAanquandai = true;
        }

        Instance = this;
    }
    public void keyProcess(uint [] bufferKey)
    {
        if (!MyCOMDevice.IsFindDeviceDt)
        {
            return;
        }

        if (bufferKey[0] != ReadHead_1 || bufferKey[1] != ReadHead_2)
        {
            return;
        }

        if (openPCVRFlag != 1)
        {
            return;
        }

        //41 - 42 - 19 - 20 gun - post
        gunX = (int)(((bufferKey[2] & 0x0f) << 8) + bufferKey[3]);           //gun x - high and low
        gunY = (int)(((bufferKey[4] & 0x0f) << 8) + bufferKey[5]);           //gun y - high and low

        gunXT = gunX;
        gunYT = gunY;

        if (gunXT > posXMax && gunXT > posXMin)
        {
            if (posXMax > posXMin)
            {
                gunXT = posXMax;
            }
            else
            {
                gunXT = posXMin;
            }
        }
        else if (gunXT < posXMax && gunXT < posXMin)
        {
            if (posXMax > posXMin)
            {
                gunXT = posXMin;
            }
            else
            {
                gunXT = posXMax;
            }
        }

        if (posXMin == posXMax)
        {
            posXMax = posXMin + 1;
        }

        if (posYMin == posYMax)
        {
            posYMax = posYMin + 1;
        }

        if (gunYT > posYMax && gunYT > posYMin)
        {
            if (posYMax > posYMin)
            {
                gunYT = posYMax;
            }
            else
            {
                gunYT = posYMin;
            }
        }
        else if (gunYT < posYMax && gunYT < posYMin)
        {
            if (posYMax > posYMin)
            {
                gunYT = posYMin;
            }
            else
            {
                gunYT = posYMax;
            }
        }

        if (CtrlForHardWare.GetInstance() != null)
        {
            CtrlForHardWare.GetInstance().OnMoveShootCursor((float)Mathf.Abs(gunXT - posXMin) / Mathf.Abs(posXMax - posXMin), (float)Mathf.Abs(gunYT - posYMin) / Mathf.Abs(posYMax - posYMin));
        }

        CoinCurPcvr = bufferKey[6];
        if (IsSubPlayerCoin)
        {
            IsSubPlayerCoin = false;
        }
        else
        {
            if (CoinCurPcvr > 0)
            {
                mOldCoinNum += CoinCurPcvr;
                CoinCurGame  = (int)mOldCoinNum;

                SubPcvrCoin((int)CoinCurPcvr);

                if (CtrlForHardWare.GetInstance() != null)
                {
                    CtrlForHardWare.GetInstance().OnClickInsertBt();
                }
            }
        }

        //3 - setPanel selectBt
        if (!bSetEnterKeyDown && (bufferKey[9] & 0x02) == 0x02)
        {
            bSetEnterKeyDown = true;
        }
        else if (bSetEnterKeyDown && (bufferKey[9] & 0x02) == 0x00)
        {
            bSetEnterKeyDown = false;

            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickSetBt();
            }
        }

        //4 - setPanel moveBt
        if (!bSetMoveKeyDown && (bufferKey[9] & 0x04) == 0x04)
        {
            bSetMoveKeyDown = true;
        }
        else if (bSetMoveKeyDown && (bufferKey[9] & 0x04) == 0x00)
        {
            bSetMoveKeyDown = false;
            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickMoveBt();
            }
        }

        //8-7 - huizhong chuanganqi
        if (!huizhongCGQ && (bufferKey[8] & 0x80) == 0x80)
        {
            huizhongCGQ = true;
        }
        else if (huizhongCGQ && (bufferKey[8] & 0x80) == 0x00)
        {
            huizhongCGQ = false;

            //add infor here -- lxy

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }

        //8 - stop urgent
        if (!stopUrgentY && (bufferKey[9] & 0x01) == 0x01)
        {
            stopUrgentY = true;

            if (!stopUrgent && (!p1AnquandaiOpen || (PlayerController.IsKaiqiang && !p2AnquandaiOpen)))
            {
                Debug.Log("stop urgent do nothing!");
            }
            else
            {
                stopUrgent = !stopUrgent;

                if (stopUrgent && UIController.GetInstance() != null)
                {
                    UIController.GetInstance().CloseDonggan();
                    UIController.GetInstance().openLeAnquandaiP1(false);
                    UIController.GetInstance().openLeAnquandaiP2(false);
                }
                else if (!stopUrgent && UIController.GetInstance() != null)
                {
                    if (!p1AnquandaiOpen)
                    {
                        UIController.GetInstance().closeLeAnquandaiP1();
                    }

                    if (PlayerController.IsKaiqiang && !p2AnquandaiOpen)
                    {
                        UIController.GetInstance().closeLeAnquandaiP2();
                    }
                }

                if (!stopUrgent && UIController.GetInstance() != null)
                {
                    UIController.GetInstance().OpenDonggan();
                }
            }
        }
        else if (stopUrgentY && (bufferKey[9] & 0x01) == 0x00)
        {
            stopUrgentY = false;

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }
        //ffffffffffffffffff lxy change
        if (!p1AnquandaiPress && (bufferKey[8] & 0x01) == 0x01)
        {
            p1AnquandaiPress = true;
            p1AnquandaiOpen  = true;

            if (Loading.GetInstance())
            {
                Loading.GetInstance().openLeAnquandaiP1();
            }

            if (!stopUrgent && UIController.GetInstance())
            {
                if (!PlayerController.IsKaiqiang || (PlayerController.IsKaiqiang && p2AnquandaiOpen))
                {
                    UIController.GetInstance().openLeAnquandaiP1(true);
                }
                else
                {
                    UIController.GetInstance().openLeAnquandaiP1(false);
                }
            }
        }
        else if (p1AnquandaiPress && (bufferKey[8] & 0x01) == 0x00)
        {
            p1AnquandaiPress = false;
            p1AnquandaiOpen  = false;

            if (!openAanquandai)
            {
                p1AnquandaiOpen = true;
            }

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }

        if (!stopUrgent && !p1AnquandaiOpen && UIController.GetInstance())
        {
            UIController.GetInstance().closeLeAnquandaiP1();
        }
        //fffffffffffffffffffffff lxy change
        if (!p2AnquandaiPress && (bufferKey[8] & 0x02) == 0x02)
        {
            p2AnquandaiPress = true;
            p2AnquandaiOpen  = true;

            if (Loading.GetInstance())
            {
                Loading.GetInstance().openLeAnquandaiP2();
            }

            if (!stopUrgent && UIController.GetInstance())
            {
                if (p1AnquandaiOpen)
                {
                    UIController.GetInstance().openLeAnquandaiP2(true);
                }
                else
                {
                    UIController.GetInstance().openLeAnquandaiP2(false);
                }
            }
        }
        else if (p2AnquandaiPress && (bufferKey[8] & 0x02) == 0x00)
        {
            p2AnquandaiPress = false;
            p2AnquandaiOpen  = false;

            if (!openAanquandai)
            {
                p2AnquandaiOpen = true;
            }

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }

        if (!stopUrgent && !p2AnquandaiOpen && UIController.GetInstance() && PlayerController.IsKaiqiang)
        {
            UIController.GetInstance().closeLeAnquandaiP2();
        }

        //30 - check congJi move state ?????????????? lxy ---- bian pin qi tingzhi biaoji
        if ((bufferKey[9] & 0x08) == 0x08)
        {
            //moving
        }
        else if ((bufferKey[9] & 0x08) == 0x00)
        {
            //stop moving
        }

        //37 - turn left
        if (!turnLeftPressDown && (bufferKey[8] & 0x04) == 0x00)
        {
            turnLeftPressDown = true;
            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickMoveLeft();
            }
        }
        else if (turnLeftPressDown && (bufferKey[8] & 0x04) == 0x00)
        {
            if ((Application.loadedLevel - chenNum == 2 || Application.loadedLevel - chenNum == 4) && !bZhendong)
            {
                qinangStateRight = 11;
            }
        }
        else if (turnLeftPressDown && (bufferKey[8] & 0x04) == 0x04)
        {
            turnLeftPressDown = false;
            qinangStateRight  = 12;
        }

        //38 - turn right
        if (!turnRightPressDown && (bufferKey[8] & 0x08) == 0x00)
        {
            turnRightPressDown = true;
            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickMoveRight();
            }

            if ((Application.loadedLevel - chenNum == 2 || Application.loadedLevel - chenNum == 4) && !bZhendong)
            {
                qinangStateLeft = 11;
            }
        }
        else if (turnRightPressDown && (bufferKey[8] & 0x08) == 0x00)
        {
            if ((Application.loadedLevel - chenNum == 2 || Application.loadedLevel - chenNum == 4) && !bZhendong)
            {
                qinangStateLeft = 11;
            }
        }
        else if (turnRightPressDown && (bufferKey[8] & 0x08) == 0x08)
        {
            turnRightPressDown = false;
            qinangStateLeft    = 12;
        }

        //shache
        if (turnLeftPressDown && turnRightPressDown)
        {
            //shache here
            m_IsShache = true;
            if (ZhujuemaController.GetInstance() != null && PlayerController.GetInstance() != null)
            {
                ZhujuemaController.GetInstance().OnClickShacheBt();
                PlayerController.GetInstance().OnClickShacheBt();
            }
            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickShacheBt();
            }
        }
        else
        {
            m_IsShache = false;
        }

        if (!bPlayerStartKeyDownP1 && (bufferKey[8] & 0x10) == 0x10)
        {
            bPlayerStartKeyDownP1 = true;
        }
        else if (bPlayerStartKeyDownP1 && (bufferKey[8] & 0x10) == 0x00)
        {
            bPlayerStartKeyDownP1 = false;
            if (CtrlForHardWare.GetInstance() != null)
            {
                CtrlForHardWare.GetInstance().OnClickBeginBt1P();
            }
        }

        //40 - shooting
        if ((bufferKey[8] & 0x20) == 0x20)
        {
            if (PlayerShoot.GetInstance() != null)
            {
                PlayerShoot.GetInstance().OnClickFire();
            }
            if (SetPanel.GetInstance() != null && !bPlayerOnRocket)
            {
                bPlayerOnRocket = true;
                SetPanel.GetInstance().OnClickFireBt();
            }

            //2p start button chang ffffffffffffffffffffffffffffffffffffff lxy
            if (!bPlayerStartKeyDownP2)
            {
                bPlayerStartKeyDownP2 = true;
            }
        }
        else if ((bufferKey[8] & 0x20) == 0x00)
        {
            if (PlayerShoot.GetInstance() != null)
            {
                PlayerShoot.GetInstance().m_IsFire = false;
            }
            if (SetPanel.GetInstance() != null)
            {
                bPlayerOnRocket = false;
            }

            //2p start button chang ffffffffffffffffffffffffffffffffffffff lxy
            if (bPlayerStartKeyDownP2)
            {
                bPlayerStartKeyDownP2 = false;
                if (CtrlForHardWare.GetInstance() != null)
                {
                    CtrlForHardWare.GetInstance().OnClickBeginBt2P();
                }
            }
        }

        //9-6 - chuan gan
        if ((bufferKey[9] & 0x40) == 0x40)
        {
            //speed
            jiasuChuanganqi = true;
        }
        else
        {
            jiasuChuanganqi = false;
        }

        //9-4 - 2pshooting
        if (!bPlayerOnShootP2 && (bufferKey[9] & 0x10) == 0x10)
        {
            bPlayerOnShootP2 = true;
        }
        else if (bPlayerOnShootP2 && (bufferKey[9] & 0x10) == 0x00)
        {
            bPlayerOnShootP2 = false;

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }

        //9-5 - 2p daodan
        if (!bPlayerOnRocketP2 && (bufferKey[9] & 0x20) == 0x20)
        {
            bPlayerOnRocketP2 = true;
        }
        else if (bPlayerOnRocketP2 && (bufferKey[9] & 0x20) == 0x00)
        {
            bPlayerOnRocketP2 = false;

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }

        //8-6 - 1p daodan
        if (!bPlayerOnRocketP1 && (bufferKey[8] & 0x40) == 0x40)
        {
            bPlayerOnRocketP1 = true;
        }
        else if (bPlayerOnRocketP1 && (bufferKey[8] & 0x40) == 0x00)
        {
            bPlayerOnRocketP1 = false;

            if (SetPanel.GetInstance())
            {
                SetPanel.GetInstance().OnClickOtherButtonInPanel();
            }
        }
    }