예제 #1
0
 //if its collides with player, destroy the item
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         Nebulite nebulite = GameObject.FindObjectsOfType <Nebulite>()[0];
         nebulite.AddNebulite(10);
         Destroy(gameObject);
     }
 }
예제 #2
0
    private int level;               //the amount of nebulite gathered in a level

    void Awake()
    {
        // If the instance reference has not been set, yet,
        if (instance == null)
        {
            // Set this instance as the instance reference.
            instance = this;
            PlayerPrefs.DeleteAll();
            PlayerPrefs.SetInt("P1Weapon", 0);
            PlayerPrefs.SetInt("P2Weapon", 0);
            total = 500; //to be later changed to allow save/load
            level = 0;   //nebulite aquired starts at zero
        }
        else if (instance != this)
        {
            // If the instance reference has already been set, and this is not the
            // the instance reference, destroy this game object.
            Destroy(gameObject);
        }

        // Do not destroy this object, when we load a new scene.
        DontDestroyOnLoad(gameObject);
    }