Ejemplo n.º 1
0
    public static void Disconnect()
    {
        PhotonNetwork.Disconnect();
        PhotonNetwork.DestroyAll();

        PageManager.Open <MainMenuPage>();
    }
    IEnumerator ClearAllSlime()
    {
        yield return(new WaitForSeconds(2f));

        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.DestroyAll();
        }

        //Clear all the teams with building
        if (team_red.Count > 0)
        {
            team_red.Clear();
        }
        if (team_blue.Count > 0)
        {
            team_blue.Clear();
        }
        if (team_invisible.Count > 0)
        {
            team_invisible.Clear();
        }


        objectPooler.DestoryObjectPool();
    }
Ejemplo n.º 3
0
    // 보스유저 승리화면 출력 코루틴
    IEnumerator CoBossWin()
    {
        PhotonNetwork.OpCleanActorRpcBuffer(PhotonNetwork.LocalPlayer.ActorNumber);
        yield return(new WaitForSeconds(0.1f));

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.DestroyAll();
        }

        Time.timeScale   = 1;                                                // 배속 원상복귀 (3번 탄막을 사용하고 있는 경우에 대응하여)
        Winningtext.text = "            유령 Win!\n[ 유령들이 방송국을 점거했다 ... ]";
        Returntext.text  = "스테이지를 종료합니다...";
        BossWin.SetActive(true);

        yield return(new WaitForSeconds(5f));                                 // 5초간 결과화면 표시

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.Destroy(GameObject.Find("RoomManager"));
            PhotonNetwork.LoadLevel("Room Scene");
        }
        PhotonNetwork.CurrentRoom.IsOpen    = true;
        PhotonNetwork.CurrentRoom.IsVisible = true;
        Destroy(this.gameObject);
    }
