CakeMeister

door phan 15

Jul 11th, 2017
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class Door : MonoBehaviour {
  7.  
  8.     public int Levelload = 1;
  9.     public gamemaster gm;
  10.  
  11.     // Use this for initialization
  12.     void Start () {
  13.         gm = GameObject.FindGameObjectWithTag("gamemaster").GetComponent<gamemaster>();
  14.     }
  15.  
  16.     private void OnTriggerEnter2D(Collider2D col)
  17.     {
  18.         if (col.CompareTag("Player"))
  19.         {
  20.             savescore();
  21.             gm.Inputtext.text = ("Press E to enter");
  22.         }
  23.     }
  24.  
  25.     private void OnTriggerStay2D(Collider2D col)
  26.     {
  27.         if (col.CompareTag("Player"))
  28.         {
  29.             if (Input.GetKey(KeyCode.E))
  30.             {
  31.                 savescore();
  32.                 SceneManager.LoadScene(Levelload);
  33.             }
  34.         }
  35.     }
  36.  
  37.     private void OnTriggerExit2D(Collider2D col)
  38.     {
  39.         if (col.CompareTag("Player"))
  40.         {
  41.             gm.Inputtext.text = ("");
  42.         }
  43.     }
  44.  
  45.     void savescore()
  46.     {
  47.         PlayerPrefs.SetInt("points", gm.points);
  48.     }
  49. }
Add Comment
Please, Sign In to add comment