コード例 #1
0
        void SetupPoint(PlatformSection currentSection, PlatformPoint[] points, PlatformPoint point)
        {
            var _platformPoints = points.OrderBy(x => x.OrderId).ToArray();
            var orderId         = point.OrderId;

            if (_platformPoints[_platformPoints.Length - 1].OrderId == point.OrderId)
            {
                point.OrderId = _platformPoints[_platformPoints.Length - 1].OrderId + 1;
            }
            else
            {
                point.OrderId++;
                var pointsToUpdate = currentSection.platformPoints.Where(x => x.OrderId >= point.OrderId).OrderBy(x => x.OrderId).ToArray();
                for (var i = 0; i < pointsToUpdate.Length; i++)
                {
                    pointsToUpdate[i].OrderId++;
                    pointsToUpdate[i].name = "Point_" + pointsToUpdate[i].OrderId;
                }
            }

            point.name = "Point_" + point.OrderId;
            currentSection.platformPoints.Add(point);

            var all      = currentSection.transform.parent.GetComponentsInChildren <PlatformSection>();
            var sections = all.Where(x => x != currentSection).ToArray();

            foreach (var section in sections)
            {
                if (section.platformPoints.Count < currentSection.platformPoints.Count)
                {
                    section.AddPointAtOrderId(orderId, point.transform.localPosition);
                }
            }
        }
コード例 #2
0
ファイル: Platform.cs プロジェクト: RayGar/CS-4331-Project3
        //sets up a new section that's just been added to the platform
        void SetupSection(PlatformSection[] sections, PlatformSection section)
        {
            var platformSections = sections.OrderBy(x => x.OrderId).ToArray();

            section.OrderId = platformSections[platformSections.Length - 1].OrderId + 1;
            section.name    = "Section_" + section.OrderId;
            _platformSections.Add(section);
        }