// Called by ShootTarget instances when a valid mouseDown is detected public static void TargetHit(Vector3 position, TARGET_COLOUR colour) { // Grab next available text animation instance from object pool EffectManager hit_effect = m_instance.m_hit_effects[m_instance.m_hit_effect_index]; // Position effect object hit_effect.transform.position = position; // Grab reference to the audio effect setup on our text animation AudioEffectSetup audio_setup = hit_effect.GetAnimation(0).GetAction(0).GetAudioEffectSetup(0); // Depending on its colour value, dynamically alter the audio effect setup data. // Then set the text to the associated word, which automatically performs the necessary PrepareAnimationData() step. // Note: If text wasn't changing, you'd need to manually call hit_effect.PrepareAnimationData() before playing the animation, in order to see the effects of your changes switch (colour) { case TARGET_COLOUR.RED: audio_setup.m_audio_clip = m_instance.m_boom_clip; audio_setup.m_offset_time.SetConstant(0.2f); audio_setup.m_volume.SetConstant(0.5f); audio_setup.m_pitch.SetRandom(1.5f, 2.2f, true); hit_effect.SetText("BOOM!"); m_instance.m_points_manager.AddPoints(1); break; case TARGET_COLOUR.GREEN: audio_setup.m_audio_clip = m_instance.m_ding_clip; audio_setup.m_offset_time.SetConstant(0); audio_setup.m_volume.SetConstant(1); audio_setup.m_pitch.SetRandom(1.8f, 2.2f, true); hit_effect.SetText("DING!"); m_instance.m_points_manager.AddPoints(2); break; case TARGET_COLOUR.BLUE: audio_setup.m_audio_clip = m_instance.m_ding_clip; audio_setup.m_offset_time.SetConstant(0); audio_setup.m_volume.SetConstant(1); audio_setup.m_pitch.SetRandom(0.8f, 0.9f, true); hit_effect.SetText("DONG!"); m_instance.m_points_manager.AddPoints(3); break; } // hit_effect.PrepareAnimationData(); // Not required, since we've already set the text above, which will automatically prepare the animation data hit_effect.PlayAnimation(); // Progress the object pool index m_instance.m_hit_effect_index = (m_instance.m_hit_effect_index + 1) % EFFECT_POOL_SIZE; }
// Called by ShootTarget instances when a valid mouseDown is detected public static void TargetHit(Vector3 position, TARGET_COLOUR colour) { // Grab next available text animation instance from object pool EffectManager hit_effect = m_instance.m_hit_effects[m_instance.m_hit_effect_index]; // Position effect object hit_effect.transform.position = position; // Grab reference to the audio effect setup on our text animation AudioEffectSetup audio_setup = hit_effect.GetAnimation(0).GetAction(0).GetAudioEffectSetup(0); // Depending on its colour value, dynamically alter the audio effect setup data. // Then set the text to the associated word, which automatically performs the necessary PrepareAnimationData() step. // Note: If text wasn't changing, you'd need to manually call hit_effect.PrepareAnimationData() before playing the animation, in order to see the effects of your changes switch(colour) { case TARGET_COLOUR.RED: audio_setup.m_audio_clip = m_instance.m_boom_clip; audio_setup.m_offset_time.SetConstant(0.2f); audio_setup.m_volume.SetConstant(0.5f); audio_setup.m_pitch.SetRandom(1.5f, 2.2f, true); hit_effect.SetText("BOOM!"); m_instance.m_points_manager.AddPoints(1); break; case TARGET_COLOUR.GREEN: audio_setup.m_audio_clip = m_instance.m_ding_clip; audio_setup.m_offset_time.SetConstant(0); audio_setup.m_volume.SetConstant(1); audio_setup.m_pitch.SetRandom(1.8f, 2.2f, true); hit_effect.SetText("DING!"); m_instance.m_points_manager.AddPoints(2); break; case TARGET_COLOUR.BLUE: audio_setup.m_audio_clip = m_instance.m_ding_clip; audio_setup.m_offset_time.SetConstant(0); audio_setup.m_volume.SetConstant(1); audio_setup.m_pitch.SetRandom(0.8f, 0.9f, true); hit_effect.SetText("DONG!"); m_instance.m_points_manager.AddPoints(3); break; } // hit_effect.PrepareAnimationData(); // Not required, since we've already set the text above, which will automatically prepare the animation data hit_effect.PlayAnimation(); // Progress the object pool index m_instance.m_hit_effect_index = (m_instance.m_hit_effect_index+1) % EFFECT_POOL_SIZE; }
void SetupRandomColour() { m_colour = (TARGET_COLOUR) Random.Range(0,3); switch(m_colour) { case TARGET_COLOUR.BLUE: m_active_colour = m_blue_colour; break; case TARGET_COLOUR.GREEN: m_active_colour = m_green_colour; break; case TARGET_COLOUR.RED: m_active_colour = m_red_colour; break; } }
void SetupRandomColour() { m_colour = (TARGET_COLOUR)Random.Range(0, 3); switch (m_colour) { case TARGET_COLOUR.BLUE: m_active_colour = m_blue_colour; break; case TARGET_COLOUR.GREEN: m_active_colour = m_green_colour; break; case TARGET_COLOUR.RED: m_active_colour = m_red_colour; break; } }