Esempio n. 1
0
    private void BuildLevel(Level level)
    {
        foreach (PuzzlePiece puzzle in level.LeftSide)
        {
            GameObject       clone = Instantiate(puzzlePrefab);
            PuzzleController pc    = clone.GetComponent <PuzzleController>();
            pc.Init(puzzle);
            leftPuzzlePool.Add(pc);
            puzzlesToSpawnPool.Add(pc);
            puzzleMap.Add(puzzle, pc);

            clone.SetActive(false);
        }

        foreach (PuzzlePiece puzzle in level.RightSide)
        {
            GameObject       clone = Instantiate(puzzlePrefab);
            PuzzleController pc    = clone.GetComponent <PuzzleController>();
            pc.Init(puzzle);
            rightPuzzlePool.Add(pc);
            puzzlesToSpawnPool.Add(pc);
            puzzleMap.Add(puzzle, pc);

            clone.SetActive(false);
        }
    }
    //============================================================================================================================================================
    // Aggregate function, that processes whole generation
    void CreatePuzzle()
    {
        Random.InitState(System.DateTime.Now.Millisecond);

        puzzleGrid = new PuzzleElement[cols * rows];

        try
        {
            image = TextureUtility.PrepareAsset(image);

            GeneratePuzzlePieces(cols, rows, subElement, elementBaseSize, image);
            CreateAtlas();
            ConvertToSprites();
            puzzle = CreateGameObjects().AddComponent <PuzzleController>();
            puzzle.Prepare();

            if (generateBackground)
            {
                puzzle.GenerateBackground(image);
            }
        }
        catch (System.Exception ex)
        {
            EditorUtility.DisplayDialog("ERROR", "SOMETHING GONE WRONG! \n \n" + ex.Message, "OK");
        }


        EditorUtility.ClearProgressBar();
    }
Esempio n. 3
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Esempio n. 4
0
 //-----------------------------------------------------------------------------------------------------
 //Aggregate function, that processes whole generation using external image available online (imagePath should starts from "http://")  or localy - (imagePath should starts from "file://")
 public void CreateFromExternalImage(string imagePath)
 {
     puzzle = null;
     image  = new Texture2D(1, 1);
     path   = imagePath;
     StartCoroutine(LoadTextureFromWeb());
 }
	private void Start ()
	{
		if (Instance == null) Instance = this;
		else Destroy(Instance);

		dialogue = GameObject.FindObjectOfType<Dialogue>();
	}
Esempio n. 6
0
    public void NewBoard()
    {
        int     randomIndex;
        float   slimex = topLeftPos[0];
        float   slimey = topLeftPos[1];
        Vector3 slimepos;

        PuzzleController pc = gameObject.GetComponent <PuzzleController>();

        slimeWidth  = slimes[0].GetComponent <SpriteRenderer>().bounds.size.x;
        slimeHeight = slimes[0].GetComponent <SpriteRenderer>().bounds.size.y;

        // Instantiate 64 slimes in a grid of 8 by 8
        for (int i = 0; i < 8; i++)
        {
            slimex = topLeftPos[0];
            slimey = topLeftPos[1] - i * slimeHeight - i * ypadding;
            for (int j = 0; j < 8; j++)
            {
                randomIndex    = Random.Range(0, slimes.Length);
                slimex         = topLeftPos[0] + j * slimeWidth + j * xpadding;
                slimepos       = new Vector3(slimex, slimey, 0);
                pc.board[i][j] = Instantiate(slimes[randomIndex], slimepos, Quaternion.identity);
                pc.board[i][j].GetComponent <Coordinates>().x = i;
                pc.board[i][j].GetComponent <Coordinates>().y = j;
            }
        }
    }
Esempio n. 7
0
    //정상적으로 강조할 수 있는 블록들인지 확인 후 정상적이면 체크. //
    private bool TryEmphasisBlocks(Pos pos, PuzzleController tile)
    {
        bool wrongPosOnMap = false;

        for (int i = 0, max = tile.blockPos.Count; i < max; i++)
        {
            int x = tile.blockPos[i].x + pos.x;
            int y = tile.blockPos[i].y + pos.y;
            if (x < 0 || x >= Define.width || y < 0 || y >= Define.height)
            {
                wrongPosOnMap = true;
                emphasisTiles.Clear();
                break;
            }
            if (!mapData.GetBlockOnMap(x, y).IsSame(TileData.BlockType.None))
            {
                wrongPosOnMap = true;
                emphasisTiles.Clear();
                break;
            }

            emphasisTiles.Add(new Pos(x, y));
        }
        return(wrongPosOnMap);
    }
