示例#1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (!GameManager.manager.dead && !GameManager.manager.movingReset)
     {
         if (collision.collider.tag == "Player")
         {
             if (GameManager.manager.invincible > 0)
             {
                 if (!isSpike)
                 {
                     gameObject.SetActive(false);
                     transform.position = start_pos.position;
                 }
             }
             else
             {
                 shake.Shake();
                 GameManager.manager.dead = true;
             }
         }
         else if (collision.collider.tag == "Projectile")
         {
             if (shootable)
             {
                 gameObject.SetActive(false);
                 transform.position = start_pos.position;
             }
         }
     }
 }
示例#2
0
 public AttackResult Attacked()
 {
     if (dashing)
     {
         DashOnDashPushBack();
         var part = Instantiate(dashOnDashParticlesPrefab, transform.position, transform.rotation);
         Destroy(part.gameObject, 1f);
         camShake.Shake(DashOnDashCamShake_Dur, DashOnDashCamShake_Amp, DashOnDashCamShake_Freq);
         PlaySound(audioSource, dashOnDashSound, dashOnDashVolume);
         return(AttackResult.ATTACK);
     }
     if (parrying)
     {
         BlockAttack();
         PlaySound(audioSource, stunBlockSound, stunBlockVolume);
         return(AttackResult.PARRY);
     }
     if (blocking)
     {
         BlockAttack();
         PlaySound(audioSource, blockSound, blockVolume);
         return(AttackResult.BLOCK);
     }
     else
     {
         DamagePushBack();
         takingDamage    = true;
         damageCountdown = damageTime;
         StartCoroutine("TakingDamageFX");
         ChangeLife(gameManager.dashDamage);
         PlaySound(audioSource, damageSound, damageVolume);
         return(AttackResult.DAMAGED);
     }
 }
示例#3
0
    private void ZigZag()
    {
        move_direction = new Vector2(x_dir, y_dir);
        if (touching_ground)
        {
            //change direction
            //going_up = !going_up;
            shake.Shake();
            y_dir = 1;
        }

        if (touching_ceiling)
        {
            shake.Shake();
            y_dir = -1;
        }

        if (touching_left_wall)
        {
            shake.Shake();
            // going_left = !going_left;
            x_dir = 1;
        }

        if (touching_right_wall)
        {
            shake.Shake();
            x_dir = -1;
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (pc.isDashingDown)
        {
            downwardDash.Play();
            secondary.Play();
            StartCoroutine(cs.Shake(ampGain, freqGain, duration));
        }

        if (pc.hasDashedDown && pc.gCheck.isGrounded)
        {
            landEffect.Play();
            StartCoroutine(cs.Shake(ampGain, freqGain, duration));
        }
    }
示例#5
0
 void Die()
 {
     spawner.enemies.Remove(this);
     player.Kills += 1;
     CS.Shake();
     Destroy(gameObject);
 }
示例#6
0
    //Statements for the collider, If you're hit, you get X amount of invincibility frames
    private void OnTriggerEnter(Collider col)
    {
        //If the Player object collides with an object with that "Wrong soul" tag, it takes a life off, and starts the invincibility frames.

        if (col.gameObject.tag == "Soul")
        {
            Color color     = currentColor;
            Color soulColor = col.GetComponent <SpriteRenderer>().color;
            if ((color != soulColor))

            {
                Lives--;
                Counter       = 120;
                AmountOfSouls = 0;
                camShaking.Shake(0.1f, 0.5f);

                colCount++;
            }
            else
            {
                AmountOfSouls++;
            }
            Destroy(col.gameObject);
        }
    }
示例#7
0
    // Start is called before the first frame update
    void Start()
    {
        cs = GameManager.instance.cs;

        StartCoroutine(cs.Shake(ampGain, freqGain, duration));

        Destroy(gameObject, 5);
    }
    //camera shake
    public void CamShake(float intensity)
    {
        CamShake camShake = Camera.main.GetComponent <CamShake> ();

        if (camShake != null)
        {
            camShake.Shake(intensity);
        }
    }
示例#9
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         shake.Shake();
         Debug.Log("player hit deathzone");
         GameManager.manager.finalSpeed = 0;
     }
 }