Ejemplo n.º 4
0
    public void Update()
    {
        if (SceneManager.GetActiveScene().name.Equals("Game Scene"))
        {
            if (PhotonNetwork.IsMasterClient)
            {
                if (GameObject.Find("RoomManager") != null)
                {
                    // 사람 수 적음
                    if ((PhotonNetwork.PlayerList.Length < GameObject.Find("RoomManager").GetComponent <Room>().readyCnt) || (GameObject.Find("RoomManager").GetComponent <Room>().checkBoss.Count == 0))
                    {
                        PhotonNetwork.OpCleanActorRpcBuffer(PhotonNetwork.LocalPlayer.ActorNumber);
                        PhotonNetwork.DestroyAll();
                        if (PhotonNetwork.InRoom)
                        {
                            PhotonNetwork.LeaveRoom();
                        }
                    }

                    // 모든 유저가 사망했을 경우
                    if (GameObject.Find("RoomManager").GetComponent <Room>().checkBoss.Count == PhotonNetwork.PlayerList.Length + 1)
                    {
                        pv.RPC("BossWinUI", RpcTarget.All);
                    }
                    // 제한시간이 모두 지남
                    if (gameovercheck)
                    {
                        pv.RPC("ArmWinUI", RpcTarget.All);
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
 public override void OnLeftRoom()
 {
     if (PhotonNetwork.player.IsMasterClient)
     {
         PhotonNetwork.DestroyAll();
     }
 }
    private IEnumerator EndGame()
    {
        yield return(new WaitForSeconds(10));

        PhotonNetwork.DestroyAll();
        PhotonNetwork.LeaveRoom();
    }
Ejemplo n.º 7
0
    void ReloadRoomScene()
    {
        return; // pour l'instant

        PhotonNetwork.DestroyAll();
        PhotonNetwork.LoadLevel("0-MainMenu");
    }
Ejemplo n.º 8
0
 void OnDisconnectFromPhoton()
 {
     Cursor.visible   = true;
     Cursor.lockState = CursorLockMode.None;
     PhotonNetwork.DestroyAll();
     Application.LoadLevel("MainMenu");
 }
Ejemplo n.º 9
0
    void OnBeforeReloadMainScene()
    {
        if (mode == Mode.Online && PhotonNetwork.connected)
        {
            // If the master client is loading a new map and we're in multiplayer,
            // just always keep the room and consider this a map change for the room.

            string newJoinCode         = GameBuilderApplication.CurrentGameOptions.joinCode;
            bool   tryingToJoinNewRoom = !newJoinCode.IsNullOrEmpty() && newJoinCode != PhotonNetwork.room.Name;
            bool   keepRoom            = PhotonNetwork.isMasterClient && !tryingToJoinNewRoom;

            if (!keepRoom)
            {
                Util.Log("Disconnecting, and probably reconnecting into a new game.");
                PhotonNetwork.Disconnect();
            }
            else
            {
                Util.Log("Staying connected, just switching scenes. Telling other players to reconnect to the same room..");
                photonView.RPC("JoinRoomRPC", PhotonTargets.Others, GetJoinedRoomName());

                // This DestroyAll is crucial. If we don't call it, the UserBody's of
                // non-master players seem to stick around in a weird way..where the
                // master doesn't see them, but new players (and reconnects) do..
                PhotonNetwork.DestroyAll();

                state = State.SwitchingScene;
            }
        }
    }
Ejemplo n.º 10
0
        private void EndGame()
        {
            // set game state to ending
            state = GameState.Ending;

            // set timer to 0
            if (timerCoroutine != null)
            {
                StopCoroutine(timerCoroutine);
            }
            currentMatchTime = 0;
            RefreshTimerUI();

            // disable room
            if (PhotonNetwork.IsMasterClient)
            {
                PhotonNetwork.DestroyAll();

                if (!perpetual)
                {
                    PhotonNetwork.CurrentRoom.IsVisible = false;
                    PhotonNetwork.CurrentRoom.IsOpen    = false;
                }
            }

            // activate map camera
            mapcam.SetActive(true);

            // show end game ui
            ui_endgame.gameObject.SetActive(true);
            Leaderboard(ui_endgame.Find("Leaderboard"));

            // wait X seconds and then return to main menu
            StartCoroutine(End(6f));
        }
Ejemplo n.º 11
0
        void EndGame()
        {
            state = GameState.Ending;

            //disable room
            if (PhotonNetwork.IsMasterClient)
            {
                PhotonNetwork.DestroyAll();

                if (!perpetual)
                {
                    PhotonNetwork.CurrentRoom.IsVisible = false;
                    PhotonNetwork.CurrentRoom.IsOpen    = false;
                }
            }

            //activate map camera
            mapCam.SetActive(true);

            //show end game ui
            ui_endgame.gameObject.SetActive(true);
            Leaderboard(ui_endgame.Find("Leaderboard"));

            StartCoroutine(End(10f));
        }
Ejemplo n.º 12
0
 public void DestroyAllPlayers()
 {
     if (PhotonNetwork.isMasterClient)
     {
         PhotonNetwork.DestroyAll();
     }
 }
Ejemplo n.º 13
0
    IEnumerator CoArmWin()
    {
        PhotonNetwork.OpCleanActorRpcBuffer(PhotonNetwork.LocalPlayer.ActorNumber);
        yield return(new WaitForSeconds(0.1f));

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.DestroyAll();
        }

        // 50초가 경과할 동안 다른 메서드(인원 수 부족, 모두 보스가 됨)가 실행되지 않은 경우
        // 아르마딜로 승리
        Time.timeScale = 1;                                          // 배속 원상복귀 (3번 탄막을 사용하고 있는 경우에 대응하여)
        ArmadilloWin.SetActive(true);
        Winningtext.text = "          아르마딜로 Win!\n[아르마딜로들이 방송국을 지켜냈다...]";
        Returntext.text  = "스테이지를 종료합니다...";
        yield return(new WaitForSeconds(5f));                        // 5초간 결과화면 표시

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.Destroy(GameObject.Find("RoomManager"));
            PhotonNetwork.LoadLevel("Room Scene");
        }
        PhotonNetwork.CurrentRoom.IsOpen    = true;
        PhotonNetwork.CurrentRoom.IsVisible = true;
        Destroy(this.gameObject);
    }
Ejemplo n.º 14
0
 public void LeaveMatch()
 {
     StopAllCoroutines();
     PhotonNetwork.DestroyAll(true);
     PhotonNetwork.Disconnect();
     StartCoroutine(WaitAndReturnToLauncher());
 }
    private void RPC_PlayAgain()
    {
        panelGO.SetActive(false);

        if (PhotonNetwork.LocalPlayer == PhotonNetwork.MasterClient)
        {
            PhotonNetwork.DestroyAll();
        }

        InitializeVar();
        panelGOMatchIsActive            = false;
        MatchDates.Instance.countRondas = 1;
        MatchDates.Instance.winner      = 0;
        countRondaMenu.text             = "Ronda " + MatchDates.Instance.countRondas;

        MatchDates.Instance.pointRondasPlayer1 = 0;
        MatchDates.Instance.pointRondasPlayer2 = 0;
        MatchDates.Instance.selectedFicha      = null;

        GameObject textPointsPlayer1 = tableMenu.transform.GetChild(0).gameObject;
        GameObject textPointsPlayer2 = tableMenu.transform.GetChild(1).gameObject;

        textPointsPlayer1.transform.GetComponent <Text>().text = MatchDates.Instance.pointRondasPlayer1.ToString();
        textPointsPlayer2.transform.GetComponent <Text>().text = MatchDates.Instance.pointRondasPlayer2.ToString();

        childpanelGOMatch.GetComponent <Animation>().Play("PanelOut");
        StartCoroutine(WaitOutPanelGO());
    }
    IEnumerator CleanupGame()
    {
        // Stop Enemyspawner works
        enemySpawner.SetActive(false);

        // Remove all zombies and players
        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.DestroyAll();
        }

        // Remove inspectors
        GameObject inspector = GameObject.FindWithTag("Inspector");

        if (inspector != null)
        {
            Destroy(inspector);
        }

        // Remove bodies
        GameObject[] bodies = GameObject.FindGameObjectsWithTag("Body");
        foreach (GameObject body in bodies)
        {
            Destroy(body);
        }

        alives         = 0;
        spawnedPlayers = 0;
        ResetWaitingRoomUI();

        globalSoundManager.PlayMusic(mainBGM);

        yield break;
    }
Ejemplo n.º 17
0
    public void OnEvent(byte eventCode, object content, int senderId)
    {
        // Do something
        if (eventCode == 0)
        {
            //object[] data = (object[])content;

            if (GameManager.instance.GetComponent <GameManager>().gameSceneA)
            {
                PhotonNetwork.LoadLevel("MainGame");
            }
            else if (GameManager.instance.GetComponent <GameManager>().gameSceneB)
            {
                PhotonNetwork.LoadLevel("MainGameB");
            }
        }
        if (eventCode == 1)
        {
            //object[] data = (object[])content;

            PhotonNetwork.LeaveRoom();
            PhotonNetwork.Disconnect();
            PhotonNetwork.DestroyAll();
            Debug.Log("DISCONNECTING / NUMBER OF PLAYER IS: " + PhotonNetwork.room.PlayerCount);
            GameManager.instance.GetComponent <GameManager>().waiting = true;
            SceneManager.LoadScene("MainMenu");
        }
    }
Ejemplo n.º 18
0
 /// <summary>
 /// 最初から
 /// </summary>
 public void SceneReset()
 {
     GlobalGameManager._instance.gameRestartCount += 1;
     PhotonNetwork.DestroyAll();
     PhotonNetwork.isMessageQueueRunning = false;
     PhotonNetwork.LoadLevel("SceneGame");
 }
        public void OnEvent(EventData photonEvent)
        {
            byte eventCode = photonEvent.Code;

            Debug.Log(string.Format("Received an event with code {0}", Convert.ToInt64(eventCode)));
            if (eventCode == GameStartEventCode)
            {
                Debug.Log(string.Format("Starting a game ... with {0} players : {1}", PlayerRegister.GetCount(), PlayerRegister.GetPlayerInfo()));

                // Start the game
                gameManager.StartGame();
            }
            if (eventCode == GameExitEventCode)
            {
                // Destroying all available players network
                PhotonNetwork.DestroyAll(false);

                // Unregistered all players
                PlayerRegister.DeleteAll();

                // Game is running, force to change into Main Menu
                SceneManager.LoadScene("EasyMainMenu/Scenes/MainMenu");

                // Disconnect server connection
                PhotonNetwork.Disconnect();
            }
        }
Ejemplo n.º 20
0
    private void EndGame()
    {
        state = GameState.Ending;

        if (timerCoroutine != null)
        {
            StopCoroutine(timerCoroutine);
        }
        currentMatchTime = 0;
        RefreshTimerUI();

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.DestroyAll();
            if (!perpetual)
            {
                PhotonNetwork.CurrentRoom.IsVisible = false;
                PhotonNetwork.CurrentRoom.IsOpen    = false;
            }
        }

        mapcam.SetActive(true);

        ui_endgame.gameObject.SetActive(true);
        ui_leaderboard.gameObject.SetActive(false);

        Debug.Log("Accessing Leaderboard FUnction");
        Leaderboard(ui_endgame.Find("Leaderboard")); //////////////

        StartCoroutine(End(6f));
    }
Ejemplo n.º 21
0
        private void EndGame()
        {
            //Set game state to ending
            state = GameState.Ending;

            //Disable room
            if (PhotonNetwork.IsMasterClient)
            {
                PhotonNetwork.DestroyAll();

                if (!perpetual)
                {
                    PhotonNetwork.CurrentRoom.IsVisible = false;
                    PhotonNetwork.CurrentRoom.IsOpen    = false;
                }
            }

            //Activate map camera
            mapcam.SetActive(true);

            //Show end game ui
            ui_endgame.gameObject.SetActive(true);
            Leaderboard(ui_endgame.Find("Leaderboard"));

            //Wait x seconds and then return to main menu
            StartCoroutine(End(6f));
        }
Ejemplo n.º 22
0
        private void Update()
        {
            if (PhotonNetwork.CurrentRoom.PlayerCount == 1)
            {
                PhotonNetwork.DestroyAll();
                PhotonNetwork.LeaveRoom();
                SceneManager.LoadScene(3);
            }



            if (photonView.IsMine && IsOnline == true)
            {
                if (currentHealth <= 0)
                {
                    OnDeath();
                }



                MyUpdate();
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    Jump();
                }
            }
        }