Esempio n. 8
0
    private PuzzleController MakeTutorialTile(int idx)
    {
        PuzzleController tile = PoolManager.GetObject <PuzzleController>();

        TileData tileData = new TileData();

        tileData.SetNormalTile(idx);

        int tileType, rotation;

        switch (idx)
        {
        case 0:
            tileType = 0;
            rotation = 1;
            break;

        case 1:
            tileType = 5;
            rotation = 0;
            break;

        case 2:
        default:
            tileType = 3;
            rotation = 0;
            break;
        }

        PuzzleTable puzzleTable = DataManager.GetInstance().GetTileTable(tileType);

        tile.SetData(puzzleTable, tileData, rotation);
        return(tile);
    }
Esempio n. 9
0
    public void OnValueChanged(int result)
    {
        Toggle stopToggle = GameObject.Find("StopToggle").GetComponent <Toggle>();

        PuzzleController puzzleController = GameObject.Find("PuzzleController").GetComponent <PuzzleController>();

        puzzleController.replayStop = stopToggle.isOn;
    }
 //==========================================================================================================================================================
 public void OnEnable()
 {
     puzzle = target as PuzzleController;
     if (!Application.isPlaying && puzzle.pieces != null)
     {
         puzzle.Prepare();
     }
 }
Esempio n. 11
0
    // Start is called before the first frame update
    void Start()
    {
        puzzleController = GameObject.FindGameObjectWithTag("PuzzleController").GetComponent <PuzzleController>();
        tools            = gameObject.transform.GetComponentsInChildren <Tool>();

        endLevelSplash = GameObject.FindGameObjectWithTag("EndLevelSplash");
        endLevelSplash.SetActive(false);
    }
Esempio n. 12
0
    // Start is called before the first frame update
    void Start()
    {
        currentPuzzleId  = 1;
        menuManager      = GameObject.FindObjectOfType <MenuManager>();
        puzzleController = GameObject.FindObjectOfType <PuzzleController>();

        Reset();
    }
Esempio n. 13
0
    private int Width; // 横軸

    #endregion Fields

    #region Constructors

    public PieceTouch(PuzzleController parent, int height, int width, float pieceSize)
    {
        mRoot = parent;
        Height = height;
        Width = width;

        PieceSize = pieceSize;
    }
Esempio n. 14
0
    private void OnPress(bool bPressed)
    {
        if (isMoving || !GameManager.IsPlaying() || !TileSystem.CanClickTile())
        {
            if (clickedTile == null)
            {
                return;
            }
            else
            {
                bPressed = false;
            }
        }

        isPressing = bPressed;

        if (bPressed)
        {
            clickedTile = this;

            clickedPos  = new Vector3(UICamera.lastTouchPosition.x, UICamera.lastTouchPosition.y, 0f);
            clickedPos *= ScreenSizeGetter.width / (float)Screen.width;
            clickedPos -= new Vector3(ScreenSizeGetter.halfWidth, ScreenSizeGetter.halfHeight);
            clickedPos -= mTrans.localPosition;

            //Vector3 fingerDistance = Vector3.zero;
            //switch (DataManager.GetInstance().touchOption)
            //{
            //    case 0:
            //        fingerDistance.y = 100f;
            //        break;
            //    case 1:
            //        fingerDistance.y = 300f;
            //        break;
            //    default:
            //    case 2:
            //        fingerDistance.y = 500f;
            //        break;
            //}

            //clickedPos += fingerDistance;
            clickedPos += Define.fingerDistance;

            body.localPosition += clickedPos;

            bGetBigger  = true;
            bGetSmaller = false;
        }
        else
        {
            clickedTile = null;
            if (putPuzzleCallback != null)
            {
                putPuzzleCallback(this);
            }
        }
    }
Esempio n. 15
0
    private int Width; // 横軸

    #endregion Fields

    #region Constructors

    /* コンストラクタ */
    public PuzzleJudgment(PuzzleController parent, int height, int width, int deleteCount)
    {
        mRoot = parent;

        Height = height;
        Width = width;

        DeleteCount = deleteCount;
    }
Esempio n. 16
0
    public override void Init(PuzzleController controller, string puzzleId)
    {
        base.Init(controller, puzzleId);

        blockGrid   = new ColorBlock[gridSizeX, gridSizeY];
        blockStates = new int[gridSizeX, gridSizeY];

        ShuffleArray(blockStartStates);
        SetBlocksOnStartPosition();
    }
