public override void OnEnter()
        {
            tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

            if (module != null)
            {
                int            gameModeId   = module.gameModeId;
                tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

                if (gameModeData != null)
                {
                    int          camerasSetId = gameModeData.camerasSetId;
                    tnCamerasSet camerasSet   = tnGameData.GetCameraSetMain(camerasSetId);

                    if (camerasSet != null)
                    {
                        int           stadiumId   = module.stadiumId;
                        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

                        if (stadiumData != null)
                        {
                            GameObject cameraPrefab = camerasSet.GetCamera(stadiumData.cameraId);

                            if (cameraPrefab != null)
                            {
                                if (storeResult != null && !storeResult.IsNone)
                                {
                                    storeResult.Value = cameraPrefab.gameObject;
                                }
                            }
                        }
                    }
                }
            }

            Finish();
        }
Ejemplo n.º 2
0
    private void CreateCamera()
    {
        GameObject spawnPointGo = GameObject.Find(s_Camera_SpawnPoint_Name);

        Vector3 spawnPointPosition = (spawnPointGo != null) ? spawnPointGo.transform.position : Vector3.zero;

        spawnPointPosition.z = -15f;

        tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>();

        if (matchSettingsModule == null)
        {
            return;
        }

        int            gameModeId   = matchSettingsModule.gameModeId;
        tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId);

        if (gameModeData == null)
        {
            return;
        }

        int          cameraSetId = gameModeData.camerasSetId;
        tnCamerasSet cameraSet   = tnGameData.GetCameraSetMain(cameraSetId);

        if (cameraSet == null)
        {
            return;
        }

        int           stadiumId   = matchSettingsModule.stadiumId;
        tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId);

        if (stadiumData == null)
        {
            return;
        }

        GameObject cameraPrefab = cameraSet.GetCamera(stadiumData.cameraId);

        if (cameraPrefab == null)
        {
            return;
        }

        m_GameCameraGO      = Instantiate <GameObject>(cameraPrefab);
        m_GameCameraGO.name = "GameCamera";
        m_GameCameraGO.tag  = "GameCamera";

        tnGameCamera gameCamera = m_GameCameraGO.GetComponent <tnGameCamera>();

        if (gameCamera != null)
        {
            gameCamera.SetPosition(spawnPointPosition);
        }
        else
        {
            m_GameCameraGO.transform.position = spawnPointPosition;
        }

        m_GameCameraGO.transform.rotation = Quaternion.identity;
    }