public ActionColorProgression GetColourProg(List<LetterAction> letter_actions, ActionColorProgression defaultColourProg) { if (m_action_index < 0 && m_data_type == ANIMATION_DATA_TYPE.COLOUR) { // Marked as using the default text colouring return defaultColourProg; } if (m_action_index >= letter_actions.Count) return null; LetterAction letter_action = letter_actions [m_action_index]; switch (m_data_type) { case ANIMATION_DATA_TYPE.COLOUR: return m_start_state ? letter_action.m_start_colour : letter_action.m_end_colour; } return null; }
public void PrepareData(TextFxAnimationManager anim_manager, ref LetterSetup[] letters, LetterAnimation animation_ref, int action_idx, ANIMATION_DATA_TYPE what_to_update, int num_letters, int num_white_space_chars_to_include, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, ActionColorProgression defaultTextColour, bool prev_action_end_state = true) { // Set progression reference datas m_start_colour.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.COLOUR, true); m_start_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_ROTATION, true); m_start_pos.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.POSITION, true); m_start_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_SCALE, true); m_global_start_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_ROTATION, true); m_global_start_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_SCALE, true); m_end_colour.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.COLOUR, false); m_end_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_ROTATION, false); m_end_pos.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.POSITION, false); m_end_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_SCALE, false); m_global_end_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_ROTATION, false); m_global_end_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_SCALE, false); // Prepare Data if(what_to_update == ANIMATION_DATA_TYPE.DURATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.AnimatePer, m_duration_progression.OverrideAnimatePerOption)); if((what_to_update == ANIMATION_DATA_TYPE.AUDIO_EFFECTS || what_to_update == ANIMATION_DATA_TYPE.ALL) && m_audio_effects != null) { foreach(AudioEffectSetup effect_setup in m_audio_effects) { effect_setup.m_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_delay.AnimatePer, effect_setup.m_delay.OverrideAnimatePerOption)); effect_setup.m_offset_time.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_offset_time.AnimatePer, effect_setup.m_offset_time.OverrideAnimatePerOption)); effect_setup.m_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_volume.AnimatePer, effect_setup.m_volume.OverrideAnimatePerOption)); effect_setup.m_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_pitch.AnimatePer, effect_setup.m_pitch.OverrideAnimatePerOption)); } } if((what_to_update == ANIMATION_DATA_TYPE.PARTICLE_EFFECTS || what_to_update == ANIMATION_DATA_TYPE.ALL) && m_particle_effects != null) { foreach(ParticleEffectSetup effect_setup in m_particle_effects) { effect_setup.m_position_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_position_offset.AnimatePer, effect_setup.m_position_offset.OverrideAnimatePerOption), null); effect_setup.m_rotation_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_rotation_offset.AnimatePer, effect_setup.m_rotation_offset.OverrideAnimatePerOption), null); effect_setup.m_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_delay.AnimatePer, effect_setup.m_delay.OverrideAnimatePerOption)); effect_setup.m_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_duration.AnimatePer, effect_setup.m_duration.OverrideAnimatePerOption)); } } if(m_action_type == ACTION_TYPE.BREAK) { if(prev_action != null) { m_start_colour.SetValueReference(prev_action_end_state ? prev_action.m_end_colour : prev_action.m_start_colour); m_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_end_euler_rotation : prev_action.m_start_euler_rotation ); m_start_pos.SetValueReference( prev_action_end_state ? prev_action.m_end_pos : prev_action.m_start_pos ); m_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_end_scale : prev_action.m_start_scale ); m_global_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_global_end_euler_rotation : prev_action.m_global_start_euler_rotation ); m_global_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_global_end_scale : prev_action.m_global_start_scale ); } m_end_colour.SetValueReference(m_start_colour); m_end_euler_rotation.SetValueReference(m_start_euler_rotation ); m_end_pos.SetValueReference( prev_action.m_start_pos ); m_end_scale.SetValueReference( prev_action.m_start_scale ); m_global_end_euler_rotation.SetValueReference(prev_action.m_global_start_euler_rotation ); m_global_end_scale.SetValueReference( prev_action.m_global_start_scale ); return; } if (animation_ref.m_letters_to_animate_option != LETTERS_TO_ANIMATE.ALL_LETTERS || (((ValueProgression)m_delay_progression.Progression) != ValueProgression.Eased && ((ValueProgression)m_delay_progression.Progression) != ValueProgression.EasedCustom)) m_delay_with_white_space_influence = false; if(what_to_update == ANIMATION_DATA_TYPE.DELAY || what_to_update == ANIMATION_DATA_TYPE.ALL) m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters + (m_delay_with_white_space_influence ? num_white_space_chars_to_include : 0), num_words, num_lines, animate_per, m_delay_progression.AnimatePer, m_delay_progression.OverrideAnimatePerOption)); if(what_to_update == ANIMATION_DATA_TYPE.COLOUR || what_to_update == ANIMATION_DATA_TYPE.ALL) { if(m_offset_from_last && prev_action != null) { m_start_colour.SetValueReference(prev_action_end_state ? prev_action.m_end_colour : prev_action.m_start_colour ); } else { m_start_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_colour.AnimatePer, m_start_colour.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_colour : defaultTextColour, prev_action == null || m_colour_transition_active); } m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.AnimatePer, m_end_colour.OverrideAnimatePerOption), m_start_colour, prev_action == null || m_colour_transition_active); } if(m_offset_from_last && prev_action != null) { if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_pos.SetValueReference( prev_action_end_state ? prev_action.m_end_pos : prev_action.m_start_pos ); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_end_euler_rotation : prev_action.m_start_euler_rotation ); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_end_scale : prev_action.m_start_scale ); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_global_end_euler_rotation : prev_action.m_global_start_euler_rotation ); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_global_end_scale : prev_action.m_global_start_scale ); } else { float[] start_pos_curve_letter_progressions = null; if( ( what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL ) && m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX) { // Pre calculate letter progression values based on letter spacing start_pos_curve_letter_progressions = m_start_pos.BezierCurve.GetLetterProgressions(anim_manager, ref letters, m_letter_anchor_start); } if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_pos.CalculatePositionProgressions( anim_manager, animation_ref, ref start_pos_curve_letter_progressions, letters, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_pos.AnimatePer, m_start_pos.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_pos : null, prev_action == null || m_position_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_euler_rotation.AnimatePer, m_start_euler_rotation.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_euler_rotation : null, m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_start_pos.BezierCurve : null, prev_action == null || m_local_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_scale.AnimatePer, m_start_scale.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_scale : null, prev_action == null || m_local_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_start_euler_rotation.AnimatePer, m_global_start_euler_rotation.OverrideAnimatePerOption), prev_action != null ? prev_action.m_global_end_euler_rotation : null, null, prev_action == null || m_global_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_scale.CalculateProgressions( GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_start_scale.AnimatePer, m_global_start_scale.OverrideAnimatePerOption), prev_action != null ? prev_action.m_global_end_scale : null, prev_action == null || m_global_scale_transition_active); } float[] end_pos_curve_letter_progressions = null; if( ( what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL ) && m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX) { // Pre calculate letter progression values based on letter spacing end_pos_curve_letter_progressions = m_end_pos.BezierCurve.GetLetterProgressions(anim_manager, ref letters, m_letter_anchor_end); } if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_pos.CalculatePositionProgressions(anim_manager, animation_ref, ref end_pos_curve_letter_progressions, letters, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_pos.AnimatePer, m_end_pos.OverrideAnimatePerOption), m_start_pos, prev_action == null || m_position_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_euler_rotation.AnimatePer, m_end_euler_rotation.OverrideAnimatePerOption), m_start_euler_rotation, m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_end_pos.BezierCurve : null, prev_action == null || m_local_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_scale.AnimatePer, m_end_scale.OverrideAnimatePerOption), m_start_scale, prev_action == null || m_local_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_end_euler_rotation.AnimatePer, m_global_end_euler_rotation.OverrideAnimatePerOption), m_global_start_euler_rotation, null, prev_action == null || m_global_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_end_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_end_scale.AnimatePer, m_global_end_scale.OverrideAnimatePerOption), m_global_start_scale, prev_action == null || m_global_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LETTER_ANCHOR || what_to_update == ANIMATION_DATA_TYPE.ALL) CalculateLetterAnchorOffset(); }
public ActionColorProgression Clone() { ActionColorProgression color_progression = new ActionColorProgression(new VertexColour()); color_progression.m_progression_idx = Progression; color_progression.m_ease_type = m_ease_type; color_progression.m_from = m_from.Clone(); color_progression.m_to = m_to.Clone(); color_progression.m_to_to = m_to_to.Clone(); color_progression.m_to_to_bool = m_to_to_bool; color_progression.m_is_offset_from_last = m_is_offset_from_last; color_progression.m_unique_randoms = m_unique_randoms; color_progression.m_override_animate_per_option = m_override_animate_per_option; color_progression.m_animate_per = m_animate_per; color_progression.m_use_colour_gradients = m_use_colour_gradients; color_progression.m_override_alpha = m_override_alpha; return color_progression; }
public void CalculateProgressions(int num_progressions, ActionColorProgression offset_prog, bool variableActive = true) { if(!variableActive) { SetValueReference(offset_prog); return; } else if(m_is_offset_from_last) { m_value_state = PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE; m_offset_progression = offset_prog.GetOffsetReference(); } else m_value_state = PROGRESSION_VALUE_STATE.UNIQUE; // Initialise the array of values. Array of only one if all progressions share the same constant value. m_values = new VertexColour[Progression == (int) ValueProgression.Eased || Progression == (int) ValueProgression.EasedCustom || Progression == (int) ValueProgression.Random ? num_progressions : 1]; // Calculate progression values if(Progression == (int) ValueProgression.Random) { for(int idx=0; idx < num_progressions; idx++) { m_values[idx] = ValueFrom.Add(ValueTo.Sub(ValueFrom).Multiply(UnityEngine.Random.value)); } } else if(Progression == (int) ValueProgression.Eased) { float progression; for(int idx=0; idx < num_progressions; idx++) { progression = num_progressions == 1 ? 0 : (float)idx / ((float)num_progressions - 1f); if(m_to_to_bool) { if(progression <= 0.5f) { m_values[idx] = ValueFrom.Add((ValueTo.Sub(ValueFrom)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression/0.5f))); } else { progression -= 0.5f; m_values[idx] = ValueTo.Add((ValueThen.Sub(ValueTo)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression/0.5f))); } } else { m_values[idx] = ValueFrom.Add((ValueTo.Sub(ValueFrom)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression))); } } } else if(Progression == (int) ValueProgression.EasedCustom) { float progression; for(int idx=0; idx < num_progressions; idx++) { progression = num_progressions == 1 ? 0 : (float)idx / ((float)num_progressions - 1f); m_values[idx] = ValueFrom.Add((ValueTo.Sub(ValueFrom)).Multiply(m_custom_ease_curve.Evaluate(progression))); } } else if(Progression == (int) ValueProgression.Constant) { for(int idx=0; idx < m_values.Length; idx++) { m_values[idx] = ValueFrom; } } }
public void ConvertFromFlatColourProg(ActionColorProgression flat_colour_progression) { m_progression_idx = flat_colour_progression.Progression; m_ease_type = flat_colour_progression.EaseType; m_from = new VertexColour(flat_colour_progression.ValueFrom); m_to = new VertexColour(flat_colour_progression.ValueTo); m_to_to = new VertexColour(flat_colour_progression.ValueThen); m_to_to_bool = flat_colour_progression.UsingThirdValue; m_is_offset_from_last = flat_colour_progression.IsOffsetFromLast; m_unique_randoms = flat_colour_progression.UniqueRandom; }
public VertexColour GetValue(List<LetterAction> all_letter_actions, int progression_idx, ActionColorProgression defaultAnimColourProg) { VertexColour colValue = new VertexColour (Color.clear); if((m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE || m_value_state == PROGRESSION_VALUE_STATE.REFERENCE)) { ActionColorProgression offsetProgression = m_offset_progression.GetColourProg(all_letter_actions, defaultAnimColourProg); if(offsetProgression != null) { colValue = offsetProgression.GetValue(all_letter_actions, progression_idx, defaultAnimColourProg); if(m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE && m_override_alpha) colValue.ClearAlpha(); } } if(m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE || m_value_state == PROGRESSION_VALUE_STATE.UNIQUE) { int num_vals = m_values.Length; if(num_vals > 1 && progression_idx < num_vals) { colValue = colValue.Add( m_values[progression_idx] ); } else if(num_vals==1) { colValue = colValue.Add( m_values[0] ); } else { colValue = colValue.Add(new VertexColour(Color.clear) ); } } return colValue; }
public VertexColour GetValue(List<LetterAction> all_letter_actions, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per_default, ActionColorProgression defaultAnimColourProg) { return GetValue(all_letter_actions, GetProgressionIndex(progression_variables,animate_per_default), defaultAnimColourProg); }
public void SetValueReference(ActionColorProgression progression) { m_value_state = PROGRESSION_VALUE_STATE.REFERENCE; m_offset_progression = progression.ReferenceData; }