Ejemplo n.º 1
0
    // here IEnumerator has no retuen type
    public IEnumerator RespawnDelay()
    {
        // shows death particles
        Instantiate(deathParticleObj, player.transform.position, player.transform.rotation);

        player.enabled = false;                                      // so that user have no control over player after death ;
        player.GetComponent <Renderer>().enabled     = false;        // so that player is not shown after death
        player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; // setting velocity to 0 so that camera wont move with the player ...

        yield return(new WaitForSeconds(respwanDelayTime));

        // re enabling player features
        player.enabled = true;
        player.GetComponent <Renderer>().enabled = true;

        // player is moved to the checkpoint gameobjects position.  which is changed as player passes through each chekcpoint
        player.transform.position = checkpointPos.transform.position;

        // Spwan particle

        // resets player healht on respwaning
        //  even though we are resetting player health in update() of helath manager,
        //when player respwans sometime if he is taking continous damage at respwaning full health is not given
        //so we are resetting the helth here again
        HealthManger.ResetHealth();
    }
Ejemplo n.º 2
0
 public void OnTriggerEnter2D(Collider2D gameItem)
 {
     if (gameItem.tag == "Player")
     {
         HealthManger.AddHealth();
         audio.Play();
     }
     Destroy(gameObject);
 }
Ejemplo n.º 3
0
    }       // END OF UPDATE()

    public void OnTriggerEnter2D(Collider2D gameItem)
    {
        // if player is hit by laser then
        if (gameItem.tag == "Player")
        {
            HealthManger.Damage(damageValue);
        }
        // for sparks
        Instantiate(sparkObj, transform.position, transform.rotation);
        Destroy(gameObject);
    }
Ejemplo n.º 4
0
    public void OnTriggerEnter2D(Collider2D gameItem)
    {
        // if player hits me then
        if (gameItem.tag == "Player")
        {
            // decreasing the health of the player;
            HealthManger.Damage(damageValue);


            // code for knocking back the player
            player.knockbackCounter = player.knockbackDelay;

            // if player is knocked from the right side then
            if (gameItem.transform.position.x < transform.position.x)
            {
                player.rightKnock = true;
            }
            else
            {
                player.rightKnock = false;
            }
        }
    }