예제 #1
0
    public void click_dice()
    {
        Debug.Log("click_dice - room_player_id : " + this.room_player_id);
        if (my_turn)
        {
            Debug.Log("click dice");
            //message 생성
            StringBuilder sb = new StringBuilder();
            sb.Append("GOMIN");
            sb.Append(Global.Major_Game);
            sb.Append(Global.Game_DiceRoll);
            sb.Append(Global.padding);
            sb.Append(Global.room_number);

            //send
            if (Socket_script.send_message(sb))
            {
                Debug.Log("Send Success");
            }
            else
            {
                Debug.Log("Send Fail");
            }
        }
        //int player = 1;
        //GameObject.Find("Canvas/Player/Player"+player).GetComponent<Player_script>().move_position(0, 39);
        //change_board_color(1, 1);
        //draw_building(33);
    }
예제 #2
0
    private void request_player_info()
    {
        //message 생성
        StringBuilder sb = new StringBuilder();

        sb.Append("GOMIN");
        sb.Append(Global.Major_User);
        sb.Append(Global.User_Record);
        sb.Append(Global.padding);
        sb.Append(Socket_script.user_idx);

        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        string[] param = return_message.Split(' ');
        try
        {
            Player_Info.text = Socket_script.user_id + "\n" + param[0] + "승 | " + param[1] + "패 (" + (Int32.Parse(param[0]) / (Int32.Parse(param[0]) + Int32.Parse(param[1]))) + "%)";
        }catch {
            Player_Info.text = Socket_script.user_id + "\n0승 | 0패 (0) ";
        }
    }
예제 #3
0
    public void reload_list()
    {
        //message 생성
        StringBuilder sb = new StringBuilder();

        sb.Append("GOMIN");
        sb.Append(Global.Major_Room);
        sb.Append(Global.Room_List);
        sb.Append(Global.padding);

        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        Room_List.Clear();

        //list count
        int list_count = Int32.Parse(return_message);

        Debug.Log("list_count : " + list_count);

        //add room to list
        for (int i = 0; i < list_count; i++)
        {
            Room_Info room_info = new Room_Info();
            return_message = Socket_script.receive_message();
            string[] param = return_message.Split(' ');

            room_info.Room_ID    = Int32.Parse(param[0]);
            room_info.status     = Int32.Parse(param[1]);
            room_info.Player_Num = "( " + param[2] + " / " + "4)";
            room_info.Name       = param[3];

            room_info.OnButtonClick = new Button.ButtonClickedEvent();
            room_info.OnButtonClick.AddListener(() => enter_room(room_info.Room_ID));

            Room_List.Add(room_info);
        }
        Socket_script.receive_message();

        this.Binding();
        Debug.Log("click");
    }
예제 #4
0
    public void create_id()
    {
        get_id_password();
        Debug.Log("id = " + id);
        Debug.Log("password = "******"GOMIN");
        sb.Append(Global.Major_User);
        sb.Append(Global.User_Signup);
        sb.Append(Global.padding);
        sb.Append(id);
        sb.Append(Global.delim);
        sb.Append(password);
        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        Debug.Log(return_message);
        if (return_message == Global.Fail)//중복 ID 존재
        {
            popup_name = "Error";
            popup_text = "중복된 아이디가 있습니다.";
        }
        else//ID 생성 성공
        {
            popup_name = "Success";
            popup_text = "아이디가 생성되었습니다.";
        }
        showPopUp = true;
    }
예제 #5
0
    public void Login()
    {
        get_id_password();
        Debug.Log("id = " + id);
        Debug.Log("password = "******"GOMIN");
        sb.Append(Global.Major_User);
        sb.Append(Global.User_Login);
        sb.Append(Global.padding);
        sb.Append(id);
        sb.Append(Global.delim);
        sb.Append(password);
        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        if (return_message == Global.Fail)
        {
            popup_name = "Error";
            popup_text = "아이디와 비밀번호를 확인해주세요.";
            showPopUp  = true;
        }
        else
        {
            user_idx = Int32.Parse(return_message);
            Socket_script.user_idx = user_idx;
            Socket_script.user_id  = id;
            SceneManager.LoadScene("list_scene");
        }
    }
