Exemplo n.º 1
0
    public IEnumerator RespawnPlayerCo()
    {
        //death particles
        Instantiate(deathParticle, pcRigid.transform.position, pcRigid.transform.rotation);
        player.SetActive(false);
        player.GetComponent <Renderer> ().enabled = false;
        //Gravity Reset
        gravityStore = pcRigid.GetComponent <Rigidbody2D>().gravityScale;
        pcRigid.GetComponent <Rigidbody2D>().gravityScale = 1f;
        pcRigid.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point penalty
        Scoremanager.AddPoints(-pointPenaltyOnDeath);
        //debug manager
        Debug.Log("Hero Respawn");
        //respawn delay
        yield return(new WaitForSeconds(respawnDelay));

        //gravity restore
        pcRigid.GetComponent <Rigidbody2D>().gravityScale = gravityStore;
        //match hero's transform position
        pcRigid.transform.position = currentCheckPoint.transform.position;
        //Show PC
        player.SetActive(true);
        player.GetComponent <Renderer>().enabled = true;
        Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
    }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Enemy")
     {
         Instantiate(enemyDeath, other.transform.position, other.transform.rotation);
         Destroy(other.gameObject);
         Scoremanager.AddPoints(pointsForKill);
     }//Instantiate(projectileParticle, transform.position transform.rotation);
     Destroy(gameObject);
 }
Exemplo n.º 3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.layer == 11)     // if touching specified layer
        {
            Scoremanager.AddPoints(PointsToAddS); // adds points

            Destroy(gameObject, DestroyDelay);    // Destroys on gameobject on delay
            Instantiate(DeathParticle, transform.position, transform.rotation);
        }
    }
Exemplo n.º 4
0
    //piutting in colider for coin
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Hero")
        {
            LevelManager.SetSpawn(xValue, yValue);

            Scoremanager.AddPoints(coinValue);

            Destroy(gameObject);
        }
    }
Exemplo n.º 5
0
    //piutting in colider for coin
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Hero")
        {
            print("you've collected a flower! ");

            Scoremanager.AddPoints(coinValue);

            Destroy(gameObject);
        }
    }
Exemplo n.º 6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }

        Scoremanager.AddPoints(pointsToAdd);

        Destroy(gameObject);
    }
Exemplo n.º 7
0
    public IEnumerator RespawnPlayerCo()
    {
        // generte death particles
        Instantiate(deathParticles, pc.transform.position, pc.transform.rotation); // first thing we want created is death particle
                                                                                   // hide player
                                                                                   //   pc.enabled = false;
        pc2.SetActive(false);

        pc.GetComponent <Renderer>().enabled = false;

        // gravity reset
        gravityStore = pc.GetComponent <Rigidbody2D>().gravityScale;
        // pc.GetComponent<Rigidbody2D>().gravityScale = 0f;
        pc.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        // Point Penalty
        Scoremanager.AddPoints(-pointPenaltyOnDeath);

        // Debug Message
        Debug.Log("Player Respawn");

        // Respawn Delay
        yield return(new WaitForSeconds(respawnDelay));

        // Gravity Restore
        pc.GetComponent <Rigidbody2D>().gravityScale = gravityStore;

        // Match Players transform position
        pc.transform.position = currentCheckPoint.transform.position;

        // show player
        //  pc.enabled = true;
        pc2.SetActive(true);
        pc.GetComponent <Renderer>().enabled = true;

        //spawn pc
        Instantiate(respawnParticles, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
    }