Beispiel #1
0
    public void BackButton()
    {
//		CancelInvoke ();

//		if (getCustomPropertiesClass() != CHARACTER_CLASS.NULL || getCustomPropertiesTeam() != TEAM.NULL) {
//			RoomLevelHelper.SetRoomCustomPropertyPlayerClass (RoomLevelHelper.PLAYER_CLASS, true, RoomLevelHelper.PLAYER_TEAM);
////			print ("setting true : " + RoomLevelHelper.PLAYER_CLASS.ToString () + ", " + RoomLevelHelper.PLAYER_TEAM.ToString ());
//		} else
//			print ("NULL NOW");

        if (RoomLevelHelper.PLAYER_CLASS != CHARACTER_CLASS.NULL || RoomLevelHelper.PLAYER_TEAM != TEAM.NULL)
        {
            RoomLevelHelper.SetRoomCustomPropertyPlayerClass(RoomLevelHelper.PLAYER_CLASS, true, RoomLevelHelper.PLAYER_TEAM);
        }

        _playButton.interactable = false;
        DeselectAllClassButtons();

        Invoke("leaveRoom", 0.2f);
//		PhotonNetwork.LeaveRoom ();

        foreach (var btn in _ClassButtons)
        {
            btn.GetComponent <Button> ().interactable = true;
        }
    }
Beispiel #2
0
    /// <summary>
    /// Called after disconnecting from the Photon server.
    /// </summary>
    /// <remarks>In some cases, other callbacks are called before OnDisconnectedFromPhoton is called.
    /// Examples: OnConnectionFail() and OnFailedToConnectToPhoton().</remarks>
    public override void OnDisconnectedFromPhoton()
    {
//		print ("disconnected");
        base.OnDisconnectedFromPhoton();
        Cursor.lockState = CursorLockMode.None;
        StartCoroutine(CoroutineHelper.IELoadAsyncScene(RoomLevelHelper.GetSceneName(RoomLevelHelper.SCENE.MAIN_MENU)));
    }
Beispiel #3
0
    public void StartSinglePlayer(/*RoomLevelHelper.SCENE scene*/)
    {
//		if (!_startSceneLocked) {
//			StartCoroutine (CoroutineHelper.IELoadAsyncScene (sceneName));
//			_startSceneLocked = true;
//		}
        if (!_startSceneLocked)
        {
            PhotonNetwork.Disconnect();
            PhotonNetwork.offlineMode = true;
            MainMenuController.MMC.StartScene(RoomLevelHelper.GetSceneName(RoomLevelHelper.SCENE.PRISON /*scene*/));
            _startSceneLocked = true;
        }
    }
Beispiel #4
0
    //dev controlls
    void Update()
    {
                #if UNITY_EDITOR
        if (PhotonNetwork.isMasterClient)
        {
            if (Input.GetKeyUp(KeyCode.P))
            {
                if (AIController.AIC.GetIsAIMovementAllowed())
                {
                    AIController.AIC.SetIsAIMovementAllowed(false);
                }
                else
                {
                    AIController.AIC.SetIsAIMovementAllowed(true);
                }
            }
        }
        if (GameController.GC.CurrentPlayerCharacter == null)
        {
            if (GameController.GC.IsGameOver)
            {
                if (Input.GetKeyUp(KeyCode.Q))
                {
                    Cursor.lockState = CursorLockMode.None;
                    StartCoroutine(CoroutineHelper.IELoadAsyncScene(RoomLevelHelper.GetSceneName(RoomLevelHelper.SCENE.SURVEY)));
                }
            }
            else
            {
//				if (Input.GetKeyUp (KeyCode.R)) {
//					UIController.SINGLETON.SetDevText ("");
//					NetworkManager.SINGLETON.spawnPlayer ();
//
//					if (RoomLevelHelper.ROOMTYPE == ROOM_TYPE.COOP) {
//						GameController.GC.SetLives (GameController.GC.Lives - 1);
//					} else {
////						if (RoomLevelHelper.PLAYER_TEAM == TEAM.ONE) {
////							PvpManager.SINGLETON.SetTeamLife (PvpManager.SINGLETON.Team_1_Life - 1, PvpManager.SINGLETON.Team_2_Life);
////						} else if (RoomLevelHelper.PLAYER_TEAM == TEAM.TWO) {
////							PvpManager.SINGLETON.SetTeamLife (PvpManager.SINGLETON.Team_1_Life, PvpManager.SINGLETON.Team_2_Life - 1);
////						}
//					}
//				}
            }
        }
                #endif
    }
