// Start is called before the first frame update
    void Start()
    {
        UL = GameObject.Find("MoveUL").GetComponent <Button>();
        UR = GameObject.Find("MoveUR").GetComponent <Button>();
        DL = GameObject.Find("MoveDL").GetComponent <Button>();
        DR = GameObject.Find("MoveDR").GetComponent <Button>();

        yRotUp    = GameObject.Find("RotateUR").GetComponent <Button>();
        yRotDown  = GameObject.Find("RotateDL").GetComponent <Button>();
        xzRotUp   = GameObject.Find("RotateUL").GetComponent <Button>();
        xzRotDown = GameObject.Find("RotateDR").GetComponent <Button>();

        snapDown = GameObject.Find("SnapDown").GetComponent <Button>();

        cam     = GameObject.Find("CameraSwap").GetComponent <CameraSwap>();
        spawner = GameObject.Find("SpawnPoint").GetComponent <Spawner>();

        yRotUp.onClick.AddListener(yRotateUp);
        yRotDown.onClick.AddListener(yRotateDown);
        xzRotUp.onClick.AddListener(xzRotateUp);
        xzRotDown.onClick.AddListener(xzRotateDown);
        UL.onClick.AddListener(moveUL);
        DR.onClick.AddListener(moveDR);
        UR.onClick.AddListener(moveUR);
        DL.onClick.AddListener(moveDL);
        snapDown.onClick.AddListener(forceDown);
    }
Пример #2
0
    IEnumerator Initialize()
    {
        yield return(new WaitForSeconds(0.0001f));

        _rotationScript          = _playerGameObject.GetComponent(typeof(RotateWithLocationProvider)) as RotateWithLocationProvider;
        _cameraScript            = _playerGameObject.GetComponent(typeof(CameraSwap)) as CameraSwap;
        _rotationButtonScript    = _rotationIcon.GetComponent(typeof(Button)) as Button;
        _perspectiveButtonScript = _perspectiveIcon.GetComponent(typeof(Button)) as Button;

        if (Transitions.locations == null)
        {
            InitializeObjectsFromNewLocations();
            Transitions.locations       = _locations;
            Transitions.locationStrings = _locationStrings;
            Transitions.cameraSetting   = true;
            Transitions.rotationSetting = true;
        }
        else
        {
            _locations       = Transitions.locations;
            _locationStrings = Transitions.locationStrings;
            InitializeObjectsFromExistingLocations();
            SyncComponentSettings();
        }

        InitializePlayerInstance();

        InitializeOverviewMap();

        if (Transitions.isOverviewActive)
        {
            Transitions.isOverviewActive = false;
            EnableOverviewMap();
        }
    }
Пример #3
0
    private void Start()
    {
        rectTransform = pauseMenu.GetComponent <RectTransform>();

        //Hide Pause off screen
        rectTransform.anchoredPosition = new Vector2(0f, 1000f);

        cameraSwap = FindObjectOfType <CameraSwap>();
    }
Пример #4
0
 public void Back()
 {
     cameraSwap = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraSwap>();
     FindObjectOfType <AudioManager>().Play("Click2");
     cameraSwap.swapCamera();
     controls.SetActive(false);
     volume.SetActive(false);
     graphics.SetActive(false);
 }
