示例#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 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");
            }
        }
    }