Inheritance: MonoBehaviour
示例#1
0
        public static void SetShakeShader()
        {
            unbindVignetteShader();
            ShakeEffect effect = new ShakeEffect();

            effect.RunBlocking(TimeSpan.FromSeconds(5));
        }
示例#2
0
    public void ShakeCamera(float length, float stength, float fadeToStrength)
    {
        ShakeEffect newEffect = new ShakeEffect(length, stength);

        newEffect.TransitionStrength(fadeToStrength);
        shakeEffects.Add(newEffect);
    }
示例#3
0
 private void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
 public void AddShake(float lifetime, Vector3 spread, float minSpeed, float maxSpeed)
 {
     if (_shakeEffect == null && TargetAttributes != null)
     {
         _shakeEffect = new ShakeEffect(lifetime, TargetAttributes.DistanceModifier, spread, minSpeed, maxSpeed);
     }
 }
    private void Start()
    {
        mainCameraBehaviour = Camera.main.GetComponent <ShakeEffect>();

        switch (controller)
        {
        case Controllers.Kinect:
        {
            GetComponent <KinectPlayerController>().enabled = true;
            GetComponent <PlayerControllerRieles>().enabled = false;

            break;
        }

        case Controllers.Keyboard:
        {
            GetComponent <KinectPlayerController>().enabled = false;
            GetComponent <PlayerControllerRieles>().enabled = true;

            break;
        }

        default:
            break;
        }
    }
示例#6
0
    public static void ShakeCamera(float _intensity, float _duration, float _frequency, AnimationCurve _intensityCurve)
    {
        if (cameraShaker == null)
        {
            cameraShaker = new GameObject().AddComponent <ShakeEffect>();
            cameraShaker.gameObject.name = "Camera Shaker";
        }
        ShakeData i_shakeData = new ShakeData(_intensity * (PlayerPrefs.GetFloat("REU_Screenshake_intensity", 100) / 100), _duration, _frequency);

        i_shakeData.intensityCurve = _intensityCurve;
        if (currentShake != null)
        {
            if (_intensity > currentShake.intensity)
            {
                shakeList.Add(currentShake);
                currentShake = i_shakeData;
                shakeList.Add(i_shakeData);
            }
            else
            {
                shakeList.Add(i_shakeData);
            }
        }
        else
        {
            currentShake = i_shakeData;
            shakeList.Add(i_shakeData);
        }
    }
示例#7
0
 // Start is called before the first frame update
 void Awake()
 {
     origin      = transform.position;
     pi          = new PlayerInput();
     rb          = GetComponent <Rigidbody2D>();
     anim        = GetComponentInParent <Animator>();
     shakeEffect = new ShakeEffect();
 }
示例#8
0
 // Use this for initialization
 void Start()
 {
     shakeFX = GetComponent<ShakeEffect>();
     shakeFX.loop = true;
     carController = transform.root.GetComponent<CarController>();
     initialPos = transform.localPosition;
     cam = GetComponent<Camera>();
 }
示例#9
0
    public void Start()
    {
        localRigidbody = GetComponent <Rigidbody>();
        localRenderer  = GetComponent <Renderer>();
        audioSource    = GetComponent <AudioSource>();
        shakeEffect    = Camera.main.GetComponent <ShakeEffect>();

        localRenderer.material.color = playerColor;
    }
示例#10
0
        protected override void DoInit()
        {
            base.DoInit();

            _rigid             = GetComponent <Rigidbody2D> ();
            _rigid.isKinematic = true;
            _collid            = GetComponent <Collider2D> ();
            _collid.isTrigger  = true;
            Vector2DUtils.ChangePositionZ(transform, (float)ZIndexs.o4);
            _shakeEffect = GetComponent <ShakeEffect> ();
//			_shakeEffect.autoStart = false;
        }
示例#11
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("Nie moze byc dwoch instancji klasy ShakeEffect na scenie!");
        }
        else
        {
            instance = this;
        }

        randomSeed = Random.Range(0f, 1f);
    }
