Example #1
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Goal"))
     {
         RoomGoal roger = other.gameObject.GetComponent <RoomGoal>();
         Assert.IsNotNull(roger, "Goal object doesn't have a RoomGoal script");
         if (roger.getIsDone() == false)
         {
             roger.activate();
             _animUI.SetTrigger("PickupGoal");
             AkSoundEngine.PostEvent("fx_button", gameObject);
             AkSoundEngine.PostEvent("fx_next", gameObject);
         }
     }
     else if (other.CompareTag("Pickable"))
     {
         Pickable pickable = other.GetComponent <Pickable>();
         Assert.IsNotNull(pickable, "Missing script on a Glitch Pickage");
         if (!pickable.isPickedup())
         {
             pickable.pickup();
             _speechBubble.showBubble(pickable.data.message, pickable.data.duration);
             AkSoundEngine.PostEvent("fx_bulle", gameObject);
         }
     }
     else if (other.gameObject.name == "sword")
     {
         GameObject.Destroy(other.gameObject);
         this.pickupWeapon();
     }
 }
    // -------------------------------------------------------------------------
    // Debug / Cheat functions
    // -------------------------------------------------------------------------
    private void activateAllGoals()
    {
        // If done before, goals object may have not been created yet
        this.goals = GameObject.FindGameObjectsWithTag("Goal");
        Assert.IsNotNull(this.goals);
        Assert.IsTrue(this.goals.Length > 0, "No goal found for this map?");

        foreach (GameObject o in this.goals)
        {
            // Sounds like some object have the tag 'Goal' but shouldn't
            RoomGoal roger = o.GetComponent <RoomGoal>();
            Assert.IsNotNull(roger, "Goal tag without RoomGoal script!");
            if (roger != null)
            {
                roger.activate();
            }
        }
    }