예제 #1
0
        IEnumerator Start()
        {
            m_TwitchPlayerQueue.onValidated += m_TwitchPlayerQueue_onValidated;
            while (enabled)
            {
                if (m_Queue.Count > 0)
                {
                    string nick = m_Queue.Dequeue();
                    TwitchPlayerController playerController = SpawnPlayerPrefabs(nick);
                    m_MonitorStringsEvents.onStringArray.AddListener(playerController.OnDisplayNameChange);

                    m_MonitorNumberEvents.onTwitchCommand.AddListener(playerController.OnReset);

                    m_MonitorNumberEvents.onTwitchCommand.AddListener(playerController.OnMoveUniDirection);
                    m_MonitorNumberEvents.onTwitchCommand.AddListener(playerController.OnMove);
                }
                yield return(new WaitForSeconds(m_Rate));
            }
        }
예제 #2
0
        /// <summary>
        /// Spawn a user object for a player
        /// <para>Override in derived classes to Instantiate additional objects and associate them with the PlayerController</para>
        /// </summary>
        /// <param name="nick">The viewer requesting the spawn</param>
        protected virtual TwitchPlayerController SpawnPlayerPrefabs(string nick)
        {
            TwitchPlayerController playerController = GameObject.Instantiate <TwitchPlayerController>(m_PlayerController);

            playerController.StartNew(nick, m_Trans.position + m_Offset);
            playerController.gameObject.name = string.Concat(m_PlayerController.name, ".", nick);

            if (!m_Objects[nick].Contains(playerController.gameObject))
            {
                m_Objects[nick].Add(playerController.gameObject);
                PlayerPrefabInstantiated(playerController, playerController.gameObject);
            }

            for (int i = 0; i < m_Others.Length; i++)
            {
                GameObject otherGO = GameObject.Instantiate <GameObject>(m_Others[i]);
                if (!m_Objects[nick].Contains(otherGO))
                {
                    m_Objects[nick].Add(otherGO);
                    PlayerPrefabInstantiated(playerController, otherGO);
                }
            }
            return(playerController);
        }
예제 #3
0
 /// <summary>
 /// Gives derived classes an oppotunity to modify the GameObject
 /// </summary>
 /// <param name="playerController">Player controller created</param>
 /// <param name="playerGameObject">Player associated GameObject created</param>
 protected virtual void PlayerPrefabInstantiated(TwitchPlayerController playerController, GameObject playerGameObject)
 {
 }