Beispiel #1
0
    public void EnterQueue()
    {
        Debug.Log("Queue");
        int num = 0;

        for (byte i = 0; i < 3; i++)
        {
            proInfo    = new IOEvent();
            proInfo.ID = this.Read(num);
            byte state = this.Read(num + 1);
            proInfo.IsPush1     = this.IsBool(IOParser.GetBit(7, state));
            proInfo.IsPush2     = this.IsBool(IOParser.GetBit(6, state));
            proInfo.IsShake     = this.IsBool(IOParser.GetBit(5, state));
            proInfo.IsWarning   = this.IsBool(IOParser.GetBit(4, state));
            proInfo.IsOutTicket = this.IsBool(IOParser.GetBit(3, state));
            proInfo.IsCoin      = this.IsBool(IOParser.GetBit(2, state));
            proInfo.IsStart     = this.IsBool(IOParser.GetBit(1, state));
            proInfo.IsSet       = this.IsBool(IOParser.GetBit(0, state));
            proInfo.RockerBar   = new Vector3(this.Read(num + 2), this.Read(num + 3), 0);
            proInfo.ScreenPos   = IOParser.World2ScreenPos(proInfo.RockerBar, i);
            num += 4;
            if (quequeInfo[i].Count > 5)
            {
                this.quequeInfo[i].Dequeue();
            }
            this.quequeInfo[i].Enqueue(proInfo);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 根据得到的字节数进行解析
    /// </summary>
    /// <param name="bytes">上位机一次能接受到的所有的字节数</param>
    /// <param name="ioEvent">存储按键事件</param>
    public static void GetBools(byte[] bytes, IOEvent ioEvent)
    {
        //byte[0]为协议头
        byte k = bytes[1];
        byte q = bytes[2];

        ioEvent.IsGather    = (IOParser.GetBit(0, k) == 1);
        ioEvent.IsPullDown  = (IOParser.GetBit(1, k) == 1);
        ioEvent.IsPullUp    = (IOParser.GetBit(2, k) == 1);
        ioEvent.IsTurnRight = (IOParser.GetBit(3, k) == 1);
        ioEvent.IsTurnLeft  = (IOParser.GetBit(4, k) == 1);
        ioEvent.IsMissile   = (IOParser.GetBit(5, k) == 1);
        ioEvent.IsStart     = (IOParser.GetBit(6, k) == 1);
        ioEvent.IsCoin      = (IOParser.GetBit(7, k) == 1);

        ioEvent.IsConfirm  = (IOParser.GetBit(7, q) == 1);
        ioEvent.IsSelect   = (IOParser.GetBit(6, q) == 1);
        ioEvent.IsResetEye = (IOParser.GetBit(5, q) == 1);
        ioEvent.IsUpEye    = (IOParser.GetBit(4, q) == 1);
        ioEvent.IsDownEye  = (IOParser.GetBit(3, q) == 1);
        ioEvent.IsTicket   = (IOParser.GetBit(2, q) == 1);
    }
Beispiel #3
0
    public void ReadDatas()
    {
        byte h = serialiohost.Read(-1);

        byte k = serialiohost.Read(0);
        byte q = serialiohost.Read(1);

        ioevent[0].IsGather    = (IOParser.GetBit(0, k) == 1);
        ioevent[0].IsPullDown  = (IOParser.GetBit(1, k) == 1);
        ioevent[0].IsPullUp    = (IOParser.GetBit(2, k) == 1);
        ioevent[0].IsTurnRight = (IOParser.GetBit(3, k) == 1);
        ioevent[0].IsTurnLeft  = (IOParser.GetBit(4, k) == 1);
        ioevent[0].IsMissile   = (IOParser.GetBit(5, k) == 1);
        ioevent[0].IsStart     = (IOParser.GetBit(6, k) == 1);
        ioevent[0].IsCoin      = (IOParser.GetBit(7, k) == 1);

        ioevent[0].IsConfirm  = (IOParser.GetBit(7, q) == 1);
        ioevent[0].IsSelect   = (IOParser.GetBit(6, q) == 1);
        ioevent[0].IsResetEye = (IOParser.GetBit(5, q) == 1);
        ioevent[0].IsUpEye    = (IOParser.GetBit(4, q) == 1);
        ioevent[0].IsDownEye  = (IOParser.GetBit(3, q) == 1);
        ioevent[0].IsTicket   = (IOParser.GetBit(2, q) == 1);

        IOManager.Instance.NeedOutPutTicket = System.BitConverter.ToInt32(new byte[] { serialiohost.Read(4), serialiohost.Read(3), 0, 0 }, 0);

        serialiohost.ResetRead();

        if (h == 0xAA)
        {
            // 投币
            if (ioevent[0].IsCoin)
            {
                ioo.gameMode.Normal();
                SettingManager.Instance.AddCoin();
                SettingManager.Instance.Save();
                EventDispatcher.TriggerEvent(EventDefine.Event_Update_Coin);
            }

            if (ioevent[0].IsMissile)
            {
                if (ioo.gameMode.State == GameState.Coin)
                {
                    ioo.gameMode.Normal();
                }
                EventDispatcher.TriggerEvent(EventDefine.Event_Sure_Or_Missile);
            }

            //if (ioo.gameMode.State == GameState.Coin)
            //{
            //    // 开始游戏
            //    if (ioevent[0].IsStart)
            //    {
            //        ioo.gameMode.Normal();
            //        EventDispatcher.TriggerEvent(EventDefine.Event_Button_Sure);
            //    }
            //}

            // 射击
            if (ioo.gameMode.State == GameState.Play)
            {
                if (ioevent[0].IsStart)
                {
                    //EventDispatcher.TriggerEvent(EventDefine.Event_Player_Fire);
                    ioo.gameMode.Player.IsPress = true;
                    ioo.gameMode.CanFire        = true;
                }
                else
                {
                    ioo.gameMode.Player.IsPress = false;
                    ioo.gameMode.CanFire        = false;
                }

                if (ioevent[0].IsGather)
                {
                    EventDispatcher.TriggerEvent(EventDefine.Event_Player_Gather);
                }
            }

            //if (ioo.gameMode.State == GameState.Continue)
            //{
            //    if (ioevent[0].IsStart)
            //    {
            //        EventDispatcher.TriggerEvent(EventDefine.Event_Button_Sure);
            //    }
            //}

            //if (ioo.gameMode.State == GameState.Select)
            //{
            //    // 确认地图
            //    if (ioevent[0].IsStart)
            //    {
            //        EventDispatcher.TriggerEvent(EventDefine.Event_Button_Sure);
            //    }
            //}

            // 后台A
            if (ioevent[0].IsConfirm)
            {
                ioo.gameMode.Normal();
                EventDispatcher.TriggerEvent(EventDefine.Event_Button_A);
            }

            // 后台B
            if (ioevent[0].IsSelect)
            {
                ioo.gameMode.Normal();
                EventDispatcher.TriggerEvent(EventDefine.Event_Button_B);
            }

            IOManager.Instance.ResetEvent_0(0);
        }
    }