void InitializePatterns() { _listPatterns = new List<PatternColorGame>(); List<Vector3> patternSquare = new List<Vector3>(); patternSquare.Add(new Vector3(0, 0, 0)); patternSquare.Add(new Vector3(4, 0, 0)); patternSquare.Add(new Vector3(4, 0, 4)); patternSquare.Add(new Vector3(0, 0, 4)); /* patternSquare.Add(new Vector3(6, 0, 0)); patternSquare.Add(new Vector3(10, 0, 0)); patternSquare.Add(new Vector3(10, 0, 4)); patternSquare.Add(new Vector3(6, 0, 4)); */ /* patternSquare.Add(new Vector3(6, 0, 6)); patternSquare.Add(new Vector3(10, 0, 6)); patternSquare.Add(new Vector3(10, 0, 10)); patternSquare.Add(new Vector3(6, 0, 10)); */ /* patternSquare.Add(new Vector3(0, 0, 6)); patternSquare.Add(new Vector3(4, 0, 6)); patternSquare.Add(new Vector3(4, 0, 10)); patternSquare.Add(new Vector3(0, 0, 10)); */ _listPatterns.Add(new PatternColorGame(patternSquare)); List<Vector3> patternBigSquare = new List<Vector3>(); patternBigSquare.Add(new Vector3(0, 0, 0)); patternBigSquare.Add(new Vector3(10, 0, 0)); patternBigSquare.Add(new Vector3(10, 0, 10)); patternBigSquare.Add(new Vector3(0, 0, 10)); _listPatterns.Add(new PatternColorGame(patternBigSquare)); List<Vector3> patternRandom = new List<Vector3>(); patternRandom.Add(new Vector3(0, 0, 0)); patternRandom.Add(new Vector3(0, 0, 4)); patternRandom.Add(new Vector3(4, 0, 4)); patternRandom.Add(new Vector3(4, 0, 8)); patternRandom.Add(new Vector3(8, 0, 8)); patternRandom.Add(new Vector3(8, 0, 0)); _listPatterns.Add(new PatternColorGame(patternRandom)); _currentPattern = _listPatterns[Random.Range(0, _listPatterns.Count)]; }
void SetCurrentPattern() { _currentPattern = new PatternColorGame(); List<Vector3> positions = new List<Vector3>(); _indexCurrentPattern = Random.Range(0, _listPatterns.Count); _currentPattern._count = _listPatterns[_indexCurrentPattern]._count; _currentPattern._indexBottom = _listPatterns[_indexCurrentPattern]._indexBottom; _currentPattern._indexTop = _listPatterns[_indexCurrentPattern]._indexTop; _currentPattern._indexLeft = _listPatterns[_indexCurrentPattern]._indexLeft; _currentPattern._indexRight = _listPatterns[_indexCurrentPattern]._indexRight; for (int i = 0; i < _listPatterns[_indexCurrentPattern]._count; ++i) { positions.Add(_listPatterns[_indexCurrentPattern]._positions[i]); } Vector3 previousPosition = positions[0]; Vector3 currentPosition; Vector3 difference; positions[0] = transform.position; for (int i = 1; i < positions.Count; ++i) { currentPosition = positions[i]; difference = currentPosition - previousPosition; positions[i] = positions[i - 1] + difference; previousPosition = currentPosition; } _currentPattern._positions = positions; }