예제 #1
0
    private void createLevel()
    {
        Random random = new Random();

        foreach (var player in _playerDeviceIdList)
        {
            for (int i = 0; i <= maxSteps; i++)
            {
                List <int> rands = new List <int>();
                for (int j = 1; j <= 4; j++)
                {
                    if (rands.Sum(t => Convert.ToInt32(t)) >= maxButtons * 100)
                    {
                        rands.Add(0);
                    }
                    else
                    {
                        rands.Add(random.Next(0, 100));
                    }
                }

                ButtonState left  = rands[0] > 50 ? ButtonState.Pressed : ButtonState.Released;
                ButtonState right = rands[1] > 50 ? ButtonState.Pressed : ButtonState.Released;
                ButtonState up    = rands[2] > 50 ? ButtonState.Pressed : ButtonState.Released;
                ButtonState down  = rands[3] > 50 ? ButtonState.Pressed : ButtonState.Released;

                PadState target = new PadState(left, right, up, down);

                PlayerTour tour = new PlayerTour(i, player, target, false);
                this._playerTours.Add(tour);
            }
        }
    }
예제 #2
0
 public PlayerTour(int tour, int deviceId, PadState target, bool successful)
 {
     Tour       = tour;
     DeviceID   = deviceId;
     Target     = target;
     Successful = successful;
 }
예제 #3
0
 public bool CompareTo(PadState other)
 {
     return
         (this.left == other.left &&
          this.right == other.right &&
          this.up == other.up &&
          this.down == other.down);
 }
예제 #4
0
    private static void OnMessage(int @from, JToken data)
    {
        string type = (string)data["type"];

        if (type == "button")
        {
            object payload = (object)data["payload"];
            if (payload != null)
            {
                int up    = Convert.ToInt32(data["payload"]["up"].ToString());
                int down  = Convert.ToInt32(data["payload"]["down"].ToString());
                int left  = Convert.ToInt32(data["payload"]["left"].ToString());
                int right = Convert.ToInt32(data["payload"]["right"].ToString());

                PadState state = new PadState(
                    left == 0 ? ButtonState.Released : ButtonState.Pressed,
                    right == 0 ? ButtonState.Released : ButtonState.Pressed,
                    up == 0 ? ButtonState.Released : ButtonState.Pressed,
                    down == 0 ? ButtonState.Released : ButtonState.Pressed
                    );

                if (!PlayerPadState.ContainsKey(from))
                {
                    PlayerPadState.Add(from, state);
                }
                else
                {
                    PlayerPadState[from] = state;
                }
            }
        }

        if (type == "state")
        {
            var isReady = (bool)data["ready"];
            if (!isReady)
            {
                if (_readyPlayerList.Contains(from))
                {
                    _readyPlayerList.Remove(from);
                }
            }
            else
            {
                if (!_readyPlayerList.Contains(from))
                {
                    _readyPlayerList.Add(from);
                }
            }

            Debug.Log("State From: " + from + " Type: State | Ready: " + isReady + " Ready Player Count: " +
                      _readyPlayerList.Count);
        }
    }
예제 #5
0
        //internal void difference(int ddx, int ddy)
        //{
        //    dx += ddx;
        //    dy += ddy;
        //    //throw new NotImplementedException();
        //}
        internal void move(PadState padState)
        {
            int dx = 0;
            int dy = 0;
            int d = 6;      // 自機の速度

            dx += padState.osareteru(PadState.Buttons.left) ? -d : 0;
            dx += padState.osareteru(PadState.Buttons.right) ? +d : 0;
            dy += padState.osareteru(PadState.Buttons.up) ? -d : 0;
            dy += padState.osareteru(PadState.Buttons.down) ? +d : 0;
            //if (e.KeyCode == Keys.A) j1.difference(-1, 0);
            //if (e.KeyCode == Keys.D) j1.difference(+1, 0);
            //if (e.KeyCode == Keys.W) j1.difference(0, -1);
            //if (e.KeyCode == Keys.S) j1.difference(0, +1);
            x += dx;
            y += dy;

            if (x < 0) x = 0;   // 画面左端からはみ出させない
            if (x > screenWidth - width) x = screenWidth - width;       // 画面右端からはみ出させない
            if (y < 0) y = 0;   // 画面上端からはみ出させない
            if (y > screenHeight - height) y = screenHeight - height;   // 画面下端からはみ出させない

            //throw new NotImplementedException();
        }
예제 #6
0
파일: Pad.cs 프로젝트: JFarlette/Hopper
 public Pad(char id, PadState state, PadSelection selection)
 {
     ID = id;
     State = state;
     Selection = selection;
 }
예제 #7
0
파일: Pond.cs 프로젝트: JFarlette/Hopper
 private PadState SetPadState(char padName, PadState newState)
 {
     byte padIndex = sm_padMap[padName];
     PadState oldState = m_pads[padIndex];
     m_pads[padIndex] = newState;
     return oldState;
 }
예제 #8
0
파일: Pond.cs 프로젝트: JFarlette/Hopper
 public void SetPad(char padName, PadState padState)
 {
     m_pads[sm_padMap[padName]] = padState;
 }