示例#10
0
    //Called by opponent on hit
    public void ApplyDamage(float dmgreceived)
    {
        print(gameObject.name + " got hit");

        if (stun == eStun.blocking)
        {
            //CVoice.PlayVoiceSound();
            CVoice.PlayImpactSound();
            StartCoroutine(camShake.Shake(0.15f, 0.4f));
            hitPoints -= dmgreceived;
            GameManager.instance.UpdateHP();
        }
        else if (stun == eStun.blockbroken)
        {
            state = ePlayerState.Hurt;
            //anim.SetBool("knockdown", true);        //TODO implement knockdown anim
            CVoice.PlayLongCrySound();
            StartCoroutine(camShake.Shake(0.15f, 0.4f));
            hitPoints -= dmgreceived;
            GameManager.instance.UpdateHP();
        }
        else if (stun == eStun.jumped)
        {
            state = ePlayerState.Hurt;
            anim.SetTrigger("longhurt");
            CVoice.PlayVoiceSound();
            StartCoroutine(camShake.Shake(0.15f, 0.4f));
            hitPoints -= dmgreceived;
            GameManager.instance.UpdateHP();
        }
        else if (stun == eStun.normal)
        {
            state = ePlayerState.Hurt;
            anim.SetTrigger("hurt");
            CVoice.PlayVoiceSound();
            StartCoroutine(camShake.Shake(0.15f, 0.4f));
            hitPoints -= dmgreceived;
            GameManager.instance.UpdateHP();
        }

        print(gameObject.name + "s HP: " + hitPoints);
        stun = eStun.normal;
    }
示例#11
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         PlayerController _playerPhysic = FindObjectOfType <PlayerController>();
         _playerPhysic.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static;
         _playerPhysicIsStatic = true;
         StartCoroutine(cs.Shake(ampGain, freqGain, duration));
     }
 }
    void Shoot()
    {
        if (timeBtwShots > 0)
        {
            return;
        }

        RaycastHit2D info   = Physics2D.Raycast(muzzle.position, transform.right, Distance, shootWut);
        GameObject   obj    = Instantiate(projectile, muzzle.position, Quaternion.identity);
        Bullet       bullet = obj.GetComponent <Bullet>();

        CS.Shake();
        if (offset == 0)
        {
            bullet.offset = -90f;
        }
        else
        {
            bullet.offset = 90f;
        }

        audioSource.Play();
        if (info.collider != null)
        {
            if (!info.collider.CompareTag("Environment"))
            {
                Enemy enemy = info.collider.GetComponent <Enemy>();
                if (enemy != null)
                {
                    Vector3 popUp = info.collider.gameObject.transform.position;
                    if (!isCritical)
                    {
                        enemy.TakeDamage(Damage);
                        DamagePopUp.DamagePop(pfDamagePopup, "Hit", popUp);
                    }
                    if (isCritical)
                    {
                        enemy.TakeDamage(Critical);
                        DamagePopUp.DamagePop(pfDamagePopup, "Critical", popUp);
                    }
                }
            }
        }
        if (isCritical)
        {
            Fired        = 0;
            TillCritical = Random.Range(4, 6);
        }
        if (RecoilIsActive)
        {
            playerController.KnockBack(10f, new Vector2(1f, 0f), RecoilForce);
        }
        Fired++;
        timeBtwShots = totalTimeBtwShots;
    }
示例#13
0
 private void shoot()
 {
     if (!shot && open)
     {
         shot = true;
         gun.GetChild(0).gameObject.GetComponent <ParticleSystem>().Play();
         gun.GetComponent <Animation>().Play();
         StartCoroutine(shakeScript.Shake(0.2f, 0.05f));
         Invoke("resetShot", 0.25f);
     }
 }
示例#14
0
    public void Damage(int amount)
    {
        // no less than zero
        Health = (Health - amount < 0)
                ? 0
                : Health - amount;

        OnPlayerHealthChanged?.Invoke();

        camShake.Shake();
    }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        if (timeTick[0] >= 0)
        {
            timeTick[0] -= Time.deltaTime;
        }
        else
        {
            //colR.enabled = false;
        }

        if (timeTick[1] >= 0)
        {
            timeTick[1] -= Time.deltaTime;
        }
        else
        {
            //colL.enabled = false;
        }

        if (co.isDashingL)
        {
            StartCoroutine(cs.Shake(amplitudeGain, frequencyGain, duration));
            //colR.enabled = true;
            //colL.enabled = false;
            burstL.Play();
            circleL.Play();
            timeTick[0] = timeTickMax;
        }

        if (co.isDashingR)
        {
            StartCoroutine(cs.Shake(amplitudeGain, frequencyGain, duration));
            //colL.enabled = true;
            //colR.enabled = false;
            burstR.Play();
            circleR.Play();
            timeTick[1] = timeTickMax;
        }
    }
