コード例 #1
0
ファイル: SingSceneController.cs プロジェクト: eldan-dex/Play
    void Start()
    {
        LoadSceneData();

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in sceneData.SelectedPlayerProfiles)
        {
            sceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            CreatePlayerController(playerProfile, micProfile);
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog("Missing microphones", $"No microphone for player(s) {playerNameCsv}");
        }

        // Associate LyricsDisplayer with one of the (duett) players
        if (!PlayerControllers.IsNullOrEmpty())
        {
            LyricsDisplayer lyricsDisplayer = FindObjectOfType <LyricsDisplayer>();
            PlayerControllers[0].LyricsDisplayer = lyricsDisplayer;
        }

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());
    }
コード例 #2
0
 internal void SetPlayerController(QPlayerController player)
 {
     while (player.PlayerControllerId >= PlayerControllers.Count)
     {
         PlayerControllers.Add(new QPlayerController());
     }
     PlayerControllers[player.PlayerControllerId] = player;
 }
コード例 #3
0
    private void Start()
    {
        normalScript = Player.GetComponent <PlayerControllers>();
        //rotationScript = Player.GetComponent<PlayerScriptWithDifferentRotation>();
        // activateRotation = Player.GetComponent<ActivateRotation>();

        normalScript.enabled = true;
        // rotationScript.enabled = false;
    }
コード例 #4
0
ファイル: SingSceneController.cs プロジェクト: bmwalters/Play
    private void CreatePlayerController(PlayerProfile playerProfile, MicProfile micProfile)
    {
        string           voiceIdentifier  = GetVoiceIdentifier(playerProfile);
        PlayerController playerController = GameObject.Instantiate <PlayerController>(playerControllerPrefab);

        playerController.Init(sceneData.SelectedSongMeta, playerProfile, voiceIdentifier, micProfile);

        PlayerControllers.Add(playerController);
    }
コード例 #5
0
    private void CreatePlayerController(PlayerProfile playerProfile, MicProfile micProfile)
    {
        string           voiceName        = GetVoiceName(playerProfile);
        PlayerController playerController = GameObject.Instantiate <PlayerController>(playerControllerPrefab);

        sceneInjector.Inject(playerController);
        playerController.Init(playerProfile, voiceName, micProfile);

        PlayerControllers.Add(playerController);
    }
コード例 #6
0
    private void UpdateSongFinishedStats()
    {
        List <SongStatistic> songStatistics = PlayerControllers
                                              .Select(playerController => new SongStatistic(playerController.PlayerProfile.Name,
                                                                                            playerController.PlayerProfile.Difficulty,
                                                                                            playerController.PlayerScoreController.TotalScore))
                                              .ToList();

        statistics.RecordSongFinished(SongMeta, songStatistics);
    }
コード例 #7
0
        /// <summary>
        /// Обработчик события удаления игрока
        /// </summary>
        /// <param name="parPlayer">Удаленный игрок</param>
        private void OnPlayerRemovedHandler(MPlayer parPlayer)
        {
            MPlayerController foundPlayerController = PlayerControllers.FirstOrDefault(parX => parX.MPlayerRef == parPlayer);

            if (foundPlayerController == null)
            {
                return;
            }

            PlayerControllers.Remove(foundPlayerController);
        }
コード例 #8
0
    void Update()
    {
        PlayerControllers.ForEach(it => it.SetCurrentBeat(CurrentBeat));

        // TODO: Updating the pitch detection (including the dummy singers) for this frame must come after updating the current sentence.
        // Otherwise, a pitch event may be fired for a beat of the "previous" sentence where no note is expected,
        // afterwards the sentence changes (the note is expected now), but the pitch event is lost.

        if (Application.isEditor)
        {
            DummySingers.ForEach(it => it.UpdateSinging(CurrentBeat));
        }
    }
コード例 #9
0
    public void SkipToNextSentence()
    {
        double nextStartBeat = PlayerControllers.Select(it => it.GetNextStartBeat()).Min();

        if (nextStartBeat < 0)
        {
            return;
        }

        double targetPositionInMillis = BpmUtils.BeatToMillisecondsInSong(SongMeta, nextStartBeat) - 500;

        if (targetPositionInMillis > 0 && targetPositionInMillis > PositionInSongInMillis)
        {
            songAudioPlayer.PositionInSongInMillis = targetPositionInMillis;
        }
    }
