public void addSpecificItem(string itemName) { GameObject go = GameObject.Find(itemName); DropABox l = (DropABox)go.GetComponent(typeof(DropABox)); l.DropBox(); canvas_Items.gameObject.SetActive(false); //canvas_Minimap.gameObject.SetActive (true); }
public void addItem(string playerID, string itemName, float scale, float weight) { if (Network.player.ToString() == playerID) { if (itemName == "stone") { mainStone.transform.localScale = original_stone; mainStone.GetComponent <Rigidbody> ().mass = 1f; // mainStone.transform.localScale = new Vector3(mainStone.transform.localScale.x * scale, mainStone.transform.localScale.y * scale, mainStone.transform.localScale.z * scale); mainStone.GetComponent <Rigidbody> ().mass = weight; Launcher l = (Launcher)mainStone.GetComponent(typeof(Launcher)); l.createCapsule(); BuoyancyForce b = (BuoyancyForce)mainStone.GetComponent(typeof(BuoyancyForce)); b.Resolution = 3; b.Resolution = b.Resolution * int.Parse(scale.ToString()); } else if (itemName == "tube") { tube.transform.localScale = new Vector3(2f, 1.5f, 2f); tube.GetComponent <Rigidbody> ().mass = 1f; tube.transform.localScale = new Vector3(tube.transform.localScale.x * scale, tube.transform.localScale.y * scale, tube.transform.localScale.z * scale); tube.GetComponent <Rigidbody> ().mass = weight; // BuoyancyForce b = (BuoyancyForce) tube.GetComponent(typeof(BuoyancyForce)); // b.Resolution = 3; // b.Resolution = b.Resolution * int.Parse(scale.ToString()); DropABox drop = (DropABox)Button_AddTube.GetComponent(typeof(DropABox)); drop.DropBox(); } else if (itemName == "torus") { torus.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); torus.GetComponent <Rigidbody> ().mass = 1f; torus.transform.localScale = new Vector3(torus.transform.localScale.x * scale, torus.transform.localScale.y * scale, torus.transform.localScale.z * scale); torus.GetComponent <Rigidbody> ().mass = weight; // BuoyancyForce b = (BuoyancyForce) torus.GetComponent(typeof(BuoyancyForce)); // b.Resolution = 3; // b.Resolution = b.Resolution * int.Parse(scale.ToString()); DropABox drop = (DropABox)Button_AddTorus.GetComponent(typeof(DropABox)); drop.DropBox(); } else if (itemName == "duck") { duck.transform.localScale = new Vector3(4, 4, 4); duck.GetComponent <Rigidbody> ().mass = 1f; duck.transform.localScale = new Vector3(duck.transform.localScale.x * scale, duck.transform.localScale.y * scale, duck.transform.localScale.z * scale); duck.GetComponent <Rigidbody> ().mass = weight; AddDuckOnClient l = (AddDuckOnClient)Button_AddDuck.GetComponent(typeof(AddDuckOnClient)); l.DropDuck(); } } }