Beispiel #1
0
    public void EditLevel()
    {
        PuzzleLoader pl = Instantiate(puzzleLoader).GetComponent <PuzzleLoader>();

        pl.loadMode    = LevelManager.LevelMode.Editor;
        pl.levelToLoad = BinarySaveSystem.LoadFile <Level>(Path.Combine(Application.persistentDataPath, "Levels", lastLevelShown.id));
    }
Beispiel #2
0
    void Start()
    {
        Screen.orientation = ScreenOrientation.LandscapeLeft;

        TimerHandler.instance.StartTimerHandler();
        PuzzleLoader.instance.LoadData();
        PuzzleLoader.instance.LoadLevelAtlas();
        cantPieces    = int.Parse(PuzzleLoader.instance.Get("Amount"));
        width         = int.Parse(PuzzleLoader.instance.Get("Col"));
        height        = int.Parse(PuzzleLoader.instance.Get("Row"));
        pieceSize     = int.Parse(PuzzleLoader.instance.Get("Size")) * PuzzleLoader.RESOLUTION_MULTIPLIER;
        scrambleSteps = int.Parse(PuzzleLoader.instance.Get("Iterations"));
        piecesList    = new List <PuzzlePiece>();
        piecesMatrix  = new PuzzlePiece[width, height];

        pieceSizeDefault = pieceSize;
        gameStarted      = false;

        levelLabel.text = "" + PuzzleLoader.currentLevel;
        xMovementLeft   = false;
        xMovementRight  = false;
        yMovementTop    = false;
        yMovementBottom = false;
        previewOpened   = false;
        gameFinished    = false;
        piecesErased    = 0;
        soundOn         = true;
        iTween.Init(previewPivot.gameObject);

        StartScreen("Menu");
        PuzzleLoader.ResetRoot();
        SoundManager.PlayMusic("GameMusic");
    }
    void Update()
    {
        //Movement control
        float moveX = Input.GetAxis("Horizontal");
        float moveZ = Input.GetAxis("Vertical");

        Vector3 moveHorizontal = transform.right * moveX;
        Vector3 moveVertical   = transform.forward * moveZ;

        Vector3 velocity = (moveHorizontal + moveVertical) * speed;

        rb.MovePosition(rb.position + (velocity * Time.deltaTime));

        //Camera control
        float rotY = Input.GetAxis("Mouse X");

        Vector3 rotation = new Vector3(0f, rotY, 0f) * sensitivity;

        float rotX = Input.GetAxis("Mouse Y");

        float cameraRotationX = rotX * sensitivity;

        rb.MoveRotation(rb.rotation * Quaternion.Euler(rotation));

        if (cam != null)
        {
            currentCameraRotationX -= cameraRotationX;
            currentCameraRotationX  = Mathf.Clamp(currentCameraRotationX, -cameraRotationLimit, cameraRotationLimit);

            cam.transform.localEulerAngles = new Vector3(currentCameraRotationX, 0f, 0f);
        }

        // this is for (not)using your mouse again ingame
        if (Input.GetKeyDown(KeyCode.L))
        {
            if (wantedMode == CursorLockMode.None)
            {
                wantedMode = CursorLockMode.Locked;
            }
            else
            {
                wantedMode = CursorLockMode.None;
            }
            SetCursorState();
        }
        // Interaction key
        if (Input.GetKey(KeyCode.E))
        {
            ray = cam.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, MaxTouchDistance))
            {
                PuzzleLoader loader = hit.transform.parent.GetComponent <PuzzleLoader>();
                if (loader != null)
                {
                    loader.OnUsed();
                }
            }
        }
    }
Beispiel #4
0
    public void RestartLevel()
    {
        Time.timeScale = 1;
        PuzzleLoader pl = Instantiate(puzzleLoader).GetComponent <PuzzleLoader>();

        pl.loadMode    = finishMode;
        pl.levelToLoad = levelLoaded;
    }
    //#if UNITY_EDITOR
    //[MenuItem("GameObject/UI/Linear Progress Bar")]
    //public static void addLinearProgressBar()
    //{
    //GameObject obj = Instantiate(Resources.Load<GameObject>("UI/Linear Progress Bar"));
    //obj.transform.SetParent(Selection.activeGameObject.transform, false);
    //}
    //#endif

    //public int minimum;
    //public int maximum;
    //public int current;
    //public Image mask;
    //public Image fill;
    //public Color color;


    // Start is called before the first frame update
    void Start()
    {
        //slider = gameObject.GetComponent<Slider>();
        slider.value = 0;
        //IncrementProgress(0.75f);
        slider.gameObject.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = Color.yellow;

        loadingScene = false;
        puzzleLoader = GameObject.Find("PuzzleManager").GetComponent <PuzzleManager>().PuzzleLoaders[IslandPuzzleType.SwitchPuzzleIsland];
    }