예제 #6
0
    public void play_game_btn()
    {
        Debug.Log("play_game_btn");
        //message 생성
        StringBuilder sb = new StringBuilder();

        sb.Append("GOMIN");
        sb.Append(Global.Major_Room);
        sb.Append(Global.Room_Start);
        sb.Append(Global.padding);
        sb.Append(Global.room_number);

        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }
    }
예제 #7
0
    private void enter_room(int room_id)
    {
        //message 생성
        StringBuilder sb = new StringBuilder();

        sb.Append("GOMIN");
        sb.Append(Global.Major_Room);
        sb.Append(Global.Room_Enter);
        sb.Append(Global.padding);
        sb.Append(room_id);
        sb.Append(Global.delim);
        sb.Append(Socket_script.user_idx);

        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        if (return_message != Global.Fail)
        {
            Global.room_maker  = false;
            Global.room_number = room_id;
            SceneManager.LoadScene("room_scene");
        }
        else
        {
            Debug.Log(return_message);
            Debug.Log("게임 입장이 실패했습니다.");
        }
    }
예제 #8
0
    private void create_game_process()
    {
        //message 생성
        StringBuilder sb = new StringBuilder();

        sb.Append("GOMIN");
        sb.Append(Global.Major_Room);
        sb.Append(Global.Room_Create);
        sb.Append(Global.padding);
        sb.Append(Socket_script.user_idx);
        sb.Append(Global.delim);
        sb.Append(game_name);

        //send
        if (Socket_script.send_message(sb))
        {
            Debug.Log("Send Success");
        }
        else
        {
            Debug.Log("Send Fail");
        }

        //receive
        string return_message = Socket_script.receive_message();

        if (return_message != Global.Fail)
        {
            Global.room_maker  = true;
            Global.room_number = Int32.Parse(return_message);
            SceneManager.LoadScene("room_scene");
        }
        else
        {
            Debug.Log("게임 생성이 실패했습니다.");
        }
    }
예제 #9
0
    public static void send_position()
    {
        if (my_turn)
        {
            Debug.Log("Game visit");
            //message 생성
            StringBuilder sb = new StringBuilder();
            sb.Append("GOMIN");
            sb.Append(Global.Major_Game);
            sb.Append(Global.Game_Visit);
            sb.Append(Global.padding);
            sb.Append(Global.room_number);

            //send
            if (Socket_script.send_message(sb))
            {
                Debug.Log("Send Success");
            }
            else
            {
                Debug.Log("Send Fail");
            }
        }
    }
예제 #10
0
 void OnApplicationQuit()
 {
     s_instance = null;
     //게임종료시 삭제.
 }
