Ejemplo n.º 1
0
    public void Bash(Collision2D info)
    {
        bashSound.Play();
        bashingDirection = (info.transform.position.x - this.transform.position.x);
        Healthbar   enemyHealth    = info.gameObject.GetComponent <Healthbar>();
        Rigidbody2D enemyRigidBody = info.gameObject.GetComponent <Rigidbody2D>();
        GameObject  enemyExtentedFeaturesFeather = info.gameObject.GetComponent <ExtentedFeatures>().Feather;

        ChickenController enemyController = info.gameObject.GetComponent <ChickenController>();


        enemyHealth.Damage(amoutOfBashing); //currentHealth -= amoutOfBashing;
                                            //enemyRigidBody.AddForce(new Vector2(Mathf.Sign(bashingDirection) * bashingPower, 0), ForceMode2D.Force);
        enemyRigidBody.AddForce(new Vector2(Mathf.Sign(bashingDirection) * bashingPower, 5), ForceMode2D.Force);

        GameObject enemyFeather = GameObject.Instantiate(enemyExtentedFeaturesFeather);

        enemyFeather.transform.position = info.transform.position;
        enemyFeather.transform.parent   = info.transform;
        // enemyFeather.GetComponent<ParticleSystem>().playbackSpeed = featherPlayBackSpeed;

        GameObject popupText = GameObject.Instantiate(popupScore);

        popupText.transform.parent   = info.transform;
        popupText.transform.position = info.transform.position;

        popupText.GetComponent <PopUpScore>().setup((int)amoutOfBashing, popupDouration, raiseSpeed);
        popupText.GetComponent <PopUpScore>().color = enemyController.chickColor;
        bashCoolDownSlider.value = bashCoolDownSlider.maxValue;
        //bashingcoolDownTime = 0;
    }
    IEnumerator LoseEnergy()
    {
        while (true)
        {
            playersHealth.Damage(amountOfLoose);

            yield return(new WaitForSeconds(loseTime));
        }
    }
Ejemplo n.º 3
0
    void triggerActivated(Collider2D collision)
    {
        bool ignore = false;

        if (!ignore)
        {
            Healthbar healthbar = collision.gameObject.GetComponent <Healthbar>();
            if (healthbar != null)
            {
                healthbar.Damage(damage);
                damageEvent.Invoke();
                damagePosition.Invoke(collision.transform.position);
                damageCollider.Invoke(collision);
            }
        }
    }
Ejemplo n.º 4
0
    void collisionActivated(Collision2D collision)
    {
        bool ignore = false;

        if (layers != (layers | (1 << collision.gameObject.layer))) //thanks StackOverflow
        {
            ignore = true;
        }

        if (!ignore)
        {
            Healthbar healthbar = collision.gameObject.GetComponent <Healthbar>();
            if (healthbar != null)
            {
                healthbar.Damage(damage);
                damagePosition.Invoke(collision.transform.position);
            }
        }
    }
 public void PlayerDeath()
 {
     playerHealth.Damage(1000);
     PlayerAnimator.SetTrigger("Death");
     CameraAnimator.SetTrigger("isDead");
 }