예제 #1
0
    IEnumerator Parry()
    {
        if (CanParry())
        {
            if (currentParryState == ParryState.None)
            {
                playerAnim.Play("Parry");
                CustomFunctions.PlaySound(parryBubbleSound);
                currentParryState = ParryState.IsParrying;
                parryCircle.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
                while (parryCircle.transform.localScale.x > 0)
                {
                    parryCircle.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f) * Mathf.Exp(1.5f - parryCircle.transform.localScale.x);
                    yield return(new WaitForSeconds(0.01f));
                }
            }

            if (parryCircle.transform.localScale.x <= 0)
            {
                //print("DONE");
                currentParryState = ParryState.ParryCooldown;
                if (parryWasSuccessful == false)
                {
                    yield return(new WaitForSeconds(0.2f));
                }

                StopParry();
            }
        }

        yield break;
    }
예제 #2
0
 public void DestroyThis()
 {
     if (hitParticlePrefab != null)
     {
         GameObject hitParticle = Instantiate(hitParticlePrefab);
         hitParticle.transform.position = this.transform.position;
         CustomFunctions.PlaySound(CustomFunctions.instance.ammoHit);
         Destroy(hitParticle, 1f);
     }
     Destroy(this.gameObject);
 }
예제 #3
0
    void BounceAmmo(Collision2D collision)
    {
        if (currentNumberOfBounces < numberOfBouncesBeforeDestroying)
        {
            currentNumberOfBounces++;

            CustomFunctions.PlaySound(bounceSound);
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z - 180f);
        }
        else
        {
            ammoDamageZone.DestroyThis();
        }
    }
예제 #4
0
    void ApplyJumpForce()
    {
        CustomFunctions.PlaySound(CustomFunctions.instance.jumpSound);
        playerRigidbody.velocity = new Vector2(0f, 0f);

        playerRigidbody.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
        if (GetComponent <PlayerHealth>().currentHealth > 0)
        {
            anim.Play("Jump");
        }

        /*GameObject spawnedJumpParticles = Instantiate(jumpParticlesPrefab, this.transform);
         * spawnedJumpParticles.transform.position = this.transform.position;
         * Destroy(spawnedJumpParticles, 1f);*/
    }
예제 #5
0
    void IHealthEntity.DoDamage(float damageAmount, GameObject playerThatShot)
    {
        if (currentHealth <= 0) //if we're playing the death anim, we dont take damage
        {
            return;
        }

        currentHealth -= damageAmount;
        CustomFunctions.HitPause();
        CustomFunctions.PlaySound(getHitSound);

        if (currentHealth <= 0)
        {
            Die(playerThatShot);
        }
    }
예제 #6
0
    void Shoot()
    {
        if (playerController == null)
        {
            playerController = GetComponent <PlayerController>();
        }

        if (playerHealth == null)
        {
            playerHealth = GetComponent <PlayerHealth>();
        }

        if (currentWeaponAction != null)
        {
            if (playerController.CanMove() || playerHealth.currentParryState == PlayerHealth.ParryState.IsParrying)
            {
                if (playerHealth.currentParryState == PlayerHealth.ParryState.IsParrying)
                {
                    playerHealth.StopParry();
                }

                if (currentWeaponState == WeaponState.ReadyToShoot)
                {
                    if (currentAmmo > 0)
                    {
                        currentWeaponAction.Shoot();
                        CameraShaker.Instance.ShakeOnce(1f, 2f, 0.1f, 0.1f);
                        CustomFunctions.PlaySound(GameManager.instance.weaponDatabase.allWeapons[currentWeapon].weaponShootSound);
                        currentWeaponState = WeaponState.WaitingForNextShot;
                        RemoveAmmo();
                        StartCoroutine(WaitForNextShot());
                        if (currentWeaponAction.OnShoot != null)
                        {
                            currentWeaponAction.OnShoot();
                        }
                    }
                }
            }
        }
    }
예제 #7
0
    public void TakeHitEffect(float damageAmount, GameObject playerThatShot)
    {
        if (currentParryState != ParryState.IsParrying)
        {
            RefreshDamageDisplay();
            CustomFunctions.HitPause();
            CustomFunctions.PlaySound(getHitSound);
            DisplayDamageOnMap(damageAmount, false);
            StopCoroutine(HitEffectSpriteBlink());
            StartCoroutine(HitEffectSpriteBlink());
        }
        else
        {
            ResetParry();
            CustomFunctions.PlaySound(parryHitSound);
            RefreshDamageDisplay();
            DisplayDamageOnMap(damageAmount, true);
            CustomFunctions.HitPause();
        }

        //print("Take hit effect with current health " + currentHealth);
    }