예제 #11
0
    private void play_game()
    {
        while (end_init == false)
        {
        }

        while (true)
        {
            Debug.Log("while--");
            string return_message = Socket_script.receive_message();
            if (Socket_script.message_type == Global.Room_Alert_Enter)
            {
                Debug.Log("Room_Alert_Enter");
                string[] parse      = return_message.Split(Global.delim);
                int      player_num = Int32.Parse(parse[0]);
                Debug.Log("Player Num : " + player_num);
                for (int i = 0; i < player_num; i++)
                {
                    player_info[i].id             = parse[i + 1];
                    player_info[i].money          = Global.Start_Money;
                    player_info[i].is_empty       = false;
                    player_info[i].room_player_id = i + 1;
                    player_info[i].position       = 0;
                    if (Int32.Parse(parse[i + 1]) == Socket_script.user_idx)
                    {
                        this.room_player_id = i + 1;
                    }
                }
                set_log_ready("새로운 플레이어가 접속했습니다.");
            }
            else if (Socket_script.message_type == Global.Room_Start)
            {
                set_log_ready("게임이 시작됩니다.");
                while (true)
                {
                    while (main_thread_log_finish == false)
                    {
                    }
                    return_message = Socket_script.receive_message();
                    if (Socket_script.message_type == Global.Game_Turn)
                    {
                        Debug.Log("Game Turn");
                        lock (lock_obj)
                        {
                            if (this.room_player_id == Int32.Parse(return_message))
                            {
                                my_turn    = true;
                                showMyTurn = true;
                            }
                            else
                            {
                                my_turn = false;
                            }
                        }
                        lock (lock_string)
                        {
                            //set_log_ready(("플레이어" + return_message.ToString() + "이(가)순서입니다."));
                            string tmp = Int32.Parse(return_message).ToString();
                            //set_log_ready("플레이어" + return_message.ToString() + "이(가)순서입니다.");
                            set_log_ready("플레이어 " + tmp + "의 순서입니다.");
                        }
                    }
                    else if (Socket_script.message_type == Global.Game_DiceRoll)
                    {
                        string[] token = return_message.Split(Global.delim);
                        int      turn  = Int32.Parse(token[0]);
                        int      dice  = Int32.Parse(token[1]);
                        if (turn != 0)
                        {
                        }
                        else
                        {
                            //showIsolation = true;
                        }
                    }
                    else if (Socket_script.message_type == Global.Game_Move)
                    {
                        Debug.Log("Game Move");
                        string[] token = return_message.Split(Global.delim);
                        int      turn  = Int32.Parse(token[0]);
                        int      dice  = Int32.Parse(token[1]);
                        main_thread_turn = turn;
                        main_thread_dice = dice;
                        set_log_ready("플레이어 " + main_thread_turn.ToString() + "이(가) 이동했습니다.");
                        main_thread_check = true;
                    }
                    else if (Socket_script.message_type == Global.Game_Buy)
                    {
                        Debug.Log("buy restaurant");
                        string turn       = main_thread_turn.ToString();
                        string restaurant = board_arr[player_info[main_thread_turn - 1].position].name;
                        set_log_ready("플레이어 " + turn + " 이(가) " + restaurant + "를 구매했습니다.");
                        main_thread_buy = true;
                    }
                    else if (Socket_script.message_type == Global.Game_Pay)
                    {
                        Debug.Log("Game_Pay");
                        string[] token = return_message.Split(Global.delim);
                        Debug.Log(return_message);
                        int chk   = Int32.Parse(token[0]);
                        int pay   = Int32.Parse(token[1]);
                        int recv  = Int32.Parse(token[2]);
                        int money = Int32.Parse(token[3]);

                        if (chk == 1)
                        {
                            if (pay == 0 && recv != 0)
                            {
                                player_info[recv - 1].money += money;
                            }
                            else if (pay != 0 && recv == 0)
                            {
                                player_info[pay - 1].money -= money;
                            }
                            else
                            {
                                player_info[recv - 1].money += money;
                                player_info[pay - 1].money  -= money;
                            }

                            main_thread_change_player_info = true;
                            main_thread_pay_user           = pay;
                            main_thread_recv_user          = recv;
                            main_thread_money = money;
                            showPay           = true;
                        }
                    }
                    else if (Socket_script.message_type == Global.Game_GoldKey)
                    {
                        Debug.Log("Golden Key");
                        GoldKey_message = Global.Golden_Key[Int32.Parse(return_message)];
                        Debug.Log("GoldKey message : " + GoldKey_message);
                        showGoldKey = true;
                    }
                    else if (Socket_script.message_type == Global.Game_BuyCheck)
                    {
                        Debug.Log("Buy Check");
                        target_board = board_arr[player_info[main_thread_turn - 1].position];
                        showBuyCheck = true;
                    }
                    else if (Socket_script.message_type == Global.Game_Isolation)
                    {
                        Debug.Log("Isolation");
                        showIsolation = true;
                    }
                    else if (Socket_script.message_type == Global.Game_Salay)
                    {
                        Debug.Log("Salay");
                        int turn = Int32.Parse(return_message);
                        player_info[turn - 1].money   += Global.Game_Salay;
                        main_thread_change_player_info = true;
                    }
                }
            }
        }
    }