Beispiel #6
0
 void Awake()
 {
     if (mInst == null)
     {
         mInst        = this;
         currentLevel = 1;
         LoadAtlas();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Beispiel #7
0
    //Start is called before the first frame update
    void Start()
    {
        lineRend               = GetComponent <LineRenderer>();
        lineRend.enabled       = false;
        laserStartingDirection = lineRend.GetPosition(lineRend.positionCount - 1) - lineRend.GetPosition(lineRend.positionCount - 2);
        ray           = new Ray2D(lineRend.GetPosition(lineRend.positionCount - 2), laserStartingDirection);
        receiverColor = GameObject.FindWithTag("Receiver").GetComponent <SpriteRenderer>().color;

        //for this gameObject color (Laser)
        sr            = GetComponent <SpriteRenderer>();
        originalColor = sr.color;

        loadingScene = false;
        puzzleLoader = GameObject.Find("PuzzleManager").GetComponent <PuzzleManager>().PuzzleLoaders[IslandPuzzleType.LaserPuzzleIsland];
    }
Beispiel #8
0
    public void PlayLevel()
    {
        switch (lastLevelShown.type)
        {
        case LevelInfo.LevelType.Online:
            DataTransferer.instance.DownloadLevel(lastLevelShown.id);
            break;

        case LevelInfo.LevelType.Local:
            PuzzleLoader pl = Instantiate(puzzleLoader).GetComponent <PuzzleLoader>();
            pl.loadMode    = LevelManager.LevelMode.Play;
            pl.levelToLoad = BinarySaveSystem.LoadFile <Level>(Path.Combine(Application.persistentDataPath, "Levels", lastLevelShown.id));
            break;
        }
    }
    IEnumerator StartDownloadLevel(string id)
    {
        string url = serverURL + "levels/" + id;

        UnityWebRequest w = UnityWebRequest.Get(url);

        yield return(w.SendWebRequest());

        if (w.error != null)
        {
            Debug.Log("Error: " + w.error);
        }
        else
        {
            PuzzleLoader puzzleLoader = Instantiate(PuzzleSelectorManager.instance.puzzleLoader).GetComponent <PuzzleLoader>();
            puzzleLoader.loadMode    = LevelManager.LevelMode.Play;
            puzzleLoader.levelToLoad = (Level)BinarySaveSystem.ByteArrayToObject(w.downloadHandler.data);
        }
        w.Dispose();
    }
Beispiel #10
0
    void Start()
    {
        boxes = new BoxTile[width * height];
        Transform boxGroup = this.gameObject.transform.Find("Boxes");

        UnityEngine.Assertions.Assert.AreEqual(width * height, boxGroup.childCount);
        UnityEngine.Assertions.Assert.AreNotEqual(transitionAnimation, null);

        for (int i = 0; i < boxGroup.childCount; ++i)
        {
            BoxTile[] neighbors = new BoxTile[4] {
                null, null, null, null
            };
            int j   = 0;
            int row = i / height;
            int col = i - row * width;

            if (row > 0)  // add up
            {
                neighbors[j++] = boxGroup.GetChild(i - width).GetComponent <BoxTile>();
            }
            if (row < height - 1) // add down
            {
                neighbors[j++] = boxGroup.GetChild(i + width).GetComponent <BoxTile>();
            }
            if (col > 0)  // add left
            {
                neighbors[j++] = boxGroup.GetChild(i - 1).GetComponent <BoxTile>();
            }
            if (col < width - 1) // add right
            {
                neighbors[j++] = boxGroup.GetChild(i + 1).GetComponent <BoxTile>();
            }

            boxes[i] = boxGroup.GetChild(i).GetComponent <BoxTile>();
            boxes[i].setNeighbors(neighbors);
        }

        loadingScene = false;
        puzzleLoader = GameObject.Find("PuzzleManager").GetComponent <PuzzleManager>().PuzzleLoaders[IslandPuzzleType.LightPuzzleIsland];
    }
Beispiel #11
0
    // Called 1st
    // Inititialization
    private void Start()
    {
        // Test to make sure there is a puzzle loader
        PuzzleLoader puzzleLoader = PuzzleLoader.Instance;

        if (puzzleLoader == null)
        {
            return;
        }
        // Test to see if we have a puzzle we are trying to load into
        PuzzleLoadData data = puzzleLoader.GetPuzzleData();

        if (data == null)
        {
            return;
        }

        // Move the player
        Vector3 pos = data.StartPosition;

        if (pos != Vector3.negativeInfinity)
        {
            PlayerMovement.Instance.GetComponent <GridMover>().SetPosition(pos);
        }

        // Unlock their shape states
        int[] shapeUnlockStates = data.ShapeUnlockStates;
        foreach (int state in shapeUnlockStates)
        {
            SkillController.Instance.UnlockSkillState(SkillController.SkillEnum.Shape, state);
        }

        // Unlock their color states
        int[] colorUnlockStates = data.ColorUnlockStates;
        foreach (int state in colorUnlockStates)
        {
            SkillController.Instance.UnlockSkillState(SkillController.SkillEnum.Color, state);
        }
    }