void OnGUI()
    {
        GUI.BeginGroup(new Rect(Screen.width - buttonWidth * 2 - 130 - buttonSpacing * 40, buttonSpacing, buttonWidth + buttonSpacing * 160, buttonHeight / 3 - buttonSpacing * 4));
        GUI.Box(new Rect(0, 0, buttonWidth * 2 - 135 + buttonSpacing * 2, buttonHeight / 6 + 18 + buttonSpacing * 5), "");
        CarSelectionGridInt = GUI.SelectionGrid(new Rect(buttonSpacing, buttonSpacing, buttonWidth * 2, buttonHeight / 4), CarSelectionGridInt, ThumbnailsLocked, 6);
        GUI.EndGroup();


/*
 * If selected car is bought you can see filled info box and car itself
 */
        if (xmlReaderRights.lotusStatus_ != 0)
        {
            ThumbnailsLocked[1] = LotusLogo;

            if (CarSelectionGridInt == 1)
            {
                Cata.SetActiveRecursively(false);
                F599.SetActiveRecursively(false);
                FCa.SetActiveRecursively(false);
                Lambo.SetActiveRecursively(false);
                Lotus.SetActiveRecursively(true);

                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Lotus Evora");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), LotusCarInfo);

                CarSelectionGridInt = 1;
            }
        }

        if (xmlReaderRights.lamboStatus_ != 0)
        {
            ThumbnailsLocked[2] = LamborghiniLogo;

            if (CarSelectionGridInt == 2)
            {
                Cata.SetActiveRecursively(false);
                F599.SetActiveRecursively(false);
                FCa.SetActiveRecursively(false);
                Lambo.SetActiveRecursively(true);
                Lotus.SetActiveRecursively(false);

                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Lamborghini Murcielago");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), LamboCarInfo);
            }
        }

        if (xmlReaderRights.fCaStatus_ != 0)
        {
            ThumbnailsLocked[3] = FerrariCALogo;

            if (CarSelectionGridInt == 3)
            {
                Cata.SetActiveRecursively(false);
                F599.SetActiveRecursively(false);
                FCa.SetActiveRecursively(true);
                Lambo.SetActiveRecursively(false);
                Lotus.SetActiveRecursively(false);

                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Ferrari California");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), FCaCarInfo);
            }
        }

        if (xmlReaderRights.f599Status_ != 0)
        {
            ThumbnailsLocked[4] = Ferrari599Logo;

            if (CarSelectionGridInt == 4)
            {
                Cata.SetActiveRecursively(false);
                F599.SetActiveRecursively(true);
                FCa.SetActiveRecursively(false);
                Lambo.SetActiveRecursively(false);
                Lotus.SetActiveRecursively(false);

                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Ferrari 599");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), F599CarInfo);
            }
        }

/*
 * Shows Price tag for every car that is not bought
 */
        if (xmlReaderRights.lotusStatus_ == 0)            // for Lotus
        {
            if (CarSelectionGridInt == 1)
            {
                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Lotus Evora");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), lotusPrice + " \n Your money $" + money);
            }
        }

        if (xmlReaderRights.lamboStatus_ == 0)   //for Lambo
        {
            if (CarSelectionGridInt == 2)
            {
                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Lamborghini Murcielago");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), lamboPrice + " \n Your money $" + money);
            }
        }
        if (xmlReaderRights.fCaStatus_ == 0)                     //for Ferrari CA
        {
            if (CarSelectionGridInt == 3)
            {
                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Ferrari California");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), fCaPrice + " \n Your money $" + money);
            }
        }
        if (xmlReaderRights.f599Status_ == 0)            //for Ferrari 599
        {
            if (CarSelectionGridInt == 4)
            {
                GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Ferrari F599");
                GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), f599Price + " \n Your money $" + money);
            }
        }

/*
 * Unity car is always active!
 */
        if (CarSelectionGridInt == 0)
        {
            Cata.SetActiveRecursively(true);
            F599.SetActiveRecursively(false);
            FCa.SetActiveRecursively(false);
            Lambo.SetActiveRecursively(false);
            Lotus.SetActiveRecursively(false);

            CarSelectionGridInt = 0;
            GUI.Box(new Rect(0, 0, Screen.width - 1150, Screen.height - 400), "Unit One");
            GUI.Box(new Rect(0, 20, Screen.width - 1150, Screen.height - 400), UnityCarInfo);
        }

        if (GUI.Button(new Rect(0, Screen.height - 50, 100, 50), "Back")) // Brings you back to the Main Menu

        {
            Application.LoadLevel("Menu");
        }

        xmlReaderRights reader = new xmlReaderRights();

        reader.Start();
    }
