Drop.CreatePotion C# (CSharp) Method

CreatePotion() public static method

public static CreatePotion ( Transform t, bool parent = false ) : GameObject
t Transform
parent bool
return GameObject
	public static GameObject CreatePotion(Transform t, bool parent = false){
		string shape   = PotionGen.RandomShape();
		string effect  = PotionGen.RandomEffect();
		Potion potionC = null;
		Debug.Log(effect);
		Color color   = PotionGen.GetColor(effect);
		GameObject potion = MonoBehaviour.Instantiate(Resources.Load("Prefabs/Objects/Potions/Potion_"+shape)) as GameObject;

		switch(effect){
			case "Healing":
				potionC = potion.AddComponent<PotionOfHealing>();
			break;
			case "Harming":
				potionC = potion.AddComponent<PotionOfHarming>();
			break;
			case "Poison":
				potionC = potion.AddComponent<PotionOfPoison>();
			break;
			case "Burning":
				potionC = potion.AddComponent<PotionOfBurning>();
			break;
			case "Freezing":
				potionC = potion.AddComponent<PotionOfFreezing>();
			break;
			case "Shocking":
				potionC = potion.AddComponent<PotionOfShocking>();
			break;
		}

		if(parent)potion.transform.parent = t;
		potion.transform.position                        = t.position;
		potion.GetComponent<Rigidbody>().velocity        = new Vector3((0.5f-Random.value)*5,Random.value*5,(0.5f-Random.value)*5);
		potion.GetComponent<Rigidbody>().angularVelocity = new Vector3(0.5f-Random.value*5,Random.value*5,0.5f-Random.value*5);
		potionC.shape = shape;
		potionC.effect = effect;
		return potion;
	}