public void ImportData(Boomlagoon.JSON.JSONObject json_data, string assetNameSuffix = "")
        {
            m_letters_to_animate            = json_data["m_letters_to_animate"].Array.JSONtoListInt();
            m_letters_to_animate_custom_idx = (int)json_data["m_letters_to_animate_custom_idx"].Number;
            m_letters_to_animate_option     = (LETTERS_TO_ANIMATE)(int)json_data["m_letters_to_animate_option"].Number;

            m_letter_actions = new List <LetterAction>();
            LetterAction letter_action;

            foreach (Boomlagoon.JSON.JSONValue action_data in json_data["ACTIONS_DATA"].Array)
            {
                letter_action = new LetterAction();
                letter_action.ImportData(action_data.Obj, assetNameSuffix);
                m_letter_actions.Add(letter_action);
            }

            m_loop_cycles = new List <ActionLoopCycle>();
            if (json_data.ContainsKey("LOOPS_DATA"))
            {
                ActionLoopCycle loop_cycle;

                foreach (Boomlagoon.JSON.JSONValue loop_data in json_data["LOOPS_DATA"].Array)
                {
                    loop_cycle = new ActionLoopCycle();
                    loop_cycle.ImportData(loop_data.Obj);

                    // Check for invalid loops
                    if (loop_cycle.m_start_action_idx < m_letter_actions.Count && loop_cycle.m_end_action_idx < m_letter_actions.Count)
                    {
                        m_loop_cycles.Add(loop_cycle);
                    }
                }
            }
        }
Esempio n. 2
0
 public void InsertAction(int index, LetterAction action)
 {
     if (index >= 0 && index <= m_letter_actions.Count)
     {
         m_letter_actions.Insert(index, action);
     }
 }
Esempio n. 3
0
    public void ImportData(JSONObject json_data)
    {
        m_letters_to_animate            = json_data["m_letters_to_animate"].Array.JSONtoListInt();
        m_letters_to_animate_custom_idx = (int)json_data["m_letters_to_animate_custom_idx"].Number;
        m_letters_to_animate_option     = (LETTERS_TO_ANIMATE)(int)json_data["m_letters_to_animate_option"].Number;


        m_loop_cycles = new List <ActionLoopCycle>();

        if (json_data.ContainsKey("LOOPS_DATA"))
        {
            ActionLoopCycle loop_cycle;

            foreach (JSONValue loop_data in json_data["LOOPS_DATA"].Array)
            {
                loop_cycle = new ActionLoopCycle();
                loop_cycle.ImportData(loop_data.Obj);
                m_loop_cycles.Add(loop_cycle);
            }
        }

        m_letter_actions = new List <LetterAction>();
        LetterAction letter_action;

        foreach (JSONValue action_data in json_data["ACTIONS_DATA"].Array)
        {
            letter_action = new LetterAction();
            letter_action.ImportData(action_data.Obj);
            m_letter_actions.Add(letter_action);
        }
    }
Esempio n. 4
0
    public void SoftResetStarts(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per)
    {
        if (m_use_gradient_start)
        {
            if (!m_offset_from_last && m_start_vertex_colour.UniqueRandom)
            {
                m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.Values : null);
            }
        }
        else
        {
            if (!m_offset_from_last && m_start_colour.UniqueRandom)
            {
                m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.Values : null);
            }
        }

        if (!m_offset_from_last)
        {
            if (m_start_pos.UniqueRandom)
            {
                m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.Values : null);
            }
            if (m_start_euler_rotation.UniqueRandom)
            {
                m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.Values : null);
            }
            if (m_start_scale.UniqueRandom)
            {
                m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.Values : null);
            }
        }
    }
    public void AddAction(LetterAction letter_action)
    {
        if (m_letter_actions == null)
            m_letter_actions = new List<LetterAction>();

        m_letter_actions.Add(letter_action);
    }
        public void PrepareData(TextFxAnimationManager anim_manager, LetterSetup[] letters, ANIMATION_DATA_TYPE what_to_update, int num_words, int num_lines, AnimatePerOptions animate_per)
        {
            if (letters == null || letters.Length == 0)
            {
                return;
            }

            if (m_letters_to_animate == null || what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.ANIMATE_ON)
            {
                CalculateLettersToAnimate(letters);
            }

            if (what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.COLOUR || m_defaultTextColourProgression == null)
            {
                // Set values for default text colour progression
                VertexColour[] defaultextColours = new VertexColour[m_letters_to_animate.Count];

                for (int idx = 0; idx < m_letters_to_animate.Count; idx++)
                {
                    defaultextColours[idx] = letters[m_letters_to_animate[idx]].BaseColour;
                }

                m_defaultTextColourProgression.SetValues(defaultextColours);

                // Mark as the default colour progression
                m_defaultTextColourProgression.SetReferenceData(-1, ANIMATION_DATA_TYPE.COLOUR, true);
            }


            // Prepare progression data in all actions
            LetterAction letter_action;
            LetterAction prev_action           = null;
            bool         prev_action_end_state = true;

            for (int action_idx = 0; action_idx < m_letter_actions.Count; action_idx++)
            {
                letter_action = m_letter_actions[action_idx];

                letter_action.PrepareData(anim_manager, ref letters, this, action_idx, what_to_update, m_letters_to_animate.Count, m_num_white_space_chars_to_include, num_words, num_lines, prev_action, animate_per, m_defaultTextColourProgression, prev_action_end_state);

                if (letter_action.m_action_type == ACTION_TYPE.ANIM_SEQUENCE)
                {
                    // Set default previous action settings
                    prev_action_end_state = true;
                    prev_action           = letter_action;
                }

                // Check for reverse loops, and how the animation should progress from there
                foreach (ActionLoopCycle loop_cycle in m_loop_cycles)
                {
                    if (loop_cycle.m_end_action_idx == action_idx && loop_cycle.m_loop_type == LOOP_TYPE.LOOP_REVERSE && !loop_cycle.m_finish_at_end)
                    {
                        prev_action           = m_letter_actions[loop_cycle.m_start_action_idx];
                        prev_action_end_state = false;
                    }
                }
            }
        }
Esempio n. 7
0
    public void AddAction(LetterAction letter_action)
    {
        if (m_letter_actions == null)
        {
            m_letter_actions = new List <LetterAction>();
        }

        m_letter_actions.Add(letter_action);
    }
Esempio n. 8
0
        public void LetterAction_OpensLetter()
        {
            var state = new GameState(new Word("a"));
            var input = Substitute.For <TextReader>();

            input.ReadLine().Returns("1");
            var letterAction = new LetterAction(input, Substitute.For <TextWriter>());

            letterAction.Act(state);
            state.CurrentWord.View.Should().Be("a");
        }
Esempio n. 9
0
        public void LetterAction_WaitsCorrectLetterIndex()
        {
            var state = new GameState(new Word("a"));
            var input = Substitute.For <TextReader>();

            input.ReadLine().Returns("0", "-13", "445", "sdsd", "1");
            var letterAction = new LetterAction(input, Substitute.For <TextWriter>());

            letterAction.Act(state);
            state.CurrentWord.View.Should().Be("a");
            input.Received(5).ReadLine();
        }
Esempio n. 10
0
        public LetterAction AddAction()
        {
            if (m_letter_actions == null)
            {
                m_letter_actions = new List <LetterAction>();
            }

            LetterAction newAction = new LetterAction();

            m_letter_actions.Add(newAction);

            return(newAction);
        }
Esempio n. 11
0
    public void SetAnimationVars(LetterSetup master_letter)
    {
        m_anim_state_vars = master_letter.AnimStateVars.Clone();

        m_current_letter_action = null;

        // clone the list of active loop cycles, so that the list reference is not shared between two letters
        m_anim_state_vars.m_active_loop_cycles = new List <ActionLoopCycle>();
        foreach (ActionLoopCycle loop_cycle in master_letter.AnimStateVars.m_active_loop_cycles)
        {
            m_anim_state_vars.m_active_loop_cycles.Add(loop_cycle.Clone());
        }
    }
Esempio n. 12
0
        ActionFloatProgression GetFloatVariable(ANIMATION_DATA_TYPE type, LetterAction letterAction)
        {
            switch (type)
            {
            case ANIMATION_DATA_TYPE.DURATION:
                return(letterAction.m_duration_progression);

            case ANIMATION_DATA_TYPE.DELAY:
                return(letterAction.m_delay_progression);

            default:
                return(null);
            }
        }
        public void InsertAction(int index, LetterAction action)
        {
            if (m_letter_actions == null)
            {
                m_letter_actions = new List <LetterAction>();
            }

            if (index >= 0 && index <= m_letter_actions.Count)
            {
                m_letter_actions.Insert(index, action);
            }

            UpdateLoopCyclesAfterIndex(index, 1);
        }
        public void AddAction(LetterAction letter_action, int index)
        {
            if (m_letter_actions == null)
            {
                m_letter_actions = new List <LetterAction>();
            }

            if (index < 0)
            {
                m_letter_actions.Add(letter_action);
            }
            else
            {
                m_letter_actions.Insert(index, letter_action);
            }
        }
Esempio n. 15
0
    public void Recycle(string character, int letter_idx, Mesh mesh, Vector3 base_offset, ref CustomCharacterInfo char_info, int line_num, int word_idx)
    {
        m_character   = character;
        m_mesh        = mesh;
        m_base_offset = base_offset;

        m_progression_variables = new AnimationProgressionVariables(letter_idx, word_idx, line_num);

        SetupLetterMesh(ref char_info);

        if (m_flipped)
        {
            // flip UV coords in x axis.
            m_mesh.uv = new Vector2[] { mesh.uv[3], mesh.uv[2], mesh.uv[1], mesh.uv[0] };
        }

        m_current_letter_action = null;
    }
Esempio n. 16
0
    void SetCurrentLetterAction(LetterAction letter_action)
    {
        m_current_letter_action = letter_action;

        m_action_delay    = Mathf.Max(m_current_letter_action.m_delay_progression.GetValue(m_progression_variables, m_last_animate_per), 0);
        m_action_duration = Mathf.Max(m_current_letter_action.m_duration_progression.GetValue(m_progression_variables, m_last_animate_per), 0);

        // Check if action is in a loopreverse_onetime delay case. If so, set delay to 0.
        if (m_anim_state_vars.m_active_loop_cycles != null &&
            m_anim_state_vars.m_active_loop_cycles.Count > 0 &&
            m_anim_state_vars.m_active_loop_cycles[0].m_delay_first_only &&
            !m_anim_state_vars.m_active_loop_cycles[0].FirstPass &&
            m_current_letter_action.m_delay_progression.m_progression != ValueProgression.Constant)
        {
            if (m_anim_state_vars.m_reverse || !m_current_letter_action.m_force_same_start_time)
            {
                m_action_delay = 0;
            }
        }
    }
Esempio n. 17
0
    public LetterAction ContinueActionFromThis()
    {
        LetterAction letter_action = new LetterAction();

        // Default to offset from previous and not be folded in editor
        letter_action.m_offset_from_last = true;
        letter_action.m_editor_folded    = true;

        letter_action.m_use_gradient_start = m_use_gradient_start;
        letter_action.m_use_gradient_end   = m_use_gradient_end;

        letter_action.m_position_axis_ease_data = m_position_axis_ease_data.Clone();
        letter_action.m_rotation_axis_ease_data = m_rotation_axis_ease_data.Clone();
        letter_action.m_scale_axis_ease_data    = m_scale_axis_ease_data.Clone();

        letter_action.m_start_colour        = m_end_colour.Clone();
        letter_action.m_end_colour          = m_end_colour.Clone();
        letter_action.m_start_vertex_colour = m_end_vertex_colour.Clone();
        letter_action.m_end_vertex_colour   = m_end_vertex_colour.Clone();

        letter_action.m_start_pos = m_end_pos.CloneThis();
        letter_action.m_end_pos   = m_end_pos.CloneThis();

        letter_action.m_start_euler_rotation = m_end_euler_rotation.Clone();
        letter_action.m_end_euler_rotation   = m_end_euler_rotation.Clone();

        letter_action.m_start_scale = m_end_scale.Clone();
        letter_action.m_end_scale   = m_end_scale.Clone();

        letter_action.m_delay_progression    = new ActionFloatProgression(0);
        letter_action.m_duration_progression = new ActionFloatProgression(1);

        letter_action.m_letter_anchor_start = m_letter_anchor_2_way ? m_letter_anchor_end : m_letter_anchor_start;

        letter_action.m_ease_type = m_ease_type;

        return(letter_action);
    }
Esempio n. 18
0
        ActionVector3Progression GetVector3Variable(ANIMATION_DATA_TYPE type, LetterAction letterAction)
        {
            switch (type)
            {
            case ANIMATION_DATA_TYPE.GLOBAL_ROTATION:
                return(m_startState ? letterAction.m_global_start_euler_rotation : letterAction.m_global_end_euler_rotation);

            case ANIMATION_DATA_TYPE.LOCAL_ROTATION:
                return(m_startState ? letterAction.m_start_euler_rotation : letterAction.m_end_euler_rotation);

            case ANIMATION_DATA_TYPE.POSITION:
                return(m_startState ? letterAction.m_start_pos : letterAction.m_end_pos);

            case ANIMATION_DATA_TYPE.GLOBAL_SCALE:
                return(m_startState ? letterAction.m_global_start_scale : letterAction.m_global_end_scale);

            case ANIMATION_DATA_TYPE.LOCAL_SCALE:
                return(m_startState ? letterAction.m_start_scale : letterAction.m_end_scale);

            default:
                return(null);
            }
        }
