예제 #1
0
    public void KnockbackLand(int i)
    {
        knockback = true;
        float x = 1; float y = 1;

        StartCoroutine(_shaker.Shake());

        if (i == 1)
        {
            x = -1; y = -1;
            StartCoroutine(LandKnockback(new Vector2(x, y)));
        }
        else if (i == 2)
        {
            y = -1;
            StartCoroutine(LandKnockback(new Vector2(x, y)));
        }
        else if (i == 3)
        {
            StartCoroutine(LandKnockback(new Vector2(x, y)));
        }
        else if (i == 4)
        {
            x = -1;
            StartCoroutine(LandKnockback(new Vector2(x, y)));
        }
    }
예제 #2
0
 static public int Shake(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         Shaker        self = (Shaker)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         self.Shake(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
예제 #3
0
 /// <summary>
 /// Control how many damage the player take
 /// </summary>
 /// <param name="damage"></param>
 public void TakeDamage(int damage)
 {
     health -= damage;
     shaker.Shake(0.1f);
     UIGestion();
     Debug.Log(health);
 }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         shaker.Shake(duration);
     }
 }
예제 #5
0
        private void HandleDeath()
        {
            if (isDead)
            {
                return;
            }
            isDead = true;

            splatter.Spawn(dieSplatterSettins, transform.position, null, dieSplatterColor);

            if (screenShake != null)
            {
                screenShake.magnitude = shakeMagnitude;
                screenShake.duration  = shakeDuration;
                screenShake.Shake();
            }

            // If this is last target - restart.
            numTargets--;
            if (numTargets <= 0)
            {
                StartCoroutine(HandleGameCompleted());
            }
            else
            {
                gameObject.SetActive(false);
            }
        }
예제 #6
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         StartCoroutine(sk.Shake(.15f, .4f));
     }
 }
예제 #7
0
    public void SetOn(bool on)
    {
        if (!gameOver && isOn != on)
        {
            isOn = on;

            animator.SetBool("isOn", isOn);
            pulsator.enabled = isOn;
            cameraShaker.Shake();

            if (!isOn)
            {
                timeOff = Random.Range(2.0f, 8.0f);
                timeAcc = 0.0f;
                audioManager.CreateTemporaryAudioSource("BoardSwitchOff");
                backgroundMusic.pitch = 0.5f;
            }
            else
            {
                audioManager.CreateTemporaryAudioSource("BoardSwitchOn");
                backgroundMusic.pitch = 1.0f;
                board.SpeedUp();
            }
        }
    }
예제 #8
0
 // Update is called once per frame
 void Update()
 {
     if (shake == true)
     {
         shake = false;
         MyShaker.Shake(ShakePreset);
     }
 }
예제 #9
0
 private void Update()
 {
     //Start the shake, with a fade-in time of 1 second.
     if (Input.GetKeyDown(KeyCode.Q))
     {
         MyShaker.Shake(ShakePreset);
     }
 }
예제 #10
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         PlayerControl.Instance.Alive = false;
         StartCoroutine(shaker.Shake(cameraRef, duration, magnitude, rotationMagnitude));
         StartCoroutine(ActivateSawSound());
     }
 }
예제 #11
0
    public void DestroyMissile()
    {
        Shaker.Shake(0.1f);
        Vector3   pos = new Vector3(transform.position.x, transform.position.y, -2f);
        Transform exp = Instantiate(GameManager.Instance.ExplosionPrefab, pos, Quaternion.identity);

        exp.GetComponent <Explosion>().PlayExplosionSound("small");
        Destroy(gameObject);
    }
예제 #12
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.name == this.gameObject.name)
     {
         Debug.Log("aaaaaaaaaa");
         Sound.PlaySound("crash");
         shaker.Shake(shake_preset);
     }
 }
 public static void Die()
 {
     died = true;
     Shaker.SetShakeLengthSpeed(1f, 55f);
     Shaker.Shake(0.12f);
     Reder.MakeRed("dead");
     Time.timeScale = 0.5f;
     AfterGameButtonListeners.year = Year.GetYear();
     BlackFader.GoToScene("AfterGame", UnityEngine.SceneManagement.LoadSceneMode.Single, 1f, Instance.Ressurect, null);
 }
예제 #14
0
        public void ShakeTest()
        {
            var generator = new StubRandom();
            var die       = new Die(generator);
            var shaker    = new Shaker();

            shaker.AddDie(die);
            shaker.Shake();
            Assert.True(shaker.Dice.First().FaceValue == StubRandom.DEFAULT_VALUE);
        }
예제 #15
0
    void DestroyBullet()
    {
        Destroy(gameObject);
        ScreenshakeManager Shaker;

        if (Shaker = Camera.main.GetComponent <ScreenshakeManager>())
        {
            Shaker.Shake(0.2f);
        }
    }