示例#16
0
 // Update is called once per frame
 void Update()
 {
     if (co.isDoubleJumping && canPlay)
     {
         StartCoroutine(cs.Shake(amplitudeGain, frequencyGain, duration));
         jumpParticles.Play();
         secondary.Play();
         canPlay = false;
     }
     else if (co.gCheck.isGrounded && !canPlay)
     {
         canPlay = true;
     }
 }
 public void Fire()
 {
     particleSystem1.Play();
     particleSystem2.Play();
     SoundCatalog.PlayGroanSound();
     player.weakened      = true;
     m_firing             = true;
     transform.localScale = new Vector3(1f, 0f, 1f);
     gameObject.SetActive(true);
     timeElapsed = 0f;
     CamShake.Shake(launchDuration, 0.5f);
     StopAllCoroutines();
     StartCoroutine(FiringRoutine());
 }
示例#18
0
    IEnumerator Entrance()
    {
        if (state)
        {
            anim.SetBool("bossEnter", true);
            yield return(new WaitForSeconds(1.1f));

            StartCoroutine(cameraShake.Shake(0.2f, 0.4f));
            yield return(new WaitForSeconds(0.5f));

            FindObjectOfType <DialogueManager>().StartDialogue(dialogue);
            state = false;
        }
    }
示例#19
0
    private void Shoot()
    {
        readyToShoot = false;

        //Spread
        float x = Random.Range(-spread, spread);
        float y = Random.Range(-spread, spread);

        //Calculate Direction with Spread
        Vector3 direction = fpsCam.transform.forward + new Vector3(x, y, 0);

        //RayCast
        if (Physics.Raycast(fpsCam.transform.position, direction, out rayHit, range, whatIsEnemy))
        {
//            Debug.Log(rayHit.collider.name);

            if (rayHit.collider.CompareTag("Enemy"))
            {
                rayHit.collider.GetComponent <Target>().takeDamage(damage);
            }
            if (rayHit.collider.CompareTag("Target"))
            {
                rayHit.collider.GetComponent <IsTargetHiit>().damaged(damage);
            }
        }

        //ShakeCamera
        StartCoroutine(CamShake.Shake(duration, magnitude));
        //CamShake.Shake(duration, magnitude);

        //Graphics
        if (rayHit.collider.CompareTag(("Bullet Hole Able")))
        {
            GameObject ImpactGo = Instantiate(bulletHoleGraphic, rayHit.point, Quaternion.LookRotation(-rayHit.normal));
        }


        Instantiate(muzzleFlash, attackPoint.position, Quaternion.identity);

        bulletsLeft--;
        bulletsShot--;

        Invoke("ResetShot", timeBetweenShooting);

        if (bulletsShot > 0 && bulletsLeft > 0)
        {
            Invoke("Shoot", timeBetweenShots);
        }
    }
示例#20
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         if (!GameManager.manager.dead)
         {
             if (GameManager.manager.invincible <= 0)
             {
                 shake.Shake();
                 GameManager.manager.pushing_time = 0;
                 GameManager.manager.dead         = true;
             }
         }
     }
 }
示例#21
0
 // Update is called once per frame
 void Update()
 {
     if (collectedCrystals > 4 && !triggered)
     {
         triggered      = true;
         triggerTime    = Time.time;
         gate.isEnabled = true;
         gate.endgame   = true;
         CamShake.Shake(60.0f, 0.4f);
     }
     if (collectedCrystals > 4 && triggered)
     {
         triggered = true;
         text.text = "! WARNING !" + Environment.NewLine + "!GET BACK TO THE PORTAL!" + Environment.NewLine + "CAVERN DESTRUCTION IN: " + (60.0f - (Time.time - triggerTime)).ToString();
     }
 }
示例#22
0
    public IEnumerator Stun(float time)
    {
        if (!Stunned && !shield.isInvincible)
        {
            stunFX.Play();
            CamShake camShake = Camera.main.GetComponent <CamShake>();
            camShake.StartCoroutine(camShake.Shake(0.1f, 0.05f));
            Stunned = true;

            yield return(new WaitForSeconds(time));

            if (Stunned)
            {
                Stunned = false;
            }
        }
    }
示例#23
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            var damageable = other.gameObject.GetComponent <Damageable>();

            if (damageable != null)
            {
                damageable.InflictDamage(inflictedDamage);
            }

            if (onDeathParticleSystem != null)
            {
                Instantiate(onDeathParticleSystem, transform.position, Quaternion.identity);
                CamShake.Shake(0.2f, 0.05f);
            }

            Destroy(gameObject);
        }