Esempio n. 19
0
        public static int ImportLegacyData(this LetterAction letter_action, List <object> data_list, int index_offset = 0)
        {
            KeyValuePair <string, string> value_pair;
            string key, value;
            int    idx;

            letter_action.ClearAudioEffectSetups();
            letter_action.ClearParticleEffectSetups();

            AudioEffectSetup    audio_setup  = null;
            ParticleEffectSetup effect_setup = null;

            for (idx = index_offset; idx < data_list.Count; idx++)
            {
                value_pair = (KeyValuePair <string, string>)data_list[idx];
                key        = value_pair.Key;
                value      = value_pair.Value;

                if (key.Equals("ACTION_DATA_END"))
                {
                    // reached end of this Actions import data

                    letter_action.m_colour_transition_active          = true;
                    letter_action.m_position_transition_active        = true;
                    letter_action.m_local_scale_transition_active     = true;
                    letter_action.m_local_rotation_transition_active  = true;
                    letter_action.m_global_scale_transition_active    = true;
                    letter_action.m_global_rotation_transition_active = true;
                    break;
                }

                switch (key)
                {
                case "m_action_type":
                    letter_action.m_action_type = (ACTION_TYPE)int.Parse(value); break;

                case "m_ease_type":
                    letter_action.m_ease_type = (EasingEquation)int.Parse(value); break;

                case "m_force_same_start_time":
                    letter_action.m_force_same_start_time = bool.Parse(value); break;

                // Legacy letter anchor import support
                case "m_letter_anchor":
                    letter_action.m_letter_anchor_start = int.Parse(value);
                    letter_action.m_letter_anchor_2_way = false;
                    break;

                // New letter anchor import support
                case "m_letter_anchor_start":
                    letter_action.m_letter_anchor_start = int.Parse(value); break;

                case "m_letter_anchor_end":
                    letter_action.m_letter_anchor_end = int.Parse(value); break;

                case "m_letter_anchor_2_way":
                    letter_action.m_letter_anchor_2_way = bool.Parse(value); break;


                case "m_offset_from_last":
                    letter_action.m_offset_from_last = bool.Parse(value); break;

                case "m_position_axis_ease_data":
                    letter_action.m_position_axis_ease_data.ImportLegacyData(value); break;

                case "m_rotation_axis_ease_data":
                    letter_action.m_rotation_axis_ease_data.ImportLegacyData(value); break;

                case "m_scale_axis_ease_data":
                    letter_action.m_scale_axis_ease_data.ImportLegacyData(value); break;


                case "m_start_colour":
                    letter_action.m_start_colour.ImportLegacyData(value); break;

                case "m_end_colour":
                    letter_action.m_end_colour.ImportLegacyData(value); break;

                case "m_start_euler_rotation":
                    letter_action.m_start_euler_rotation.ImportLegacyData(value); break;

                case "m_end_euler_rotation":
                    letter_action.m_end_euler_rotation.ImportLegacyData(value); break;

                case "m_start_pos":
                    letter_action.m_start_pos.ImportLegacyData(value); break;

                case "m_end_pos":
                    letter_action.m_end_pos.ImportLegacyData(value); break;

                case "m_start_scale":
                    letter_action.m_start_scale.ImportLegacyData(value); break;

                case "m_end_scale":
                    letter_action.m_end_scale.ImportLegacyData(value); break;

                case "m_delay_progression":
                    letter_action.m_delay_progression.ImportLegacyData(value); break;

                case "m_duration_progression":
                    letter_action.m_duration_progression.ImportLegacyData(value); break;


                case "m_audio_on_start":
                    if (value.PathToAudioClip() != null)
                    {
                        audio_setup = new AudioEffectSetup()
                        {
                            m_audio_clip = value.PathToAudioClip(), m_play_when = PLAY_ITEM_EVENTS.ON_START, m_effect_assignment = PLAY_ITEM_ASSIGNMENT.PER_LETTER, m_loop_play_once = false
                        };
                    }
                    break;

                case "m_audio_on_start_delay":
                    if (audio_setup != null)
                    {
                        audio_setup.m_delay.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_start_offset":
                    if (audio_setup != null)
                    {
                        audio_setup.m_offset_time.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_start_pitch":
                    if (audio_setup != null)
                    {
                        audio_setup.m_pitch.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_start_volume":
                    if (audio_setup != null)
                    {
                        audio_setup.m_volume.ImportLegacyData(value);
                        letter_action.AddAudioEffectSetup(audio_setup);
                        audio_setup = null;
                    }
                    break;

                case "m_audio_on_finish":
                    if (value.PathToAudioClip() != null)
                    {
                        audio_setup = new AudioEffectSetup()
                        {
                            m_audio_clip = value.PathToAudioClip(), m_play_when = PLAY_ITEM_EVENTS.ON_FINISH, m_effect_assignment = PLAY_ITEM_ASSIGNMENT.PER_LETTER, m_loop_play_once = false
                        };
                    }
                    break;

                case "m_audio_on_finish_delay":
                    if (audio_setup != null)
                    {
                        audio_setup.m_delay.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_finish_offset":
                    if (audio_setup != null)
                    {
                        audio_setup.m_offset_time.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_finish_pitch":
                    if (audio_setup != null)
                    {
                        audio_setup.m_pitch.ImportLegacyData(value);
                    }
                    break;

                case "m_audio_on_finish_volume":
                    if (audio_setup != null)
                    {
                        audio_setup.m_volume.ImportLegacyData(value);
                        letter_action.AddAudioEffectSetup(audio_setup);
                        audio_setup = null;
                    }
                    break;


                // BACKWARDS COMPATIBILITY PARTICLE IMPORT
                case "m_emitter_on_start":
                    if (value.PathToParticleEmitter() != null)
                    {
                        effect_setup = new ParticleEffectSetup()
                        {
                            m_legacy_particle_effect = value.PathToParticleEmitter(),
                            m_play_when                 = PLAY_ITEM_EVENTS.ON_START,
                            m_loop_play_once            = false,
                            m_rotation_offset           = new ActionVector3Progression(new Vector3(0, 180, 0)),
                            m_rotate_relative_to_letter = true,
                            m_effect_type               = PARTICLE_EFFECT_TYPE.LEGACY
                        };
                    }
                    break;

                case "m_emitter_on_start_delay":
                    if (effect_setup != null)
                    {
                        effect_setup.m_delay.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_start_duration":
                    if (effect_setup != null)
                    {
                        effect_setup.m_duration.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_start_follow_mesh":
                    if (effect_setup != null)
                    {
                        effect_setup.m_follow_mesh = bool.Parse(value);
                    }
                    break;

                case "m_emitter_on_start_offset":
                    if (effect_setup != null)
                    {
                        effect_setup.m_position_offset.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_start_per_letter":
                    if (effect_setup != null)
                    {
                        effect_setup.m_effect_assignment = bool.Parse(value) ? PLAY_ITEM_ASSIGNMENT.PER_LETTER : PLAY_ITEM_ASSIGNMENT.CUSTOM;
                        if (effect_setup.m_effect_assignment == PLAY_ITEM_ASSIGNMENT.CUSTOM)
                        {
                            effect_setup.m_effect_assignment_custom_letters = new List <int>()
                            {
                                0
                            }
                        }
                        ;

                        letter_action.AddParticleEffectSetup(effect_setup);
                        effect_setup = null;
                    }
                    break;

                case "m_emitter_on_finish":
                    if (value.PathToParticleEmitter() != null)
                    {
                        effect_setup = new ParticleEffectSetup()
                        {
                            m_legacy_particle_effect = value.PathToParticleEmitter(),
                            m_play_when                 = PLAY_ITEM_EVENTS.ON_FINISH,
                            m_loop_play_once            = false,
                            m_rotation_offset           = new ActionVector3Progression(new Vector3(0, 180, 0)),
                            m_rotate_relative_to_letter = true,
                            m_effect_type               = PARTICLE_EFFECT_TYPE.LEGACY
                        };
                    }
                    break;

                case "m_emitter_on_finish_delay":
                    if (effect_setup != null)
                    {
                        effect_setup.m_delay.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_finish_duration":
                    if (effect_setup != null)
                    {
                        effect_setup.m_duration.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_finish_follow_mesh":
                    if (effect_setup != null)
                    {
                        effect_setup.m_follow_mesh = bool.Parse(value);
                    }
                    break;

                case "m_emitter_on_finish_offset":
                    if (effect_setup != null)
                    {
                        effect_setup.m_position_offset.ImportLegacyData(value);
                    }
                    break;

                case "m_emitter_on_finish_per_letter":
                    if (effect_setup != null)
                    {
                        effect_setup.m_effect_assignment = bool.Parse(value) ? PLAY_ITEM_ASSIGNMENT.PER_LETTER : PLAY_ITEM_ASSIGNMENT.CUSTOM;
                        if (effect_setup.m_effect_assignment == PLAY_ITEM_ASSIGNMENT.CUSTOM)
                        {
                            effect_setup.m_effect_assignment_custom_letters = new List <int>()
                            {
                                0
                            }
                        }
                        ;

                        letter_action.AddParticleEffectSetup(effect_setup);
                        effect_setup = null;
                    }
                    break;
                }
            }

            return(idx);
        }
Esempio n. 20
0
        public List <VariableStateListener> GetSettingData(TextFxAnimationManager animation_manager, int action_start_offset = 0, int loop_start_offset = 0)
        {
            LetterAnimation letterAnimation = animation_manager.GetAnimation(m_animation_idx);
            LetterAction    letterAction    = letterAnimation != null?letterAnimation.GetAction(m_action_idx + action_start_offset) : null;

            if (letterAction == null)
            {
                return(null);
            }


//			if((m_data_type == ANIMATION_DATA_TYPE.POSITION && m_startState && letterAction.m_start_pos.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.POSITION && !m_startState && letterAction.m_end_pos.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.LOCAL_ROTATION && m_startState && letterAction.m_start_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.LOCAL_ROTATION && !m_startState && letterAction.m_end_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_ROTATION && m_startState && letterAction.m_global_start_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_ROTATION && !m_startState && letterAction.m_global_end_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.LOCAL_SCALE && m_startState && letterAction.m_start_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.LOCAL_SCALE && !m_startState && letterAction.m_end_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_SCALE && m_startState && letterAction.m_global_start_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_SCALE && !m_startState && letterAction.m_global_end_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.COLOUR && m_startState && letterAction.m_start_colour.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
//			   (m_data_type == ANIMATION_DATA_TYPE.COLOUR && !m_startState && letterAction.m_end_colour.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)))
//			{
//				animation_manager.PrepareAnimationData(m_data_type);
//
//				if(!animation_manager.Playing)
//				{
//					// Set the current state of the animation to show effect of changes
//					animation_manager.SetAnimationState(m_action_idx,
//					                                    m_startState ? 0 : 1,
//					                                    update_mesh: true);
//				}
//			}
//			else if(m_data_type == ANIMATION_DATA_TYPE.DURATION && letterAction.m_duration_progression.DrawQuickEditorGUI("Lerp Duration", gui_x_offset, ref gui_y_offset, gui_already_changed))
//			{
//				animation_manager.PrepareAnimationData(m_data_type);
//
//				animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.DELAY);
//			}
//			else
            if (m_data_type == ANIMATION_DATA_TYPE.DELAY ||
                m_data_type == ANIMATION_DATA_TYPE.DURATION)
            {
                return(GetFloatVariable(m_data_type, letterAction).GetStateListeners());
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.POSITION ||
                     m_data_type == ANIMATION_DATA_TYPE.GLOBAL_SCALE ||
                     m_data_type == ANIMATION_DATA_TYPE.LOCAL_SCALE ||
                     m_data_type == ANIMATION_DATA_TYPE.GLOBAL_ROTATION ||
                     m_data_type == ANIMATION_DATA_TYPE.LOCAL_ROTATION)
            {
                return(GetVector3Variable(m_data_type, letterAction).GetStateListeners());
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.COLOUR)
            {
                return(m_startState ? letterAction.m_start_colour.GetStateListeners() : letterAction.m_end_colour.GetStateListeners());
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.DELAY_EASED_RANDOM_SWITCH)
            {
                return(new List <VariableStateListener>()
                {
                    new VariableStateListener()
                    {
                        m_startToggleValue = letterAction.m_delay_progression.Progression == (int)ValueProgression.Random, m_onToggleStateChangeCallback = (bool state) => {
                            if (state)
                            {
                                letterAction.m_delay_progression.SetRandom(letterAction.m_delay_progression.ValueFrom, letterAction.m_delay_progression.ValueTo, letterAction.m_delay_progression.UniqueRandomRaw);
                            }
                            else
                            {
                                letterAction.m_delay_progression.SetEased(letterAction.m_delay_progression.ValueFrom, letterAction.m_delay_progression.ValueTo);
                            }

                            animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.DELAY);
                        }
                    }
                });
            }

            return(null);
        }
        public void ImportPresetSectionData(Boomlagoon.JSON.JSONObject json_data, LetterSetup[] letters, int action_insert_index, int loop_insert_index, ref int num_actions_added, ref int num_loops_added, string assetNameSuffix = "")
        {
            if (m_letter_actions == null)
            {
                m_letter_actions = new List <LetterAction>();
            }

            float timing_scale = -1;

            if (m_letters_to_animate == null || m_letters_to_animate.Count == 0)
            {
                CalculateLettersToAnimate(letters);
            }

            if (json_data.ContainsKey("SAMPLE_NUM_LETTERS_ANIMATED") && m_letters_to_animate != null && m_letters_to_animate.Count > 0)
            {
                timing_scale = m_letters_to_animate.Count / ((float)json_data["SAMPLE_NUM_LETTERS_ANIMATED"].Number);
            }


            LetterAction letter_action;

            num_actions_added = 0;
            foreach (Boomlagoon.JSON.JSONValue action_data in json_data["ACTIONS_DATA"].Array)
            {
                letter_action = new LetterAction();
                letter_action.ImportData(action_data.Obj, assetNameSuffix, timing_scale: timing_scale);

                if (num_actions_added == 0 && action_insert_index > 0)
                {
                    // Inserting new actions into the middle of the animation. Set first action to continue from last
                    letter_action.m_offset_from_last = true;
                }

                InsertAction(action_insert_index + num_actions_added, letter_action);

                num_actions_added++;
            }


            if (m_loop_cycles == null)
            {
                m_loop_cycles = new List <ActionLoopCycle>();
            }


            num_loops_added = 0;

            if (json_data.ContainsKey("LOOPS_DATA"))
            {
                ActionLoopCycle loop_cycle;

                foreach (Boomlagoon.JSON.JSONValue loop_data in json_data["LOOPS_DATA"].Array)
                {
                    loop_cycle = new ActionLoopCycle();
                    loop_cycle.ImportData(loop_data.Obj);
                    loop_cycle.m_start_action_idx += action_insert_index;
                    loop_cycle.m_end_action_idx   += action_insert_index;

                    // Check for invalid loops
                    if (loop_cycle.m_start_action_idx < m_letter_actions.Count && loop_cycle.m_end_action_idx < m_letter_actions.Count)
                    {
                        m_loop_cycles.Insert(loop_insert_index + num_loops_added, loop_cycle);

                        num_loops_added++;
                    }
                }
            }
        }
        public bool DrawGUISetting(TextFxAnimationManager animation_manager, float gui_x_offset, ref float gui_y_offset, bool gui_already_changed, int action_start_offset = 0, int loop_start_offset = 0)
        {
            LetterAnimation letterAnimation = animation_manager.GetAnimation(m_animation_idx);
            LetterAction    letterAction    = letterAnimation != null?letterAnimation.GetAction(m_action_idx + action_start_offset) : null;

            if (letterAction == null)
            {
                return(false);
            }


            if ((m_data_type == ANIMATION_DATA_TYPE.POSITION && m_startState && letterAction.m_start_pos.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.POSITION && !m_startState && letterAction.m_end_pos.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.LOCAL_ROTATION && m_startState && letterAction.m_start_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.LOCAL_ROTATION && !m_startState && letterAction.m_end_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_ROTATION && m_startState && letterAction.m_global_start_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_ROTATION && !m_startState && letterAction.m_global_end_euler_rotation.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.LOCAL_SCALE && m_startState && letterAction.m_start_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.LOCAL_SCALE && !m_startState && letterAction.m_end_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_SCALE && m_startState && letterAction.m_global_start_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.GLOBAL_SCALE && !m_startState && letterAction.m_global_end_scale.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.COLOUR && m_startState && letterAction.m_start_colour.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)) ||
                (m_data_type == ANIMATION_DATA_TYPE.COLOUR && !m_startState && letterAction.m_end_colour.DrawQuickEditorGUI(this, gui_x_offset, ref gui_y_offset, gui_already_changed)))
            {
                animation_manager.PrepareAnimationData(m_data_type);

                if (!animation_manager.Playing)
                {
                    // Set the current state of the animation to show effect of changes
                    animation_manager.SetAnimationState(m_action_idx,
                                                        m_startState ? 0 : 1,
                                                        update_mesh: true);
                }
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.DURATION && letterAction.m_duration_progression.DrawQuickEditorGUI("Lerp Duration", gui_x_offset, ref gui_y_offset, gui_already_changed))
            {
                animation_manager.PrepareAnimationData(m_data_type);

                animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.DELAY);
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.DELAY && letterAction.m_delay_progression.DrawQuickEditorGUI("Delay Easing (Seconds)", gui_x_offset, ref gui_y_offset, gui_already_changed))
            {
                animation_manager.PrepareAnimationData(m_data_type);
            }
//			else if(m_data_type == ANIMATION_DATA_TYPE.COLOUR_START_END && letterAction.m_start_colour.DrawQuickEditorGUI(this, ref gui_y_offset, gui_already_changed))
//			{
//				// Set end colour to be the same at start colour
//				if(letterAction.m_start_colour.Progression == (int) ValueProgression.Constant)
//					letterAction.m_end_colour.SetConstant(letterAction.m_start_colour.ValueFrom);
//				else if(letterAction.m_start_colour.Progression == (int) ValueProgression.Eased)
//				{
//					if(letterAction.m_start_colour.UsingThirdValue)
//						letterAction.m_end_colour.SetEased(letterAction.m_start_colour.ValueFrom, letterAction.m_start_colour.ValueTo, letterAction.m_start_colour.ValueThen);
//					else
//						letterAction.m_end_colour.SetEased(letterAction.m_start_colour.ValueFrom, letterAction.m_start_colour.ValueTo);
//				}
//				else if(letterAction.m_start_colour.Progression == (int) ValueProgression.EasedCustom)
//					letterAction.m_end_colour.SetEasedCustom(letterAction.m_start_colour.ValueFrom, letterAction.m_start_colour.ValueTo);
//				else if(letterAction.m_start_colour.Progression == (int) ValueProgression.Random)
//					letterAction.m_end_colour.SetRandom(letterAction.m_start_colour.ValueFrom, letterAction.m_start_colour.ValueTo);
//
//				animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.COLOUR_END);
//
//				animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.COLOUR_START);
//
//				if(!animation_manager.Playing)
//				{
//					// Set the current state of the animation to show effect of changes
//					animation_manager.SetAnimationState(m_action_idx, Mathf.Clamp(m_action_progress_state_override, 0f, 1f), update_mesh: true);
//				}
//			}
            else if (m_data_type == ANIMATION_DATA_TYPE.EASE_TYPE)
            {
                letterAction.m_ease_type = (EasingEquation)EditorGUI.EnumPopup(new Rect(gui_x_offset, gui_y_offset, 350, LINE_HEIGHT), m_setting_name, letterAction.m_ease_type);

                if (!gui_already_changed && GUI.changed)
                {
                    animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.ALL);
                }

                gui_y_offset += LINE_HEIGHT;
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.DELAY_EASED_RANDOM_SWITCH)
            {
                bool newSelection = EditorGUI.Toggle(new Rect(gui_x_offset, gui_y_offset, 250, LINE_HEIGHT), "Randomised?", letterAction.m_delay_progression.Progression == (int)ValueProgression.Random);

                if (!gui_already_changed && GUI.changed)
                {
                    if (newSelection)
                    {
                        letterAction.m_delay_progression.SetRandom(letterAction.m_delay_progression.ValueFrom, letterAction.m_delay_progression.ValueTo, letterAction.m_delay_progression.UniqueRandomRaw);
                    }
                    else
                    {
                        letterAction.m_delay_progression.SetEased(letterAction.m_delay_progression.ValueFrom, letterAction.m_delay_progression.ValueTo);
                    }

                    animation_manager.PrepareAnimationData(ANIMATION_DATA_TYPE.DELAY);
                }

                gui_y_offset += LINE_HEIGHT;
            }
            else if (m_data_type == ANIMATION_DATA_TYPE.NUM_LOOP_ITERATIONS)
            {
                ActionLoopCycle loop_cycle = letterAnimation.GetLoop(m_action_idx + loop_start_offset);

                if (loop_cycle != null)
                {
                    loop_cycle.m_number_of_loops = EditorGUI.IntField(new Rect(gui_x_offset, gui_y_offset, 250, LINE_HEIGHT), m_setting_name, loop_cycle.m_number_of_loops);
                }


                gui_y_offset += LINE_HEIGHT;
            }

            return(!gui_already_changed && GUI.changed);
        }
Esempio n. 23
0
    void SetupMesh(LetterAction letter_action, float action_progress, bool first_action_call, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress)
    {
        if(first_action_call || !letter_action.StaticPosition || !letter_action.StaticRotation || !letter_action.StaticScale)
        {
            Vector3[] mesh_verts = new Vector3[4];
            for(int idx=0; idx < 4; idx++)
            {
                // rotate vertices
                // handle letter anchor x-offset
                Vector3 anchor_offset = Vector3.zero;
                if(letter_action.m_letter_anchor == TextAnchor.UpperRight || letter_action.m_letter_anchor == TextAnchor.MiddleRight || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(m_width, 0, 0);
                }
                else if(letter_action.m_letter_anchor == TextAnchor.UpperCenter || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.LowerCenter)
                {
                    anchor_offset += new Vector3(m_width / 2, 0, 0);
                }

                // handle letter anchor y-offset
                if(letter_action.m_letter_anchor == TextAnchor.MiddleLeft || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.MiddleRight)
                {
                    anchor_offset += new Vector3(0, m_height / 2, 0);
                }
                else if(letter_action.m_letter_anchor == TextAnchor.LowerLeft || letter_action.m_letter_anchor == TextAnchor.LowerCenter || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(0, m_height, 0);
                }

                mesh_verts[idx] = m_base_vertices[idx];

                mesh_verts[idx] -= anchor_offset;

                // Scale verts
        //				if(first_action_call) // || !letter_action.StaticScale)
        //				{
                    Vector3 from_scale = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
                    Vector3 to_scale = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

                    if(letter_action.m_scale_axis_ease_data.m_override_default)
                    {
                        mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                        new Vector3(	EffectManager.FloatLerp(from_scale.x, to_scale.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
                                                        EffectManager.FloatLerp(from_scale.y, to_scale.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
                                                        EffectManager.FloatLerp(from_scale.z, to_scale.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress))));
                    }
                    else
                    {
                        mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                            EffectManager.Vector3Lerp(
                            from_scale,
                            to_scale,
                            action_progress)
                            );
                    }
        //				}

                // Rotate vert
        //				if(first_action_call) // || !letter_action.StaticRotation)
        //				{
                    Vector3 from_rotation = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
                    Vector3 to_rotation = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

                    if(letter_action.m_rotation_axis_ease_data.m_override_default)
                    {
                        mesh_verts[idx] = 	Quaternion.Euler
                                            (
                                                EffectManager.FloatLerp(from_rotation.x, to_rotation.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
                                                EffectManager.FloatLerp(from_rotation.y, to_rotation.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
                                                EffectManager.FloatLerp(from_rotation.z, to_rotation.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
                                            ) * mesh_verts[idx];;
                    }
                    else
                    {
                        mesh_verts[idx] = Quaternion.Euler(
                                                    EffectManager.Vector3Lerp(
                                                        from_rotation,
                                                        to_rotation,
                                                        action_progress)
                                                    )
                                                    * mesh_verts[idx];
                    }
        //				}

                mesh_verts[idx] += anchor_offset;

                // translate vert
                Vector3 from_pos = (!letter_action.m_start_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_start_pos.GetValue(progression_variables, animate_per);
                Vector3 to_pos = (!letter_action.m_end_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_end_pos.GetValue(progression_variables, animate_per);

                if(letter_action.m_position_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] += new Vector3(	EffectManager.FloatLerp(from_pos.x, to_pos.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
                                                    EffectManager.FloatLerp(from_pos.y, to_pos.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
                                                    EffectManager.FloatLerp(from_pos.z, to_pos.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
                }
                else
                {
                    mesh_verts[idx] += EffectManager.Vector3Lerp(
                        from_pos,
                        to_pos,
                        action_progress);
                }

            }
            m_mesh.vertices = mesh_verts;
        }

        if(first_action_call || !letter_action.StaticColour)
        {
            if(letter_action.m_use_gradient_start || letter_action.m_use_gradient)
            {
                start_colour = letter_action.m_start_vertex_colour.GetValue(progression_variables, animate_per);
            }
            else
            {
                start_colour = new VertexColour(letter_action.m_start_colour.GetValue(progression_variables, animate_per));
            }

            if(letter_action.m_use_gradient_end || letter_action.m_use_gradient)
            {
                end_colour = letter_action.m_end_vertex_colour.GetValue(progression_variables, animate_per);
            }
            else
            {
                end_colour = new VertexColour(letter_action.m_end_colour.GetValue(progression_variables, animate_per));
            }

            if(!m_flipped)
            {
                m_mesh.colors = new Color[]{
                    Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress),
                    Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                    Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                    Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress)};
            }
            else
            {
                m_mesh.colors = new Color[]{
                    Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                    Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                    Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress),
                    Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress)
                };
            }
        }
    }
Esempio n. 24
0
    void SetCurrentLetterAction(LetterAction letter_action)
    {
        m_current_letter_action = letter_action;

        m_action_delay = Mathf.Max(m_current_letter_action.m_delay_progression.GetValue(m_progression_variables, m_last_animate_per), 0);
        m_action_duration = Mathf.Max(m_current_letter_action.m_duration_progression.GetValue(m_progression_variables, m_last_animate_per), 0);

        // Check if action is in a loopreverse_onetime delay case. If so, set delay to 0.
        if(	m_anim_state_vars.m_active_loop_cycles != null &&
            m_anim_state_vars.m_active_loop_cycles.Count > 0 &&
            m_anim_state_vars.m_active_loop_cycles[0].m_delay_first_only &&
            !m_anim_state_vars.m_active_loop_cycles[0].FirstPass &&
            m_current_letter_action.m_delay_progression.m_progression != ValueProgression.Constant)
        {
            if(m_anim_state_vars.m_reverse || !m_current_letter_action.m_force_same_start_time)
            {
                m_action_delay = 0;
            }
        }
    }
 public void AddAction(LetterAction letter_action)
 {
     AddAction(letter_action, -1);
 }
Esempio n. 26
0
    public void SoftReset(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, bool first_action = false)
    {
        if(m_use_gradient || m_use_gradient_start)
        {
            if(!m_offset_from_last && m_start_vertex_colour.UniqueRandom && !first_action)
            {
                m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.m_values : null);
            }
        }
        else
        {
            if(!m_offset_from_last && m_start_colour.UniqueRandom && !first_action)
            {
                m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.m_values : null);
            }
        }

        if(!m_offset_from_last && !first_action)
        {
            if(m_start_pos.UniqueRandom)
            {
                m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.m_values : null);
            }
            if(m_start_euler_rotation.UniqueRandom)
            {
                m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.m_values : null);
            }
            if(m_start_scale.UniqueRandom)
            {
                m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.m_values : null);
            }
        }

        // End State Unique Randoms
        if(m_use_gradient || m_use_gradient_end)
        {
            if(m_end_vertex_colour.UniqueRandom)
            {
                m_end_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_vertex_colour.m_values);
            }
        }
        else
        {
            if(m_end_colour.UniqueRandom)
            {
                m_end_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_colour.m_values);
            }
        }
        if(m_end_pos.UniqueRandom)
        {
            m_end_pos.CalculateUniqueRandom(progression_variables, animate_per, m_start_pos.m_values);
        }
        if(m_end_euler_rotation.UniqueRandom)
        {
            m_end_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, m_start_euler_rotation.m_values);
        }
        if(m_end_scale.UniqueRandom)
        {
            m_end_scale.CalculateUniqueRandom(progression_variables, animate_per, m_start_scale.m_values);
        }

        // Timing unique randoms
        if(m_delay_progression.UniqueRandom)
        {
            m_delay_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }
        if(m_duration_progression.UniqueRandom)
        {
            m_duration_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }

        if(m_audio_on_start != null)
        {
            if(m_audio_on_start_volume.UniqueRandom)
                m_audio_on_start_volume.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_start_delay.UniqueRandom)
                m_audio_on_start_delay.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_start_offset.UniqueRandom)
                m_audio_on_start_offset.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_start_pitch.UniqueRandom)
                m_audio_on_start_pitch.CalculateUniqueRandom(progression_variables, animate_per);
        }
        if(m_audio_on_finish != null)
        {
            if(m_audio_on_finish_volume.UniqueRandom)
                m_audio_on_finish_volume.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_finish_delay.UniqueRandom)
                m_audio_on_finish_delay.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_finish_offset.UniqueRandom)
                m_audio_on_finish_offset.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_audio_on_finish_pitch.UniqueRandom)
                m_audio_on_finish_pitch.CalculateUniqueRandom(progression_variables, animate_per);
        }

        if(m_emitter_on_start != null)
        {
            if(m_emitter_on_start_offset.UniqueRandom)
                m_emitter_on_start_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
            if(m_emitter_on_start_delay.UniqueRandom)
                m_emitter_on_start_delay.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_emitter_on_start_duration.UniqueRandom)
                m_emitter_on_start_duration.CalculateUniqueRandom(progression_variables, animate_per);
        }
        if(m_emitter_on_finish != null)
        {
            if(m_emitter_on_finish_offset.UniqueRandom)
                m_emitter_on_finish_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
            if(m_emitter_on_finish_delay.UniqueRandom)
                m_emitter_on_finish_delay.CalculateUniqueRandom(progression_variables, animate_per);
            if(m_emitter_on_finish_duration.UniqueRandom)
                m_emitter_on_finish_duration.CalculateUniqueRandom(progression_variables, animate_per);
        }
    }
