void UpdatePuzzleChecker(int roomID) { if (roomID == -1) { return; } if (!m_puzzleChecker.ContainsKey(roomID)) { return; } float refX = 0f; float refY = 0f; for (int i = 0; i < m_puzzleChecker[roomID].Count; ++i) { Vector3 currentPos = Vector3.zero; PuzzleBehavior currentPiece = m_puzzleChecker[roomID][i].behavior; currentPos.x = currentPiece.transform.localPosition.x; currentPos.y = currentPiece.transform.localPosition.y; //Debug.Log("UPDATE " + currentPos); m_puzzleChecker[roomID][i].currentPos.x = currentPos.x / currentPiece.GetForegroundWidth(); m_puzzleChecker[roomID][i].currentPos.y = currentPos.y / currentPiece.GetForegroundHeight(); if (i == 0) { refX = currentPos.x / currentPiece.GetForegroundWidth(); refY = currentPos.y / currentPiece.GetForegroundHeight(); } m_puzzleChecker[roomID][i].currentPos.x -= refX; m_puzzleChecker[roomID][i].currentPos.y -= refY; //Debug.Log(i); //m_puzzleChecker[roomID][i].Display(); } }
void AddPuzzlePieceToChecker(int roomID, PuzzleBehavior puzzlePiece) { if (roomID == -1) { return; } if (puzzlePiece == null) { return; } Vector3 currentPos = Vector3.zero; currentPos.x = puzzlePiece.transform.localPosition.x; currentPos.y = puzzlePiece.transform.localPosition.y; // Debug.Log("ADD " + currentPos); if (!m_puzzleChecker.ContainsKey(roomID)) { m_puzzleChecker[roomID] = new List <PuzzleSolutionCheck>(); } PuzzleSolutionCheck currentSolutionCheck = new PuzzleSolutionCheck(); currentSolutionCheck.initialPos.x = currentPos.x / puzzlePiece.GetForegroundWidth(); currentSolutionCheck.initialPos.y = currentPos.y / puzzlePiece.GetForegroundHeight(); currentSolutionCheck.behavior = puzzlePiece; m_puzzleChecker[roomID].Add(currentSolutionCheck); m_puzzleChecker[roomID][m_puzzleChecker[roomID].Count - 1].solutionPos.x = currentSolutionCheck.initialPos.x - m_puzzleChecker[roomID][0].initialPos.x; m_puzzleChecker[roomID][m_puzzleChecker[roomID].Count - 1].solutionPos.y = currentSolutionCheck.initialPos.y - m_puzzleChecker[roomID][0].initialPos.y; //Debug.Log(m_puzzleChecker[roomID].Count-1); //m_puzzleChecker[roomID][m_puzzleChecker[roomID].Count-1].Display(); }