Esempio n. 1
0
    public void Vote_The_Player(int myindex, int otherindex)
    {
        if (myIndex == myindex)
        {
            sendVotePlayer = new VotePlayer();
            sendVotePlayer.votedPlayerIndex      = myindex;    //4
            sendVotePlayer.pointedOutPlayerIndex = otherindex; //0

            string data = JsonUtility.ToJson(sendVotePlayer, prettyPrint: true);
            SocketManger.Socket.Emit("SendPlayerVote", data);
            Debug.Log("내가 보낸 데이터 서버 전송" + myindex);

            Cancel_The_Vote(otherindex);
            voteSkipButton.SetActive(false);
            for (int i = 0; i < numOfPlayer; i++)
            {
                playerButton[i].interactable = false;
            }
        }
        Debug.Log("상대방이 보낸 데이터 서버 전송" + myindex);
        //해당 플레이어의 케릭터에 표시해야함
        votedImage[myindex].color = normal;
        isItAlert = true;
        justOne   = true;

        if (otherindex == numOfPlayer)
        {
            skippedVotingPlayerImage[myindex].sprite = playerImageSprite[myindex];
        }
        else
        {
            votedPlayerImage[otherindex, myindex].sprite = playerImageSprite[myindex];
        }
    }
Esempio n. 2
0
    public void Init()
    {
        //토론 패널
        discuss        = this.transform.parent.gameObject;
        discuss_script = discuss.GetComponent <Discuss>();

        //토론 패널 메인 텍스트
        mainText      = this.transform.GetChild(0).GetComponent <Text>();
        beforeVoting  = "임포스터는 누구인가?";
        afterVoting   = "투표 결과";
        mainText.text = beforeVoting;

        //메시지 알람 이미지
        alertMessage = this.transform.GetChild(1).transform.GetChild(0).gameObject;
        isItAlert    = false;
        justOne      = true;
        alertMessage.SetActive(isItAlert);

        //투표 결과 중 투표 스킵 텍스트
        skippedVotingText = this.transform.GetChild(8).gameObject;
        skippedVotingText.SetActive(false);

        for (int i = 0; i < numOfPlayer; i++)
        {
            //플레이어 버튼
            playerButton[i] = this.transform.GetChild(i + 2).GetComponent <Button>();
            playerButton[i].interactable = true;


            //플레이어 이미지
            playerImage[i]        = this.transform.GetChild(i + 2).transform.GetChild(0).GetComponent <Image>();
            playerImageSprite[i]  = Resources.Load <Sprite>(playerImageString[i]);
            playerImage[i].sprite = playerImageSprite[i];

            //플레이어 이름
            playerText[i]      = this.transform.GetChild(i + 2).transform.GetChild(1).GetComponent <Text>();
            playerText[i].text = playerTextString[i];

            //투표한 플레이어 이미지
            for (int j = 0; j < numOfPlayer; j++)
            {
                votedPlayerImage[i, j]        = this.transform.GetChild(i + 2).transform.GetChild(2).transform.GetChild(j).GetComponent <Image>();
                votedPlayerImage[i, j].sprite = null;
                votedPlayerImage[i, j].color  = transparent;
            }

            //신고자를 구별해주는 이미지
            bellImage[i] = this.transform.GetChild(i + 2).transform.GetChild(3).GetComponent <Image>();
            if (playerTextString[i] != playerMeetingId)
            {
                bellImage[i].color = transparent;
            }

            //해당 플레이어를 투표하는 버튼
            voteButton[i] = this.transform.GetChild(i + 2).transform.GetChild(4).gameObject;
            voteButton[i].SetActive(false);

            //해당 플레이어를 투표하지 않는 버튼
            notVoteButton[i] = this.transform.GetChild(i + 2).transform.GetChild(5).gameObject;
            notVoteButton[i].SetActive(false);

            //투표했는지 확인하는 이미지
            votedImage[i]       = this.transform.GetChild(i + 2).transform.GetChild(6).GetComponent <Image>();
            votedImage[i].color = transparent;

            //투표 스킵한 플레이어 이미지
            skippedVotingPlayerImage[i]        = skippedVotingText.transform.GetChild(0).transform.GetChild(i).GetComponent <Image>();
            skippedVotingPlayerImage[i].sprite = null;
            skippedVotingPlayerImage[i].color  = transparent;
        }

        //투표 스킵 버튼
        voteSkipButton = this.transform.GetChild(7).gameObject;
        voteSkipButton.SetActive(true);

        //투표를 스킵하는 버튼
        skipButton = voteSkipButton.transform.GetChild(1).gameObject;
        skipButton.SetActive(false);

        //투표를 스킵하지 않는 버튼
        notSkipButton = voteSkipButton.transform.GetChild(2).gameObject;
        notSkipButton.SetActive(false);

        //투표 타이머
        voteTimer         = this.transform.GetChild(9).GetComponent <Text>();
        voteTimer.text    = null;
        byTheEndOfTheVote = "투표 종료까지 : ";
        upToConfirmation  = "확인까지 : ";
        isDone            = false;
        coroutine         = Voting_Timer(120);

        //채팅창
        chatWindow = this.transform.GetChild(10).gameObject;
        chatWindow.SetActive(false);

        SocketManger.Socket.On("GetPlayerVote", (data) =>
        {
            //서버에서 받은 데이터값
            VotePlayer getVotePlayer = new VotePlayer();
            string json   = JsonConvert.SerializeObject(data.Json.args[0]);
            getVotePlayer = JsonUtility.FromJson <VotePlayer>(json);

            whoIsVoted      = getVotePlayer.votedPlayerIndex;
            whoIsPointedOut = getVotePlayer.pointedOutPlayerIndex;
            Debug.Log("서버에서 전달 받음");
            isItGet = true;
        });

        StartCoroutine(coroutine);
    }