Ejemplo n.º 23
0
        //Funzione che si occupa della gestione della fine partita
        private void EndGame()
        {
            //set game state to ending
            state = GameState.Ending;

            //set timer to 0

            if (timerCoroutine != null)
            {
                StopCoroutine(timerCoroutine);
            }
            currentMatchTime = 0;
            RefreshTimerUI();


            if (PhotonNetwork.IsMasterClient)
            {
                PhotonNetwork.DestroyAll();
                PhotonNetwork.CurrentRoom.IsVisible = false;
                PhotonNetwork.CurrentRoom.IsOpen    = false;
            }

            mapcam.SetActive(true);

            hud_endgame.gameObject.SetActive(true);
            Leaderboard(hud_endgame.Find("Leaderboard"));

            StartCoroutine(End(6f));
        }
Ejemplo n.º 24
0
    //게임 오버후 자동 카운트 다운후 게임 다시 시작
    IEnumerator RestartCountdown()
    {
        int count = 10;

        while (count > 0)
        {
            //씬 이동 전 모든 오브젝트들을 삭제하여 더이상 동기화 할 오브젝트가 없도록 한다
            if (count == 5 && PhotonNetwork.IsMasterClient)
            {
                PhotonNetwork.DestroyAll();
            }

            //5초가 남았을때 부터 카운트 다운을 보여준다.
            if (count <= 5)
            {
                GameOverUi.GetComponent <Text>().text = "ReGame " + count;
            }

            yield return(new WaitForSeconds(1));

            count--;
        }

        SceneManager.LoadScene(0);
    }
