Example #1
0
    void OnGUI()
    {
        if(racing)
        {
            string editorCameraSettings = "";
            if(editor)
                editorCameraSettings = racingCamera.GetComponent<skaterCamera>().dataToString();
            string[] racingArray = new string[]{"A/D - Strafe",
                "R - Reset to start",
                "T - Switch between racer/editor",
                "Camera Settings: '7/Y', '8/U', '9,I',",
                "'0/O', '-/P', '=/['",
                "Camera Settings: 'Angle',",
                "'translate x,y,z', 'rotation x,y'",
                editorCameraSettings};

            var lapTimes = GetComponent<lapTimer>().lapTimes;
            for(int x=0;x<lapTimes.Length;x++)
            {
            }

            GUITextList(12, Color.black,  racingArray);
        }
        else
        {
            // Draw segment buttons
            /* Save new 32 78 , 42 83
             * Save as 32 84 , 42 89
             * Name 43 78 , 57 83
             * No 43 84 , 57 89
             * Load 58 78 , 68 83
             * Next 58 84 , 68 87
             * Prev 58 88 , 68 91
             */
            Rect a;
            a = rectGroup(1, 32, 78, 42, 83)[0];
            if(GUI.Button(a, "Save New"))
            {
                int saveNo = 0;
                trackSegmentPool.segment s = new trackSegmentPool.segment();
                while(true)
                {
                    saveNo = Random.Range(0, 100000);
                    if(!usaveRef.ifSlot(saveNo))
                        break;
                }
                partSegmentNumber = saveNo.ToString();
                usaveRef.slot = saveNo;
                usaveRef.allResize(0);
                usaveRef.iarray = partNumbers;
                usaveRef.insertBefore(0, partDifficultyClass, true);
                usaveRef.farray = s.vectorToFloatArray(partParameters);
                usaveRef.varray = new Vector3[1];
                usaveRef.varray[0] = new Vector3((float) partMinDifficulty, (float) partMaxDifficulty, 0f);
                usaveRef.sarray = new string[1];
                usaveRef.sarray[0] = partName;
                usaveRef.saveFile();
            }
            a = rectGroup(1, 32, 84, 42, 89)[0];
            if(GUI.Button(a, "Save as#"))
            {
                int saveNo = int.Parse(partSegmentNumber);
                trackSegmentPool.segment s = new trackSegmentPool.segment();
                if(saveNo>=0 && saveNo < 100000)
                {
                    usaveRef.slot = saveNo;
                    usaveRef.allResize(0);
                    usaveRef.iarray = partNumbers;
                    usaveRef.insertBefore(0, partDifficultyClass, true);
                    usaveRef.farray = s.vectorToFloatArray(partParameters);
                    usaveRef.varray = new Vector3[1];
                    usaveRef.varray[0] = new Vector3((float) partMinDifficulty, (float) partMaxDifficulty, 0f);
                    usaveRef.sarray = new string[1];
                    usaveRef.sarray[0] = partName;
                    usaveRef.saveFile();
                }
            }
            a = rectGroup(1, 43, 78, 57, 83)[0];
            partName = GUI.TextField(a, partName);
            a = rectGroup(1, 43, 84, 57, 89)[0];
            partSegmentNumber = GUI.TextField(a, partSegmentNumber);
            a = rectGroup(1, 58, 78, 68, 83)[0];
            if(GUI.Button(a, "Load"))
            {
                int saveNo = int.Parse(partSegmentNumber);
                load(saveNo);
            }
            a = rectGroup(1, 58, 84, 68, 87)[0];
            if(GUI.Button(a, "Next"))
            {
                int saveNo = int.Parse(partSegmentNumber) + 1;
                bool foundSegment = false;
                for(int x=saveNo;x<100000;x++)
                {
                    if(usaveRef.ifSlot(x))
                    {
                        load (x);
                        foundSegment = true;
                        break;
                    }
                }
                if(!foundSegment)
                {
                    for(int x=0;x<saveNo;x++)
                    {
                        if(usaveRef.ifSlot(x))
                        {
                            load (x);
                            foundSegment = true;
                            break;
                        }
                    }
                }
            }
            a = rectGroup(1, 58, 88, 68, 91)[0];
            if(GUI.Button(a, "Prev"))
            {
                int saveNo = int.Parse(partSegmentNumber) - 1;
                bool foundSegment = false;
                for(int x=saveNo;x>=0;x--)
                {
                    if(usaveRef.ifSlot(x))
                    {
                        load (x);
                        foundSegment = true;
                        break;
                    }
                }
                if(!foundSegment)
                {
                    for(int x=100000;x>saveNo;x--)
                    {
                        if(usaveRef.ifSlot(x))
                        {
                            load (x);
                            foundSegment = true;
                            break;
                        }
                    }
                }
            }
            /* Min+ 36 71 , 41 74
             * Min- 36 74 , 41 77
             * Max+ 59 71 , 64 74
             * Max- 59 74 , 64 77
             */
            a = rectGroup(1, 36, 71, 41, 74)[0];
            if(GUI.Button(a, "Min+"))
            {
                if(partMinDifficulty+1<partMaxDifficulty)
                    partMinDifficulty += 1;
            }
            a = rectGroup(1, 36, 74, 41, 77)[0];
            if(GUI.Button(a, "Min-"))
            {
                if(partMinDifficulty>0)
                    partMinDifficulty += -1;
            }
            a = rectGroup(1, 59, 71, 64, 74)[0];
            if(GUI.Button(a, "Max+"))
            {
                partMaxDifficulty += 1;
            }
            a = rectGroup(1, 59, 74, 64, 77)[0];
            if(GUI.Button(a, "Max-"))
            {
                if(partMaxDifficulty>(partMinDifficulty+1))
                    partMaxDifficulty += -1;
            }
            GUI.Label(rectGroup(1, 42, 68, 46, 71)[0], partMinDifficulty.ToString());
            GUI.Label(rectGroup(1, 56, 68, 58, 71)[0], partMaxDifficulty.ToString());
            hoverPlaneRef.GetComponent<iceMove>().forwardSpeed = hoverPlaneRef.GetComponent<iceMove>().defaultSpeed +
                GUI.HorizontalSlider(rectGroup(1, 45, 72, 55, 76)[0], hoverPlaneRef.GetComponent<iceMove>().forwardSpeed - hoverPlaneRef.GetComponent<iceMove>().defaultSpeed, partMinDifficulty, partMaxDifficulty);
            GUI.Label(rectGroup(1, 49, 68, 51, 71)[0], hoverPlaneRef.GetComponent<iceMove>().returnDifficulty().ToString());
            // Difficulty CLASS modifier
            a = rectGroup(1, 74, 71, 79, 74)[0];
            if(GUI.Button(a, "Class+"))
            {
                if(partDifficultyClass<3)
                    partDifficultyClass += 1;
            }
            a = rectGroup(1, 74, 74, 79, 77)[0];
            if(GUI.Button(a, "Class-"))
            {
                if(partDifficultyClass>1)
                    partDifficultyClass += -1;
            }
            GUI.Label(rectGroup(1, 71, 68, 73, 71)[0], partDifficultyClass.ToString());

            // Draw parameter sliders
            roundEverything ();
            if(selectedPartParams>0)
            {
                Rect[] rectArray = rectGroup(selectedPartParams, 80, 10, 96, 90, 20);
                float oldValue;
                bool redoTrack = false;
                for(int x=0;x<rectArray.Length;x++)
                {
                    oldValue = partParameters[(int)paramReferences[x].w].w;
                    partParameters[(int)paramReferences[x].w].w = GUI.HorizontalSlider(rectArray[x], partParameters[(int)paramReferences[x].w].w, paramReferences[x].x, paramReferences[x].y);
                    GUI.Label(new Rect(rectArray[x].position.x-10 ,rectArray[x].position.y-1, rectArray[x].position.x-1, rectArray[x].position.y+3), partParameters[(int)paramReferences[x].w].w.ToString());
                    if(!redoTrack)
                    {
                        if(oldValue!=partParameters[(int)paramReferences[x].w].w)
                            redoTrack = true;
                        selectedExtraParam = x;
                    }
                }
                if(redoTrack)
                    generateTrack();
            }

            GUITextList(12, Color.black,  new string[]{"Current(" + GetComponent<trackPartPool>().returnNewPartNumber(partNumbers[currentPart], 0) + "): " + trackParts[currentPart].GetComponent<trackPartData>().name,
                                        "W - Change part",
                                        "S - Change part",
                                        "A - Nav Next part",
                                        "D - Nav Previous part",
                                        "T - Switch between racer/editor",
                                        "F - Invert part",
                                        "Backspace - Delete current part"});
        }
        roundEverything ();
    }
Example #2
0
 void load(int saveNo)
 {
     if(saveNo>=0 && saveNo < 100000)
     {
         trackSegmentPool.segment s = new trackSegmentPool.segment();
         usaveRef.slot = saveNo;
         usaveRef.allResize(0);
         usaveRef.loadFile(true);
         partDifficultyClass = usaveRef.iarray[0];
         partNumbers = new int[usaveRef.iarray.Length-1];
         for(int x=1;x<usaveRef.iarray.Length;x++)
             partNumbers[x-1] = usaveRef.iarray[x];
         partParameters = s.floatToVectorArray(usaveRef.farray);
         partMinDifficulty = (int) usaveRef.varray[0].x;
         partMaxDifficulty = (int) usaveRef.varray[0].y;
         partName = usaveRef.sarray[0];
         partSegmentNumber = saveNo.ToString();
         generateTrack();
     }
 }