Esempio n. 27
0
    public void PrepareData(int num_letters, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, bool prev_action_end_state = true)
    {
        m_static_position = false;
        m_static_rotation = false;
        m_static_scale    = false;
        m_static_colour   = false;

        m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.m_animate_per, m_duration_progression.m_override_animate_per_option));

        if (m_audio_on_start != null)
        {
            m_audio_on_start_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_volume.m_animate_per, m_audio_on_start_volume.m_override_animate_per_option));
            m_audio_on_start_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_offset.m_animate_per, m_audio_on_start_offset.m_override_animate_per_option));
            m_audio_on_start_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_delay.m_animate_per, m_audio_on_start_delay.m_override_animate_per_option));
            m_audio_on_start_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_pitch.m_animate_per, m_audio_on_start_pitch.m_override_animate_per_option));
        }
        if (m_audio_on_finish != null)
        {
            m_audio_on_finish_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_volume.m_animate_per, m_audio_on_finish_volume.m_override_animate_per_option));
            m_audio_on_finish_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_offset.m_animate_per, m_audio_on_finish_offset.m_override_animate_per_option));
            m_audio_on_finish_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_delay.m_animate_per, m_audio_on_finish_delay.m_override_animate_per_option));
            m_audio_on_finish_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_pitch.m_animate_per, m_audio_on_finish_pitch.m_override_animate_per_option));
        }
        if (m_emitter_on_start != null)
        {
            m_emitter_on_start_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_offset.m_animate_per, m_emitter_on_start_offset.m_override_animate_per_option), null);
            m_emitter_on_start_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_delay.m_animate_per, m_emitter_on_start_delay.m_override_animate_per_option));
            m_emitter_on_start_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_duration.m_animate_per, m_emitter_on_start_duration.m_override_animate_per_option));
        }
        if (m_emitter_on_finish != null)
        {
            m_emitter_on_finish_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_offset.m_animate_per, m_emitter_on_finish_offset.m_override_animate_per_option), null);
            m_emitter_on_finish_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_delay.m_animate_per, m_emitter_on_finish_delay.m_override_animate_per_option));
            m_emitter_on_finish_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_duration.m_animate_per, m_emitter_on_finish_duration.m_override_animate_per_option));
        }

        if (m_action_type == ACTION_TYPE.BREAK)
        {
            return;
        }

        m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_delay_progression.m_animate_per, m_delay_progression.m_override_animate_per_option));


        if (m_offset_from_last && prev_action != null)
        {
            m_use_gradient_start = prev_action.m_use_gradient_end || prev_action.m_use_gradient;

            if (prev_action_end_state)
            {
                if (m_use_gradient_start)
                {
                    m_start_vertex_colour.m_values = prev_action.m_end_vertex_colour.m_values;
                }
                else
                {
                    m_start_colour.m_values = prev_action.m_end_colour.m_values;
                }
            }
            else
            {
                if (m_use_gradient_start)
                {
                    m_start_vertex_colour.m_values = prev_action.m_start_vertex_colour.m_values;
                }
                else
                {
                    m_start_colour.m_values = prev_action.m_start_colour.m_values;
                }
            }
        }
        else
        {
            if (m_use_gradient_start || m_use_gradient || (prev_action != null && (prev_action.m_use_gradient_end || prev_action.m_use_gradient)))
            {
                if (!m_use_gradient_start && !m_use_gradient)
                {
                    // Need to convert flat colour into a vertex colour
                    m_use_gradient_start = true;
                    m_use_gradient       = false;

                    m_start_vertex_colour.ConvertFromFlatColourProg(m_start_colour);
                }

                // add this colour to previous state
                m_start_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_vertex_colour.m_animate_per, m_start_vertex_colour.m_override_animate_per_option),
                                                            prev_action != null && (prev_action.m_use_gradient_end || prev_action.m_use_gradient) ? prev_action.m_end_vertex_colour.m_values : null,
                                                            prev_action != null && (!prev_action.m_use_gradient_end && !prev_action.m_use_gradient) ? prev_action.m_end_colour.m_values : null);
            }
            else
            {
                m_start_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_colour.m_animate_per, m_start_colour.m_override_animate_per_option),
                                                     prev_action != null ? prev_action.m_end_colour.m_values : null);
            }
        }

        if (m_use_gradient_end || m_use_gradient || m_use_gradient_start || m_use_gradient)
        {
            if (!m_use_gradient_end && !m_use_gradient)
            {
                // Need to convert flat colour into a vertex colour
                m_use_gradient_end = true;
                m_use_gradient     = false;

                m_end_vertex_colour.ConvertFromFlatColourProg(m_end_colour);
            }

            m_end_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_vertex_colour.m_animate_per, m_end_vertex_colour.m_override_animate_per_option),
                                                      (m_use_gradient_start || m_use_gradient) ? m_start_vertex_colour.m_values : null,
                                                      (!m_use_gradient_start && !m_use_gradient) ? m_start_colour.m_values : null);
        }
        else
        {
            m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.m_animate_per, m_end_colour.m_override_animate_per_option),
                                               m_start_colour.m_values);
        }

        // Static Colour check
        if (m_use_gradient_start && m_use_gradient_end && m_start_vertex_colour.m_values.Length == 1 && m_end_vertex_colour.m_values.Length == 1 && m_start_vertex_colour.GetValue(0).Equals(m_end_vertex_colour.GetValue(0)))
        {
            m_static_colour = true;
//			Debug.LogError("Static vertex colours");
        }
        else if (!m_use_gradient_start && !m_use_gradient_end && m_start_colour.m_values.Length == 1 && m_end_colour.m_values.Length == 1 && m_start_colour.GetValue(0).Equals(m_end_colour.GetValue(0)))
        {
            m_static_colour = true;
//			Debug.LogError("Static flat colours");
        }


        if (m_offset_from_last && prev_action != null)
        {
            m_start_pos.m_values            = prev_action_end_state ? prev_action.m_end_pos.m_values : prev_action.m_start_pos.m_values;
            m_start_euler_rotation.m_values = prev_action_end_state ? prev_action.m_end_euler_rotation.m_values : prev_action.m_start_euler_rotation.m_values;
            m_start_scale.m_values          = prev_action_end_state ? prev_action.m_end_scale.m_values : prev_action.m_start_scale.m_values;
        }
        else
        {
            m_start_pos.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_pos.m_animate_per, m_start_pos.m_override_animate_per_option),
                                              prev_action != null ? prev_action.m_end_pos.m_values : new Vector3[] { Vector3.zero });
            m_start_euler_rotation.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_euler_rotation.m_animate_per, m_start_euler_rotation.m_override_animate_per_option),
                                                         prev_action != null ? prev_action.m_end_euler_rotation.m_values : new Vector3[] { Vector3.zero });
            m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_scale.m_animate_per, m_start_scale.m_override_animate_per_option),
                                                prev_action != null ? prev_action.m_end_scale.m_values : new Vector3[] { Vector3.zero });
        }

        m_end_pos.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_pos.m_animate_per, m_end_pos.m_override_animate_per_option), m_start_pos.m_values);
        m_end_euler_rotation.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_euler_rotation.m_animate_per, m_end_euler_rotation.m_override_animate_per_option), m_start_euler_rotation.m_values);
        m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_scale.m_animate_per, m_end_scale.m_override_animate_per_option), m_start_scale.m_values);

        if (m_start_pos.m_values.Length == 1 && m_end_pos.m_values.Length == 1 && m_start_pos.m_values[0].Equals(m_end_pos.m_values[0]) && m_start_pos.m_force_position_override == m_end_pos.m_force_position_override)
        {
            m_static_position = true;
//			Debug.Log("Static positions");
        }
        if (m_start_euler_rotation.m_values.Length == 1 && m_end_euler_rotation.m_values.Length == 1 && m_start_euler_rotation.m_values[0].Equals(m_end_euler_rotation.m_values[0]))
        {
            m_static_rotation = true;
//			Debug.Log("Static rotations");
        }
        if (m_start_scale.m_values.Length == 1 && m_end_scale.m_values.Length == 1 && m_start_scale.m_values[0].Equals(m_end_scale.m_values[0]))
        {
            m_static_scale = true;
//			Debug.Log("Static scales");
        }
    }
