// Use this for initialization

    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
    }
Example #2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #3
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);
    }
Example #4
0
    // public player player1;

    //public float kickForce;



    // Start is called before the first frame update
    void Start()
    {
        anim = GetComponent <Animator>();

        scoremanager = GameObject.FindWithTag("Scoremanager").GetComponent <Scoremanager>(); //calls scoremanager

        //  player1 = GetComponent<player>();\
    }
Example #5
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);
 }
Example #6
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);
        }
    }
Example #7
0
    //piutting in colider for coin
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Hero")
        {
            LevelManager.SetSpawn(xValue, yValue);

            Scoremanager.AddPoints(coinValue);

            Destroy(gameObject);
        }
    }
Example #8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(instance);
     }
 }
Example #9
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);
        }
    }
Example #10
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }

        Scoremanager.AddPoints(pointsToAdd);

        Destroy(gameObject);
    }
Example #11
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);
    }
Example #12
0
 // Start is called before the first frame update
 void Start()
 {
     scoremanager = GameObject.FindWithTag("Scoremanager").GetComponent <Scoremanager>(); //calls scoremanager
 }
Example #13
0
 // Use this for initialization
 void Start()
 {
     SM = GameObject.FindGameObjectWithTag("GM").GetComponent <Scoremanager> ();
     this.GetComponent <Rigidbody2D> ().velocity = new Vector3(0, speed, 0);
 }