Beispiel #5
0
    /// <summary>
    /// Selects This Character Class
    /// </summary>
    public void SelectClass()
    {
        if (RoomLevelHelper.PLAYER_CLASS != CHARACTER_CLASS.NULL || RoomLevelHelper.PLAYER_TEAM != TEAM.NULL)
        {
            RoomLevelHelper.SetRoomCustomPropertyPlayerClass(RoomLevelHelper.PLAYER_CLASS, true, RoomLevelHelper.PLAYER_TEAM);
        }
        else
        {
//			print ("NULL");
        }

        //deselect all other buttons(visual)
        _uisc.DeselectAllClassButtons();

//		//mark as selected(visual only)
//		_btn.image.color = _btn.colors.highlightedColor;

        _uisc.SetSelectedClass(_class, _team);
    }
Beispiel #6
0
    /// <summary>
    /// Select a class by interacting with UI(button for instance)
    /// </summary>
    /// <param name="newClass">New class.</param>
    public void SetSelectedClass(CHARACTER_CLASS newClass, TEAM team)
    {
        //todo: maybe not here, but add a feature that continuesly check if the certain character is not taken(by another player joining and selecting simultaniously).
//		_selectedClass = newClass;
        //Save the selected class
        RoomLevelHelper.PLAYER_CLASS = newClass;
        RoomLevelHelper.PLAYER_TEAM  = team;

        setPlayerCustomProperties(newClass, team);

        RoomLevelHelper.SetRoomCustomPropertyPlayerClass(RoomLevelHelper.PLAYER_CLASS, false, RoomLevelHelper.PLAYER_TEAM);


        if ((bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_MASTER_IN_GAME] || PhotonNetwork.isMasterClient)
        {
            //enable loading a scene since class has been selected
            _playButton.interactable = true;
        }
    }
Beispiel #7
0
    /// <summary>
    /// Called when a remote player left the room. This PhotonPlayer is already removed from the playerlist at this time.
    /// </summary>
    /// <remarks>When your client calls PhotonNetwork.leaveRoom, PUN will call this method on the remaining clients.
    /// When a remote client drops connection or gets closed, this callback gets executed. after a timeout
    /// of several seconds.</remarks>
    /// <param name="player">Player.</param>
    public override void OnPhotonPlayerDisconnected(PhotonPlayer player)
    {
        base.OnPhotonPlayerDisconnected(player);
        Debug.Log("Player Disconnected " + player.name + ", PlayerCharacterList : " + PlayerCharacterStatusHandler.Get_PVs().Count);
        //Destroy player character when leaving a room
        List <PhotonView> pvlist = new List <PhotonView> ();

        foreach (var pv in PlayerCharacterStatusHandler.Get_PVs())
        {
            //seems like owner is null when the player is disconnected
            //or transfered ownership to sceneview
            //or still has old owner info
            if (pv.owner == null || pv.isSceneView || pv.owner == player)
            {
                pvlist.Add(pv);
//				print ("Owner found, deleting owener objects");
            }
//			//dev
//			print("owner id : " + pv.ownerId +", owner name : " + pv.owner.name + ", disconnected player id : " + player.ID);
        }

        //new master takes control of destroying disconnect player character
        if (PhotonNetwork.isMasterClient)
        {
            foreach (var pp in pvlist)
            {
                if (pp.GetComponent <PlayerCombatHandler> () != null)
                {
                    RoomLevelHelper.SetRoomCustomPropertyPlayerClass(pp.GetComponent <PlayerCombatHandler> ().GetClass(), true, pp.GetComponent <PlayerCombatHandler> ().GetTeam());
                }
                PhotonNetwork.Destroy(pp);
                PhotonNetwork.RemoveRPCs(pp);
//				_photonView.RPC ("RPC_Remove_Photon_View_List_Player", PhotonTargets.All, pp.viewID);
                Remove_Photon_View_List_Player(pp);
            }
        }
    }
