示例#1
0
    //完成
    void OnFinish()
    {
        if (!Application.isPlaying)
        {
            for (int i = 0; i < _particleSystems.Length; i++)
            {
                StopSimulate(_particleSystems[i]);
            }

            for (int i = 0; i < _effects.Length; i++)
            {
                HideOtherRenderer(_effects[i].transform);
            }
        }
        else
        {
            Stop();
        }

        if (finishCallBack != null)
        {
            finishCallBack();
            finishCallBack = null; //仅需回掉一次
        }

        _time     = 0;
        _isFinish = true;
    }
 /// <summary>
 /// Настройка поведения снаряда
 /// </summary>
 public void SetupProjectileBehaviour(WeaponProjectile weaponProjectile, Vector3 velocity, ProjectileCallback projectileCallback = ProjectileCallback.PROJECTILE_CALLBACK_NONE)
 {
     this.weaponProjectile   = weaponProjectile;
     this.projectileCallback = projectileCallback;
     gameObject.GetComponent <Rigidbody>().velocity = velocity;
 }
示例#3
0
    /// <summary>
    /// 通用Update
    /// </summary>
    /// <param name="time"></param>
    public void CommonUpdate(float time)
    {
        if (!_isInit || _isFinish)
        {
            return;
        }
        float t = time / flyTime;

        if (t > 1)
        {
            t = 1;
            if (!_isFadeOut)
            {
                _isFadeOut = true;
                if (_particleSystems != null)
                {
                    for (int i = 0; i < _particleSystems.Length; i++)
                    {
                        _particleSystems[i].EnableEmission(false);
                    }
                }
            }
            if (hitCallBack != null)
            {
                hitCallBack();
                hitCallBack = null;//仅需回掉一次
            }
        }
        if (_particleSystems != null)
        {
            for (int i = 0; i < _particleSystems.Length; i++)
            {
                PlaySimulate(_particleSystems[i], _effects[i], time, time - effectTimes[i], i);
                effectTimes[i] = time;
            }
        }

        float y = (motionCurve.Evaluate(System.Math.Min(0, 1.0f)) - motionCurve.Evaluate(System.Math.Min(t, 1.0f))) * 10;

        if (t > 0.8 && isTarget) // 如果以后需要刷新目标位置可以使用
        {
            if (isOnly && mainTarget != null)
            {
            }
            else
            {
            }
        }

        if (_effects != null)
        {
            for (int i = 0; i < _effects.Length; i++)
            {
                if (_effects[i] == null)
                {
                    continue;
                }
                Vector3 behind = (_tagetPoints[i] - transform.position);
                _effects[i].transform.position = transform.position + t * behind + new Vector3(0f, y, 0f);
                if (isLookAtTarget)
                {
                    _effects[i].transform.LookAt(_tagetPoints[i]);
                }
            }
        }

        if (time > flyTime + fadeOutTime)
        {
            OnFinish();
        }
    }