Ejemplo n.º 25
0
    private void EndGame()
    {
        state = GameState.Ending;

        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.DestroyAll();

            if (!perpetual)
            {
                PhotonNetwork.CurrentRoom.IsVisible = false;
                PhotonNetwork.CurrentRoom.IsOpen    = false;
            }
        }


        mapcam.SetActive(true);



        ui_endgame.gameObject.SetActive(true);
        ui_endtext      = GameObject.Find("HUD/End Game/Design/Message").GetComponent <Text>();
        ui_endtext.text = "Winner - " + sd.profile.username;
        Leaderboard(ui_endgame.Find("Leaderboard"));

        StartCoroutine(End(5f));
    }
Ejemplo n.º 26
0
 void RPC_EndGame()
 {
     if (TimerCoroutine != null)
     {
         StopCoroutine(TimerCoroutine);
     }
     CurrentGameTime = 0;
     RefreshTimerUI();
     GameUI.GamePaused = true;
     Cursor.visible    = true;
     Cursor.lockState  = CursorLockMode.None;
     GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
     foreach (GameObject p in players)
     {
         Destroy(p.gameObject);
     }
     WinnerScreenCalculation();
     WinnerScreen.SetActive(true);
     if (PhotonNetwork.IsMasterClient)
     {
         leavegame.gameObject.SetActive(true);
         PhotonNetwork.CurrentRoom.IsVisible = false;
         PhotonNetwork.DestroyAll();
     }
 }