Exemple #2
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 205, Screen.width - 1150, Screen.height - 500), "Buy"))
        {
            //////////////////////// LOTUS
            if (ChooseCar.CarSelectionGridInt == 1 && xmlReaderRights.lotusStatus_ == 0 && xmlReaderRights.money_ >= lotusPrice)          // Selected Lotus, not already bought, you have enogh money

            {
                xmlReaderRights reader = new xmlReaderRights();
                reader.Start();

                xmlReaderRights.money_       = xmlReaderRights.money_ - lotusPrice;
                xmlReaderRights.lotusStatus_ = 1;

                //textWriter = new XmlTextWriter(_FileLocation + "\\Save\\" + _FileName, Encoding.UTF8);
                textWriter = new XmlTextWriter(_FileLocation + _FileName, Encoding.UTF8);
                textWriter.WriteStartDocument();

                textWriter.WriteStartElement("User");

                textWriter.WriteStartElement("Name");
                textWriter.WriteString(xmlReaderRights.name_);
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Money");
                textWriter.WriteString(xmlReaderRights.money_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LotusStatus");
                textWriter.WriteString(xmlReaderRights.lotusStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LamboStatus");
                textWriter.WriteString(xmlReaderRights.lamboStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("FerrariCaStatus");
                textWriter.WriteString(xmlReaderRights.fCaStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Ferrari599Status");
                textWriter.WriteString(xmlReaderRights.f599Status_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteEndElement();

                textWriter.WriteEndDocument();


                textWriter.Close();

                Application.LoadLevel("ChooseCar");
            }
            ///////////////// LAMBO
            if (ChooseCar.CarSelectionGridInt == 2 && xmlReaderRights.lamboStatus_ == 0 && xmlReaderRights.money_ >= lamboPrice)          // Selected Lotus, not already bought, you have enogh money

            {
                xmlReaderRights reader = new xmlReaderRights();
                reader.Start();

                xmlReaderRights.money_       = xmlReaderRights.money_ - lamboPrice;
                xmlReaderRights.lamboStatus_ = 1;

                //	textWriter = new XmlTextWriter(_FileLocation + "\\Save\\" + _FileName, Encoding.UTF8);
                textWriter = new XmlTextWriter(_FileLocation + _FileName, Encoding.UTF8);
                textWriter.WriteStartDocument();

                textWriter.WriteStartElement("User");

                textWriter.WriteStartElement("Name");
                textWriter.WriteString(xmlReaderRights.name_);
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Money");
                textWriter.WriteString(xmlReaderRights.money_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LotusStatus");
                textWriter.WriteString(xmlReaderRights.lotusStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LamboStatus");
                textWriter.WriteString(xmlReaderRights.lamboStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("FerrariCaStatus");
                textWriter.WriteString(xmlReaderRights.fCaStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Ferrari599Status");
                textWriter.WriteString(xmlReaderRights.f599Status_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteEndElement();

                textWriter.WriteEndDocument();


                textWriter.Close();

                Application.LoadLevel("ChooseCar");
            }
            //////////////////FCA
            if (ChooseCar.CarSelectionGridInt == 3 && xmlReaderRights.fCaStatus_ == 0 && xmlReaderRights.money_ >= fCaPrice)                                  // Selected Lotus, not already bought, you have enogh money

            {
                xmlReaderRights reader = new xmlReaderRights();
                reader.Start();

                xmlReaderRights.money_     = xmlReaderRights.money_ - fCaPrice;
                xmlReaderRights.fCaStatus_ = 1;

                //textWriter = new XmlTextWriter(_FileLocation + "\\Save\\" + _FileName, Encoding.UTF8);
                textWriter = new XmlTextWriter(_FileLocation + _FileName, Encoding.UTF8);
                textWriter.WriteStartDocument();

                textWriter.WriteStartElement("User");

                textWriter.WriteStartElement("Name");
                textWriter.WriteString(xmlReaderRights.name_);
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Money");
                textWriter.WriteString(xmlReaderRights.money_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LotusStatus");
                textWriter.WriteString(xmlReaderRights.lotusStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LamboStatus");
                textWriter.WriteString(xmlReaderRights.lamboStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("FerrariCaStatus");
                textWriter.WriteString(xmlReaderRights.fCaStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Ferrari599Status");
                textWriter.WriteString(xmlReaderRights.f599Status_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteEndElement();

                textWriter.WriteEndDocument();


                textWriter.Close();

                Application.LoadLevel("ChooseCar");
            }
            if (ChooseCar.CarSelectionGridInt == 4 && xmlReaderRights.f599Status_ == 0 && xmlReaderRights.money_ >= f599Price)                                  // Selected Lotus, not already bought, you have enogh money

            {
                xmlReaderRights reader = new xmlReaderRights();
                reader.Start();

                xmlReaderRights.money_      = xmlReaderRights.money_ - f599Price;
                xmlReaderRights.f599Status_ = 1;

                //	textWriter = new XmlTextWriter(_FileLocation + "\\Save\\" + _FileName, Encoding.UTF8);
                textWriter = new XmlTextWriter(_FileLocation + _FileName, Encoding.UTF8);
                textWriter.WriteStartDocument();

                textWriter.WriteStartElement("User");

                textWriter.WriteStartElement("Name");
                textWriter.WriteString(xmlReaderRights.name_);
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Money");
                textWriter.WriteString(xmlReaderRights.money_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LotusStatus");
                textWriter.WriteString(xmlReaderRights.lotusStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("LamboStatus");
                textWriter.WriteString(xmlReaderRights.lamboStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("FerrariCaStatus");
                textWriter.WriteString(xmlReaderRights.fCaStatus_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteStartElement("Ferrari599Status");
                textWriter.WriteString(xmlReaderRights.f599Status_.ToString());
                textWriter.WriteEndElement();

                textWriter.WriteEndElement();

                textWriter.WriteEndDocument();


                textWriter.Close();

                Application.LoadLevel("ChooseCar");
            }

            xmlReaderRights readerXml = new xmlReaderRights();
            readerXml.Start();
        }
    }