Esempio n. 28
0
    void SetupMesh(LetterAction letter_action, float action_progress, bool first_action_call, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress)
    {
        if (first_action_call || !letter_action.StaticPosition || !letter_action.StaticRotation || !letter_action.StaticScale)
        {
            Vector3[] mesh_verts = new Vector3[4];
            for (int idx = 0; idx < 4; idx++)
            {
                // rotate vertices
                // handle letter anchor x-offset
                Vector3 anchor_offset = Vector3.zero;
                if (letter_action.m_letter_anchor == TextAnchor.UpperRight || letter_action.m_letter_anchor == TextAnchor.MiddleRight || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(m_width, 0, 0);
                }
                else if (letter_action.m_letter_anchor == TextAnchor.UpperCenter || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.LowerCenter)
                {
                    anchor_offset += new Vector3(m_width / 2, 0, 0);
                }

                // handle letter anchor y-offset
                if (letter_action.m_letter_anchor == TextAnchor.MiddleLeft || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.MiddleRight)
                {
                    anchor_offset += new Vector3(0, m_height / 2, 0);
                }
                else if (letter_action.m_letter_anchor == TextAnchor.LowerLeft || letter_action.m_letter_anchor == TextAnchor.LowerCenter || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(0, m_height, 0);
                }

                mesh_verts[idx] = m_base_vertices[idx];

                mesh_verts[idx] -= anchor_offset;

                // Scale verts
//				if(first_action_call) // || !letter_action.StaticScale)
//				{
                Vector3 from_scale = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
                Vector3 to_scale   = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

                if (letter_action.m_scale_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                                    new Vector3(EffectManager.FloatLerp(from_scale.x, to_scale.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
                                                                EffectManager.FloatLerp(from_scale.y, to_scale.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
                                                                EffectManager.FloatLerp(from_scale.z, to_scale.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress))));
                }
                else
                {
                    mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                                    EffectManager.Vector3Lerp(
                                                        from_scale,
                                                        to_scale,
                                                        action_progress)
                                                    );
                }
//				}

                // Rotate vert
//				if(first_action_call) // || !letter_action.StaticRotation)
//				{
                Vector3 from_rotation = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
                Vector3 to_rotation   = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

                if (letter_action.m_rotation_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] = Quaternion.Euler
                                      (
                        EffectManager.FloatLerp(from_rotation.x, to_rotation.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
                        EffectManager.FloatLerp(from_rotation.y, to_rotation.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
                        EffectManager.FloatLerp(from_rotation.z, to_rotation.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
                                      ) * mesh_verts[idx];;
                }
                else
                {
                    mesh_verts[idx] = Quaternion.Euler(
                        EffectManager.Vector3Lerp(
                            from_rotation,
                            to_rotation,
                            action_progress)
                        )
                                      * mesh_verts[idx];
                }
//				}

                mesh_verts[idx] += anchor_offset;

                // translate vert
                Vector3 from_pos = (!letter_action.m_start_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_start_pos.GetValue(progression_variables, animate_per);
                Vector3 to_pos   = (!letter_action.m_end_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_end_pos.GetValue(progression_variables, animate_per);

                if (letter_action.m_position_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] += new Vector3(EffectManager.FloatLerp(from_pos.x, to_pos.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
                                                   EffectManager.FloatLerp(from_pos.y, to_pos.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
                                                   EffectManager.FloatLerp(from_pos.z, to_pos.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
                }
                else
                {
                    mesh_verts[idx] += EffectManager.Vector3Lerp(
                        from_pos,
                        to_pos,
                        action_progress);
                }
            }
            m_mesh.vertices = mesh_verts;
        }


        if (first_action_call || !letter_action.StaticColour)
        {
            if (letter_action.m_use_gradient_start || letter_action.m_use_gradient)
            {
                start_colour = letter_action.m_start_vertex_colour.GetValue(progression_variables, animate_per);
            }
            else
            {
                start_colour = new VertexColour(letter_action.m_start_colour.GetValue(progression_variables, animate_per));
            }

            if (letter_action.m_use_gradient_end || letter_action.m_use_gradient)
            {
                end_colour = letter_action.m_end_vertex_colour.GetValue(progression_variables, animate_per);
            }
            else
            {
                end_colour = new VertexColour(letter_action.m_end_colour.GetValue(progression_variables, animate_per));
            }

            if (!m_flipped)
            {
                m_mesh.colors = new Color[] {
                    Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress),
                    Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                    Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                    Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress)
                };
            }
            else
            {
                m_mesh.colors = new Color[] {
                    Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                    Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                    Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress),
                    Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress)
                };
            }
        }
    }
Esempio n. 29
0
    public void SoftReset(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, bool first_action = false)
    {
        if (m_use_gradient_start)
        {
            if (!m_offset_from_last && m_start_vertex_colour.UniqueRandom && !first_action)
            {
                m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.Values : null);
            }
        }
        else
        {
            if (!m_offset_from_last && m_start_colour.UniqueRandom && !first_action)
            {
                m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.Values : null);
            }
        }

        if (!m_offset_from_last && !first_action)
        {
            if (m_start_pos.UniqueRandom)
            {
                m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.Values : null);
            }
            if (m_start_euler_rotation.UniqueRandom)
            {
                m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.Values : null);
            }
            if (m_start_scale.UniqueRandom)
            {
                m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.Values : null);
            }
        }

        // End State Unique Randoms
        if (m_use_gradient_end)
        {
            if (m_end_vertex_colour.UniqueRandom)
            {
                m_end_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_vertex_colour.Values);
            }
        }
        else
        {
            if (m_end_colour.UniqueRandom)
            {
                m_end_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_colour.Values);
            }
        }
        if (m_end_pos.UniqueRandom)
        {
            m_end_pos.CalculateUniqueRandom(progression_variables, animate_per, m_start_pos.Values);
        }
        if (m_end_euler_rotation.UniqueRandom)
        {
            m_end_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, m_start_euler_rotation.Values);
        }
        if (m_end_scale.UniqueRandom)
        {
            m_end_scale.CalculateUniqueRandom(progression_variables, animate_per, m_start_scale.Values);
        }


        // Timing unique randoms
        if (m_delay_progression.UniqueRandom)
        {
            m_delay_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }
        if (m_duration_progression.UniqueRandom)
        {
            m_duration_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }

        if (m_audio_effects != null)
        {
            foreach (AudioEffectSetup effect_setup in m_audio_effects)
            {
                if (effect_setup.m_delay.UniqueRandom)
                {
                    effect_setup.m_delay.CalculateUniqueRandom(progression_variables, animate_per);
                }
                if (effect_setup.m_offset_time.UniqueRandom)
                {
                    effect_setup.m_offset_time.CalculateUniqueRandom(progression_variables, animate_per);
                }
                if (effect_setup.m_volume.UniqueRandom)
                {
                    effect_setup.m_volume.CalculateUniqueRandom(progression_variables, animate_per);
                }
                if (effect_setup.m_pitch.UniqueRandom)
                {
                    effect_setup.m_pitch.CalculateUniqueRandom(progression_variables, animate_per);
                }
            }
        }

        if (m_particle_effects != null)
        {
            foreach (ParticleEffectSetup effect_setup in m_particle_effects)
            {
                if (effect_setup.m_position_offset.UniqueRandom)
                {
                    effect_setup.m_position_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
                }
                if (effect_setup.m_rotation_offset.UniqueRandom)
                {
                    effect_setup.m_rotation_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
                }
                if (effect_setup.m_delay.UniqueRandom)
                {
                    effect_setup.m_delay.CalculateUniqueRandom(progression_variables, animate_per);
                }
                if (effect_setup.m_duration.UniqueRandom)
                {
                    effect_setup.m_duration.CalculateUniqueRandom(progression_variables, animate_per);
                }
            }
        }
    }
