Nanook.TheGhost.ProjectSong.adjustFaceOff C# (CSharp) Method

adjustFaceOff() private method

Combine overlapping sections
private adjustFaceOff ( int faceOff ) : int[]
faceOff int
return int[]
        private int[] adjustFaceOff(int[] faceOff)
        {
            List<int> fo = new List<int>();
            for (int i = 0; i < faceOff.Length; i += 2)
            {
                //if this section overlaps with the last section then combine them
                if (fo.Count >= 2 && faceOff[i - 2] + faceOff[(i - 2) + 1] >= faceOff[i])
                {
                    fo[fo.Count - 1] = (faceOff[i] + faceOff[i + 1]) - fo[fo.Count - 2]; //combine sections
                }
                else
                {
                    fo.Add(faceOff[i]);
                    fo.Add(faceOff[i + 1]);
                }
            }

            return fo.ToArray();
        }