예제 #16
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "enem01" || collision.gameObject.tag == "enem02" || collision.gameObject.tag == "enem03")
     {
         GameObject firework = Instantiate(particles, transform.position, Quaternion.identity);
         firework.GetComponent <ParticleSystem>().Play();
         Destroy(firework, 1f);
         Destroy(gameObject);
         //Shake camera
         camShake.Shake(camShakeAmt, 0.2f);
         AudioManager.instance.PlaySound("PlayerHit");
     }
     else
     {
         GameObject firework = Instantiate(particles, transform.position, Quaternion.identity);
         firework.GetComponent <ParticleSystem>().Play();
         Destroy(firework, 1f);
         Destroy(gameObject);
     }
 }
예제 #17
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Shaker myScript = (Shaker)target;

        if (GUILayout.Button("Shake"))
        {
            myScript.Shake();
        }
    }
예제 #18
0
    protected override void OnTakeDamage(int amount)
    {
        int val = Mathf.Clamp(CurHealth - amount, 0, MaxHealth);

        bar.SetValue(val);

        if (shaker != null)
        {
            shaker.Shake(0.5f);
        }
    }
예제 #19
0
파일: Balloon.cs 프로젝트: Gr1nS1de/Rotary
        private IEnumerator HandleBaloonPop(Vector3 pos)
        {
            gameObject.SetActive(false);
            splatter.Spawn(pos);
            if (screenShake != null)
            {
                screenShake.Shake();
            }

            yield return(0);
        }
예제 #20
0
 /// <summary>
 /// Fait subir des dégâts au joueur
 /// </summary>
 /// <param name="amount">Montant de dégâts reçu</param>
 public void TakeDamages(int amount)
 {
     health -= amount;
     /* Animation Shake*/
     myShaker.Shake(preset);
     if (health <= 0)
     {
         health = 0;
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
     SetHealth(health);
 }
예제 #21
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "boundUP")
        {
            direcao = new Vector3(direcao.x, -direcao.y);
        }

        else if (col.tag == "bounderies")
        {
            direcao = new Vector3(-direcao.x, direcao.y);
        }

        else if (col.tag == "bloco")
        {
            Vector3 cp           = col.ClosestPoint(transform.position);
            Vector3 rel_position = transform.position - cp;

            if (Mathf.Abs(rel_position.y) > 0.1)
            {
                direcao = new Vector3(direcao.x, -direcao.y);
            }
            else
            {
                direcao = new Vector3(-direcao.x, direcao.y);
            }

            // Debug.Log($"cp: {cp} | rel: {rel_position.normalized}");

            gm.pontos++;

            sound_behavior.PlaySound("log_break");
        }

        else if (col.tag == "Player")
        {
            Vector3 rel_position = transform.position - col.transform.position;

            Debug.Log($"col: {col.transform.position} | pos: {transform.position} | rel: {rel_position} ");

            BallMovment(rel_position.x * 2, rel_position.x * 2);
        }

        else
        {
            gm.vidas--;
            shaker.Shake(preset);
            Reset();
            sound_behavior.PlaySound("dmg");

            // direcao = new Vector3(0, 0).normalized;
        }
    }
예제 #22
0
파일: Pickup.cs 프로젝트: Gr1nS1de/Rotary
        private void HandleParticleCollision(Vector3 position, Vector3 velocity)
        {
            if (splatterManager != null)
            {
                splatterManager.Spawn(position, velocity.normalized, splatterColor);
            }

            // Screen shake on landing.
            if (screenShake != null)
            {
                screenShake.Shake();
            }
        }
예제 #23
0
    public virtual void Damage()
    {
        if (isDead == false)
        {
            health -= 1;
            shaker.Shake(.15f, damageShakeAmount);

            if (health <= 0)
            {
                isDead = true;
                Invoke("OnHealthDepleted", shaker.ShakeDuration);
            }
        }
    }
예제 #24
0
        private void Start()
        {
            VerticalMovement = GetComponentInParent <VerticalMovement>();
            Dash             = GetComponentInParent <DashMovement>();
            Shaker           = GameObject.Find("Main Camera").GetComponent <CameraShaker>();

            Fragments = fragments.Select(f => new Fragment()
            {
                Renderer = f.GetComponent <SpriteRenderer>(),
                Light    = f.GetComponent <Light2D>()
            })
                        .ToArray();

            foreach (var fragment in Fragments)
            {
                fragment.Light.enabled  = false;
                fragment.Renderer.color = unActiveFragmentColor;
            }

            VerticalMovement.Subscribe(VerticalState.Rising, OnStateEnter, () =>
            {
                Reset();
                bool isSquash = VerticalMovement.PreviousState != VerticalState.WallSliding;
                JumpStretch   = Stretch(isSquash);
                StartCoroutine(JumpStretch);
            });

            VerticalMovement.Subscribe(VerticalState.Grounded, OnStateEnter, () =>
            {
                Reset();
                LandSquash = Stretch(false);
                StartCoroutine(LandSquash);
            });

            Dash.Subscribe(DashState.Dashing, OnStateEnter, () =>
            {
                Reset();
                bool isSquash = Mathf.Abs(Inputs.DashDirection.y) == 1;
                DashStretch   = Stretch(isSquash);
                StartCoroutine(DashStretch);

                if (CameraShake != null)
                {
                    StopCoroutine(CameraShake);
                }

                CameraShake = Shaker.Shake(shakeDuration, shakeIntensity);
                StartCoroutine(CameraShake);
            });
        }