Esempio n. 30
0
    public void Recycle(string character, int letter_idx, Mesh mesh, Vector3 base_offset, ref CustomCharacterInfo char_info, int line_num, int word_idx)
    {
        m_character = character;
        m_mesh = mesh;
        m_base_offset = base_offset;

        m_progression_variables = new AnimationProgressionVariables(letter_idx, word_idx, line_num);

        SetupLetterMesh(ref char_info);

        if(m_flipped)
        {
            // flip UV coords in x axis.
            m_mesh.uv = new Vector2[] {mesh.uv[3], mesh.uv[2], mesh.uv[1], mesh.uv[0]};
        }

        m_current_letter_action = null;
    }
Esempio n. 31
0
    public void SoftReset(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, bool first_action = false)
    {
        if (m_use_gradient || m_use_gradient_start)
        {
            if (!m_offset_from_last && m_start_vertex_colour.UniqueRandom && !first_action)
            {
                m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.m_values : null);
            }
        }
        else
        {
            if (!m_offset_from_last && m_start_colour.UniqueRandom && !first_action)
            {
                m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.m_values : null);
            }
        }

        if (!m_offset_from_last && !first_action)
        {
            if (m_start_pos.UniqueRandom)
            {
                m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.m_values : null);
            }
            if (m_start_euler_rotation.UniqueRandom)
            {
                m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.m_values : null);
            }
            if (m_start_scale.UniqueRandom)
            {
                m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.m_values : null);
            }
        }

        // End State Unique Randoms
        if (m_use_gradient || m_use_gradient_end)
        {
            if (m_end_vertex_colour.UniqueRandom)
            {
                m_end_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_vertex_colour.m_values);
            }
        }
        else
        {
            if (m_end_colour.UniqueRandom)
            {
                m_end_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_colour.m_values);
            }
        }
        if (m_end_pos.UniqueRandom)
        {
            m_end_pos.CalculateUniqueRandom(progression_variables, animate_per, m_start_pos.m_values);
        }
        if (m_end_euler_rotation.UniqueRandom)
        {
            m_end_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, m_start_euler_rotation.m_values);
        }
        if (m_end_scale.UniqueRandom)
        {
            m_end_scale.CalculateUniqueRandom(progression_variables, animate_per, m_start_scale.m_values);
        }


        // Timing unique randoms
        if (m_delay_progression.UniqueRandom)
        {
            m_delay_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }
        if (m_duration_progression.UniqueRandom)
        {
            m_duration_progression.CalculateUniqueRandom(progression_variables, animate_per);
        }

        if (m_audio_on_start != null)
        {
            if (m_audio_on_start_volume.UniqueRandom)
            {
                m_audio_on_start_volume.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_start_delay.UniqueRandom)
            {
                m_audio_on_start_delay.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_start_offset.UniqueRandom)
            {
                m_audio_on_start_offset.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_start_pitch.UniqueRandom)
            {
                m_audio_on_start_pitch.CalculateUniqueRandom(progression_variables, animate_per);
            }
        }
        if (m_audio_on_finish != null)
        {
            if (m_audio_on_finish_volume.UniqueRandom)
            {
                m_audio_on_finish_volume.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_finish_delay.UniqueRandom)
            {
                m_audio_on_finish_delay.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_finish_offset.UniqueRandom)
            {
                m_audio_on_finish_offset.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_audio_on_finish_pitch.UniqueRandom)
            {
                m_audio_on_finish_pitch.CalculateUniqueRandom(progression_variables, animate_per);
            }
        }

        if (m_emitter_on_start != null)
        {
            if (m_emitter_on_start_offset.UniqueRandom)
            {
                m_emitter_on_start_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
            }
            if (m_emitter_on_start_delay.UniqueRandom)
            {
                m_emitter_on_start_delay.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_emitter_on_start_duration.UniqueRandom)
            {
                m_emitter_on_start_duration.CalculateUniqueRandom(progression_variables, animate_per);
            }
        }
        if (m_emitter_on_finish != null)
        {
            if (m_emitter_on_finish_offset.UniqueRandom)
            {
                m_emitter_on_finish_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
            }
            if (m_emitter_on_finish_delay.UniqueRandom)
            {
                m_emitter_on_finish_delay.CalculateUniqueRandom(progression_variables, animate_per);
            }
            if (m_emitter_on_finish_duration.UniqueRandom)
            {
                m_emitter_on_finish_duration.CalculateUniqueRandom(progression_variables, animate_per);
            }
        }
    }
Esempio n. 32
0
	public LetterAction ContinueActionFromThis()
	{
		var letter_action = new LetterAction();

		// Default to offset from previous and not be folded in editor
		letter_action.m_offset_from_last = true;
		letter_action.m_editor_folded = true;

		letter_action.m_use_gradient_start = m_use_gradient_start;
		letter_action.m_use_gradient_end = m_use_gradient_end;

		letter_action.m_position_axis_ease_data = m_position_axis_ease_data.Clone();
		letter_action.m_rotation_axis_ease_data = m_rotation_axis_ease_data.Clone();
		letter_action.m_scale_axis_ease_data = m_scale_axis_ease_data.Clone();

		letter_action.m_start_colour = m_end_colour.Clone();
		letter_action.m_end_colour = m_end_colour.Clone();
		letter_action.m_start_vertex_colour = m_end_vertex_colour.Clone();
		letter_action.m_end_vertex_colour = m_end_vertex_colour.Clone();

		letter_action.m_start_pos = m_end_pos.CloneThis();
		letter_action.m_end_pos = m_end_pos.CloneThis();

		letter_action.m_start_euler_rotation = m_end_euler_rotation.Clone();
		letter_action.m_end_euler_rotation = m_end_euler_rotation.Clone();

		letter_action.m_start_scale = m_end_scale.Clone();
		letter_action.m_end_scale = m_end_scale.Clone();

		letter_action.m_delay_progression = new ActionFloatProgression(0);
		letter_action.m_duration_progression = new ActionFloatProgression(1);

		letter_action.m_letter_anchor_start = m_letter_anchor_2_way ? m_letter_anchor_end : m_letter_anchor_start;

		letter_action.m_ease_type = m_ease_type;

		return letter_action;
	}