Esempio n. 17
0
    //해당 타일을 맵 위에 놓는다. //
    public void PutPuzzleOnMap(PuzzleController tile)
    {
        tileList.Remove(tile);
        PoolManager.ReturnObject <PuzzleController>(tile);

        for (int i = 0, max = emphasisTiles.Count; i < max; i++)
        {
            mapData.GetBlockOnMap(emphasisTiles[i]).SetTileType(tile.tileType);
        }
    }
Esempio n. 18
0
    //랜덤하게 퍼즐 타일을 생성. //
    private PuzzleController MakeRandomTile()
    {
        PuzzleController tile = PoolManager.GetObject <PuzzleController>();

        TileData    tileData    = GetTileData();
        PuzzleTable puzzleTable = DataManager.GetInstance().GetTileTable(tileTypeRandomTable.GetRandomIdx());

        tile.SetData(puzzleTable, tileData, Random.Range(0, 4));
        return(tile);
    }
Esempio n. 19
0
        public void PuzzleGetFail()
        {
            var settingsMoq = new Mock <IOptions <AppSettings> >();

            settingsMoq.Setup(x => x.Value).Returns(testSettings);
            var                    controller   = new PuzzleController(settingsMoq.Object, testPuzzle);
            var                    result       = controller.Get(5);
            ActionResult           testResult   = (ActionResult)result.Result;
            BadRequestObjectResult objectResult = Assert.IsType <BadRequestObjectResult>(testResult);
        }
Esempio n. 20
0
    private PuzzleController MakeTile(List <Define.PuzzleType> puzzleType)
    {
        PuzzleController tile = PoolManager.GetObject <PuzzleController>();

        TileData    tileData    = GetTileData();
        int         idx         = (int)puzzleType[Random.Range(0, puzzleType.Count)];
        PuzzleTable puzzleTable = DataManager.GetInstance().GetTileTable(idx);

        tile.SetData(puzzleTable, tileData, Random.Range(0, 4));
        return(tile);
    }
Esempio n. 21
0
    void Start()
    {
        data.CreateLists();
        currentController  = swapController;
        data.levelSettings = GameController.main.levelToLoad;
        SetBackground(data.levelSettings.background);
        GenerateWave(0);

        CreateHeroCards();
        data.isLevelLoaded = true;
    }
Esempio n. 22
0
    // Start is called before the first frame update
    void Start()
    {
        playerController = FindObjectOfType <PlayerController>();
        defaultInstance  = this;

        foreach (Puzzle p in puzzles)
        {
            puzzlesCompleted.Add(p, false);
        }

        // SetPuzzleActive(2);
    }
Esempio n. 23
0
    public virtual void Init(PuzzleController controller, string id)
    {
        this.controller = controller;
        puzzleId        = id;

        foreach (BaseComponent component in components)
        {
            component.Init(this);
        }

        ResetPuzzle();
    }
Esempio n. 24
0
    //-----------------------------------------------------------------------------------------------------
    // Switch puzzle and background to another
    public void SwitchPuzzle(PuzzleController _puzzle, Renderer _background)
    {
        if (_puzzle && _puzzle != puzzle)
        {
            StartPuzzle(_puzzle);
        }

        if (_background && _background != background)
        {
            PrepareBackground(_background);
        }
    }
Esempio n. 25
0
    public IEnumerator PositionPuzzleBasic()
    {
        SoundManager.GetInstance().PlaySound(Define.SoundType.TileMoveBack);

        Vector3 pos = GetPos(tileIdx);

        InitData();
        mTrans.localPosition = pos;
        yield return(null);

        clickedTile = null;
    }
Esempio n. 26
0
 protected override void Awake()
 {
     base.Awake();
     instance  = this;
     blockOri  = block.GetComponent <RectTransform> ().anchoredPosition;
     cellOri   = letterCell.GetComponent <RectTransform> ().anchoredPosition;
     saveData  = TextManager.Instance.ReadProgress <PuzzleSaveData> ("PuzzleProgress.json");
     hint.info = "puzzlehintcost";
     hint.SetHint();
     hint.HintEvent += ClickHint;
     InitColor();
     SetReadData();
 }