Ejemplo n.º 27
0
 public void Update()
 {
     if (SceneManager.GetActiveScene().name.Equals("Game Scene"))
     {
         if (PhotonNetwork.IsMasterClient)
         {
             // 사람 수 적음
             if ((PhotonNetwork.PlayerList.Length < readyCnt) || (checkBoss.Count == 0))
             {
                 PhotonNetwork.DestroyAll();
                 if (PhotonNetwork.InRoom)
                 {
                     PhotonNetwork.LeaveRoom();
                 }
             }
             else if (checkBoss.Count == PhotonNetwork.PlayerList.Length + 1)             // 게임 종료
             {
                 // 모두 보스됨
                 PhotonNetwork.DestroyAll();
                 if (PhotonNetwork.InRoom)
                 {
                     PhotonNetwork.LeaveRoom();
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
 private void OnTriggerEnter(Collider other)
 {
     if (PhotonNetwork.NickName == "VR" && other.CompareTag("VRPlayer"))
     {
         PhotonNetwork.DestroyAll();
         photonView.RPC("ReloadScenesForAllPlayers", RpcTarget.All);
     }
 }
Ejemplo n.º 29
0
 public void LuaBackToLobby()
 {
     PhotonNetwork.LeaveRoom();
     PhotonNetwork.OfflineMode = false;
     PhotonNetwork.LocalPlayer.CustomProperties.Clear();
     PhotonNetwork.DestroyAll(true);
     ExitGame();
 }
Ejemplo n.º 30
0
 public void LuaBackToRoom()
 {
     PhotonNetwork.DestroyAll();
     PhotonNetwork.CurrentRoom.CustomProperties.Clear();
     PhotonNetwork.CurrentRoom.IsOpen    = true;
     PhotonNetwork.CurrentRoom.IsVisible = true;
     PhotonNetwork.CurrentRoom.SetStartTime((int)PhotonNetwork.Time);
 }