//UpdateLine void UpdateLine(Vector3 housePosition, string touchedHouse, Touch touch) { int hitPosition = int.Parse(touchedHouse); //If begin a touch, check if the touch is in a Extremety (SpecialPositions) or on the tip of an unfinished line if (touch.phase.ToString() == "Began") { if (specialPositions.Contains(hitPosition)) { var listIndex = specialPositions.FindIndex(i => i == hitPosition); int currentLine = (int)Mathf.Floor((float)listIndex / 2); line = lines[currentLine]; line.ResetLine(housePosition, hitPosition, allNodes); generatingLine = true; } else { foreach (LineGenerator lineGen in lines) { if ((lineGen.arrayPos.Count != 0) ? (hitPosition == lineGen.arrayPos.Last()) : false) { line = lineGen; generatingLine = true; break; } } } } //If person is moving its pressed finger, check if it went to a new unused position; else if (touch.phase.ToString() == "Moved" && generatingLine) { bool readyToAdd = true; if (!specialPositions.Contains(hitPosition) || hitPosition == line.lineExtremities[0] || hitPosition == line.lineExtremities[1]) { foreach (LineGenerator lineGen in lines) { if (lineGen.arrayPos.Contains(hitPosition) && lineGen.lineId != line.lineId) { readyToAdd = false; } } if (readyToAdd) { line.AddLinePoint(housePosition, hitPosition, true); } else { generatingLine = false; } } else { generatingLine = false; } if (!line.lineStatus) { line.CheckLineStatus(allNodes); } if (line.lineStatus) { generatingLine = false; } CheckVictory(); } else if (touch.phase.ToString() == "Ended") { generatingLine = false; } }