Example #1
0
        /// <summary> override object's Equals() method </summary>
        public override bool Equals(object obj)
        {
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            LoopState oState = obj as LoopState;

            return(Name == oState.Name && Index == oState.Index && SelfTransitions == oState.SelfTransitions);
        }
Example #2
0
        /// <summary> LoopState Setter
        /// (calling it rather than _state will ensure variables that need to be changed and
        /// methods() that need to be called with the LoopState are
        /// Will discuss my struggle with information hiding vs. principle of least suprise in interview
        /// </summary>
        /// <exception cref="ArgumentNullException"> Thrown if NewLoopState is null </exception>
        /// <exception cref="MultipleActiveLoopsInFGException">
        /// Thrown if after method, multiple loops associated with one fg are now active </exception>
        private void SetLoopState(LoopState value, uint currMeasure)
        {
            //Preconditions
            if (value == null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", value),
                                                "value");
            }

            //Change State
            this._state = value;

            //Every time Loop State is changed, must also:
            mat.BeginAnimation();
            this.measureOfLastStateChange = currMeasure;
            Console.WriteLine("Set MusicalLoop's new state to: " + _state.Name);

            if (!lFGHashMap.CheckMaxOneActiveFGLoop(funcGroup))
            {
                throw new MultipleActiveLoopsInFGException(funcGroup.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// Method called to handle NewMeasureEvent:
        /// - Makes prevLoop Inactive,
        /// - Updates to nextState if necessary
        /// </summary>
        /// <param name="source"> (Object) object which triggered the event </param>
        /// <param name="e"> (NewMeasureEventArgs) arguments associated with event </param>
        public void OnNewMeasureEvent(object source, NewMeasureEventArgs e)
        {
            if (!phasingOut)
            {
                Console.WriteLine("Musical Loop recieved NewMeasureEvent!");
                LoopState lState = GetLoopState();

                if (lState.Name.Equals("Syncing"))
                {
                    if (prevLoop != null)
                    {
                        prevLoop.SetInactive(e.TotalMeasures);
                        prevLoop = null;
                    }
                    particleSystem.PlayQueuedEffects();
                }

                LoopState newState = lState.NewMeasureHandler(e.TotalMeasures, measureOfLastStateChange);
                if (newState != null)
                {
                    SetLoopState(newState, e.TotalMeasures);
                }
            }
        }