Beispiel #8
0
    /// <summary>
    /// Loads the scene which is determined by when creating or joining existing room
    /// </summary>
    public void LoadScene()
    {
//		RoomLevelHelper.SCENE currentLevel = (RoomLevelHelper.SCENE)RoomLevelHelper.ROOM_INFO.customProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_CURRENT_SCENE];
        RoomLevelHelper.SCENE currentLevel = RoomLevelHelper.CURRENT_SCENE;
        MainMenuController.MMC.StartScene(RoomLevelHelper.GetSceneName(currentLevel));
    }
Beispiel #9
0
    public override void OnJoinedRoom()
    {
        base.OnJoinedRoom();

        //ready to receieve RPC calls
        PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable()
        {
            {
                RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_IN_GAME_SCENE,
                true
            }
        });

        if (!PhotonNetwork.isMasterClient)
        {
            updatePVs();
            //find randome available team & class
            bool warriorAvail       = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE];
            bool tankAvail          = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE];
            bool archerAvail        = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE];
            bool warriorAvail_Team2 = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE_TEAM_2];
            bool tankAvail_Team2    = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE_TEAM_2];
            bool archerAvail_Team2  = (bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE_TEAM_2];

            if (warriorAvail_Team2)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.WARRIOR;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.TWO;
            }
            else if (warriorAvail)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.WARRIOR;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.ONE;
            }
            else if (tankAvail_Team2)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.TANK;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.TWO;
            }
            else if (tankAvail)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.TANK;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.ONE;
            }
            else if (archerAvail)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.ARCHER;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.ONE;
            }
            else if (archerAvail_Team2)
            {
                RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.ARCHER;
                RoomLevelHelper.PLAYER_TEAM  = TEAM.TWO;
            }
            else
            {
                print("NO AVAILABLE CLASS and team");
            }
        }
        else
        {
            RoomLevelHelper.PLAYER_CLASS = CHARACTER_CLASS.WARRIOR;
            RoomLevelHelper.PLAYER_TEAM  = TEAM.ONE;

            PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable()
            {
                //			{ RoomLevelHelper.CUSTOM_ROOM_PROPERTY_CURRENT_LEVEL, RoomLevelHelper.LEVEL_PRISON_HASH },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_CURRENT_SCENE, RoomLevelHelper.CURRENT_SCENE },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE, false },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE, true },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE, true },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE_TEAM_2, true },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE_TEAM_2, true },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE_TEAM_2, true },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_ROOM_TYPE, RoomLevelHelper.ROOMTYPE },
                { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_MASTER_IN_GAME, true }
            });

//			PhotonNetwork.room.SetCustomProperties (new ExitGames.Client.Photon.Hashtable () { {
//					RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_MASTER_IN_GAME,
//					true
//				}
//			});
        }

        RoomLevelHelper.SetRoomCustomPropertyPlayerClass(RoomLevelHelper.PLAYER_CLASS, false, RoomLevelHelper.PLAYER_TEAM);

        PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable()
        {
            {
                RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_CLASS,
                RoomLevelHelper.PLAYER_CLASS
            }, {
                RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_TEAM,
                RoomLevelHelper.PLAYER_TEAM
            }, {
                RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_HEALTH,
                0
            }
        });

        //get random available class & team
    }