コード例 #10
0
ファイル: MGgGameState.cs プロジェクト: closedsum/Gg
        public override void Init()
        {
            base.Init();

            GameObject gopc = MonoBehaviour.Instantiate(FCgManager_Prefab.Get().EmptyGameObject);

            gopc.name = "MGgPlayerController";
            PlayerControllers.Add(gopc.AddComponent <MGgPlayerController>());

            Player = (MGgPlayerController)PlayerControllers[0];

            Player.Index = 0;
            Player.Init();

            ICgManager_Projectile.Init(typeof(FCgManager_Projectile));
            ICgManager_Projectile.Get().TypeMap.Add(EGgProjectileType.Bullet, typeof(MGgProjectile));
            ICgManager_Projectile.Get().CreatePool(EGgProjectileType.Bullet, 10);
        }
コード例 #11
0
    public void SkipToNextSentence()
    {
        double nextStartBeat = PlayerControllers.Select(it => it.GetNextStartBeat()).Min();

        if (nextStartBeat < 0)
        {
            return;
        }

        // For debugging, go fast to next lyrics. In production, give the player some time to prepare.
        double offsetInMillis         = Application.isEditor ? 500 : 1500;
        double targetPositionInMillis = BpmUtils.BeatToMillisecondsInSong(SongMeta, nextStartBeat) - offsetInMillis;

        if (targetPositionInMillis > 0 && targetPositionInMillis > PositionInSongInMillis)
        {
            songAudioPlayer.PositionInSongInMillis = targetPositionInMillis;
        }
    }
コード例 #12
0
ファイル: InputManager.cs プロジェクト: AndrewWhite1/JAG
    private void Awake()
    {
        controls = new PlayerControllers();

        //setup movement input
        controls.Move.Jump.performed += ctx => Move(0);
        controls.Move.Left.performed += ctx => Move(1);
        controls.Move.Down.performed += ctx => Move(2);

        //setup Left Arm input
        controls.LeftArm.Rotate.performed += ctx => leftArmVector = ctx.ReadValue <Vector2>();
        controls.LeftArm.Rotate.performed += ctx => leftArmVector = Vector2.zero;
        controls.LeftArm.Pickup.performed += ctx => Pickup(false);
        controls.LeftArm.Use.performed    += ctx => Pickup(false);

        //setup Right Arm input
        controls.RightArm.Rotate.performed += ctx => rightArmVector = ctx.ReadValue <Vector2>();
        controls.RightArm.Rotate.performed += ctx => rightArmVector = Vector2.zero;
        controls.RightArm.Pickup.performed += ctx => Pickup(true);
        controls.RightArm.Use.performed    += ctx => Pickup(true);
    }
コード例 #13
0
    public void SkipToNextSingableNote()
    {
        IEnumerable <int> nextSingableNotes = PlayerControllers
                                              .Select(it => it.GetNextSingableNote(CurrentBeat))
                                              .Where(nextSingableNote => nextSingableNote != null)
                                              .Select(nextSingableNote => nextSingableNote.StartBeat);

        if (nextSingableNotes.Count() <= 0)
        {
            return;
        }
        int nextStartBeat = nextSingableNotes.Min();

        // For debugging, go fast to next lyrics. In production, give the player some time to prepare.
        double offsetInMillis         = Application.isEditor ? 500 : 1500;
        double targetPositionInMillis = BpmUtils.BeatToMillisecondsInSong(SongMeta, nextStartBeat) - offsetInMillis;

        if (targetPositionInMillis > 0 && targetPositionInMillis > PositionInSongInMillis)
        {
            SkipToPositionInSong(targetPositionInMillis);
        }
    }
コード例 #14
0
    private void InitLyricsDisplayers()
    {
        if (PlayerControllers.IsNullOrEmpty())
        {
            topLyricsDisplayer.gameObject.SetActive(false);
            bottomLyricsDisplayer.gameObject.SetActive(false);
            return;
        }

        bool needSecondLyricsDisplayer = SongMeta.GetVoices().Count > 1 && PlayerControllers.Count > 1;

        if (needSecondLyricsDisplayer)
        {
            topLyricsDisplayer.Init(PlayerControllers[0]);
            bottomLyricsDisplayer.Init(PlayerControllers[1]);
        }
        else
        {
            topLyricsDisplayer.gameObject.SetActive(false);
            bottomLyricsDisplayer.Init(PlayerControllers[0]);
        }
    }
