예제 #1
0
 public void UpdateCountdown()
 {
     if (!ar_ready)
     {
         gold_manager.SendGoldPositionUpdate();
         ar_ready = true;
     }
     start_countdown -= 1 * Time.deltaTime;
     //update clients with the current countdown
     if (start_countdown <= 0.0f)
     {
         game_started = true;
         NWMGameStart start = new NWMGameStart();
         start.started = true;
         server.SendGameStarted(start);
         server.GetComponent <InGameTimer>().StartTimer();
     }
 }
예제 #2
0
 public void SetClientGameStarted(NWMGameStart start_message)
 {
     network_GM.game_started = start_message.started;
 }
예제 #3
0
 public void SendGameStarted(NWMGameStart game_start)
 {
     SendAllClientsMessage(host_id, reliable, game_start);
 }
예제 #4
0
    private void OnDataReceived(int channel_id, int host_id, NetworkMessage message)
    {
        switch (message.operation)
        {
        case NetworkOperation.none:

            break;

        case NetworkOperation.set_ready:
            break;

        case NetworkOperation.cart_data:
            NWMCartData cart_data = (NWMCartData)message;
            ReceiveCartData(cart_data);
            break;

        case NetworkOperation.grid_single:
            NWMGridData grid_data = (NWMGridData)message;
            ReceiveSingleGridData(grid_data);
            break;

        case NetworkOperation.user_counter:
            NWMUserCount user_counter = (NWMUserCount)message;
            ReceiveUserCount(user_counter);
            break;

        case NetworkOperation.scene_load:
            NWMSceneLoad scene_load = (NWMSceneLoad)message;
            ReceiveSceneToLoad(scene_load);
            break;

        case NetworkOperation.assign_num:
            NWMAssignPlayerNum assigner = (NWMAssignPlayerNum)message;
            player_id = assigner.num;
            Debug.Log(client_id);
            break;

        case NetworkOperation.gold_pos:
            NWMGoldUpdate goldUpdate = (NWMGoldUpdate)message;
            ReceiveGoldPositionUpdate(goldUpdate);
            break;

        case NetworkOperation.player_score:
            NWMScoreUpdate scoreUpdate = (NWMScoreUpdate)message;
            ReceiveScoreUpdate(scoreUpdate);
            break;

        case NetworkOperation.player_info:
            NWMPlayerIDUpdate idUpdate = (NWMPlayerIDUpdate)message;
            ReceivePlayerDataUpdate(idUpdate);
            break;

        case NetworkOperation.game_start:
            NWMGameStart start_msg = (NWMGameStart)message;
            SetClientGameStarted(start_msg);

            break;

        case NetworkOperation.player_respawn:
            NWMPlayerRespawn respawn_data = (NWMPlayerRespawn)message;
            ReceivePlayerRepsawnData(respawn_data);
            break;

        case NetworkOperation.timer_seconds:
            NWMTimerUpdate timer_data = (NWMTimerUpdate)message;
            ReceiveUpdateTimer(timer_data);
            break;

        case NetworkOperation.game_finished:
            NWMGameFinishedSendInfo game_finished_info = (NWMGameFinishedSendInfo)message;
            ReceiveGameFinishedInfo(game_finished_info);
            break;
        }
    }