Esempio n. 1
0
    public HFX_ParticleSystem PlayParticle(Transform parent, HFX_ParticleSystem prefab)
    {
        HFX_ParticleSystem system = GameObject.Instantiate <HFX_ParticleSystem>(prefab);

        system.transform.SetParent(parent, false);
        system.SetLightingMax(1f);
        system.Delay = PlaybackTime;
        system.Play(true, 0);

        m_PlayingParticles.Add(system);
        return(system);
    }
Esempio n. 2
0
    static public void AddParticleSystemToScene(Character character, HFX_ParticleSystem particle_system, float time)
    {
        if (character == null || particle_system == null)
        {
            return;
        }

        var new_particle_system = (PrefabUtility.InstantiatePrefab(particle_system.gameObject) as GameObject).GetComponent <HFX_ParticleSystem>();

        new_particle_system.transform.SetParent(character.transform, false);
        new_particle_system.SetPlaybackTime(0f);
    }
Esempio n. 3
0
    public void UpdatePlay(float playback_time)
    {
        if (gameObject.activeInHierarchy == false)
        {
            return;
        }

        try
        {
            PlaybackTime = playback_time;

            if (m_PlayingActions.Count > 0)
            {
                for (int i = 0; i < m_PlayingActions.Count;)
                {
                    ICharacterAction action = m_PlayingActions[i];
                    if ((BattleBase.Instance == null || BattleBase.Instance.IsPause != ePauseType.Pause || action.IsPause == false) && action.Update(PlaybackTime) == false)
                    {
                        m_PlayingActions.RemoveAt(i);
                        if (action == MainAction)
                        {
                            MainAction = null;
                        }
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            if (m_AnimationAdoptor != null && IsUpdateAnimation)
            {
                m_AnimationAdoptor.Update(PlaybackTime, m_FreezeCount > 0);
            }
            Tween.UpdatePlay(PlaybackTime);

            UpdateParticles();
            if (Application.isPlaying == true && m_DefaultEffect != null && m_PlayingDefaultEffect == null)
            {
                m_PlayingDefaultEffect = PlayParticle(m_DefaultEffect);
            }
            else if (m_PlayingDefaultEffect != null && m_PlayingDefaultEffect.IsPlaying == true && m_PlayingDefaultEffect.IsFinish == false && CharacterAnimation.IsDeadEnd)
            {
                m_PlayingDefaultEffect.Finish();
            }
        }
        catch (System.Exception ex)
        {
            throw new System.Exception(string.Format("[{0}] {1}", gameObject.name, ex.Message), ex);
        }
    }
Esempio n. 4
0
 void PlayParticle()
 {
     if (particle != null)
     {
         if (m_Particle == null)
         {
             m_Particle = GameObject.Instantiate <HFX_ParticleSystem>(particle);
             m_Particle.SetLightingMax(1f);
             m_Particle.transform.SetParent(transform, false);
         }
         m_Particle.Play(false, 0);
     }
 }
Esempio n. 5
0
 virtual public void Finish()
 {
     if (particle_system != null)
     {
         GameObject.Destroy(particle_system.gameObject);
         particle_system = null;
     }
     if (sound_play != null)
     {
         sound_play.Finish();
         sound_play = null;
     }
 }
Esempio n. 6
0
    static public HFX_ParticleSystem GetParticleSystem(string name)
    {
        name = name.ToLower();

        LoadFromFile();

        HFX_ParticleSystem res = null;

        {
            res = AllAssetBundle.LoadAsset <GameObject>(name).GetComponent <HFX_ParticleSystem>();
//             res.RefreshShader();
        }

        return(res);
    }
Esempio n. 7
0
    public HFX_ParticleSystem PlayParticle(HFX_ParticleSystem particle_prefab)
    {
        HFX_ParticleSystem particle_system = GameObject.Instantiate <HFX_ParticleSystem>(particle_prefab);

        particle_system.transform.SetParent(transform, false);
        particle_system.Play(true, 0);
        m_PlayingParticles.Add(particle_system);

        if (CharacterAnimation.Material.HasProperty("_LightMax"))
        {
            particle_system.SetLightingMax(CharacterAnimation.Material.GetFloat("_LightMax"));
        }
        particle_system.SetLensTilt(CharacterAnimation.IsUIMode == true ? 0.15f : 0f);

        return(particle_system);
    }
Esempio n. 8
0
 void UpdateParticles()
 {
     if (m_PlayingParticles.Count > 0)
     {
         for (int i = 0; i < m_PlayingParticles.Count;)
         {
             HFX_ParticleSystem particle = m_PlayingParticles[i];
             if (particle.UpdatePlay(PlaybackTime) == false && BattleBase.Instance.IsPause != ePauseType.Pause)
             {
                 m_PlayingParticles.RemoveAt(i);
             }
             else
             {
                 ++i;
             }
         }
     }
 }
Esempio n. 9
0
 override protected void Start(float playback_time)
 {
     base.Start(playback_time);
     if (particle_system_prefab != null)
     {
         particle_system = GameObject.Instantiate <HFX_ParticleSystem>(particle_system_prefab);
         particle_system.transform.SetParent(target.transform, false);
         particle_system.transform.localPosition += particle_position;
         particle_system.transform.localScale     = Vector3.Scale(particle_system.transform.localScale, particle_scale);
         particle_system.SetLightingMax(IsLighting ? 1f : 0f);
         particle_system.Play(true, 0);
         particle_system.SetLensTilt(target.CharacterAnimation.IsUIMode ? 0.15f : 0f);
         if (IsHidden)
         {
             particle_system.SetHidden(true);
         }
     }
     if (sound_list != null && sound_list.Length > 0 && sound_list[0].sound != null)
     {
         sound_play = SoundManager.PlaySound(sound_list, -(playback_time - time), sound_tick, sound_count, sound_loop);
     }
 }
Esempio n. 10
0
    static void ConvertHFX_Particle()
    {
        var paths = AssetDatabase.GetAllAssetPaths().Where(p => p.StartsWith("Assets/Particle/") && p.EndsWith(".prefab")).ToList();

        int progress = 0;

        foreach (string asset in paths)
        {
            if (EditorUtility.DisplayCancelableProgressBar("Convert HFX_Particle", asset, (++progress) / (float)paths.Count))
            {
                Debug.LogWarningFormat("Canceled");
                return;
            }

            GameObject         prefab = (GameObject)AssetDatabase.LoadAssetAtPath(asset, typeof(GameObject));
            GameObject         obj    = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
            HFX_ParticleSystem ps     = obj.GetComponent <HFX_ParticleSystem>();
            ps.CheckConvert();
            PrefabUtility.ReplacePrefab(obj, prefab);
            GameObject.DestroyImmediate(obj);
        }
        EditorUtility.ClearProgressBar();
    }
Esempio n. 11
0
    protected override void Start(float playback_time)
    {
        HFX_ParticleSystem temp_particle_system_prefab = particle_system_prefab;

        particle_system_prefab = null;

        base.Start(playback_time);

        if (temp_particle_system_prefab != null)
        {
            particle_system = GameObject.Instantiate <HFX_ParticleSystem>(temp_particle_system_prefab);
            particle_system.SetLightingMax(IsLighting?1f:0f);
            particle_system.transform.localPosition += particle_position;
            particle_system.ApplyScale(ActionScale);

            switch (AttachParticle)
            {
            case eAttachParticle.Target:
            case eAttachParticle.TargetScale:
                particle_system.transform.SetParent(target.transform.parent, false);
                if (AttachParticle == eAttachParticle.TargetScale)
                {
                    Vector3 scale = particle_system.transform.localScale;
                    scale *= ActionScale;
                    particle_system.transform.localScale = scale;
                }
                break;

            case eAttachParticle.Self:
                particle_system.transform.SetParent(self.transform.parent, false);
                break;

            case eAttachParticle.World:
            case eAttachParticle.WorldScale:
            case eAttachParticle.Center:
            case eAttachParticle.SelfCenter:
            case eAttachParticle.TargetCenter:
                particle_system_container = new GameObject(particle_system.name + " Container");
                particle_system.transform.SetParent(particle_system_container.transform, false);
                particle_system_container.transform.position = self.transform.position;
                if (AttachParticle == eAttachParticle.TargetCenter && target.transform.lossyScale.x < 0f || AttachParticle != eAttachParticle.TargetCenter && self.transform.lossyScale.x < 0f)
                {
                    Vector3 scale = particle_system_container.transform.localScale;
                    scale.x = -1f;
                    particle_system_container.transform.localScale = scale;
                }

                switch (AttachParticle)
                {
                case eAttachParticle.WorldScale:
                {
                    Vector3 scale = particle_system.transform.localScale;
                    scale *= ActionScale;
                    particle_system.transform.localScale = scale;
                }
                break;

                case eAttachParticle.SelfCenter:
                {
                    var self_layout = self.transform.parent.parent.GetComponent <CharacterLayout>();
                    particle_system_container.transform.position = self_layout.Center.transform.position;
                }
                break;

                case eAttachParticle.TargetCenter:
                {
                    var target_layout = target.transform.parent.parent.GetComponent <CharacterLayout>();
                    particle_system_container.transform.position = target_layout.Center.transform.position;
                }
                break;

                case eAttachParticle.Center:
                    particle_system_container.transform.position = Vector3.zero;
                    break;
                }
                break;
            }
            particle_system.Play(true, 0);
            particle_system.SetLensTilt(target.CharacterAnimation.IsUIMode ? 0.15f : 0f);

            if (string.IsNullOrEmpty(TweenName) == false)
            {
                HFX_TweenSystem tween = self.GetComponent <HFX_TweenSystem>();
                if (tween != null)
                {
                    tween_system = particle_system.GetComponent <HFX_TweenSystem>();
                    if (tween_system == null)
                    {
                        tween_system = particle_system.gameObject.AddComponent <HFX_TweenSystem>();
                    }
                    tween_system.IsPause = true;
                    switch (AttachParticle)
                    {
                    case eAttachParticle.World:
                        tween_bundle = tween.Play(TweenName, target.transform.parent, tween_system, null, 1f);
                        tween_bundle.SetClearWhenFinish(false);
                        break;

                    case eAttachParticle.WorldScale:
                        tween_bundle = tween.Play(TweenName, target.transform.parent, tween_system, null, ActionScale);
                        tween_bundle.SetClearWhenFinish(false);
                        break;

                    default:
                        tween_bundle = tween.Play(TweenName, target.transform.parent, tween_system, target.transform.GetChild(0), ActionScale);
                        break;
                    }
                }
            }
        }
    }
Esempio n. 12
0
    protected override void Start(float playback_time)
    {
        HFX_ParticleSystem temp_particle_system_prefab = particle_system_prefab;

        particle_system_prefab = null;

        base.Start(playback_time);

        if (temp_particle_system_prefab != null)
        {
            particle_system = GameObject.Instantiate <HFX_ParticleSystem>(temp_particle_system_prefab);
            particle_system.transform.localPosition += particle_position;
            particle_system.ApplyScale(ActionScale);

            switch (AttachType)
            {
            case eAttachParticle.Self:
            case eAttachParticle.Target:
            {
                particle_system.transform.SetParent(target.transform, false);
            }
            break;

            case eAttachParticle.World:
            case eAttachParticle.WorldZero:
            case eAttachParticle.WorldScale:
            case eAttachParticle.Center:
            case eAttachParticle.SelfCenter:
            case eAttachParticle.TargetCenter:
            {
                particle_system_container = new GameObject(particle_system.name + " Container");
                particle_system.transform.SetParent(particle_system_container.transform, false);
                if (AttachType != eAttachParticle.WorldZero)
                {
                    particle_system_container.transform.position = target.transform.position;
                }
                if (target.transform.lossyScale.x < 0f)
                {
                    Vector3 scale = particle_system_container.transform.localScale;
                    scale.x = -1f;
                    particle_system_container.transform.localScale = scale;
                }

                switch (AttachType)
                {
                case eAttachParticle.WorldScale:
                {
                    float   creature_scale = target.transform.lossyScale.x;
                    Vector3 scale          = particle_system.transform.localScale;
                    scale *= creature_scale;
                    particle_system.transform.localScale = scale;

                    Vector3 pos = particle_system.transform.localPosition;
                    pos *= creature_scale;
                    particle_system.transform.localPosition = pos;
                }
                break;

                case eAttachParticle.SelfCenter:
                case eAttachParticle.TargetCenter:
                {
                    Debug.LogWarningFormat("[{0}] Do Not use SelfCenter or TargetCenter in casting", particle_system.name);
                    var target_layout = target.transform.parent.parent.GetComponent <CharacterLayout>();
                    if (target_layout)
                    {
                        particle_system_container.transform.position = target_layout.Center.transform.position;
                    }
                }
                break;

                case eAttachParticle.Center:
                    particle_system_container.transform.position = Vector3.zero;
                    break;
                }
            }
            break;
            }
            particle_system.SetLightingMax(IsLighting ? 1f : 0f);
            particle_system.Play(true, 0);
            particle_system.SetLensTilt(target.CharacterAnimation.IsUIMode ? 0.15f : 0f);
        }
    }
Esempio n. 13
0
    protected override void Start(float playback_time)
    {
        HFX_ParticleSystem temp_particle_system_prefab = particle_system_prefab;

        particle_system_prefab = null;

        base.Start(playback_time);

        if (temp_particle_system_prefab != null)
        {
            particle_system = GameObject.Instantiate <HFX_ParticleSystem>(temp_particle_system_prefab);
            particle_system.SetLightingMax(IsLighting ? 1f : 0f);
            particle_system.transform.localPosition += particle_position;
            particle_system.ApplyScale(ActionScale);

            switch (AttachType)
            {
            case eAttachParticle.Target:
            case eAttachParticle.TargetScale:
                particle_system.transform.SetParent(target.transform, false);
                if (AttachType == eAttachParticle.TargetScale)
                {
                    Vector3 scale = particle_system.transform.localScale;
                    scale *= ActionScale;
                    particle_system.transform.localScale = scale;
                }
                break;

            case eAttachParticle.World:
            case eAttachParticle.WorldScale:
            case eAttachParticle.Center:
            case eAttachParticle.SelfCenter:
            case eAttachParticle.TargetCenter:
                particle_system_container = new GameObject(particle_system.name + " Container");
                particle_system.transform.SetParent(particle_system_container.transform, false);
                particle_system_container.transform.position = target.transform.position;
                if (AttachType == eAttachParticle.TargetCenter && target.transform.lossyScale.x < 0f || AttachType != eAttachParticle.TargetCenter && target.transform.lossyScale.x < 0f)
                {
                    Vector3 scale = particle_system_container.transform.localScale;
                    scale.x = -1f;
                    particle_system_container.transform.localScale = scale;
                }

                switch (AttachType)
                {
                case eAttachParticle.WorldScale:
                {
                    Vector3 scale = particle_system.transform.localScale;
                    scale *= ActionScale;
                    particle_system.transform.localScale = scale;
                }
                break;

                case eAttachParticle.SelfCenter:
                {
                    var self_layout = target.transform.parent.parent.GetComponent <CharacterLayout>();
                    particle_system_container.transform.position = self_layout.Center.transform.position;
                }
                break;

                case eAttachParticle.TargetCenter:
                {
                    var target_layout = target.transform.parent.parent.GetComponent <CharacterLayout>();
                    particle_system_container.transform.position = target_layout.Center.transform.position;
                }
                break;

                case eAttachParticle.Center:
                    particle_system_container.transform.position = Vector3.zero;
                    break;
                }
                break;
            }
            particle_system.Play(true, 0);
            particle_system.SetLensTilt(target.CharacterAnimation.IsUIMode ? 0.15f : 0f);
        }
    }