示例#12
0
    // Start is called before the first frame update
    void Start()
    {
        // Singleton
        if (shakeEffect == null)
        {
            shakeEffect = this;
        }
        else
        {
            Destroy(gameObject);
        }

        camPosition = transform.position;
    }
示例#13
0
    public void SetEffect(string effect, float intensity = -1)
    {
        if (effect == null)
        {
            throw new CYFException("Text.SetEffect: The first argument (the effect name) is nil.\n\nSee the documentation for proper usage.");
        }
        CheckExists();
        switch (effect.ToLower())
        {
        case "none":
            textEffect = null;
            break;

        case "twitch":
            if (intensity != -1)
            {
                textEffect = new TwitchEffect(this, intensity);
            }
            else
            {
                textEffect = new TwitchEffect(this);
            }
            break;

        case "shake":
            if (intensity != -1)
            {
                textEffect = new ShakeEffect(this, intensity);
            }
            else
            {
                textEffect = new ShakeEffect(this);
            }
            break;

        case "rotate":
            if (intensity != -1)
            {
                textEffect = new RotatingEffect(this, intensity);
            }
            else
            {
                textEffect = new RotatingEffect(this);
            }
            break;

        default:
            throw new CYFException("The effect \"" + effect + "\" doesn't exist.\nYou can only choose between \"none\", \"twitch\", \"shake\" and \"rotate\".");
        }
    }
示例#14
0
    public STGEffectBase CreateEffectByType(EffectType type)
    {
        STGEffectBase effect = GetEffectFromPool(type);

        if (effect == null)
        {
            switch (type)
            {
            case EffectType.SpriteEffect:
                effect = new STGSpriteEffect();
                break;

            case EffectType.ShakeEffect:
                effect = new ShakeEffect();
                break;

            case EffectType.BreakScreenEffect:
                effect = new STGBreakScreenEffect();
                break;

            case EffectType.BurstEffect:
                effect = new STGBurstEffect();
                break;

            case EffectType.ChargeEffect:
                effect = new STGChargeEffect();
                break;

            case EffectType.BulletEliminate:
                effect = new STGBulletEliminateEffect();
                break;

            case EffectType.EnemyEliminated:
                effect = new STGEnemyEliminatedEffect();
                break;

            case EffectType.PlayerDeadEffect:
                effect = new STGPlayerDeadEffect();
                break;
            }
        }
        if (effect != null)
        {
            effect.Init();
            _effectList.Add(effect);
            _effectsCount++;
        }
        return(effect);
    }
    protected override void OnCollision(Collider2D _collider)
    {
        IceBlock _iceBlock = _collider.GetComponent <IceBlock>();

        ShakeEffect _camera = Camera.main.GetComponent <ShakeEffect>();

        _camera.Shake(0.05f, 0.2f);

        if (_iceBlock)
        {
            Destroy(_iceBlock.gameObject);
        }

        DestroyParticle();
    }
示例#16
0
    /// <summary>
    /// 抖动屏幕
    /// <para>delay</para>
    /// <para>duration</para>
    /// <para>interval 抖动间隔</para>
    /// <para>shakeLevel 震幅</para>
    /// <para>minShakeLevel 最小震幅</para>
    /// <para>maxRange 最大范围</para>
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int ShakeScreen(ILuaState luaState)
    {
        ShakeEffect effect        = EffectsManager.GetInstance().CreateEffectByType(EffectType.ShakeEffect) as ShakeEffect;
        string      name          = luaState.ToString(-7);
        int         delay         = luaState.ToInteger(-6);
        int         shakeDuration = luaState.ToInteger(-5);
        int         shakeInterval = luaState.ToInteger(-4);
        float       shakeLevel    = (float)luaState.ToNumber(-3);
        float       minShakeLevel = (float)luaState.ToNumber(-2);
        float       maxRange      = (float)luaState.ToNumber(-1);

        effect.SetName(name);
        effect.DoShake(delay, shakeDuration, shakeInterval, shakeLevel, minShakeLevel, maxRange);
        return(0);
    }
