コード例 #1
0
        private void sendScoreToPeer(Dictionary <byte, object> led_score_params)
        {
            int[] score = new int[2];
            int[] icar  = new int[2];

            score[0] = (int)led_score_params[(byte)1];
            score[1] = (int)led_score_params[(byte)2];

            icar[0] = (int)led_score_params[(byte)3];
            icar[1] = (int)led_score_params[(byte)4];

            //int iwinner = (score1<score2) ? 1 : 0;

            for (int i = 0; i < mcur_player; ++i)
            {
                int index = icur_player + i;
                if (index < 0 || index >= waiting_list.Count)
                {
                    continue;
                }
                STServerPeer peer = waiting_list[icur_player + i];
                peer.sendEventToPeer(STServerCode.CSend_GG,
                                     new Dictionary <byte, object>()
                {
                    { (byte)1, (score[i] >= score[(i + 1) % 2])?1:0 }, { (byte)2, score[i] }, { (byte)3, icar[i] }
                });

                InsertToSql(new String[] { peer.client_id, "score: " + score[i] });
            }
        }
コード例 #2
0
ファイル: STGameApp.cs プロジェクト: Rengaht/STPhotonServer
 public void SendNotifyLED(STServerCode event_code, Dictionary <byte, Object> event_param)
 {
     if (led_peer != null && led_peer.Connected)
     {
         led_peer.sendEventToPeer(new EventData((byte)event_code, event_param));
     }
     else
     {
         Log.Warn("There's no LED connected !!!");
     }
 }
コード例 #3
0
        override public void handleMessage(STServerPeer sender, STClientCode code, Dictionary <byte, object> event_params)
        {
            String sid = (event_params.ContainsKey((byte)100)) ? (String)event_params[(byte)100] : "";

            Dictionary <byte, object> response_params = new Dictionary <byte, object>();

            switch (code)
            {
            case STClientCode.APP_Join:
                Log.Warn("Join Game B!!");


                int join_success = checkJoinSuccess(event_params);
                response_params.Add((byte)1, join_success);


                if (join_success == 1)
                {
                    int iwait = getNewWaitingIndex(sender);
                    Log.Debug("New in Waiting List: " + iwait);
                    response_params.Add((byte)101, iwait);
                    addIdInGame(sid);

                    InsertToSql(new String[] { sid, "Join Game" });
                    lock (online_client)
                    {
                        online_client.Add(sender);
                    }
                    checkWaitingStatus();
                }
                else
                {
                    //sender.delayDisconnect(5);
                }

                sender.sendOpResponseToPeer(STServerCode.CJoin_Success, response_params);


                break;

            case STClientCode.APP_Rotate:
                if (isIdInGame(sid))
                {
                    game_app.SendNotifyLED(STServerCode.LSet_Rotate, event_params);
                }
                else
                {
                    Log.Error("!! Not in-game ID: " + sid + " ! Kill it!!");
                    //sender.delayDisconnect(3);
                }
                break;

            case STClientCode.LED_StartRun:
                if (waiting_list.Count >= mcur_player)
                {
                    sendStartRun();
                }
                break;

            case STClientCode.LED_EatIcon:

                int          ipeer = (int)event_params[(byte)101];
                STServerPeer peer  = null;
                if (ipeer == 1 && waiting_list.Count > 0)
                {
                    peer = waiting_list[icur_player];
                }
                if (ipeer == 0 && waiting_list.Count > 1)
                {
                    peer = waiting_list[icur_player + 1];
                }

                if (peer != null)
                {
                    peer.sendEventToPeer(STServerCode.CGameB_Eat, event_params);
                }

                break;

            case STClientCode.LED_Score:
                sender.sendOpResponseToPeer(STServerCode.LSend_Score_Success, response_params);
                //game_app.sendGameOverToAll(event_params);
                sendScoreToPeer(event_params);
                EndRound();

                InsertToSql(new String[] { "game", "End Round" });

                break;
            }
        }