Пример #1
0
        /// <summary>
        /// Removes the multi-input at <see cref="P:ith"/> index if it is in the <see cref="P:MultiInputs"/> array.
        /// </summary>
        /// <returns><c>true</c>, if the multi-input was removed, <c>false</c> otherwise.</returns>
        /// <param name="i">The index.</param>
        public override bool RemoveMultiInputAt(int i)
        {
            // Check the i.
            if (i < 0)
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] The parameter, i, cannot be lower than 0.");
                }
                return(false);
            }
            else if (i >= MultiInputs.Length)
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] The parameter, i, cannot be greater than or equal to the length of the MultiInputs.");
                }
                return(false);
            }

            // Check the length.
            if (MultiInputs.Length == 0)
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input left in the MultiInputs array.");
                }
                return(false);
            }

            // Remove the multi-input at i.
            ToryMultiInput <int> mi = multiInputList.Find((obj) => { return(obj.Id.Equals(MultiInputs[i].Id)); });

            if (mi != null && multiInputList.Remove(mi))
            {
                MultiInputs       = multiInputList.ToArray();
                mi.ValueReceived -= TriggerMultiInputValueReceivedEvent;
                mi.Interacted    -= TriggerMultiInputInteractedEvent;

                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] The multi-input of ID " + mi.Id + " removed.");
                }

                // Trigger an event.
                TriggerMultiInputRemoved(mi);

                return(true);
            }
            else
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input of ID " + mi.Id + " in the MultiInputs array");
                }
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Removes the multi-inputs of <see cref="P:Id"/>  if they are in the <see cref="P:MultiInputs"/> array.
        /// </summary>
        /// <returns><c>true</c>, if the multi-inputs were removed, <c>false</c> otherwise.</returns>
        /// <param name="id">Identifier.</param>
        public override bool RemoveMultiInput(int id)
        {
            // Check the length.
            if (MultiInputs.Length == 0)
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input left in the MultiInputs array.");
                }
                return(false);
            }

            // Remove the multi-input of the id.
            ToryMultiInput <int> mi = multiInputList.Find((obj) => { return(obj.Id.Equals(id)); });

            if (mi != null && multiInputList.Remove(mi))
            {
                MultiInputs       = multiInputList.ToArray();
                mi.ValueReceived -= TriggerMultiInputValueReceivedEvent;
                mi.Interacted    -= TriggerMultiInputInteractedEvent;

                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] The multi-input of ID " + mi.Id + " removed.");
                }

                // Trigger an event.
                TriggerMultiInputRemoved(mi);

                return(true);
            }
            // If not exist int the list.
            else
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input of ID " + mi.Id + " in the MultiInputs array");
                }
                return(false);
            }
        }
Пример #3
0
        protected virtual void Init()
        {
            // Multi-input
            multiInputList = new List <ToryMultiInput <T> >();
            MultiInputs    = new ToryMultiInput <T> [0];

            // Add an time event handler.
            ToryTime.Instance.InteractionCheckTimerTimedOut += OnInteractionCheckTimerTimedOut;

            // Add an scene event handler.
            ToryScene.Instance.Ended += OnSceneEnded;

            // Load saved values.
            InteractionType.LoadSavedValue();
            Gain.LoadSavedValue();
            FilterType.LoadSavedValue();
            OEFFrequency.LoadSavedValue();
            EnsembleSize.LoadSavedValue();
            MinimumInteraction.LoadSavedValue();
            MaxMultiInputCount.LoadSavedValue();
        }
Пример #4
0
        /// <summary>
        /// Removes the specified multi-input if it is in the <see cref="P:MultiInputs"/> array.
        /// </summary>
        /// <returns><c>true</c>, if the specified multi-input was removed, <c>false</c> otherwise.</returns>
        /// <param name="input">Input.</param>
        public override bool RemoveMultiInput(ToryMultiInput <int> input)
        {
            // Check the length.
            if (MultiInputs.Length == 0)
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input left in the MultiInputs array.");
                }
                return(false);
            }

            // Remove the multi-input.
            if (multiInputList.Remove(input))
            {
                MultiInputs          = multiInputList.ToArray();
                input.ValueReceived -= TriggerMultiInputValueReceivedEvent;
                input.Interacted    -= TriggerMultiInputInteractedEvent;

                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] The multi-input of ID " + input.Id + " removed.");
                }

                // Trigger an event.
                TriggerMultiInputRemoved(input);

                return(true);
            }
            // If not exist in the list.
            else
            {
                if (FrameworkBehaviour.CanShowLog)
                {
                    Debug.Log("[ToryInput] No multi-input of ID " + input.Id + " in the MultiInputs array");
                }
                return(false);
            }
        }
Пример #5
0
 protected void TriggerInteractedEvent(ToryMultiInput <T> input)
 {
     Interacted(input);
 }
Пример #6
0
        // Event Triggers.

        protected void TriggerValueReceivedEvent(ToryMultiInput <T> input, T processedValue)
        {
            ValueReceived(input, processedValue);
        }
Пример #7
0
 protected void TriggerMultiInputRemoved(ToryMultiInput <T> input)
 {
     MultiInputRemoved(input);
     TriggerMultiInputInteractedEvent(input);
 }
Пример #8
0
 /// <summary>
 /// Removes the specified multi-input if it is in the <see cref="P:MultiInputs"/> array.
 /// </summary>
 /// <returns><c>true</c>, if the specified multi-input was removed, <c>false</c> otherwise.</returns>
 /// <param name="input">Input.</param>
 public abstract bool RemoveMultiInput(ToryMultiInput <T> input);