Exemplo n.º 1
0
        private void Start()
        {
            //Get some bits from the indicator game object
            _indicator = Instantiate(Resources.Load <GameObject>("SpeechIndicator"));
            _indicator.transform.SetParent(transform);
            _indicator.transform.localPosition = new Vector3(0, 3, 0);

            _light     = _indicator.GetComponent <Light>();
            _transform = _indicator.GetComponent <Transform>();

            //Find the component attached to this game object which marks it as a Dissonance player representation
            _player = GetComponent <IDissonancePlayer>();

            StartCoroutine(FindPlayerState());
        }
        private void OnEnable()
        {
            // Try to find the sibling AudioListener, if there is not one then disable this script
            _listener = GetComponent <AudioListener>();
            if (_listener == null)
            {
                enabled = false;
                return;
            }

            // Try to find the `IDissonancePlayer`, if there is not one then disable this script
            _player = GetComponentInParent <IDissonancePlayer>();
            if (_player == null)
            {
                enabled = false;
                return;
            }
        }
Exemplo n.º 3
0
        public void AddTracker([NotNull] IDissonancePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player", "Cannot track a null player");
            }

            //Associate tracker with player state
            VoicePlayerState state;

            if (_players.TryGet(player.PlayerId, out state))
            {
                state.Tracker = player;
                Log.Debug("Associated position tracking for '{0}'", player.PlayerId);
            }
            else
            {
                _unlinkedPlayerTrackers[player.PlayerId] = player;
                Log.Debug("Got a player tracker for player '{0}' but that player doesn't exist yet", player.PlayerId);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Enable position tracking for the player represented by the given object
        /// </summary>
        /// <param name="player"></param>
        public void TrackPlayerPosition(IDissonancePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player", "Cannot track a null player");
            }

            //Associate tracker with player state
            var state = FindPlayer(player.PlayerId);

            if (state != null)
            {
                state.Tracker = player;
                Log.Debug("Associated position tracking for '{0}'", player.PlayerId);
            }
            else
            {
                _unlinkedPlayerTrackers.Add(player.PlayerId, player);
                Log.Debug("Got a player tracker for player '{0}' but that player doesn't exist yet", player.PlayerId);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stop position tracking for the player represented by the given object
        /// </summary>
        /// <param name="player"></param>
        public void StopTracking(IDissonancePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player", "Cannot stop tracking a null player");
            }

            //Try to remove the player from the list of untracked players, just in case we haven't linked it up yet
            if (_unlinkedPlayerTrackers.Remove(player.PlayerId))
            {
                Log.Debug("Removed unlinked state tracker for '{0}' (because StopTracking called)", player.PlayerId);
            }

            //Disassociate the tracker from the player state
            var state = FindPlayer(player.PlayerId);

            if (state != null)
            {
                state.Tracker = null;
                Log.Debug("Disassociated position tracking for '{0}' (because StopTracking called)", player.PlayerId);
            }
        }
Exemplo n.º 6
0
        public void RemoveTracker([NotNull] IDissonancePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player", "Cannot stop tracking a null player");
            }

            //Try to remove the player from the list of untracked players, just in case we haven't linked it up yet
            if (_unlinkedPlayerTrackers.Remove(player.PlayerId))
            {
                Log.Debug("Removed unlinked state tracker for '{0}' (because RemoveTracker called)", player.PlayerId);
            }
            else
            {
                //Disassociate the tracker from the player state
                VoicePlayerState state;
                if (_players.TryGet(player.PlayerId, out state))
                {
                    state.Tracker = null;
                    Log.Debug("Disassociated position tracking for '{0}' (because RemoveTracker called)", player.PlayerId);
                }
            }
        }
Exemplo n.º 7
0
        protected override void Start()
        {
            base.Start();

            _self = GetComponent <IDissonancePlayer>() ?? GetComponentInParent <IDissonancePlayer>();
        }
Exemplo n.º 8
0
 /// <summary>
 /// Stop position tracking for the player represented by the given object
 /// </summary>
 /// <param name="player"></param>
 public void StopTracking([NotNull] IDissonancePlayer player)
 {
     _playerTrackers.RemoveTracker(player);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Enable position tracking for the player represented by the given object
 /// </summary>
 /// <param name="player"></param>
 public void TrackPlayerPosition([NotNull] IDissonancePlayer player)
 {
     _playerTrackers.AddTracker(player);
 }