示例#17
0
    public void Start()
    {
        // Setting references
        body = GetComponent <Body>();
        body.GravityMultiplier = 0f;

        shakeEffect = GetComponent <ShakeEffect>();

        // Starting timer
        airTime = maxAirTime;

        // Creating start particles
        Instantiate(startParticlePrefab, transform.position, Quaternion.identity);

        // Checking for collision
        CheckForCollision();
    }
示例#18
0
    public void SetEffect(string effect, float intensity)
    {
        switch (effect.ToLower())
        {
        case "none":
            textEffect = null;
            break;

        case "twitch":
            if (intensity != -1)
            {
                textEffect = new TwitchEffect(this, intensity);
            }
            else
            {
                textEffect = new TwitchEffect(this);
            }
            break;

        case "shake":
            if (intensity != -1)
            {
                textEffect = new ShakeEffect(this, intensity);
            }
            else
            {
                textEffect = new ShakeEffect(this);
            }
            break;

        case "rotate":
            if (intensity != -1)
            {
                textEffect = new RotatingEffect(this, intensity);
            }
            else
            {
                textEffect = new RotatingEffect(this);
            }
            break;

        default:
            throw new CYFException("The effect \"" + effect + "\" doesn't exist.\nYou can only choose between \"none\", \"twitch\", \"shake\" and \"rotate\".");
        }
    }
示例#19
0
 private void CollidedByEnemyCallback(ObjectColliderBase collider, ICollisionObject enemy)
 {
     ClearCollider();
     if (!_isFinish)
     {
         Explode();
         ShakeEffect effect = EffectsManager.GetInstance().CreateEffectByType(EffectType.ShakeEffect) as ShakeEffect;
         effect.DoShake(0, 5, 1, 5);
         //ObjectColliderBase newCollider = ColliderManager.GetInstance().CreateColliderByType(eColliderType.Circle);
         //newCollider.SetSize(_size, _size);
         //newCollider.SetPosition(_curPos);
         //newCollider.SetEliminateType(eEliminateDef.PlayerSpellCard);
         //newCollider.SetColliderGroup(eColliderGroup.Enemy | eColliderGroup.EnemyBullet);
         //newCollider.SetHitEnemyDamage(_dmg);
         //newCollider.SetExistDuration(1);
         _isFinish = true;
     }
 }