コード例 #15
0
    public void OpenSongInEditor()
    {
        int maxBeatToScore = PlayerControllers
                             .Select(playerController => playerController.PlayerScoreController.NextBeatToScore)
                             .Max();

        SceneData.NextBeatToScore = Math.Max((int)CurrentBeat, maxBeatToScore);

        SceneData.PlayerProfileToScoreDataMap = new Dictionary <PlayerProfile, PlayerScoreControllerData>();
        foreach (PlayerController playerController in PlayerControllers)
        {
            SceneData.PlayerProfileToScoreDataMap.Add(playerController.PlayerProfile, playerController.PlayerScoreController.ScoreData);
        }

        SongEditorSceneData songEditorSceneData = new SongEditorSceneData();

        songEditorSceneData.PreviousSceneData      = SceneData;
        songEditorSceneData.PreviousScene          = EScene.SingScene;
        songEditorSceneData.PositionInSongInMillis = PositionInSongInMillis;
        songEditorSceneData.SelectedSongMeta       = SongMeta;
        SceneNavigator.Instance.LoadScene(EScene.SongEditorScene, songEditorSceneData);
    }
コード例 #16
0
ファイル: SingSceneController.cs プロジェクト: ST3ALth/Play
    void OnDisable()
    {
        if (sceneData.IsRestart)
        {
            sceneData.IsRestart            = false;
            sceneData.PositionInSongMillis = 0;
        }
        else
        {
            sceneData.PositionInSongMillis = PositionInSongInMillis;
        }

        if (mainOutputStream != null)
        {
            UnloadAudio();
        }

        if (videoPlayer != null)
        {
            videoPlayer.Stop();
        }

        PlayerControllers.Clear();
    }
コード例 #17
0
    public void Build()
    {
        firstSet = false;
        // Fetches other scripts for
        gameReset           = FindObjectOfType <GameReset>();
        adjacentBombChecker = FindObjectOfType <AdjacentBombChecker>();
        gameManager         = FindObjectOfType <GameManager>();
        floodCheck          = FindObjectOfType <FloodCheck>();
        playerControllers   = FindObjectOfType <PlayerControllers>();
        gridSizeX           = gameManager.gridSizeX;
        gridSizeZ           = gameManager.gridSizeZ;
        numberOfBombs       = gameManager.numberOfBombs;
        //bombDevide = gameManager.bombDevide;
        Grid = new int[gridSizeX, gridSizeZ];
        //numberOfBombs = ((gridSizeX * gridSizeZ) / bombDevide);
        for (int x = 0; x < gridSizeX; x++)
        {
            for (int z = 0; z < gridSizeZ; z++)
            {
                SpawnTile(x, z);
            }
        }
        // Initialize date for use in other scripts
        floodCheck.Initialize();
        adjacentBombChecker.Initialize();
        // Each tile knows their neighbors
        floodCheck.NeighbourAssigner();
        // Turns a set number of random safeTiles into bombTiles
        PlaceBombs();
        playerControllers.Initialize();
        // Checks every safe tile for bomb neighbors then adds the number to them
        adjacentBombChecker.CheckAdjacentBombs();
        // Sets the starting sprites
        foreach (TileSO singleTile in allTileSOs)
        {
            if (singleTile.numOfAdjacent == 0 && !firstSet && singleTile.type == Type.Safe)
            {
                singleTile.spriteHolder.gameObject.SetActive(true);
                singleTile.spriteHolder.sprite = singleTile.tileSprites[0];
                singleTile.spriteHolder.color  = Color.green;
                firstSet = true;
                firstTile.Add(singleTile);
                playerControllers.firstClick = false;
                playerControllers.firstTile  = firstTile;
            }
            else
            {
                singleTile.spriteHolder.gameObject.SetActive(true);
                singleTile.spriteHolder.sprite = singleTile.tileSprites[0];
                singleTile.spriteHolder.color  = Color.yellow;
            }
        }

        // Used to do 2 loops, figured just one was better
        //
        //foreach(TileSO singleTile in safeTileSOs)
        //{
        //    singleTile.spriteHolder.gameObject.SetActive(true);
        //    singleTile.spriteHolder.sprite = singleTile.tileSprites[0];
        //}
        // This was for testing purposes
        //foreach (TileSO singleSO in safeTileSOs)
        //{
        //    //singleSO.adjacentTMP.text = "[" + singleSO.coordX.ToString() + ","
        //    //    + singleSO.coordZ.ToString() + "]";
        //    singleSO.adjacentTMP.text = singleSO.numOfAdjacent.ToString();
        //    singleSO.adjacentTMP.gameObject.SetActive(true);
        //}
        //foreach(TileSO singleSO in bombTileSOs)
        //{
        //    singleSO.spriteHolder.color = Color.red;
        //    singleSO.spriteHolder.gameObject.SetActive(true);
        //}
    }
