// Use this for initialization
 void Start()
 {
     recordingNumber = 1;
     recordingEventNumber = 1;
     ios = new IOScript();
     newPlayback();
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        readScript             = new ReadScript();
        headObjects            = new List <ObjectInfo>();
        leftControllerObjects  = new List <ObjectInfo>();
        rightControllerObjects = new List <ObjectInfo>();

        GameObject parent = new GameObject("Tranformer");

        headGameObject            = new GameObject("Head");
        leftControllerGameObject  = new GameObject("ControllerLeft");
        rightControllerGameObject = new GameObject("ControllerRight");

        //Just for sanity in the editor
        headGameObject.transform.SetParent(parent.transform);
        leftControllerGameObject.transform.SetParent(parent.transform);
        rightControllerGameObject.transform.SetParent(parent.transform);

        GameObject cameraRig = GameObject.Find("[CameraRig]");

        cameraEye       = cameraRig.transform.FindChild("Camera (eye)");
        controllerLeft  = cameraRig.transform.FindChild("Controller (left)");
        controllerRight = cameraRig.transform.FindChild("Controller (right)");

        scores   = new List <List <float> >();
        ioWriter = new IOScript();

        //readData();

        //generateDataset();

        //deleteCollections(ref currentNumberOfCollections);
    }
        void readData(StreamReader reader, string assetName, IOScript ios)
        {
            FileInfo sourceFile;

            sourceFile = new FileInfo(assetName);
            reader     = sourceFile.OpenText();
            ios.readVectors(reader, ref vars.posVectorList, ref vars.rotVectorList, ref vars.timesList, ref timestamp);
            reader.Close();
        }
예제 #4
0
 void Awake()
 {
     if (ioScript == null)
     {
         DontDestroyOnLoad(this.gameObject);
         ioScript = this;
     }
     else if (ioScript != this)
     {
         Destroy(gameObject);
     }
 }
예제 #5
0
 void save(string fileName)
 {
     // TODO mix me with IO
     portalList.Sort((a, b) => (a.row < b.row ? -1 : (a.row > b.row ? 1 : (a.col - b.col))));
     level.portals = new int[portalList.Count];
     for (int i = 0; i < portalList.Count; i++)
     {
         level.portals[i] = portalList.IndexOf(portalMapping[portalList[i]]);
     }
     buttonList.Sort((a, b) => (a.row < b.row ? -1 : (a.row > b.row ? 1 : (a.col - b.col))));
     level.lasers  = new Laser[buttonList.Count];
     level.buttons = new int[buttonList.Count];
     for (int b = 0; b < buttonList.Count; b++)
     {
         coord pt = buttonList[b];
         level.lasers[b]  = lasers[pt];
         level.buttons[b] = b;
     }
     Debug.Log("Saving Level...");
     Debug.Log(IOScript.ExportLevel(level, levelName));
 }
    // Use this for initialization
    void Start()
    {
        GameObject cameraRig = GameObject.Find("[CameraRig]");

        head                     = cameraRig.transform.FindChild("Camera (eye)");
        controllerLeft           = cameraRig.transform.FindChild("Controller (left)");
        controllerRight          = cameraRig.transform.FindChild("Controller (right)");
        ioWriter                 = new IOScript();
        headPositions            = new List <Vector3>();
        controllerLeftPositions  = new List <Vector3>();
        controllerRightPositions = new List <Vector3>();

        headRotations            = new List <Vector3>();
        controllerLeftRotations  = new List <Vector3>();
        controllerRightRotations = new List <Vector3>();

        times = new List <float>();

        timer          = 0f;
        recording      = false;
        recordingIndex = 0;
    }
 //Needs the game objects name
 public PlaybackEvent(string objectName, StreamReader reader, string assetName, IOScript ios)
 {
     playbackGameObject = GameObject.Find(objectName);
     vars = new PlaybackVariables();
     vars.posVectorList = new List <Vector3>();
     vars.rotVectorList = new List <Vector3>();
     vars.timesList     = new List <float>();
     counter            = 0;
     readData(reader, assetName, ios);
 }