示例#24
0
    //we are hit  被攻击
    public void Hit(DamageObject d)
    {
        //Camera Shake
        CamShake camShake = Camera.main.GetComponent <CamShake>();

        if (camShake != null)
        {
            camShake.Shake(.2f);
        }

        //check for hit
        anim.SetAnimatorTrigger("Hit1");
        enemyState = UNITSTATE.HIT;

        //add small force from the impact
        LookAtTarget(d.inflictor.transform);
        anim.AddForce(-knockbackForce);
    }
示例#25
0
    //jump kick in progress
    IEnumerator JumpKickInProgress()
    {
        animator.SetAnimatorBool("JumpKickActive", true);

        //a list of enemies that we have hit
        List <GameObject> enemieshit = new List <GameObject>();

        //small delay so the animation has time to play
        yield return(new WaitForSeconds(.1f));

        //check for hit
        while (playerState.currentState == UNITSTATE.JUMPKICK)
        {
            //draw a hitbox in front of the character to see which objects it collides with
            Vector3    boxPosition  = transform.position + (Vector3.up * lastAttack.collHeight) + Vector3.right * ((int)currentDirection * lastAttack.collDistance);
            Vector3    boxSize      = new Vector3(lastAttack.CollSize / 2, lastAttack.CollSize / 2, hitZRange / 2);
            Collider[] hitColliders = Physics.OverlapBox(boxPosition, boxSize, Quaternion.identity, HitLayerMask);

            //hit an enemy only once by adding it to the list of enemieshit
            foreach (Collider col in hitColliders)
            {
                if (!enemieshit.Contains(col.gameObject))
                {
                    enemieshit.Add(col.gameObject);

                    //hit a damagable object
                    IDamagable <DamageObject> damagableObject = col.GetComponent(typeof(IDamagable <DamageObject>)) as IDamagable <DamageObject>;
                    if (damagableObject != null)
                    {
                        damagableObject.Hit(lastAttack);

                        //camera Shake
                        CamShake camShake = Camera.main.GetComponent <CamShake> ();
                        if (camShake != null)
                        {
                            camShake.Shake(.1f);
                        }
                    }
                }
            }
            yield return(null);
        }
    }
示例#26
0
    public bool Damage(float damage)
    {
        if (screenShakeOnHit && camShake != null)
        {
            StartCoroutine(camShake.Shake(shakeDuration, shakeMagnitude));
        }

        if (currentHealth - damage < 0)
        {
            currentHealth = 0;
        }
        else
        {
            currentHealth  -= damage;
            amountOfHealth -= 1;
        }

        return(IsDead());
    }
示例#27
0
    IEnumerator Initiate()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            anim.SetBool("fake", true);
            yield return(new WaitForSeconds(0.1f));

            GameObject t = Instantiate(alert, alertPos, Quaternion.identity);
            yield return(new WaitForSeconds(0.7f));

            Destroy(t);
            yield return(new WaitForSeconds(0.1f));

            StartCoroutine(cameraShake.Shake(1f, 0.4f));
            yield return(new WaitForSeconds(1.3f));

            FindObjectOfType <DialogueManager>().StartDialogue(dialogue);
            Destroy(gameObject);
        }
    }
示例#28
0
 public void takeDamage(int damage)
 {
     if (damage > hp)
     {
         this.gameObject.SetActive(false);
         if (player)
         {
             if (SpawnPoint)
             {
                 this.transform.position = SpawnPoint.position;
             }
         }
         respawn();
     }
     else
     {
         hp -= damage;
         StartCoroutine(shakeScript.Shake(0.2f, 0.1f));
     }
 }
示例#29
0
    //private void OnCollisionEnter2D(Collision2D collision)
    //{
    //    if(collision.collider.tag == "Player")
    //    {
    //        //GameManager.manager.health -= GameManager.manager.health;
    //        //shake.Shake();
    //        GameManager.manager.dead = true;

    //    }
    //}
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            if (!GameManager.manager.dead)
            {
                if (!GameManager.manager.movingReset)
                {
                    shake.Shake();
                }
            }

            if (!GameManager.manager.movingReset)
            {
                GameManager.manager.dead = true;
            }

            //collision.GetComponent<PlayerDeath>().Die();
        }
    }
示例#30
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        for (int i = 0; i < tags.Length; i++)
        {
            if (collision.collider.tag == tags[i])
            {
                gameObject.SetActive(false);
            }
        }

        if (!GameManager.manager.dead && !GameManager.manager.movingReset)
        {
            if (collision.collider.tag == "Player")
            {
                if (GameManager.manager.invincible <= 0)
                {
                    shake.Shake();
                    GameManager.manager.dead = true;
                }
            }
        }
    }