예제 #9
0
        private void reset()
        {
            Bitmap ShipBMP = new Bitmap(Path.Combine(Application.StartupPath, ShipFilePath));
            j1 = new Jiki(ShipBMP, 240, 260, width, height);    // 初期位置はてきとー
            isAlive = true;

            score = 0;
            RotationPhase = 0;

            padState = new PadState();
            //isPressed = new Dictionary<Keys, bool>();
            //isPressed.Add(Keys.A, false);
            //isPressed.Add(Keys.D, false);
            //isPressed.Add(Keys.W, false);
            //isPressed.Add(Keys.S, false);

            bullets = new List<Bullet>();   // 弾幕プールの1グループ
            enemies = new List<Enemy>();    // 敵の一味
            timer1.Interval = INTERVAL;   // ミリ秒
            stagetime = new List<TimeSpan>();
            startedTime = new List<DateTime>();
            shotTimeStamps = new List<DateTime>();
            tickTimeStamps = new List<DateTime>();
            //shotCount = 0;
            maxCountPerSec = 0;
            isRestInterval = false;
            bn = new Bitmap(System.IO.Path.Combine(Application.StartupPath, NantokaGirl1filepath));
            midx = r.Next(messages.Count);

            startedTime.Add(DateTime.Now);
            //startedTime[0] = DateTime.Now;    // まだないなら変更できない
            //t0 = DateTime.Now;

            timer1.Start();
        }
예제 #10
0
파일: Input.cs 프로젝트: heatend/stg
 public override void OnAwake()
 {
     PadHistory	= new PadInputHistory(PadHistorySize);
     CurInput	= new PadState();
 }
예제 #11
0
파일: Input.cs 프로젝트: heatend/stg
        public void Push(PadState history)
        {
            if (History.Count >= Capacity)
            {
                History.RemoveFirst();
            }

            History.AddLast(history);
        }
예제 #12
0
파일: Input.cs 프로젝트: heatend/stg
        private PadState DetectInput()
        {
            var state = new PadState();

            // 発射ボタン
            var isFireButtonDown = UnityEngine.Input.GetButtonDown("Fire1");
            if (isFireButtonDown == true)
            {
                state.FireButton = ButtonState.On;
            }

            // レバー状態
            var hAxis = UnityEngine.Input.GetAxis("Horizontal");
            var vAxis = UnityEngine.Input.GetAxis("Vertical");
            var leverState = CalcLeverState(hAxis, vAxis);

            return state;
        }
예제 #13
0
파일: DKC1.cs 프로젝트: mysidia/EffectPacks
        byte[] GetControlPattern(PadState abxy, PadState dpad)
        {
            byte[] result = new byte[16];

            // Connector?.WriteBytes(0x7e70f0, new byte[] { 0x33, 0x33,
            // 0x00, 0x00,
            // 0x00, 0x00, <- Disabled Inputs
            // 0xa0, 0x2a, <- RS1
            // 0x50, 0xd5, <- LS1
            // 0x00,  0x00, <- LS2
            // 0x00, 0x00, <- RS2
            // 0x0f, 0xc0 <- Passthrough } );

            /* ---ROM PATCH 1----
             * 0080:a28e original instruction is: txa
             * 0080:a28f original instruction is: sta 0502
             *     change ROM c0:a28e [22 80 7f 81]    ( jsl .jpmodify 817f80  )
             *   .jpmodify at ROM location c1:7f80  (aka PC=0x817f80)
             *      TXA  ;8A
             *      STA $0502 ;8D0205
             *      LDA #$3333  ;A93333
             *      CMP $7E70F0 ;CFF0707E
             *      BNE $7FDC   ;D04F
             *      stz $1E70   ;9C701E
             *      lda $7E70F4 ;AFF4707E
             *      trb $0500   ;1C0005
             *      lda $7E70F6 ;AFF6707E
             *      and $0500   ;2D0005
             *      lsr         ;4A
             *      tsb $1E70   ;0C701E
             *      lda $7E70F8 ;AFF8707E
             *      and $0500   ;2D0005
             *      asl         ;0A
             *      tsb $1E70   ;0C701E
             *      lda $7E70FE ;AFFE701E
             *      and $0500    ;2D0005
             *      tsb $1E70   ;0c701e
             *      lda $7E70FA ;AFFA707E
             *      and $0500   ;2D0005
             *      lsr         ;4A
             *      lsr         ;4A
             *      tsb $1E70   ;00701E
             *      lda $7E70FC ;AFFC707E
             *      and $0500   ;2D0005
             *      asl         ;0A
             *      asl         ;0A
             *      tsb $1E70   ;0c701e
             *      lda $1E70   ;aD701e
             *      sta $0500   ;8D0005
             *      sta $0502   ;8d0205
             *      sta $0504   ;8d0405
             *      rtl         ;6B
             *      rtl         ;6B
             */

            if (dpad != PadState.NORMAL || abxy != PadState.NORMAL)
            {
                result[0] = 0x33; /* Tell the  ROM patch to turn on */
                result[1] = 0x33;

                // Block the [Start]/Pause button while reverse controls
                // are in effect
                result[5] |= (1 << 4);
            }

            switch (dpad)
            {
            default: break;

            case PadState.INVERT:  result[7] |= 0x0A; result[9] |= 0x05; break;

            case PadState.ROTATE:  result[11] |= 0x0C; result[13] |= 0x03; break;
            }

            switch (abxy)
            {
            default: break;

            case PadState.INVERT:
            case PadState.ROTATE:
                result[6] |= 0x80;
                result[7] |= 0x80;
                result[8] |= 0x40;
                result[9] |= 0x40;
                break;
            }

            result[14] = (byte)~(result[4] | result[6] | result[8] | result[10] | result[12]);
            result[15] = (byte)~(result[5] | result[7] | result[9] | result[11] | result[13]);
            //Connector.SendMessage("result = " +  string.Join(" ", result.Select( hh => hh.ToString("X2"))  ) );
            return(result);
        }