Esempio n. 33
0
    public void PrepareData(int num_letters, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, bool prev_action_end_state = true)
    {
        m_static_position = false;
        m_static_rotation = false;
        m_static_scale = false;
        m_static_colour = false;

        m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.m_animate_per, m_duration_progression.m_override_animate_per_option));

        if(m_audio_on_start != null)
        {
            m_audio_on_start_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_volume.m_animate_per, m_audio_on_start_volume.m_override_animate_per_option));
            m_audio_on_start_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_offset.m_animate_per, m_audio_on_start_offset.m_override_animate_per_option));
            m_audio_on_start_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_delay.m_animate_per, m_audio_on_start_delay.m_override_animate_per_option));
            m_audio_on_start_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_start_pitch.m_animate_per, m_audio_on_start_pitch.m_override_animate_per_option));
        }
        if(m_audio_on_finish != null)
        {
            m_audio_on_finish_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_volume.m_animate_per, m_audio_on_finish_volume.m_override_animate_per_option));
            m_audio_on_finish_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_offset.m_animate_per, m_audio_on_finish_offset.m_override_animate_per_option));
            m_audio_on_finish_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_delay.m_animate_per, m_audio_on_finish_delay.m_override_animate_per_option));
            m_audio_on_finish_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_audio_on_finish_pitch.m_animate_per, m_audio_on_finish_pitch.m_override_animate_per_option));
        }
        if(m_emitter_on_start != null)
        {
            m_emitter_on_start_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_offset.m_animate_per, m_emitter_on_start_offset.m_override_animate_per_option), null);
            m_emitter_on_start_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_delay.m_animate_per, m_emitter_on_start_delay.m_override_animate_per_option));
            m_emitter_on_start_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_start_duration.m_animate_per, m_emitter_on_start_duration.m_override_animate_per_option));
        }
        if(m_emitter_on_finish != null)
        {
            m_emitter_on_finish_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_offset.m_animate_per, m_emitter_on_finish_offset.m_override_animate_per_option), null);
            m_emitter_on_finish_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_delay.m_animate_per, m_emitter_on_finish_delay.m_override_animate_per_option));
            m_emitter_on_finish_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_emitter_on_finish_duration.m_animate_per, m_emitter_on_finish_duration.m_override_animate_per_option));
        }

        if(m_action_type == ACTION_TYPE.BREAK)
        {
            return;
        }

        m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_delay_progression.m_animate_per, m_delay_progression.m_override_animate_per_option));

        if(m_offset_from_last && prev_action != null)
        {
            m_use_gradient_start = prev_action.m_use_gradient_end || prev_action.m_use_gradient;

            if(prev_action_end_state)
            {
                if(m_use_gradient_start)
                {
                    m_start_vertex_colour.m_values = prev_action.m_end_vertex_colour.m_values;
                }
                else
                {
                    m_start_colour.m_values = prev_action.m_end_colour.m_values;
                }
            }
            else
            {
                if(m_use_gradient_start)
                {
                    m_start_vertex_colour.m_values = prev_action.m_start_vertex_colour.m_values;
                }
                else
                {
                    m_start_colour.m_values = prev_action.m_start_colour.m_values;
                }
            }
        }
        else
        {
            if(m_use_gradient_start || m_use_gradient || (prev_action != null && (prev_action.m_use_gradient_end || prev_action.m_use_gradient)))
            {
                if(!m_use_gradient_start && !m_use_gradient)
                {
                    // Need to convert flat colour into a vertex colour
                    m_use_gradient_start = true;
                    m_use_gradient = false;

                    m_start_vertex_colour.ConvertFromFlatColourProg(m_start_colour);
                }

                // add this colour to previous state
                m_start_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_vertex_colour.m_animate_per, m_start_vertex_colour.m_override_animate_per_option),
                                                            prev_action != null && (prev_action.m_use_gradient_end || prev_action.m_use_gradient) ? prev_action.m_end_vertex_colour.m_values : null,
                                                            prev_action != null && (!prev_action.m_use_gradient_end && !prev_action.m_use_gradient) ? prev_action.m_end_colour.m_values : null);
            }
            else
            {
                m_start_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_colour.m_animate_per, m_start_colour.m_override_animate_per_option),
                                                    prev_action != null ? prev_action.m_end_colour.m_values : null);
            }
        }

        if(m_use_gradient_end || m_use_gradient || m_use_gradient_start || m_use_gradient)
        {
            if(!m_use_gradient_end && !m_use_gradient)
            {
                // Need to convert flat colour into a vertex colour
                m_use_gradient_end = true;
                m_use_gradient = false;

                m_end_vertex_colour.ConvertFromFlatColourProg(m_end_colour);
            }

            m_end_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_vertex_colour.m_animate_per, m_end_vertex_colour.m_override_animate_per_option),
                                                        (m_use_gradient_start || m_use_gradient) ? m_start_vertex_colour.m_values : null,
                                                        (!m_use_gradient_start && !m_use_gradient) ? m_start_colour.m_values : null);
        }
        else
        {
            m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.m_animate_per, m_end_colour.m_override_animate_per_option),
                                                m_start_colour.m_values);
        }

        // Static Colour check
        if(m_use_gradient_start && m_use_gradient_end && m_start_vertex_colour.m_values.Length == 1 && m_end_vertex_colour.m_values.Length == 1 && m_start_vertex_colour.GetValue(0).Equals(m_end_vertex_colour.GetValue(0)))
        {
            m_static_colour = true;
        //			Debug.LogError("Static vertex colours");
        }
        else if(!m_use_gradient_start && !m_use_gradient_end && m_start_colour.m_values.Length == 1 && m_end_colour.m_values.Length == 1 && m_start_colour.GetValue(0).Equals(m_end_colour.GetValue(0)))
        {
            m_static_colour = true;
        //			Debug.LogError("Static flat colours");
        }

        if(m_offset_from_last && prev_action != null)
        {
            m_start_pos.m_values = prev_action_end_state ? prev_action.m_end_pos.m_values : prev_action.m_start_pos.m_values;
            m_start_euler_rotation.m_values = prev_action_end_state ? prev_action.m_end_euler_rotation.m_values : prev_action.m_start_euler_rotation.m_values;
            m_start_scale.m_values = prev_action_end_state ? prev_action.m_end_scale.m_values : prev_action.m_start_scale.m_values;
        }
        else
        {
            m_start_pos.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_pos.m_animate_per, m_start_pos.m_override_animate_per_option),
                                                prev_action != null ? prev_action.m_end_pos.m_values : new Vector3[]{Vector3.zero});
            m_start_euler_rotation.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_euler_rotation.m_animate_per, m_start_euler_rotation.m_override_animate_per_option),
                                                prev_action != null ? prev_action.m_end_euler_rotation.m_values : new Vector3[]{Vector3.zero});
            m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_scale.m_animate_per, m_start_scale.m_override_animate_per_option),
                                                prev_action != null ? prev_action.m_end_scale.m_values : new Vector3[]{Vector3.zero});
        }

        m_end_pos.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_pos.m_animate_per, m_end_pos.m_override_animate_per_option), m_start_pos.m_values);
        m_end_euler_rotation.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_euler_rotation.m_animate_per, m_end_euler_rotation.m_override_animate_per_option), m_start_euler_rotation.m_values);
        m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_scale.m_animate_per, m_end_scale.m_override_animate_per_option), m_start_scale.m_values);

        if(m_start_pos.m_values.Length == 1 && m_end_pos.m_values.Length == 1 && m_start_pos.m_values[0].Equals(m_end_pos.m_values[0]) && m_start_pos.m_force_position_override == m_end_pos.m_force_position_override)
        {
            m_static_position = true;
        //			Debug.Log("Static positions");
        }
        if(m_start_euler_rotation.m_values.Length == 1 && m_end_euler_rotation.m_values.Length == 1 && m_start_euler_rotation.m_values[0].Equals(m_end_euler_rotation.m_values[0]))
        {
            m_static_rotation = true;
        //			Debug.Log("Static rotations");
        }
        if(m_start_scale.m_values.Length == 1 && m_end_scale.m_values.Length == 1 && m_start_scale.m_values[0].Equals(m_end_scale.m_values[0]))
        {
            m_static_scale = true;
        //			Debug.Log("Static scales");
        }
    }
Esempio n. 34
0
	public void SoftReset(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, bool first_action = false)
	{
		if (m_use_gradient_start)
		{
			if (!m_offset_from_last && m_start_vertex_colour.UniqueRandom && !first_action)
				m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.Values : null);
		}
		else if (!m_offset_from_last && m_start_colour.UniqueRandom && !first_action)
			m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.Values : null);

		if (!m_offset_from_last && !first_action)
		{
			if (m_start_pos.UniqueRandom)
				m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.Values : null);
			if (m_start_euler_rotation.UniqueRandom)
				m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.Values : null);
			if (m_start_scale.UniqueRandom)
				m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.Values : null);
		}

		// End State Unique Randoms
		if (m_use_gradient_end)
		{
			if (m_end_vertex_colour.UniqueRandom)
				m_end_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_vertex_colour.Values);
		}
		else if (m_end_colour.UniqueRandom)
			m_end_colour.CalculateUniqueRandom(progression_variables, animate_per, m_start_colour.Values);
		if (m_end_pos.UniqueRandom)
			m_end_pos.CalculateUniqueRandom(progression_variables, animate_per, m_start_pos.Values);
		if (m_end_euler_rotation.UniqueRandom)
			m_end_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, m_start_euler_rotation.Values);
		if (m_end_scale.UniqueRandom)
			m_end_scale.CalculateUniqueRandom(progression_variables, animate_per, m_start_scale.Values);


		// Timing unique randoms
		if (m_delay_progression.UniqueRandom)
			m_delay_progression.CalculateUniqueRandom(progression_variables, animate_per);
		if (m_duration_progression.UniqueRandom)
			m_duration_progression.CalculateUniqueRandom(progression_variables, animate_per);

		if (m_audio_effects != null)
			foreach (var effect_setup in m_audio_effects)
			{
				if (effect_setup.m_delay.UniqueRandom)
					effect_setup.m_delay.CalculateUniqueRandom(progression_variables, animate_per);
				if (effect_setup.m_offset_time.UniqueRandom)
					effect_setup.m_offset_time.CalculateUniqueRandom(progression_variables, animate_per);
				if (effect_setup.m_volume.UniqueRandom)
					effect_setup.m_volume.CalculateUniqueRandom(progression_variables, animate_per);
				if (effect_setup.m_pitch.UniqueRandom)
					effect_setup.m_pitch.CalculateUniqueRandom(progression_variables, animate_per);
			}

		if (m_particle_effects != null)
			foreach (var effect_setup in m_particle_effects)
			{
				if (effect_setup.m_position_offset.UniqueRandom)
					effect_setup.m_position_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
				if (effect_setup.m_rotation_offset.UniqueRandom)
					effect_setup.m_rotation_offset.CalculateUniqueRandom(progression_variables, animate_per, null);
				if (effect_setup.m_delay.UniqueRandom)
					effect_setup.m_delay.CalculateUniqueRandom(progression_variables, animate_per);
				if (effect_setup.m_duration.UniqueRandom)
					effect_setup.m_duration.CalculateUniqueRandom(progression_variables, animate_per);
			}
	}