예제 #25
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (isDead)
     {
         return;
     }
     if (col.gameObject.tag == "bullet")
     {
         if (!col.gameObject.GetComponent <State>().state)
         {
             if (GetComponent <Renderer>().IsVisibleFrom(cam.GetComponent <Camera>()) && !isStunned)
             {
                 Shaker.Shake(stunCameraShake);
             }
             GetComponent <SpriteRenderer>().color = new Color(255f, 255f, 0f);
             isStunned = true;
             //frozenPos = transform.position;
         }
         else if (col.gameObject.GetComponent <State>().state&& isStunned)
         {
             if (GetComponent <Renderer>().IsVisibleFrom(cam.GetComponent <Camera>()))
             {
                 Shaker.Shake(deathCamShake);
                 GetComponent <SpriteRenderer>().color = new Color(0f, 0f, 0f);
                 ps.Play();
                 ShowFloatingText();
             }
             isDead = true;
             GetComponent <SpriteRenderer>().enabled = false;
             //GetComponent<SpriteRenderer>().color = new Color(255f, 0f, 0f);
         }
         else
         {
             GetComponent <SpriteRenderer>().color = new Color(255f, 0f, 255f);
         }
     }
 }
예제 #26
0
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistince, whatsGround);
        if (isGrounded == true && wasGrounded == false)
        {
            Landing.Shake(land);
        }

        wasGrounded = isGrounded;
        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float y = Input.GetAxis("Vertical");

        move = transform.right * x + transform.forward * y;

        controler.Move(move * speed * Time.deltaTime);

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumphieght * -2f * gravity);
        }
        velocity.y += gravity * Time.deltaTime;
        controler.Move(velocity * Time.deltaTime);

        if (isGrounded == true)
        {
            if (x > 0 || y > 0)
            {
                Landing.Shake(running);
            }
        }
    }
예제 #27
0
    override protected void Affect(Collider col)
    {
        buffing = col.gameObject;
        audio.PlayOneShot(AffectSound);
        tmp = (GameObject)Instantiate(granat, transform.position - Vector3.up * 2, Quaternion.identity);

        ScreenshakeManager Shaker;

        if (Shaker = Camera.main.GetComponent <ScreenshakeManager>())
        {
            Shaker.Shake(3f, 3f, true);
        }

        Debug.Log(opis);
    }
예제 #28
0
    // Takes in a damage value to apply and the game object that caused the damage
    public void TakeDamage(int damage, GameObject attacker, string damageType, bool isCrit)
    {
        if (TryGetComponent(out Ghost ghost))
        {
            isImmuneToProjectileDamage = ghost.Phasing();
        }
        if (TryGetComponent(out Human human))
        {
            isImmuneToAllDamage = human.isPlayerDashing();
        }


        // If the host is phasing and the damage is a projectile, return
        // If the host is immune to melee, return
        if (isImmuneToMeleeDamage || damageType == "melee")
        {
            return;
        }
        // If the host is immune to all damage, return
        if (isImmuneToAllDamage)
        {
            return;
        }


        ////////////////
        //Hit connects//
        ////////////////
        if (gameObject.tag == "Player" && isCrit)
        {
            cameraShaker.Shake(.3f, 3.0f);
            gameManager.SetPlayerHit(isCrit);
        }
        // Log attacker
        lastHitBy = attacker;
        // Display the damage as a popup
        DamagePopup.Create(transform.position, damage, isCrit);
        // Flash Red to confirm hit
        StartCoroutine(FlashColor(Color.gray, 0.3f));
        // Remove the health
        RemoveHealth(damage);
        // If enemy, apply knockback and reset attack delay value
        if (gameObject.layer == 8)
        {
            TriggerKnockBack();
            TriggerAttackDelayReset();
        }
    }
예제 #29
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("PlayerBullet"))
     {
         gameObject.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
     }
     if (collision.CompareTag("Dirt"))
     {
         GameObject.Find("EnemySpawner").GetComponent <SpawnGonal>().isDirtActive = false;
         shaker.Shake(duration);
         AudioController.instance.BombExplosion(transform.position);
         Destroy(gameObject, 0.7f);
         SFXCtrl.instance.Explosion(collision.transform.position);
         // Destroy(collision.gameObject);
         collision.gameObject.SetActive(false);
     }
 }
예제 #30
0
    private void Start()
    {
        target    = GameObject.FindGameObjectWithTag("Player").transform;
        cameraRef = GameObject.FindGameObjectWithTag("MainCamera").transform;

        shaker   = GetComponent <Shaker>();
        audioSrc = GetComponent <AudioSource>();

        audioSrc.Play();

        ExplosionKill();

        if (Vector2.Distance(target.position, transform.position) < distanceToShake)
        {
            StartCoroutine(shaker.Shake(cameraRef, duration, magnitude, rotationMagnitude));
        }
    }