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(); }
void Awake() { if (!instance) { instance = this; } }
//----------------------------------------------------------------------------------------------------- //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>(); }
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; } } }
//정상적으로 강조할 수 있는 블록들인지 확인 후 정상적이면 체크. // 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); }
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); }
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(); } }
// 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); }
// Start is called before the first frame update void Start() { currentPuzzleId = 1; menuManager = GameObject.FindObjectOfType <MenuManager>(); puzzleController = GameObject.FindObjectOfType <PuzzleController>(); Reset(); }
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; }
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); } } }
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; }
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(); }
//해당 타일을 맵 위에 놓는다. // 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); } }
//랜덤하게 퍼즐 타일을 생성. // 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); }
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); }
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); }
void Start() { data.CreateLists(); currentController = swapController; data.levelSettings = GameController.main.levelToLoad; SetBackground(data.levelSettings.background); GenerateWave(0); CreateHeroCards(); data.isLevelLoaded = true; }
// 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); }
public virtual void Init(PuzzleController controller, string id) { this.controller = controller; puzzleId = id; foreach (BaseComponent component in components) { component.Init(this); } ResetPuzzle(); }
//----------------------------------------------------------------------------------------------------- // 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); } }
public IEnumerator PositionPuzzleBasic() { SoundManager.GetInstance().PlaySound(Define.SoundType.TileMoveBack); Vector3 pos = GetPos(tileIdx); InitData(); mTrans.localPosition = pos; yield return(null); clickedTile = null; }
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(); }
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); }
void Awake() { if (GetComponent <FlagController>() != null) { flagController = GetComponent <FlagController>(); } if (GetComponent <PuzzleController>() != null) { puzzleController = GetComponent <PuzzleController>(); } StartButtonUI.GetComponent <Button>().onClick.AddListener(PushStartButton); }
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)); }
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); }
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; }
private void InitData() { bGetBigger = false; bGetSmaller = false; isPressing = false; nowSize = Define.smallSizeRate; mTrans.parent = GameManager.tileRoot; clickedTile = null; SetBlocks(); SetSize(nowSize); }
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); } }
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; }
// Use this for initialization void Start() { mNowState = PuzzleState.SELECT; mPuzCon = GameObject.Find("PuzzleController").GetComponent<PuzzleController>(); }
void Start() { puzzleController = GameObject.FindObjectOfType<PuzzleController>(); }
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; }