示例#1
0
	//Object movement via Physics
	void onTriggerEnterEvent( Collider2D col )
	{
		if(col.gameObject.layer == 10)
		{
			if(_right)
			{
				col.gameObject.rigidbody2D.AddForce(moveColR);
				//Unlock Achievement
				SteamManager.StatsAndAchievements.Unlock_Nice_Game_Developers_Achievement();
				//Play crate noise
				audio.PlayOneShot(clips[0], 0.45F);
			}
			else if(!_right)
			{
				col.gameObject.rigidbody2D.AddForce(moveColL);
				//Unlock Achievement
				SteamManager.StatsAndAchievements.Unlock_Nice_Game_Developers_Achievement();
				//Play crate noise
				audio.PlayOneShot(clips[0], 0.45F);
			}
		}
		else if(col.gameObject.tag == "Key")
		{
			audio.PlayOneShot(clips[1], 0.7F);
		}
		else if(col.gameObject.tag == "Bow")
		{
			audio.PlayOneShot(clips[7], 0.7F);
			if(col.gameObject.GetComponent<CollectBow>() != null)
			{
				//Inventory add
				//Debug.Log("You found a bow!");
				_arrowCount = GameObject.Find("Player").GetComponent<Inventory>();
				_arrowCount.Arrows += 1;
				Debug.Log ("Your Arrow as been inventoried!!!"+_arrowCount.Arrows);
				
				//Quiver add
				//Debug.Log("You grabbed a bow!");
				_bowCount = GameObject.Find("Player").GetComponent<Quiver>();
				_bowCount.bow += 1;
				Debug.Log ("This is the bow count" + _bowCount.bow);
				//Update PlayerPrefs
				PlayerPrefs.SetInt("bow", _bowCount.bow);
				
				_arrowCount.InventoryOnTimer();
			}
			else if (col.gameObject.GetComponent<CollectGoldenBow>() != null)
			{
				//Inventory add
				//Debug.Log("You found a bow!");
				_arrowCount = GameObject.Find("Player").GetComponent<Inventory>();
				_arrowCount.Arrows += 5;
				_arrowCount.startCollectTimer = true;
				Debug.Log ("Your Arrow as been inventoried!!!"+_arrowCount.Arrows);
				
				//Quiver add
				//Debug.Log("You grabbed a bow!");
				_bowCount = GameObject.Find("Player").GetComponent<Quiver>();
				_bowCount.bow += 5;
				Debug.Log ("This is the bow count" + _bowCount.bow);
				//Update PlayerPrefs
				PlayerPrefs.SetInt("bow", _bowCount.bow);
				
				_arrowCount.InventoryOnTimer();
			}
			//Destroy object
			Destroy(col.gameObject);
		}
		else if(col.gameObject.tag == "Door")
		{
			audio.PlayOneShot(clips[2], 0.7F);
		}
	}