Esempio n. 35
0
    private void SetupMesh(LetterAction letter_action, LetterAction prev_action, float action_progress, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress, EffectManager effect_manager)
    {
        // construct current anchor offset vector
        m_anchor_offset = letter_action.AnchorOffsetStart;
        m_anchor_offset = new Vector3(m_anchor_offset.x * m_width, letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineRight ? 0 // zero because letters are based around the baseline already.
            : (effect_manager.IsFontBaseLineSet ? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height) : (m_anchor_offset.y * m_height)), // Legacy effect support when baseline isn't already set.
            0);

        if (letter_action.m_letter_anchor_2_way)
        {
            m_anchor_offset = letter_action.AnchorOffsetEnd;
            m_anchor_offset = Vector3.Lerp(m_anchor_offset, new Vector3(m_anchor_offset.x * m_width, letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineRight ? 0 // zero because letters are based around the baseline already.
                : (effect_manager.IsFontBaseLineSet ? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height) : (m_anchor_offset.y * m_height)), // Legacy effect support when baseline isn't already set.
                0), action_progress);
        }

        // Calculate Scale Vector
        from_vec = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
        to_vec = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

        if (letter_action.m_scale_axis_ease_data.m_override_default)
            ScaleLocal = new Vector3(EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)), EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)), EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress)));
        else
            ScaleLocal = EffectManager.Vector3Lerp(from_vec, to_vec, action_progress);

        // Calculate Rotation
        from_vec = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
        to_vec = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

        if (letter_action.m_rotation_axis_ease_data.m_override_default)
            RotationLocal = Quaternion.Euler(EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)), EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)), EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress)));
        else
            RotationLocal = Quaternion.Euler(EffectManager.Vector3Lerp(from_vec, to_vec, action_progress));

        // Calculate Position
        if (letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_offset_from_last && prev_action != null && prev_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
            from_vec = new Vector3(-m_anchor_offset.x, m_base_offset.y, 0);
        else if (letter_action.m_start_pos.ForcePositionOverride)
            from_vec = new Vector3(-m_anchor_offset.x, 0, 0);
        else
            from_vec = BaseOffset;

        from_vec += letter_action.m_start_pos.GetValue(progression_variables, animate_per);

        if (letter_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_end_pos.IsOffsetFromLast && letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
            to_vec = new Vector3(-m_anchor_offset.x, m_base_offset.y, 0);
        else if (letter_action.m_end_pos.ForcePositionOverride)
            to_vec = new Vector3(-m_anchor_offset.x, 0, 0);
        else
            to_vec = BaseOffset;

        to_vec += letter_action.m_end_pos.GetValue(progression_variables, animate_per);

        if (letter_action.m_position_axis_ease_data.m_override_default)
            m_letter_position = new Vector3(EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)), EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)), EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
        else
            m_letter_position = EffectManager.Vector3Lerp(from_vec, to_vec, action_progress);

        // Calculate letter center position
        CenterLocal = new Vector3(m_width / 2, m_height / 2, 0);
        CenterLocal -= m_anchor_offset;
        CenterLocal = Vector3.Scale(CenterLocal, ScaleLocal);
        CenterLocal = RotationLocal * CenterLocal;
        CenterLocal += m_anchor_offset + m_letter_position;

        if (mesh_verts == null || mesh_verts.Length == 0)
            mesh_verts = new Vector3[4];
        for (var idx = 0; idx < 4; idx++)
        {
            mesh_verts[idx] = m_base_vertices[idx];

            // normalise vert position to the anchor point before scaling and rotating.
            mesh_verts[idx] -= m_anchor_offset;

            // Scale verts
            mesh_verts[idx] = Vector3.Scale(mesh_verts[idx], ScaleLocal);

            // Rotate vert
            mesh_verts[idx] = RotationLocal * mesh_verts[idx];

            mesh_verts[idx] += m_anchor_offset;

            // translate vert
            mesh_verts[idx] += m_letter_position;
        }
        m_mesh.vertices = mesh_verts;

        // Sort out letters colour
        if (letter_action.m_use_gradient_start)
            start_colour = letter_action.m_start_vertex_colour.GetValue(progression_variables, animate_per);
        else
            start_colour = new VertexColour(letter_action.m_start_colour.GetValue(progression_variables, animate_per));

        if (letter_action.m_use_gradient_end)
            end_colour = letter_action.m_end_vertex_colour.GetValue(progression_variables, animate_per);
        else
            end_colour = new VertexColour(letter_action.m_end_colour.GetValue(progression_variables, animate_per));

        if (!m_flipped)
            m_mesh.colors = new[] { Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress), Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress), Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress), Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress) };
        else
            m_mesh.colors = new[] { Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress), Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress), Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress), Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress) };
    }
Esempio n. 36
0
    public void SetAnimationVars(LetterSetup master_letter)
    {
        m_anim_state_vars = master_letter.AnimStateVars.Clone();

        m_current_letter_action = null;

        // clone the list of active loop cycles, so that the list reference is not shared between two letters
        m_anim_state_vars.m_active_loop_cycles = new List<ActionLoopCycle>();
        foreach(ActionLoopCycle loop_cycle in master_letter.AnimStateVars.m_active_loop_cycles)
        {
            m_anim_state_vars.m_active_loop_cycles.Add(loop_cycle.Clone());
        }
    }
Esempio n. 37
0
    public void PrepareData(LetterSetup[] letters, int num_words, int num_lines, AnimatePerOptions animate_per)
    {
        if (letters == null || letters.Length == 0)
        {
            return;
        }

        int num_letters = letters.Length;

        // Populate list of letters to animate by index, and set Letter indexes accordingly
        if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.ALL_LETTERS)
        {
            m_letters_to_animate = new List <int>();
            for (int letter_idx = 0; letter_idx < num_letters; letter_idx++)
            {
                m_letters_to_animate.Add(letter_idx);

                letters[letter_idx].m_progression_variables.m_letter_value = letter_idx;
            }
        }
        else if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LETTER || m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER)
        {
            m_letters_to_animate = new List <int>();
            m_letters_to_animate.Add(m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LETTER ? 0 : letters.Length - 1);

            letters[m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LETTER ? 0 : letters.Length - 1].m_progression_variables.m_letter_value = 0;
        }
        else if (m_letters_to_animate_option != LETTERS_TO_ANIMATE.CUSTOM)
        {
            m_letters_to_animate = new List <int>();

            int line_idx   = m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_LINES ? 0 : -1;
            int word_idx   = m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_WORDS ? 0 : -1;
            int target_idx = 0;

            if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_WORD)
            {
                target_idx = letters[letters.Length - 1].m_progression_variables.m_word_value;
            }
            else if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LINE)
            {
                target_idx = letters[letters.Length - 1].m_progression_variables.m_line_value;
            }
            else if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.NTH_WORD || m_letters_to_animate_option == LETTERS_TO_ANIMATE.NTH_LINE)
            {
                target_idx = m_letters_to_animate_custom_idx - 1;
            }

            int letter_idx      = 0;
            int progression_idx = 0;
            foreach (LetterSetup letter in letters)
            {
                if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LINE || m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LINE || m_letters_to_animate_option == LETTERS_TO_ANIMATE.NTH_LINE)
                {
                    if (letter.m_progression_variables.m_line_value == target_idx)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx;
                        m_letters_to_animate.Add(letter_idx);
                        progression_idx++;
                    }
                }
                else if (letter.m_progression_variables.m_line_value > line_idx)
                {
                    if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LETTER_LINES)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx;
                        m_letters_to_animate.Add(letter_idx);
                        progression_idx++;
                    }
                    else if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_LINES)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx - 1;
                        m_letters_to_animate.Add(letter_idx - 1);
                        progression_idx++;
                    }
                    line_idx = letter.m_progression_variables.m_line_value;
                }

                if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_WORD || m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_WORD || m_letters_to_animate_option == LETTERS_TO_ANIMATE.NTH_WORD)
                {
                    if (letter.m_progression_variables.m_word_value == target_idx)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx;
                        m_letters_to_animate.Add(letter_idx);
                        progression_idx++;
                    }
                }
                else if (letter.m_progression_variables.m_word_value > word_idx)
                {
                    if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.FIRST_LETTER_WORDS)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx;
                        m_letters_to_animate.Add(letter_idx);
                        progression_idx++;
                    }
                    else if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_WORDS)
                    {
                        letter.m_progression_variables.m_letter_value = progression_idx;
                        m_letters_to_animate.Add(letter_idx - 1);
                        progression_idx++;
                    }
                    word_idx = letter.m_progression_variables.m_word_value;
                }

                letter_idx++;
            }

            if (m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_WORDS || m_letters_to_animate_option == LETTERS_TO_ANIMATE.LAST_LETTER_LINES)
            {
                letters[num_letters - 1].m_progression_variables.m_letter_value = letter_idx - 1;
                m_letters_to_animate.Add(letter_idx - 1);
            }
        }
        else
        {
            int progression_idx = 0;
            for (int letter_idx = 0; letter_idx < num_letters; letter_idx++)
            {
                if (m_letters_to_animate.Contains(letter_idx))
                {
                    letters[letter_idx].m_progression_variables.m_letter_value = progression_idx;

                    progression_idx++;
                }
            }
        }

        // Prepare data progression data in all actions
        LetterAction letter_action;
        LetterAction prev_action           = null;
        bool         letters_in_sync       = true;
        bool         prev_action_end_state = true;

        for (int action_idx = 0; action_idx < m_letter_actions.Count; action_idx++)
        {
            letter_action = m_letter_actions[action_idx];

            letter_action.PrepareData(m_letters_to_animate.Count, num_words, num_lines, prev_action, animate_per, prev_action_end_state);


            if (letter_action.m_action_type == ACTION_TYPE.ANIM_SEQUENCE)
            {
                // Set default previous action settings
                prev_action_end_state = true;
                prev_action           = letter_action;
            }

            // Check for reverse loops, and how the animation should progress from there
            foreach (ActionLoopCycle loop_cycle in m_loop_cycles)
            {
                if (loop_cycle.m_end_action_idx == action_idx && loop_cycle.m_loop_type == LOOP_TYPE.LOOP_REVERSE)
                {
                    prev_action           = m_letter_actions[loop_cycle.m_start_action_idx];
                    prev_action_end_state = false;
                }
            }

            // Set whether letters in the action are still in sync (starting/ending at the same time)
            if (letter_action.m_force_same_start_time)
            {
                letters_in_sync = true;
            }

            if (letter_action.m_delay_progression.m_progression != ValueProgression.Constant)
            {
                letters_in_sync = false;
            }

            letter_action.m_starting_in_sync = letters_in_sync;

            if (letter_action.m_duration_progression.m_progression != ValueProgression.Constant)
            {
                letters_in_sync = false;
            }

            letter_action.m_ending_in_sync = letters_in_sync;
        }
    }
Esempio n. 38
0
    public void PrepareData(ref LetterSetup[] letters, int num_letters, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, bool prev_action_end_state = true)
    {
        m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.AnimatePer, m_duration_progression.OverrideAnimatePerOption));


        if (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 (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)
        {
            return;
        }

        m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_delay_progression.AnimatePer, m_delay_progression.OverrideAnimatePerOption));


        if (m_offset_from_last && prev_action != null)
        {
            m_use_gradient_start = prev_action.m_use_gradient_end;

            if (prev_action_end_state)
            {
                if (m_use_gradient_start)
                {
                    m_start_vertex_colour.Values = prev_action.m_end_vertex_colour.Values;
                }
                else
                {
                    m_start_colour.Values = prev_action.m_end_colour.Values;
                }
            }
            else
            {
                if (m_use_gradient_start)
                {
                    m_start_vertex_colour.Values = prev_action.m_start_vertex_colour.Values;
                }
                else
                {
                    m_start_colour.Values = prev_action.m_start_colour.Values;
                }
            }
        }
        else
        {
            if (m_use_gradient_start || (prev_action != null && (prev_action.m_use_gradient_end)))
            {
                if (!m_use_gradient_start)
                {
                    // Need to convert flat colour into a vertex colour
                    m_use_gradient_start = true;

                    m_start_vertex_colour.ConvertFromFlatColourProg(m_start_colour);
                }

                // add this colour to previous state
                m_start_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_vertex_colour.AnimatePer, m_start_vertex_colour.OverrideAnimatePerOption),
                                                            prev_action != null && (prev_action.m_use_gradient_end) ? prev_action.m_end_vertex_colour.Values : null,
                                                            prev_action != null && (!prev_action.m_use_gradient_end) ? prev_action.m_end_colour.Values : null);
            }
            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.Values : null);
            }
        }

        if (m_use_gradient_end || m_use_gradient_start)
        {
            if (!m_use_gradient_end)
            {
                // Need to convert flat colour into a vertex colour
                m_use_gradient_end = true;

                m_end_vertex_colour.ConvertFromFlatColourProg(m_end_colour);
            }

            m_end_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_vertex_colour.AnimatePer, m_end_vertex_colour.OverrideAnimatePerOption),
                                                      (m_use_gradient_start) ? m_start_vertex_colour.Values : null,
                                                      (!m_use_gradient_start) ? m_start_colour.Values : null);
        }
        else
        {
            m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.AnimatePer, m_end_colour.OverrideAnimatePerOption),
                                               m_start_colour.Values);
        }


        if (m_offset_from_last && prev_action != null)
        {
            m_start_pos.Values            = prev_action_end_state ? prev_action.m_end_pos.Values : prev_action.m_start_pos.Values;
            m_start_euler_rotation.Values = prev_action_end_state ? prev_action.m_end_euler_rotation.Values : prev_action.m_start_euler_rotation.Values;
            m_start_scale.Values          = prev_action_end_state ? prev_action.m_end_scale.Values : prev_action.m_start_scale.Values;
        }
        else
        {
            float[] start_pos_curve_letter_progressions = null;
            if (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.m_bezier_curve.GetLetterProgressions(ref letters, m_letter_anchor_start);
            }

            m_start_pos.CalculatePositionProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_pos.AnimatePer, m_start_pos.OverrideAnimatePerOption),
                                                      prev_action != null ? prev_action.m_end_pos.Values : new Vector3[] { Vector3.zero });
            m_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters, 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.Values : new Vector3[] { Vector3.zero },
                                                                 m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_start_pos.m_bezier_curve : null);
            m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_scale.AnimatePer, m_start_scale.OverrideAnimatePerOption),
                                                prev_action != null ? prev_action.m_end_scale.Values : new Vector3[] { Vector3.zero });
        }

        float[] end_pos_curve_letter_progressions = null;
        if (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.m_bezier_curve.GetLetterProgressions(ref letters, m_letter_anchor_end);
        }

        m_end_pos.CalculatePositionProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_pos.AnimatePer, m_end_pos.OverrideAnimatePerOption), m_start_pos.Values);
        m_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_euler_rotation.AnimatePer, m_end_euler_rotation.OverrideAnimatePerOption),
                                                           m_start_euler_rotation.Values,
                                                           m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_end_pos.m_bezier_curve : null);
        m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_scale.AnimatePer, m_end_scale.OverrideAnimatePerOption), m_start_scale.Values);

        CalculateLetterAnchorOffset();
    }