Esempio n. 27
0
        public void PuzzleGetSuccess()
        {
            var settingsMoq = new Mock <IOptions <AppSettings> >();

            settingsMoq.Setup(x => x.Value).Returns(testSettings);
            var controller = new PuzzleController(settingsMoq.Object, testPuzzle);
            var result     = controller.Get(1);

            ActionResult   testResult     = (ActionResult)result.Result;
            OkObjectResult okObjectResult = Assert.IsType <OkObjectResult>(testResult);

            Assert.Equal("DDMW XJK TLUE ANCD", okObjectResult.Value);
        }
Esempio n. 28
0
    void Awake()
    {
        if (GetComponent <FlagController>() != null)
        {
            flagController = GetComponent <FlagController>();
        }
        if (GetComponent <PuzzleController>() != null)
        {
            puzzleController = GetComponent <PuzzleController>();
        }

        StartButtonUI.GetComponent <Button>().onClick.AddListener(PushStartButton);
    }
Esempio n. 29
0
        public int SolvePuzzlePart2(string input)
        {
            string[] lines = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            FloorPlan        floorPlan     = new FloorPlan();
            List <VisitNode> placesToVisit = new List <VisitNode>();

            ParseInput(lines, floorPlan, placesToVisit);

            PuzzleController pc = new PuzzleController();

            return(pc.SolvePuzzle(floorPlan, placesToVisit, true));
        }
Esempio n. 30
0
        public void PostPuzzletest()
        {
            var settingsMoq = new Mock <IOptions <AppSettings> >();

            settingsMoq.Setup(x => x.Value).Returns(testSettings);
            var controller = new PuzzleController(settingsMoq.Object, testPuzzle);
            var result     = controller.Post(postRequestCorrect);

            ActionResult   testResult     = (ActionResult)result.Result;
            OkObjectResult okObjectResult = Assert.IsType <OkObjectResult>(testResult);
            PuzzleResponse response       = (PuzzleResponse)okObjectResult.Value;

            Assert.True(response.IsCorrect);
        }
Esempio n. 31
0
    public int numCamera;       //Number of the enabled camera for the puzzle

    void Awake()
    {
        //If an PuzzleController exists and it is not this...
        if (Instance != null && Instance != this)
        {
            Debug.LogError("Error with PuzzleController script components, 2 instances " + this);
            //...destroy this and exit. There can be only one PuzzleController
            Destroy(gameObject);
            return;
        }

        //This is the Instance PuzzleController and it should persist
        Instance = this;
    }
Esempio n. 32
0
    private void InitData()
    {
        bGetBigger  = false;
        bGetSmaller = false;
        isPressing  = false;

        nowSize       = Define.smallSizeRate;
        mTrans.parent = GameManager.tileRoot;

        clickedTile = null;

        SetBlocks();
        SetSize(nowSize);
    }
Esempio n. 33
0
    public override void Init(PuzzleController controller, string puzzleId)
    {
        base.Init(controller, puzzleId);

        blockCorrectStates = new int[blocks.Length];
        for (int i = 0; i < blockCorrectStates.Length; ++i)
        {
            blockCorrectStates[i] = UnityEngine.Random.Range(0, 16);
        }

        if (numberHint)
        {
            numberHint.Init(blockCorrectStates);
        }
    }
Esempio n. 34
0
    void Start()
    {
        tc = GameObject.Find("TrackController").GetComponent<TrackController>();
        puzzle = GameObject.Find("PuzzlePanel").GetComponent<PuzzleController>();
        pieceLocked = false;
        //lockLocation = lockedPosition.position;

        // adjusting for width of reticule
        //lockLocation.x -= 40f * .0025f;
    }
Esempio n. 35
0
 // Use this for initialization
 void Start()
 {
     mNowState = PuzzleState.SELECT;
     mPuzCon = GameObject.Find("PuzzleController").GetComponent<PuzzleController>();
 }
Esempio n. 36
0
 void Start()
 {
     puzzleController = GameObject.FindObjectOfType<PuzzleController>();
 }
Esempio n. 37
0
 void Awake()
 {
     heroStrong = FindObjectOfType<HeroStrong>();
     heroFast = FindObjectOfType<HeroFast>();
     puzzleController = this.GetComponent<PuzzleController>();
 }
    Color GetColor(PuzzleController.PuzzleColor slot)
    {
        Color c = Color.red;

        switch(slot)
        {
            case PuzzleController.PuzzleColor.Blue: c = Color.blue;
                break;
            case PuzzleController.PuzzleColor.Green: c = Color.green;
                break;
            case PuzzleController.PuzzleColor.Red: c = Color.red;
                break;
            case PuzzleController.PuzzleColor.Yellow: c = Color.yellow;
                break;
        }
        return c;
    }