示例#20
0
    public override void Start()
    {
        _masterSparkObject = ResourceManager.GetInstance().GetPrefab("Prefab/Character/MarisaA", "MasterSpark");
        UIManager.GetInstance().AddGoToLayer(_masterSparkObject, LayerId.PlayerBarage);
        _masterSparkTf = _masterSparkObject.transform;
        Vector2 playerPos = Global.PlayerPos;
        Vector3 pos       = new Vector3(playerPos.x + _posOffset.x, playerPos.y + _posOffset.y, MasterSparkPosZ);

        _masterSparkTf.localPosition = pos;
        Transform tf;

        for (int i = 0; i < MovementObjectCount; i++)
        {
            tf = _masterSparkTf.Find("SparkWave" + i);
            _movementObjectTfList.Add(tf);
        }
        _sparkContainerTf = _masterSparkTf.Find("SparkContainer");
        _movementBodyTf   = _sparkContainerTf.Find("MovementBody");
        // 黑底
        _effect = EffectsManager.GetInstance().CreateEffectByType(EffectType.SpriteEffect) as STGSpriteEffect;
        _effect.SetSprite("ShapeAtlas", "ShapeCircle", eBlendMode.Normal, LayerId.STGBottomEffect, false);
        _effect.SetSize(0, 0);
        _effect.SetSpriteColor(0, 0, 0, 1);
        _effect.ChangeWidthTo(1024, 50, InterpolationMode.EaseInQuad);
        _effect.ChangeHeightTo(1024, 50, InterpolationMode.EaseInQuad);
        _effect.SetPosition(playerPos.x, playerPos.y);
        // 基础属性
        _curState = 1;
        _time     = 0;
        _duration = 30;
        _isFinish = false;
        // 震动
        ShakeEffect shakeEffect = EffectsManager.GetInstance().CreateEffectByType(EffectType.ShakeEffect) as ShakeEffect;

        shakeEffect.DoShake(0, 270, 3, 3f, 1.5f, 5);
        // 音效
        SoundManager.GetInstance().Play("se_masterspark", 0.1f, false, true);
    }
    // Based on the camera attributes and the target's special camera attributes, find out where the
    // camera should move to.
    public Vector3 GetGoalPosition(float elapsedTime)
    {
        // Our camera script can take attributes from the target.  If there are no attributes attached, we have
        // the following defaults.

        // How high in world space should the camera look above the target?
        float heightOffset = 0.0f;
        // How much should we zoom the camera based on this target?
        float distanceModifier = 1.0f;
        // By default, we won't account for any target velocity or chaos in our calculations;
        float   velocityLookAheadX = 0.0f;
        float   velocityLookAheadY = 0.0f;
        Vector2 maxLookAhead       = new Vector2(0.0f, 0.0f);

        // If our target has special attributes, use these instead of our above defaults.
        if (TargetAttributes != null)
        {
            heightOffset = TargetAttributes.HeightOffset;

            if (TargetAnimator != null && TargetAnimator.IsDead)
            {
                distanceModifier = TargetAttributes.DeathZoom;
            }
            else if (_shakeEffect != null)
            {
                distanceModifier = _shakeEffect.OldDistanceModifier;
            }
            else if (_cinematicOverride)
            {
                distanceModifier = 0.5f;
            }
            else
            {
                distanceModifier = TargetAttributes.DistanceModifier;
            }

            velocityLookAheadX = TargetAttributes.VelocityLookAheadX;
            velocityLookAheadY = TargetAttributes.VelocityLookAheadY;
            maxLookAhead       = TargetAttributes.MaxLookAhead;
        }

        Vector3 goalPosition = Target.position + new Vector3(0, heightOffset, -Distance * distanceModifier);

        Vector3 nearestEnemy = Vector3.zero;

        _enemyFocused = GetNearestEnemy(out nearestEnemy);
        if (_enemyFocused)
        {
            goalPosition += (nearestEnemy - GameManager.Player.transform.position) * 0.5f
                            + new Vector3(0, 0, -Vector3.Distance(nearestEnemy, GameManager.Player.transform.position) * 0.25f);
        }

        // Next, we refine our goalPosition by taking into account our target's current velocity.
        // This will make the camera slightly look ahead to wherever the character is going.

        // First assume there is no velocity.
        // This is so if the camera's target is not a Rigidbody, it won't do any look-ahead calculations because everything will be zero.
        Vector3 targetVelocity = Vector3.zero;

        // If we find a Rigidbody on the target, that means we can access a velocity!
        if (TargetRigidbody)
        {
            targetVelocity = TargetRigidbody.velocity;
        }


        // If the target has a velocity, we use that velocity
        if (TargetAnimator)
        {
            targetVelocity = TargetAnimator.Velocity;
        }


        // Estimate what the target's position will be in velocityLookAhead seconds (position = velocity * time).
        Vector3 lookAhead = targetVelocity;

        lookAhead.x *= velocityLookAheadX;
        lookAhead.y *= velocityLookAheadY;

        // We clamp the lookAhead vector to some sane values so that the target doesn't go offscreen.
        // This calculation could be more advanced (lengthy), taking into account the target's viewport position,
        // but this works pretty well in practice.
        lookAhead.x = Mathf.Clamp(lookAhead.x, -maxLookAhead.x, maxLookAhead.x);
        lookAhead.y = Mathf.Clamp(lookAhead.y, -maxLookAhead.y, maxLookAhead.y);
        // We never want to take z velocity into account as this is 2D.  Just make sure it's zero.
        lookAhead.z = 0.0f;

        // We want to make sure our lookahead accounts for how zoomed in the camera is
        lookAhead *= distanceModifier;

        // Stop looking ahead if we tagged it to false
        if (TargetAnimator != null && TargetAnimator.CurrentState.IsTag("NoLookAhead"))
        {
            lookAhead = Vector3.zero;
        }


        // Now add in our lookAhead calculation.  Our camera following is now a bit better!
        goalPosition += lookAhead;

        // Shake the camera if told
        if (_shakeEffect != null)
        {
            if (!_shakeEffect.IsDone)
            {
                goalPosition += _shakeEffect.Shake(elapsedTime);
            }
            else
            {
                _shakeEffect = null;
            }
        }

        // We will also make it so that the positions beyond the level boundaries are never seen.
        Vector3 clampOffset = Vector3.zero;

        // Temporarily set the camera to the goal position so we can test positions for clamping.
        // But first, save the previous position.
        Vector3 cameraPositionSave = transform.position;

        transform.position = goalPosition;

        // Get the target position in viewport space.  Viewport space is relative to the camera.
        // The bottom left is (0,0) and the upper right is (1,1)
        Vector3 targetViewportPosition = GetComponent <Camera>().WorldToViewportPoint(Target.position);

        // First clamp to the right and top.  After this we will clamp to the bottom and left, so it will override this
        // clamping if it needs to.  This only occurs if the level is really small so that the camera sees more than
        // the entire level at once.

        // What is the world position of the very upper right corner of the camera?
        Vector3 upperRightCameraInWorld = GetComponent <Camera>().ViewportToWorldPoint(new Vector3(1.0f, 1.0f, targetViewportPosition.z));

        // Find out how far outside the world the camera is right now.
        clampOffset.x = Mathf.Min(GameManager.Level.Boundaries.xMax - upperRightCameraInWorld.x, 0.0f);
        clampOffset.y = Mathf.Min((GameManager.Level.Boundaries.yMax - upperRightCameraInWorld.y), 0.0f);

        // Now we apply our clamping to our goalPosition.  Now our camera won't go past the right and top boundaries of the level!
        goalPosition += clampOffset;

        // Now we do basically the same thing, except clamp to the lower left of the level.  This will override any previous clamping
        // if the level is really small.  That way you'll for sure never see past the lower-left of the level, but if the camera is
        // zoomed out too far for the level size, you will see past the right or top of the level.

        transform.position = goalPosition;
        Vector3 lowerLeftCameraInWorld = GetComponent <Camera>().ViewportToWorldPoint(new Vector3(0.0f, 0.0f, targetViewportPosition.z));

        // Find out how far outside the world the camera is right now.
        clampOffset.x = Mathf.Max((GameManager.Level.Boundaries.xMin - lowerLeftCameraInWorld.x), 0.0f);
        clampOffset.y = Mathf.Max((GameManager.Level.Boundaries.yMin - lowerLeftCameraInWorld.y), 0.0f);

        // Now we apply our clamping to our goalPosition once again.  Now our camera won't go past the left and bottom boundaries of the level!
        goalPosition += clampOffset;

        // Now that we're done calling functions on the camera, we can set the position back to the saved position;
        transform.position = cameraPositionSave;


        return(goalPosition);
    }
 void Start()
 {
     _shakeEffect = null;
 }
示例#23
0
 public static async void SetShakeShader()
 {
     unbindVignetteShader();
     ShakeEffect effect = new ShakeEffect();
     await effect.RunAsync(TimeSpan.FromSeconds(5));
 }
示例#24
0
    public void ShakeCamera(float length, float stength)
    {
        ShakeEffect newEffect = new ShakeEffect(length, stength);

        shakeEffects.Add(newEffect);
    }
示例#25
0
 void ApplyEffect()
 {
     shake = GameObject.FindGameObjectWithTag("ShakeEffect").GetComponent <ShakeEffect> ();
     shake.CameraShake();
     Instantiate(playerEffect, transform.position, Quaternion.identity);
 }