IEnumerator Processing()
    {
        while (true)
        {
            yield return(new WaitUntil(() => gameState.GetGameState() == GameState.processing));//processing상태까지 기달

            //processing상태 == 모두가 카드를 내고 진행화면이 나오길 기다리고 있는 상태

            //yield return new WaitUntil(() => GameObject.FindGameObjectsWithTag("Card").Length - PhotonNetwork.PlayerList.Length + 1
            //== GameStaticVariable.maxHand);//모든 카드가 다 소환될때까지 기달


            processingCards = GameObject.FindGameObjectsWithTag("Card");
            for (int i = 0; i < processingCards.Length; i++)
            {
                processingCards[i].GetComponent <CardGameObject>().GetCard().SetIsReversed(false);
            }//뒷면 까기

            yield return(new WaitForSeconds(compareTime));//승부전에 대기시간

            if (PhotonNetwork.IsMasterClient)                          //masterclient는 게임진행하고 결과통보
            {
                if (player.Brawl(out SubmittedInfo winner) == true)    //가위 바위 보!
                {
                    player.AnounceResult(winner.GetActorNum(), false); //이놈이 이기고 나머지 짐
                }
                else
                {
                    player.AnounceResult(0, true);//무승부
                }
            }

            yield return(new WaitForSeconds(resultingTime));

            player.ResultDistributeCard();
            player.ClearData();
            Clearing();
            yield return(new WaitUntil(() => player.IsHandFull())); //다시 드로우한거 받을때까지 기달

            if (player.IsChampion())                                //우승하면
            {
                gameState.AskForVictory(PhotonNetwork.LocalPlayer.ActorNumber);
            }
            else//아니면
            {
                gameState.AskForNextState();//순서 - before wait processing wait processing-----
            }
            yield return(new WaitWhile(() => gameState.GetGameState() == GameState.processing));
        }
示例#2
0
    private void Update()
    {
        if (gameState.GetGameState() == GameState.processing)
        {
            isSubmitFinish = false;
        }
        if (gameState.GetGameState() != GameState.Wait)//wait상태일때만 입력받음
        {
            return;
        }
        if (isSubmitFinish)
        {
            return;
        }
        Touch touch = new Touch();

        if (Input.touchCount > 0)
        {
            touch = Input.GetTouch(0);
            Ray          ray = Camera.main.ScreenPointToRay(touch.position);
            RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity, LayerMask.GetMask("Card")); //입력좌표에 카드있나 감지
            if (hit && !isCardSelected)                                                                      //있으면
            {
                isCardSelected     = true;
                cardObject         = hit.collider.gameObject.GetComponentInParent <CardGameObject>();
                cardTransform      = hit.collider.gameObject.transform.parent;
                cardReturnPosition = cardTransform.position;
            }
            if (isCardSelected)                                                                   //카드가 잡혀있고 마우스가 계속 눌려있다면
            {
                cardTransform.position = (Vector2)Camera.main.ScreenToWorldPoint(touch.position); //마우스 따라 이동
            }
            if (touch.phase == TouchPhase.Ended && isCardSelected)
            {
                if (touch.position.y > submitZoneYPixel)
                {
                    player.SubmitCard(cardObject);//제출
                    isCardSelected = false;
                    isSubmitFinish = true;
                }
                else
                {
                    isCardSelected         = false;
                    cardTransform.position = cardReturnPosition;//원래자리로 백
                }
            }
        }
    }