Пример #5
0
    public override void DoSave(BinaryWriter _stream)
    {
        //Update Player Stats
        PlayerMovement playerMovement = player.GetComponent <PlayerMovement>();
        CameraSwap     cameraSwap     = GetComponent <CameraSwap>();

        //Save Player Stats
        SaveDataManager.SaveVector3(_stream, player.position);
        SaveDataManager.SaveVector3(_stream, player.rotation.eulerAngles);
        SaveDataManager.SaveVector3(_stream, playerMovement.lastDirection);
        SaveDataManager.SaveVector3(_stream, playerMovement.pointDirection);
        SaveDataManager.SaveVector3(_stream, playerMovement.lastCameraQuat.eulerAngles);
        _stream.Write(playerMovement.expectedSpeed);

        //Save Camera Stats
        _stream.Write(cameraSwap.GetCameraState());
        _stream.Write(cameraSwap.GetInvertHorizontal());
        _stream.Write(cameraSwap.GetInvertVertical());

        //Save World Chunks
        _stream.Write(worldChunks.Count);

        for (int i = 0; i < worldChunks.Count; i++)
        {
            WorldChunk chunk = worldChunks[i];
            SaveDataManager.SaveVector3(_stream, chunk.centrePoint);
            //SaveDataManager.SaveVector3(_stream, chunk.Size());

            for (int x = 0; x < chunk.gridData.GetLength(0); x++)
            {
                for (int y = 0; y < chunk.gridData.GetLength(1); y++)
                {
                    for (int z = 0; z < chunk.gridData.GetLength(2); z++)
                    {
                        _stream.Write(chunk.gridData[x, y, z]);
                        _stream.Write(chunk.gridRotationAngles[x, y, z]);

                        if (chunk.gridData[x, y, z] != 0)
                        {
                            Debug.Log("Saved Block at " + x + "," + y + "," + z);
                        }
                    }
                }
            }
        }
    }
Пример #6
0
    public override void DoLoad(int _version, BinaryReader _stream)
    {
        //Clear Existing Chunks
        foreach (WorldChunk chunk in worldChunks)
        {
            for (int x = 0; x < chunk.gridData.GetLength(0); x++)
            {
                for (int y = 0; y < chunk.gridData.GetLength(1); y++)
                {
                    for (int z = 0; z < chunk.gridData.GetLength(2); z++)
                    {
                        if (chunk.gridObjects[x, y, z] != null)
                        {
                            Destroy(chunk.gridObjects[x, y, z]);
                        }
                    }
                }
            }
        }

        worldChunks = new List <WorldChunk>();

        //Get Components
        PlayerMovement playerMovement = player.GetComponent <PlayerMovement>();
        CameraSwap     cameraSwap     = GetComponent <CameraSwap>();

        //Load Player Stats
        Vector3 playerPosition = SaveDataManager.LoadVector3(_stream);

        player.transform.position = playerPosition;

        Vector3 playerRotation = SaveDataManager.LoadVector3(_stream);

        player.transform.rotation = Quaternion.Euler(playerRotation);

        Vector3 lastDirection  = SaveDataManager.LoadVector3(_stream);
        Vector3 pointDirection = SaveDataManager.LoadVector3(_stream);
        Vector3 lastCameraQuat = SaveDataManager.LoadVector3(_stream);
        float   expectedSpeed  = _stream.ReadSingle();

        playerMovement.GetFromLoad(lastDirection, pointDirection, expectedSpeed, lastCameraQuat);

        //Load Camera Stats
        cameraSwap.SetCameraState(_stream.ReadBoolean());
        cameraSwap.SetInvertHorizontal(_stream.ReadBoolean());
        cameraSwap.SetInvertVertical(_stream.ReadBoolean());

        //Load World Chunks
        int worldChunkCount = _stream.ReadInt32();

        for (int i = 0; i < worldChunkCount; i++)
        {
            worldChunks.Add(new WorldChunk(i, SaveDataManager.LoadVector3(_stream)));

            WorldChunk chunk = worldChunks[worldChunks.Count - 1];

            //Load the Data
            for (int x = 0; x < chunk.gridData.GetLength(0); x++)
            {
                for (int y = 0; y < chunk.gridData.GetLength(1); y++)
                {
                    for (int z = 0; z < chunk.gridData.GetLength(2); z++)
                    {
                        int   _id       = _stream.ReadInt32();
                        float _rotation = _stream.ReadSingle();

                        //-1 is used to fill space for big items, 0 is empty, >0 is an item
                        if (_id > 0)
                        {
                            chunk.gridData[x, y, z]           = _id;
                            chunk.gridRotationAngles[x, y, z] = _rotation;
                        }
                    }
                }
            }
        }

        StartCoroutine(DoAnimatedLoad(playerMovement));
    }
Пример #7
0
 public void OptionsMenu()
 {
     cameraSwap = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraSwap>();
     FindObjectOfType <AudioManager>().Play("Click2");
     cameraSwap.swapCamera();
 }