コード例 #18
0
    void Start()
    {
        string playerProfilesCsv = SceneData.SelectedPlayerProfiles.Select(it => it.Name).ToCsv();

        Debug.Log($"{playerProfilesCsv} start (or continue) singing of {SongMeta.Title} at {SceneData.PositionInSongInMillis} ms.");

        // Prepare columns and rows for player UI
        PlayerUiArea.SetupPlayerUiGrid(SceneData.SelectedPlayerProfiles.Count, playerUiArea.GetComponent <GridLayoutGroupCellSizer>());

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in SceneData.SelectedPlayerProfiles)
        {
            SceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            PlayerController playerController = CreatePlayerController(playerProfile, micProfile);

            if (SceneData.PlayerProfileToScoreDataMap.TryGetValue(playerProfile, out PlayerScoreControllerData scoreData))
            {
                playerController.PlayerScoreController.ScoreData = scoreData;
            }
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog("Missing microphones", $"No microphone for player(s) {playerNameCsv}");
        }

        // Associate LyricsDisplayer with one of the (duett) players
        if (!PlayerControllers.IsNullOrEmpty())
        {
            LyricsDisplayer lyricsDisplayer = FindObjectOfType <LyricsDisplayer>();
            lyricsDisplayer?.Init(PlayerControllers[0]);
        }

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());

        // Rebuild whole UI
        LayoutRebuilder.ForceRebuildLayoutImmediate(CanvasUtils.FindCanvas().GetComponent <RectTransform>());
    }
コード例 #19
0
 public MoveActions(PlayerControllers wrapper)
 {
     m_Wrapper = wrapper;
 }
コード例 #20
0
ファイル: DontDestroyOnLoad.cs プロジェクト: apelofff/KUB
 // Use this for initialization
 void Start()
 {
     playerController = GetComponent <PlayerControllers>();
     playerTransforme = GetComponent <Transform>();
 }
コード例 #21
0
 void Update()
 {
     PlayerControllers.ForEach(it => it.SetCurrentBeat(CurrentBeat));
 }
コード例 #22
0
ファイル: SingSceneController.cs プロジェクト: ST3ALth/Play
 void Update()
 {
     timeOfLastMeasuredPositionInSongInMillis += Time.deltaTime * 1000.0f;
     PlayerControllers.ForEach(it => it.SetPositionInSongInMillis(PositionInSongInMillis));
 }
コード例 #23
0
 public RightArmActions(PlayerControllers wrapper)
 {
     m_Wrapper = wrapper;
 }
コード例 #24
0
 /// <summary>
 /// Обработчик события добавления нового игрока
 /// </summary>
 /// <param name="parPlayer">Новый игрок</param>
 private void OnPlayerAddedHandler(MPlayer parPlayer)
 {
     PlayerControllers.Add(new MPlayerController(parPlayer));
 }
コード例 #25
0
 // Use this for initialization
 void Start()
 {
     thePlayer          = FindObjectOfType <PlayerControllers>();
     lastPlayerPosition = thePlayer.transform.position;
 }
コード例 #26
0
ファイル: PlayerCore.cs プロジェクト: mireles001/quediaes
 void Awake()
 {
     _controller = GetComponent <PlayerControllers>();
 }