예제 #12
0
    void ShowRestaurant(int windowID)
    {
        int label_size_x  = popup_x / 3;
        int label_size_y  = popup_y / 6;
        int label_x       = popup_x / 2 - label_size_x / 2;
        int label_y       = popup_y * 3 / 6;
        int button_size_x = popup_x / 3;
        int button_size_y = popup_y / 12;
        int button_x      = popup_x / 2 - button_size_x / 2;
        int button_y      = popup_y * 7 / 8;
        int image_size_x  = popup_x * 5 / 6;
        int image_size_y  = popup_y * 2 / 5;
        int image_x       = popup_x / 2 - image_size_x / 2;
        int image_y       = popup_y / 15;
        int text_size_x   = popup_x * 5 / 6;
        int text_size_y   = popup_y * 3 / 9;
        int text_x        = popup_x / 2 - text_size_x / 2;
        int text_y        = popup_y * 1 / 2;

        //Texture image = AssetDatabase.LoadAssetAtPath(target_board.texture_path, typeof(Texture)) as Texture;

        //image
        Texture image;

        if (target_board.board_id == 0)
        {
            image = board_start;
        }
        else if (target_board.board_id == 10 || target_board.board_id == 20 || target_board.board_id == 30)
        {
            image = board_isolation;
        }
        else if (target_board.board_id == 2 || target_board.board_id == 7 || target_board.board_id == 12 || target_board.board_id == 25 || target_board.board_id == 32 || target_board.board_id == 37)
        {
            image = board_gold;
        }
        else
        {
            image = board_normal;
        }
        GUI.DrawTexture(new Rect(image_x, image_y, image_size_x, image_size_y), image);

        /*
         * // You may put a label to show a message to the player
         * GUIStyle centeredTextStyle = new GUIStyle("label");
         * centeredTextStyle.alignment = TextAnchor.MiddleCenter;
         * GUI.Label(new Rect(label_x, label_y, label_size_x, label_size_y), target_board.board_info, centeredTextStyle);
         */

        //board_info
        GUIStyle centeredTextStyle = new GUIStyle("label");

        centeredTextStyle.alignment = TextAnchor.UpperCenter;
        GUI.Label(new Rect(text_x, text_y, text_size_x, text_size_y), target_board.board_info, centeredTextStyle);
        //GUI.DrawTexture(new Rect(text_x, text_y, text_size_x, text_size_y), image);

        //button
        if (GUI.Button(new Rect(popup_x / 2 - button_size_x, button_y, button_size_x, button_size_y), "구매"))
        {
            Debug.Log("Buy(O) btn");
            //message 생성
            StringBuilder sb = new StringBuilder();
            sb.Append("GOMIN");
            sb.Append(Global.Major_Game);
            sb.Append(Global.Game_Buy);
            sb.Append(Global.padding);
            sb.Append(Global.room_number);
            sb.Append(Global.delim);
            sb.Append(Global.Success);

            //send
            if (Socket_script.send_message(sb))
            {
                Debug.Log("Send Success");
                showBuyCheck = false;
            }
            else
            {
                Debug.Log("Send Fail");
            }
        }
        if (GUI.Button(new Rect(popup_x / 2, button_y, button_size_x, button_size_y), "닫기"))
        {
            Debug.Log("Buy(X) btn");
            //message 생성
            StringBuilder sb = new StringBuilder();
            sb.Append("GOMIN");
            sb.Append(Global.Major_Game);
            sb.Append(Global.Game_Buy);
            sb.Append(Global.padding);
            sb.Append(Global.room_number);
            sb.Append(Global.delim);
            sb.Append(Global.Fail);

            //send
            if (Socket_script.send_message(sb))
            {
                Debug.Log("Send Success");
                showBuyCheck = false;
            }
            else
            {
                Debug.Log("Send Fail");
            }
        }
    }