// public function to use in Spoiler button OnClick() in his inspector public void SelectSpoiler(int id) { if (PlayerPrefs.GetInt(spoilers.carID.ToString() + "Spoiler" + id.ToString()) == 3) // 3=>true , 0=>false // Find current car T_Spoilers component { spoilers = GameObject.FindObjectOfType <T_Spoiler> (); // And then activate current selected Spoiler: spoilers.SetSpoiler(id, true); PlayerPrefs.SetInt(spoilers.carID.ToString() + "SpoilerID", id); tShop.ShowWindow(false); } else // The current selected Spoiler is not unlocked, We unlock it with reducing money from player total moneys and unlock Spoiler // Find current car T_Spoilers component { spoilers = GameObject.FindObjectOfType <T_Spoiler> (); // And then activate current selected Spoiler: spoilers.SetSpoiler(id, true); tShop.carID = spoilers.carID; tShop.itemID = id; // tShop.currentItemPrice.text = tShop.exhaustPrice [id].ToString(); tShop.itemType = ItemType.Spoiler; tShop.ShowWindow(true); } }
// public function to use in Roof button OnClick() in his inspector public void SelectRoof(int id) { if (PlayerPrefs.GetInt(roofs.carID.ToString() + "Roof" + id.ToString()) == 3) // 3=>true , 0=>false // Find current car T_Roof component { roofs = GameObject.FindObjectOfType <T_Roof> (); // And then activate current selected Roof: roofs.SetRoof(id, true); PlayerPrefs.SetInt(roofs.carID.ToString() + "RoofID", id); tShop.ShowWindow(false); } else // The current selected Roof is not unlocked, We unlock it with reducing money from player total moneys and unlock mirror // Find current car T_Roof component { roofs = GameObject.FindObjectOfType <T_Roof> (); // And then activate current selected Roof: roofs.SetRoof(id, true); tShop.carID = roofs.carID; tShop.itemID = id; // tShop.currentItemPrice.text = tShop.roofPrice[id].ToString(); tShop.itemType = ItemType.Roof; tShop.ShowWindow(true); } }
// public function to use in ring button OnClick() in his inspector public void SelectRing(int id) { if (PlayerPrefs.GetInt(rings.carID.ToString() + "Ring" + id.ToString()) == 3) // 3=>true , 0=>false // Find current car T_Rings component { rings = GameObject.FindObjectOfType <T_Rings> (); // We have 6 rings, and first de activate all rings rings.SetRing(0, false); rings.SetRing(1, false); rings.SetRing(2, false); rings.SetRing(3, false); rings.SetRing(4, false); rings.SetRing(5, false); // And then activate current selected ring: rings.SetRing(id, true); PlayerPrefs.SetInt(rings.carID.ToString() + "RingID", id); tShop.ShowWindow(false); } else // The current selected ring is not unlocked, We unlock it with reducing money from player total moneys and unlock ring // Find current car T_Rings component { rings = GameObject.FindObjectOfType <T_Rings> (); // We have 6 rings, and first de activate all rings rings.SetRing(0, false); rings.SetRing(1, false); rings.SetRing(2, false); rings.SetRing(3, false); rings.SetRing(4, false); rings.SetRing(5, false); // And then activate current selected ring: rings.SetRing(id, true); tShop.carID = rings.carID; tShop.itemID = id; // tShop.currentItemPrice.text = tShop.ringPrice[id].ToString(); tShop.itemType = ItemType.Ring; tShop.ShowWindow(true); } }