Esempio n. 39
0
    void SetupMesh(LetterAction letter_action, LetterAction prev_action, float action_progress, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress, EffectManager effect_manager)
    {
        // construct current anchor offset vector
        m_anchor_offset = letter_action.AnchorOffsetStart;
        m_anchor_offset = new Vector3(m_anchor_offset.x * m_width,
                                      letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_start == (int)TextfxTextAnchor.BaselineRight
                                                                                        ? 0             // zero because letters are based around the baseline already.
                                                                                        : (effect_manager.IsFontBaseLineSet
                                                                                                        ? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height)
                                                                                                        : (m_anchor_offset.y * m_height)),      // Legacy effect support when baseline isn't already set.
                                      0);

        if (letter_action.m_letter_anchor_2_way)
        {
            m_anchor_offset = letter_action.AnchorOffsetEnd;
            m_anchor_offset = Vector3.Lerp(m_anchor_offset,
                                           new Vector3(
                                               m_anchor_offset.x * m_width,
                                               letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_end == (int)TextfxTextAnchor.BaselineRight
                                                                                                        ? 0             // zero because letters are based around the baseline already.
                                                                                                        : (effect_manager.IsFontBaseLineSet
                                                                                                                        ? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height)
                                                                                                                        : (m_anchor_offset.y * m_height)),      // Legacy effect support when baseline isn't already set.
                                               0),
                                           action_progress);
        }


        // Calculate Scale Vector
        from_vec = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
        to_vec   = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

        if (letter_action.m_scale_axis_ease_data.m_override_default)
        {
            m_letter_scale = new Vector3(EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
                                         EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
                                         EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress)));
        }
        else
        {
            m_letter_scale = EffectManager.Vector3Lerp(
                from_vec,
                to_vec,
                action_progress);
        }

        // Calculate Rotation
        from_vec = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
        to_vec   = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

        if (letter_action.m_rotation_axis_ease_data.m_override_default)
        {
            m_letter_rotation = Quaternion.Euler
                                (
                EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
                EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
                EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
                                );
        }
        else
        {
            m_letter_rotation = Quaternion.Euler(
                EffectManager.Vector3Lerp(
                    from_vec,
                    to_vec,
                    action_progress)
                );
        }


        // Calculate Position
        if (letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_offset_from_last && prev_action != null && prev_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
        {
            from_vec = new Vector3(-m_anchor_offset.x, m_base_offset.y, 0);
        }
        else if (letter_action.m_start_pos.m_force_position_override)
        {
            from_vec = new Vector3(-m_anchor_offset.x, 0, 0);
        }
        else
        {
            from_vec = BaseOffset;
        }

        from_vec += letter_action.m_start_pos.GetValue(progression_variables, animate_per);

        if (letter_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_end_pos.IsOffsetFromLast && letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
        {
            to_vec = new Vector3(-m_anchor_offset.x, m_base_offset.y, 0);
        }
        else if (letter_action.m_end_pos.m_force_position_override)
        {
            to_vec = new Vector3(-m_anchor_offset.x, 0, 0);
        }
        else
        {
            to_vec = BaseOffset;
        }

        to_vec += letter_action.m_end_pos.GetValue(progression_variables, animate_per);

        if (letter_action.m_position_axis_ease_data.m_override_default)
        {
            m_letter_position = new Vector3(EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
                                            EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
                                            EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
        }
        else
        {
            m_letter_position = EffectManager.Vector3Lerp(
                from_vec,
                to_vec,
                action_progress);
        }

        // Calculate letter center position
        m_letter_center  = new Vector3(m_width / 2, m_height / 2, 0);
        m_letter_center -= m_anchor_offset;
        m_letter_center  = Vector3.Scale(m_letter_center, m_letter_scale);
        m_letter_center  = m_letter_rotation * m_letter_center;
        m_letter_center += m_anchor_offset + m_letter_position;


        if (mesh_verts == null || mesh_verts.Length == 0)
        {
            mesh_verts = new Vector3[4];
        }
        for (int idx = 0; idx < 4; idx++)
        {
            mesh_verts[idx] = m_base_vertices[idx];

            // normalise vert position to the anchor point before scaling and rotating.
            mesh_verts[idx] -= m_anchor_offset;

            // Scale verts
            mesh_verts[idx] = Vector3.Scale(mesh_verts[idx], m_letter_scale);

            // Rotate vert
            mesh_verts[idx] = m_letter_rotation * mesh_verts[idx];

            mesh_verts[idx] += m_anchor_offset;

            // translate vert
            mesh_verts[idx] += m_letter_position;
        }
        m_mesh.vertices = mesh_verts;



        // Sort out letters colour
        if (letter_action.m_use_gradient_start)
        {
            start_colour = letter_action.m_start_vertex_colour.GetValue(progression_variables, animate_per);
        }
        else
        {
            start_colour = new VertexColour(letter_action.m_start_colour.GetValue(progression_variables, animate_per));
        }

        if (letter_action.m_use_gradient_end)
        {
            end_colour = letter_action.m_end_vertex_colour.GetValue(progression_variables, animate_per);
        }
        else
        {
            end_colour = new VertexColour(letter_action.m_end_colour.GetValue(progression_variables, animate_per));
        }

        if (!m_flipped)
        {
            m_mesh.colors = new Color[] {
                Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress),
                Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress)
            };
        }
        else
        {
            m_mesh.colors = new Color[] {
                Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
                Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
                Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress),
                Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress)
            };
        }
    }
Esempio n. 40
0
    public void ImportData(JSONObject json_data)
    {
        m_letters_to_animate = json_data["m_letters_to_animate"].Array.JSONtoListInt();
        m_letters_to_animate_custom_idx = (int)json_data["m_letters_to_animate_custom_idx"].Number;
        m_letters_to_animate_option = (LETTERS_TO_ANIMATE)(int)json_data["m_letters_to_animate_option"].Number;

        m_loop_cycles = new List<ActionLoopCycle>();

        if (json_data.ContainsKey("LOOPS_DATA"))
        {
            ActionLoopCycle loop_cycle;

            foreach (var loop_data in json_data["LOOPS_DATA"].Array)
            {
                loop_cycle = new ActionLoopCycle();
                loop_cycle.ImportData(loop_data.Obj);
                m_loop_cycles.Add(loop_cycle);
            }
        }

        m_letter_actions = new List<LetterAction>();
        LetterAction letter_action;
        foreach (var action_data in json_data["ACTIONS_DATA"].Array)
        {
            letter_action = new LetterAction();
            letter_action.ImportData(action_data.Obj);
            m_letter_actions.Add(letter_action);
        }
    }
Esempio n. 41
0
	public void PrepareData(ref LetterSetup[] letters, int num_letters, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, bool prev_action_end_state = true)
	{
		m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.AnimatePer, m_duration_progression.OverrideAnimatePerOption));


		if (m_audio_effects != null)
			foreach (var 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 (m_particle_effects != null)
			foreach (var 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)
			return;

		m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_delay_progression.AnimatePer, m_delay_progression.OverrideAnimatePerOption));


		if (m_offset_from_last && prev_action != null)
		{
			m_use_gradient_start = prev_action.m_use_gradient_end;

			if (prev_action_end_state)
				if (m_use_gradient_start)
					m_start_vertex_colour.Values = prev_action.m_end_vertex_colour.Values;
				else
					m_start_colour.Values = prev_action.m_end_colour.Values;
			else if (m_use_gradient_start)
				m_start_vertex_colour.Values = prev_action.m_start_vertex_colour.Values;
			else
				m_start_colour.Values = prev_action.m_start_colour.Values;
		}
		else if (m_use_gradient_start || (prev_action != null && (prev_action.m_use_gradient_end)))
		{
			if (!m_use_gradient_start)
			{
				// Need to convert flat colour into a vertex colour
				m_use_gradient_start = true;

				m_start_vertex_colour.ConvertFromFlatColourProg(m_start_colour);
			}

			// add this colour to previous state
			m_start_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_vertex_colour.AnimatePer, m_start_vertex_colour.OverrideAnimatePerOption), prev_action != null && (prev_action.m_use_gradient_end) ? prev_action.m_end_vertex_colour.Values : null, prev_action != null && (!prev_action.m_use_gradient_end) ? prev_action.m_end_colour.Values : null);
		}
		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.Values : null);

		if (m_use_gradient_end || m_use_gradient_start)
		{
			if (!m_use_gradient_end)
			{
				// Need to convert flat colour into a vertex colour
				m_use_gradient_end = true;

				m_end_vertex_colour.ConvertFromFlatColourProg(m_end_colour);
			}

			m_end_vertex_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_vertex_colour.AnimatePer, m_end_vertex_colour.OverrideAnimatePerOption), (m_use_gradient_start) ? m_start_vertex_colour.Values : null, (!m_use_gradient_start) ? m_start_colour.Values : null);
		}
		else
			m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.AnimatePer, m_end_colour.OverrideAnimatePerOption), m_start_colour.Values);


		if (m_offset_from_last && prev_action != null)
		{
			m_start_pos.Values = prev_action_end_state ? prev_action.m_end_pos.Values : prev_action.m_start_pos.Values;
			m_start_euler_rotation.Values = prev_action_end_state ? prev_action.m_end_euler_rotation.Values : prev_action.m_start_euler_rotation.Values;
			m_start_scale.Values = prev_action_end_state ? prev_action.m_end_scale.Values : prev_action.m_start_scale.Values;
		}
		else
		{
			float[] start_pos_curve_letter_progressions = null;
			if (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(ref letters, m_letter_anchor_start);

			m_start_pos.CalculatePositionProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_pos.AnimatePer, m_start_pos.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_pos.Values : new[] { Vector3.zero });
			m_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters, 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.Values : new[] { Vector3.zero }, m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_start_pos.BezierCurve : null);
			m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_scale.AnimatePer, m_start_scale.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_scale.Values : new[] { Vector3.zero });
		}

		float[] end_pos_curve_letter_progressions = null;
		if (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(ref letters, m_letter_anchor_end);

		m_end_pos.CalculatePositionProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_pos.AnimatePer, m_end_pos.OverrideAnimatePerOption), m_start_pos.Values);
		m_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_euler_rotation.AnimatePer, m_end_euler_rotation.OverrideAnimatePerOption), m_start_euler_rotation.Values, m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_end_pos.BezierCurve : null);
		m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_scale.AnimatePer, m_end_scale.OverrideAnimatePerOption), m_start_scale.Values);

		CalculateLetterAnchorOffset();
	}
Esempio n. 42
0
 public void InsertAction(int index, LetterAction action)
 {
     if (index >= 0 && index <= m_letter_actions.Count)
         m_letter_actions.Insert(index, action);
 }
Esempio n. 43
0
	public void SoftResetStarts(LetterAction prev_action, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per)
	{
		if (m_use_gradient_start)
		{
			if (!m_offset_from_last && m_start_vertex_colour.UniqueRandom)
				m_start_vertex_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_vertex_colour.Values : null);
		}
		else if (!m_offset_from_last && m_start_colour.UniqueRandom)
			m_start_colour.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_colour.Values : null);

		if (!m_offset_from_last)
		{
			if (m_start_pos.UniqueRandom)
				m_start_pos.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_pos.Values : null);
			if (m_start_euler_rotation.UniqueRandom)
				m_start_euler_rotation.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_euler_rotation.Values : null);
			if (m_start_scale.UniqueRandom)
				m_start_scale.CalculateUniqueRandom(progression_variables, animate_per, prev_action != null ? prev_action.m_end_scale.Values : null);
		}
	}
Esempio n. 44
0
    private void SetCurrentLetterAction(LetterAction letter_action, AnimatePerOptions animate_per)
    {
        m_current_letter_action = letter_action;

        if (letter_action.m_action_type == ACTION_TYPE.ANIM_SEQUENCE)
            m_action_delay = Mathf.Max(m_current_letter_action.m_delay_progression.GetValue(m_progression_variables, m_last_animate_per), 0);
        m_action_duration = Mathf.Max(m_current_letter_action.m_duration_progression.GetValue(m_progression_variables, m_last_animate_per), 0);

        // Check if action is in a loopreverse_onetime delay case. If so, set delay to 0.
        if (m_anim_state_vars.m_active_loop_cycles != null && m_anim_state_vars.m_active_loop_cycles.Count > 0 && m_anim_state_vars.m_active_loop_cycles[0].m_delay_first_only && !m_anim_state_vars.m_active_loop_cycles[0].FirstPass && m_current_letter_action.m_delay_progression.Progression != (int)ValueProgression.Constant)
            if (m_anim_state_vars.m_reverse || !m_current_letter_action.m_force_same_start_time)
                m_action_delay = 0;
    }