示例#3
0
    IEnumerator OtherPlayerView()
    {
        yield return(new WaitForSeconds(0.1f));//다른 start보다 먼저 실행되는거 방지

        while (true)
        {
            Player[] players = PhotonNetwork.PlayerList;
            foreach (GameObject otherPlayer in otherPlayerGameObjects)
            {
                Destroy(otherPlayer);
            }
            otherPlayerGameObjects.Clear();


            int locateIndex = 0;
            for (int i = 0; i < players.Length; i++)
            {
                if (players[i].ActorNumber == photonPlayer.GetActorNumber())//나 자신은 표현하지 않음
                {
                    continue;
                }
                GameObject newOtherPlayer = Instantiate(otherPlayerView,
                                                        (Vector2)Camera.main.ScreenToWorldPoint(new Vector2(Camera.main.scaledPixelWidth / players.Length * (locateIndex + 1), 540)) + new Vector2(0, 3),
                                                        Quaternion.identity);
                locateIndex++;
                Text[] texts = newOtherPlayer.GetComponentsInChildren <Text>();
                texts[0].text = "ID:" + players[i].ActorNumber;
                otherPlayerGameObjects.Add(newOtherPlayer);
            }
            int pastPlayerNum = players.Length;
            yield return(new WaitUntil(() => pastPlayerNum + 1 == PhotonNetwork.PlayerList.Length));

            yield return(new WaitWhile(() => gameState.GetGameState() != GameState.BeforeGame));
        }
    }
    IEnumerator Timer()
    {
        yield return(new WaitUntil(() => gameState.GetGameState() == GameState.Wait));//gamestate가 wait가 되면

        while (true)
        {
            sm.PlayWaitAudio();
            float leftTime = GameStaticVariable.turnTime;
            while (true)
            {
                leftTime         -= Time.deltaTime;
                leftTimeText.text = "Left Time : " + Mathf.Round(leftTime * 100) / 100;
                if (leftTime < 0)//시간이 끝남
                {
                    GameObject[] cardObjects = GameObject.FindGameObjectsWithTag("Card");
                    int          ran         = Random.Range(0, GameStaticVariable.maxHand);//내 손중 몇번째 있는거 버릴지
                    int          resultIndex = 0;
                    for (int i = 0; i < cardObjects.Length; i++)
                    {
                        if (cardObjects[i].GetComponent <CardGameObject>().GetCard().IsReversed())//뒤집어져 있는건 상대거
                        {
                            continue;
                        }
                        ran--;
                        if (ran == 0)
                        {
                            resultIndex = i;
                            break;
                        }
                    }
                    player.SubmitCard(cardObjects[resultIndex].GetComponent <CardGameObject>());//랜덤카드 제출
                    leftTimeText.text = "Left Time : " + "0";
                    break;
                }
                if (playerInput.IsSubmitFinish())
                {
                    break;
                }//시간 표시
                yield return(null);
            }
            gameState.AskForNextState();
            leftTime = GameStaticVariable.turnTime;
            yield return(new WaitUntil(() => gameState.GetGameState() == GameState.processing)); //processing까지 기달

            yield return(new WaitWhile(() => gameState.GetGameState() != GameState.Wait));       //wait상태가 다시 될때까지 기달
        }
    }
    IEnumerator Ending()
    {
        yield return(new WaitUntil(() => gameState.GetGameState() == GameState.end));

        endUI.SetActive(true);
        if (PhotonNetwork.LocalPlayer.ActorNumber == gameState.GetChampionId())//우승자면
        {
            resultText.text            = "Win!";
            endUIBackgroundColor.color = Color.cyan;
        }
        else
        {
            resultText.text            = "Lose!\nwinner : " + gameState.GetChampionId();//패배자면
            endUIBackgroundColor.color = Color.red;
        }
    }
示例#6
0
 private void Update()
 {
     if (!PhotonNetwork.IsMasterClient)
     {
         return;
     }
     if ((gameState.GetGameState() == GameState.Wait) && !disTributedCompleted)
     {
         Player[] players = PhotonNetwork.PlayerList;
         for (int j = 0; j < players.Length; j++)
         {
             for (int i = 0; i < GameStaticVariable.maxHand; i++)
             {
                 pv.RPC("RPC_DistributeCard", players[j], deck.DrawCard());
             }
         }
         disTributedCompleted = true;
     }
 }