예제 #8
0
    Level boardState; //Row, Column
                      // East col+, North row+

    /* 0 = empty
     * 1 = wall
     * 2 = player
     * 3 = mimic
     * 4 = mirror
     * 10 = goal
     */

    // Use this for initialization
    void Start()
    {
        firstStart = false;

        //load level using Melody's I/O
        boardState = IOScript.ParseLevel(levelName);

        // TODO: Below the way we get the index is DISGUSTING, this whole shitshow needs refactored
        levelNum = CreateLevelSelect.levelList.IndexOf(levelName);
        LoggingManager.instance.RecordLevelStart(levelNum, levelName);

        mapOrigin = new Vector2(-boardState.cols / 2.0f, -boardState.rows / 2.0f);
        mainCamera.orthographicSize = boardState.rows / 2.0f + 1;
        tutorial.text    = boardState.tutorial;
        tutorial.enabled = true;
        if (levelNum == 0)
        {
            tutorial1.SetActive(true);
        }
        else if (levelNum == 5)
        {
            tutorial6.SetActive(true);
        }


        int buttonCount = 0;

        //instantiate lasers based on parsed lasers
        if (boardState.lasers != null)
        {
            foreach (Laser la in boardState.lasers)
            {
                LaserScript l = GameObject.Instantiate(laser);
                l.makeLaser(la, mapOrigin);
                laserList.Add(l);
            }
        }

        //instantiate items based on board
        for (int i = 0; i < boardState.rows; i++)
        {
            for (int j = 0; j < boardState.cols; j++)
            {
                if (boardState.board[i, j] == 1)
                {
                    //wall
                    GameObject w;
                    if (i == 0 || boardState.board[i - 1, j] != 1)
                    {
                        w = GameObject.Instantiate(frontWall);
                    }
                    else
                    {
                        w = GameObject.Instantiate(wall);
                    }
                    w.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                }
                else if (boardState.board[i, j] >= 10 && boardState.board[i, j] < 20)
                {
                    // goal
                    GoalScript c = GameObject.Instantiate(goal);
                    c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                    goalAtCoords.Add(new coord(i, j), c);
                    goalCoords.Add(new coord(i, j));
                }
                else if (boardState.board[i, j] >= 20 && boardState.board[i, j] < 30)
                {
                    // swap
                    GameObject c = GameObject.Instantiate(swap);
                    c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                    swapCoords.Add(new coord(i, j));
                }
                else if (boardState.board[i, j] >= 30 && boardState.board[i, j] < 40)
                {
                    // button
                    ButtonToggleScript c = GameObject.Instantiate(button);
                    c.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                    c.laser = laserList[boardState.buttons[buttonCount]];
                    c.InitButton();
                    buttonCoords.Add(new coord(i, j), c);
                    buttonCount++;
                }
                else if (boardState.board[i, j] >= 50 && boardState.board[i, j] < 60)
                {
                    // portal
                    GameObject p = GameObject.Instantiate(portal);
                    p.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                    portalCoords.Add(new coord(i, j));
                }
                else
                {
                    // ground
                    GameObject g = GameObject.Instantiate(ground);
                    g.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y, 0);
                }

                if (boardState.board[i, j] % 10 == 2)
                {
                    // player
                    player = GameObject.Instantiate(player);
                    player.SetCoords(j, i);
                    player.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + player.yOffset, -0.2f);
                    moveables.Add(player);
                }
                else if (boardState.board[i, j] % 10 == 3)
                {
                    // mimic
                    MimicScript m = GameObject.Instantiate(mimic);
                    m.SetCoords(j, i);
                    m.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + m.yOffset, -0.2f);
                    moveables.Add(m);
                }
                else if (boardState.board[i, j] % 10 == 4)
                {
                    // mirror
                    MirrorScript m = GameObject.Instantiate(mirror);
                    m.SetCoords(j, i);
                    m.transform.position = new Vector3(j + mapOrigin.x, i + mapOrigin.y + m.yOffset, -0.2f);
                    moveables.Add(m);
                }
            }
        }

        if (boardState.portals != null)
        {
            for (int i = 0; i < boardState.portals.Length; i++)
            {
                portalMap.Add(portalCoords[i], portalCoords[boardState.portals[i]]);
            }
        }
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        // initialize grid
        if (loadedLevel && levelName != null)
        {
            level = IOScript.ParseLevel(levelName);
            int b = 0;
            for (int r = 0; r < level.rows; r++)
            {
                for (int c = 0; c < level.cols; c++)
                {
                    if (level.board[r, c] / 10 == 3)
                    {
                        buttonList.Add(new coord(r, c));
                        lasers.Add(new coord(r, c), level.lasers[level.buttons[b]]);
                        b++;
                    }
                    if (level.board[r, c] / 10 == 5)
                    {
                        portalList.Add(new coord(r, c));
                    }
                }
            }
            for (int p = 0; p < level.portals.GetLength(0); p++)
            {
                portalMapping.Add(portalList[p], portalList[level.portals[p]]);
            }
        }
        else
        {
            level.board = new int[level.rows, level.cols];
            fillOutline(level);
        }
        width       *= canvas.pixelRect.width;
        sidebarWidth = canvas.pixelRect.width - width;
        height      *= canvas.pixelRect.height;

        clickTile = toggleWall;

        // creates entire view
        createAndPositionSquares(level);

        // position sidebar buttons
        saveAsButton.rectTransform.anchoredPosition = new Vector2((width + sidebarWidth / 2f), sidebarWidth / 4f);
        saveAsButton.rectTransform.sizeDelta        = new Vector2(sidebarWidth, sidebarWidth / 2f);
        saveAsButton.rectTransform.localScale       = Vector2.one;
        saveButton.rectTransform.anchoredPosition   = new Vector2((width + sidebarWidth / 2f), 3f * sidebarWidth / 4f);
        saveButton.rectTransform.sizeDelta          = new Vector2(sidebarWidth, sidebarWidth / 2f);
        saveButton.rectTransform.localScale         = Vector2.one;
        resizeButton.rectTransform.anchoredPosition = new Vector2((width + sidebarWidth / 2f), 5f * sidebarWidth / 4f);
        resizeButton.rectTransform.sizeDelta        = new Vector2(sidebarWidth, sidebarWidth / 2f);
        resizeButton.rectTransform.localScale       = Vector2.one;

        for (int i = 0; i < clickSetters.Count; i++)
        {
            RawImage button = Instantiate(this.sidebarPiece);
            button.transform.parent = this.canvas.transform;
            positionSidebarPiece(button, clickSetters[i], i, clickSetters.Count, height, sidebarWidth * 3f / 2f);
        }

        /*sidebar.rectTransform.anchoredPosition = new Vector2((width + sidebarWidth / 2f), 2.35f * sidebarWidth);
         * sidebar.rectTransform.sizeDelta = new Vector2(sidebarWidth, height - (sidebarWidth * 3f / 2f) - padding);
         * sidebar.rectTransform.localScale = Vector2.one;*/

        setNamePopUpVisible(false);
        setSizePopUpVisible(false);
    }