예제 #1
0
        // 开始具体的调试操作
        public void Execute(bool containsHeader)
        {
            Range topLeftCell = null;
            var   slopes      = GetSlopes(containsHeader, ref topLeftCell);

            if (slopes != null && slopes.Count > 0)
            {
                // 1、对横断面数据进行排序
                slopes.Sort(Comparison);

                // 2、 求分段的面积
                var segs = GetArea(slopes);
                // 4、将结果写回 Excel
                var slopesArr = SegmentData <float, double> .ConvertToArr(segs);

                var mileArr    = segs.Select(r => $"K{Math.Floor(r.Start / 1000)}+{(r.Start % 1000).ToString("000")}~K{Math.Floor(r.End / 1000)}+{(r.End % 1000).ToString("000")}").ToArray();
                var lengthArr  = segs.Select(r => (r.End - r.Start).ToString()).ToArray();
                var lengthArr2 = segs.Select(r => "长度" + (r.End - r.Start).ToString()).ToArray();
                //
                slopesArr = slopesArr.InsertVector <object, object, string>(false, new[] { mileArr, lengthArr },
                                                                            new [] { 1f, 1.1f });

                var sht = _excelApp.ActiveSheet;
                RangeValueConverter.FillRange(sht, topLeftCell.Row, topLeftCell.Column + 3, slopesArr, false);
            }
        }
        /*
         * Parsing the received json into the FlightPlanData object
         */
        private FlightPlanData CreateFlightPlanDataFromJson(dynamic obj)
        {
            FlightPlanData newFlightPlanData = BuildInitialFlightPlanDataObject(obj);

            dynamic segments = obj["segments"];
            IEnumerable <SegmentData> segmentList = new List <SegmentData>();

            foreach (var segment in segments)
            {
                double segmentLongitude = double.Parse(segment["longitude"].ToString());
                double segmentLatitude  = double.Parse(segment["latitude"].ToString());
                int    timeSpanSeconds  = int.Parse(segment["timespan_seconds"].ToString());

                SegmentData newSegment = new SegmentData()
                {
                    Longitude       = segmentLongitude,
                    Latitude        = segmentLatitude,
                    TimeSpanSeconds = timeSpanSeconds
                };
                segmentList = segmentList.Append(newSegment);
            }

            newFlightPlanData.Segments = segmentList;

            return(newFlightPlanData);
        }
예제 #3
0
    private IEnumerator MakeSegment(SegmentData d)
    {
        if (p.minSubdivisions - d.subdivision <= 0)
        {
            var mf = gameObject.AddComponent <MeshFilter>();
            mr = gameObject.AddComponent <MeshRenderer>();
            if (p.generateColliders)
            {
                mc = gameObject.AddComponent <MeshCollider>();
            }

            if (Application.isPlaying || p.editorSubdivisions - d.subdivision != 0)
            {
                mr.enabled = false;
                mr.enabled = false;
            }
            mr.receiveShadows = false;

            if (Application.isPlaying)
            {
                yield return(StartCoroutine(SegmentGenerator.Generate(d, mf, mc)));
            }
            else
            {
                IEnumerator e = SegmentGenerator.Generate(d, mf, mc);
                while (e.MoveNext())
                {
                    ;
                }
            }
            mr.sharedMaterial = p.mainMaterial;
        }
    }
예제 #4
0
        public SegmentData getSegmentData(string[] data, SegmentData segDataAux)
        {
            string[] vecMetaDataAux = data[segDataAux.Start].Split(new string[] { this.util.CharacterSplitLine }, StringSplitOptions.None);

            if (Convert.ToInt32(vecMetaDataAux[0]) > 0 && Convert.ToInt32(vecMetaDataAux[0]) <= this.util.MaxLenghtArray)
            {
                if (Convert.ToInt32(vecMetaDataAux[1]) > 0 && Convert.ToInt32(vecMetaDataAux[1]) <= this.util.MaxLenghtOperations)
                {
                    int[,,] array3D = util.InstanceArray(Convert.ToInt32(vecMetaDataAux[0]));

                    segDataAux.End = segDataAux.End + Convert.ToInt32(vecMetaDataAux[1]);

                    for (int i = segDataAux.Start + 1; i <= segDataAux.End; i++)
                    {
                        int numAux = blSentence.executeSentece(data[i], array3D, Convert.ToInt32(vecMetaDataAux[0]), Convert.ToInt32(vecMetaDataAux[1]));
                        if (numAux > -1)
                        {
                            segDataAux.ArraySum.Add(Convert.ToString(numAux));
                        }
                    }
                }
            }

            return(segDataAux);
        }
예제 #5
0
        public void ParseNext_WhenCompleteSegmentDataIsNotNull_ShouldProcessParagraphUnit()
        {
            // Arrange
            var testSegmentData = new SegmentData
            {
                SourcePath  = "SourcePath",
                SourceValue = "SourceValue",
                TargetPath  = "TargetPath",
                TargetValue = "TargetValue"
            };
            var paragraphUnitMock = A.Fake <IParagraphUnit>();
            var testee            = CreateTestee();

            testee.StartOfInput();

            A.CallTo(() => _segmendDataCollectorMock.CompleteSegmentData).Returns(testSegmentData);
            A.CallTo(() => _paragraphUnitFactoryMock.Create(
                         testSegmentData.SourcePath,
                         testSegmentData.SourceValue,
                         testSegmentData.TargetPath,
                         testSegmentData.TargetValue)).Returns(paragraphUnitMock);

            // Act
            testee.ParseNext();

            // Assert
            A.CallTo(() => _bilingualContentHandlerMock.ProcessParagraphUnit(paragraphUnitMock)).MustHaveHappened();
        }
 private string segmentcompatible(SegmentData s1, SegmentData s2, int segNr)
 {
     try {
         if (s1.name[segNr].ToLower().Contains(txtSkiptext.Text.ToLower()) && chkSkipeeprom.Checked)
         {
             Debug.WriteLine("Skipping segment: " + s1.name[segNr]);
             return("");
         }
         else
         {
             if (s1.range[segNr] == s2.range[segNr])
             {
                 return("1");
             }
             else if (s1.size[segNr] == s2.size[segNr])
             {
                 return("0");
             }
             else
             {
                 return("X");
             }
         }
     }
     catch
     {
         return("X");
     }
 }
예제 #7
0
        public static string makeQuerySegmentData(SegmentData data)
        {
            string query = "INSERT INTO [50M_SEGMENT] VALUES ('" + data.SEGMENT_ID + "','" + data.SEMANTIC_LINK_ID + "','" + data.START_LINK_ID + "','";

            query += data.START_NUM + "','" + data.START_POINT_OFFSET + "')";

            return(query);
        }
예제 #8
0
    public static float GetSize(SegmentData d)
    {
        var rad = d.planet.radius;
        var tl  = d.topLeft.normalized * rad;
        var br  = d.bottomRight.normalized * rad;

        return(Vector3.Distance(tl, br));
    }
 void Start()
 {
     m_totalFixedIncome      = BuildSegmentData("TotalFixedIncome");
     m_totalFixedExpenses    = BuildSegmentData("TotalFixedExpenses");
     m_totalVariableIncome   = BuildSegmentData("TotalVariableIncome");
     m_totalVariableExpenses = BuildSegmentData("TotalVariableExpenses");
     m_currentMonthlyBalance = BuildSegmentData("CurrentLeft");
     SetKnownSegmentColours();
 }
예제 #10
0
    private IEnumerator MakeSphere()
    {
        busy = true;
        if (planet.waterSphere != null && planet.waterHeight > 0f)
        {
            water               = Instantiate(planet.waterSphere);
            water.parent        = transform; water.localPosition = Vector3.zero;
            water.localRotation = Quaternion.identity; water.localScale = new Vector3(1f, 1f, 1f) * (planet.radius + planet.waterHeight) / 1000f;
            if (simpleView)
            {
                water.gameObject.hideFlags = HideFlags.HideInHierarchy;
            }
            water.GetComponent <Renderer>().material = planet.waterMaterial;
        }
        for (var i = 0; i < 6; i++)
        {
            var sd = new SegmentData();
            sd.planet     = planet;
            sd.topLeft    = PTHelpers.cubeSides[i][0]; sd.topRight = PTHelpers.cubeSides[i][1];
            sd.bottomLeft = PTHelpers.cubeSides[i][2]; sd.bottomRight = PTHelpers.cubeSides[i][3];
            sd.uvMin      = Vector2.zero; sd.uvMax = new Vector2(1f, 1f);

            if (!Application.isPlaying)
            {
                var    t     = SegmentGenerator.GenerateTexture(sd);
                byte[] bytes = t.EncodeToPNG();
                File.WriteAllBytes(Application.dataPath + "/../Planet" + i.ToString() + ".png", bytes);
                t.Apply();
                sd.texture = t;
                materials.heightTexture = t;
            }

            var go = new GameObject(); var tr = go.GetComponent <Transform>();
            tr.parent        = transform; tr.localPosition = Vector3.zero;
            tr.localRotation = Quaternion.identity; tr.localScale = new Vector3(1f, 1f, 1f);

            var seg = go.AddComponent <PlanetTerrainSegment>();
            segments.Add(seg);
            if (Application.isPlaying)
            {
                yield return(StartCoroutine(seg.Generate(sd)));
            }
            else
            {
                IEnumerator e = seg.Generate(sd);
                while (e.MoveNext())
                {
                    ;
                }
            }
            seg.Enable();
        }
        busy = false;
    }
예제 #11
0
        } // CreateStreamClient

        private void AddSegment(PayloadStorage.SegmentPayloadReceivedEventArgs e)
        {
            var segmentData = new SegmentData()
            {
                EndPoint           = _settings.EndPoint,
                SegmentIdentity    = e.SegmentIdentity,
                PayloadData        = e.Payload,
                DataReceivedAction = _settings.DataReceivedAction
            }; // segmentData

            _processor.AddSegment(segmentData);
        } // AddSegment
 public void LoadSegmentList(ref PcmFile PCM1)
 {
     PCM                = PCM1;
     PCMsegmentdata     = new SegmentData(PCM);
     labelBasefile.Text = Path.GetFileName(PCM.FileName);
     comboSegments.Items.Clear();
     //for (int s=0;s<PCM.segmentinfos.Length;s++)
     comboSegments.ValueMember   = "SegNr";
     comboSegments.DisplayMember = "Name";
     comboSegments.DataSource    = PCM.segmentinfos;
     setuplistview();
     LoadSegments();
 }
예제 #13
0
    private void updateSegments()
    {
        for (int i = 0; i < m_sides; i++)
        {
            float segmentTime1 = i * (MAX_ANGLE / m_sides) + m_segmentOffset;
            float segmentTime2 = (i + 1) * (MAX_ANGLE / m_sides) + m_segmentOffset;

            Vector2 curSegmentPoint  = getSegmentPoint(segmentTime1);
            Vector2 nextSegmentPoint = getSegmentPoint(segmentTime2);

            SegmentData segmentData = new SegmentData(curSegmentPoint, nextSegmentPoint);
            m_segmentData[i] = segmentData;
        }
    }
예제 #14
0
    public SegmentData subdivCopy(Vector3[] corners, Vector2[] uvs)
    {
        var d = new SegmentData();

        d.planet      = planet;
        d.subdivision = subdivision + 1;
        d.topLeft     = corners[0];
        d.topRight    = corners[1];
        d.bottomLeft  = corners[2];
        d.bottomRight = corners[3];
        d.uvMin       = uvs[0];
        d.uvMax       = uvs[1];
        return(d);
    }
예제 #15
0
        public void SetTree(NetInfo prefab, LanePosition position, TreeInfo tree)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            if (tree != GetDefaultTree(prefab, position))
            {
                newSegmentData.SetPrefabFeature(position.ToTreeFeatureFlag(), tree);
            }
            else
            {
                newSegmentData.UnsetFeature(position.ToTreeFeatureFlag());
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #16
0
        public void SetStreetLight(NetInfo prefab, PropInfo prop)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            if (prop != GetDefaultStreetLight(prefab))
            {
                newSegmentData.SetPrefabFeature(SegmentData.FeatureFlags.StreetLight, prop);
            }
            else
            {
                newSegmentData.UnsetFeature(SegmentData.FeatureFlags.StreetLight);
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #17
0
        internal override ISegmentData GetSegmentData(ulong segmentAddr)
        {
            if (CLRVersion == DesktopVersion.v2)
            {
                return(Request <ISegmentData, V2SegmentData>(DacRequests.HEAPSEGMENT_DATA, segmentAddr));
            }

            SegmentData result = (SegmentData)Request <ISegmentData, SegmentData>(DacRequests.HEAPSEGMENT_DATA, segmentAddr);

            if (IntPtr.Size == 4)
            {
                result = new SegmentData(ref result);
            }

            return(result);
        }
예제 #18
0
        private static void SetTreeFeature(SegmentData data, string treeName, SegmentData.FeatureFlags flag)
        {
            if (treeName == null)
            {
                return;
            }

            TreeInfo tree = null;

            if (treeName != NoneValue)
            {
                tree = PrefabCollection <TreeInfo> .FindLoaded(treeName);
            }

            data.SetPrefabFeature(flag, tree);
        }
        private IEnumerable <SegmentData> BuildMatchingSegmentData(IEnumerable <Segment> matchingSegments)
        {
            IEnumerable <SegmentData> matchingSegmentData = new List <SegmentData>();

            foreach (var segment in matchingSegments)
            {
                SegmentData newSegmentData = new SegmentData()
                {
                    Longitude       = segment.Longitude,
                    Latitude        = segment.Latitude,
                    TimeSpanSeconds = segment.TimeSpanSeconds
                };
                matchingSegmentData = matchingSegmentData.Append(newSegmentData);
            }

            return(matchingSegmentData);
        }
예제 #20
0
    public static float GetDistance(SegmentData d)
    {
        var rad       = d.planet.radius;
        var tl        = d.topLeft.normalized * rad;
        var tr        = d.topRight.normalized * rad;
        var bl        = d.bottomLeft.normalized * rad;
        var br        = d.bottomRight.normalized * rad;
        var cameraPos = Camera.main.transform.position;

        return(Mathf.Min(
                   Vector3.Distance((tl + br) / 2f, cameraPos),
                   Vector3.Distance(tl, cameraPos),
                   Vector3.Distance(tr, cameraPos),
                   Vector3.Distance(bl, cameraPos),
                   Vector3.Distance(br, cameraPos)
                   ));
    }
예제 #21
0
    private void setPrismLayerTransform(Transform p_layerT, int p_prismLayerIdx, int p_segmentDataIdx)
    {
        SegmentData segmentData     = m_prismLayerData [p_prismLayerIdx].getSegmentData(p_segmentDataIdx);
        Vector2     targetDirection = segmentData.getDestinationTo() - segmentData.getDestinationFrom();

        // Set the position and (look) rotation of the segment pivot
        Transform prismLayerT = p_layerT;

        prismLayerT.SetParent(transform, false);
        prismLayerT.position = segmentData.getDestinationFrom();
        prismLayerT.rotation = Quaternion.LookRotation(prismLayerT.forward, targetDirection);

        // Stretch the pivot's length
        Segment segment = prismLayerT.GetComponent <Segment> ();

        segment.setPivotLength(segmentData.getSegmentLength());
    }
예제 #22
0
 void UpdateSegments()
 {
     if (!RenderDebug)
     {
         return;
     }
     foreach (GameObject segment in segmentInstances)
     {
         if (segment == null)
         {
             continue;
         }
         SegmentData data = segment.GetComponent <SegmentData>();
         segment.transform.position = data.StartNode.transform.position;
         segment.transform.rotation = Quaternion.LookRotation(data.EndNode.transform.position - data.StartNode.transform.position);
     }
 }
예제 #23
0
    public static float GetAngle(SegmentData d)
    {
        var rad       = d.planet.radius;
        var tl        = d.topLeft.normalized * rad;
        var tr        = d.topRight.normalized * rad;
        var bl        = d.bottomLeft.normalized * rad;
        var br        = d.bottomRight.normalized * rad;
        var cameraDir = Camera.main.transform.position.normalized;

        return(Mathf.Min(
                   Vector3.Angle((tl + br).normalized, cameraDir),
                   Vector3.Angle(tl.normalized, cameraDir),
                   Vector3.Angle(tr.normalized, cameraDir),
                   Vector3.Angle(bl.normalized, cameraDir),
                   Vector3.Angle(br.normalized, cameraDir)
                   ));
    }
예제 #24
0
    private ComputeBuffer GetVariableDataBuffer()
    {
        ComputeBuffer ret = new ComputeBuffer(PointsCount * ChainLength, VariableDataStride);

        SegmentData[] data = new SegmentData[PointsCount * ChainLength];
        for (int i = 0; i < (PointsCount * ChainLength); i++)
        {
            float   x           = UnityEngine.Random.value;
            float   z           = UnityEngine.Random.value;
            Vector2 randomPoint = new Vector2(x, z);
            data[i] = new SegmentData()
            {
                Position = randomPoint
            };
        }
        ret.SetData(data);
        return(ret);
    }
예제 #25
0
        internal override ISegmentData GetSegmentData(ulong segmentAddr)
        {
            if (CLRVersion == DesktopVersion.v2)
            {
                return(Request <ISegmentData, V2SegmentData>(DacRequests.HEAPSEGMENT_DATA, segmentAddr));
            }

            ISegmentData result = Request <ISegmentData, SegmentData>(DacRequests.HEAPSEGMENT_DATA, segmentAddr);

            if (IntPtr.Size == 4 && result != null)
            {
                // fixup pointers
                SegmentData s = (SegmentData)result;
                result = new SegmentData(ref s);
            }

            return(result);
        }
예제 #26
0
    /// <summary>
    /// Sets up the triangles for each segment.
    /// If the triangle is bigger than the screen, some rays from the vanishing point will never touch the screen.
    /// Therefore we clamp the triangle to a close fit around the screen corners where possible
    /// This does complicate math a lot, but the alternatives are significant resolution loss when aiming horizontal-ish or a gigantic buffer with trash performance
    /// </summary>
    static SegmentData GetGenericSegmentParameters(
        Camera camera,
        float2 screen,
        float2 vpScreen,         // vanishing point in screenspace (pixels, can be out of bounds)
        float distToOtherEnd,
        float2 neutral,
        int primaryAxis,
        int worldYMax
        )
    {
        SegmentData segment = new SegmentData();

        int secondaryAxis = 1 - primaryAxis;

        float2 simpleCaseMin, simpleCaseMax;

        {
            // setup the end points for the 2 45 degree angle rays
            simpleCaseMin = vpScreen[secondaryAxis] - distToOtherEnd;
            simpleCaseMax = vpScreen[secondaryAxis] + distToOtherEnd;

            float a = vpScreen[primaryAxis] + distToOtherEnd * sign(neutral[primaryAxis]);
            simpleCaseMin[primaryAxis] = a;
            simpleCaseMax[primaryAxis] = a;
        }

        if (simpleCaseMax[secondaryAxis] <= 0f || simpleCaseMin[secondaryAxis] >= screen[secondaryAxis])
        {
            return(segment);            // 45 degree angles aren't on screen
        }

        if (all(vpScreen >= 0f & vpScreen <= screen))
        {
            // vp within bounds, so nothing to clamp angle wise
            segment.MinScreen = simpleCaseMin;
            segment.MaxScreen = simpleCaseMax;
        }
        else
        {
            // vp outside of bounds, so we want to check if we can clamp the segment to the screen area to prevent wasting precious buffer space
            float2 dirSimpleMiddle = lerp(simpleCaseMin, simpleCaseMax, 0.5f) - vpScreen;

            float  angleLeft = 90f, angleRight = -90f;
            float2 dirRight = default, dirLeft = default;
예제 #27
0
        protected virtual XliffTransPair ExtractSegmentedPair(SegmentData src, SegmentData tgt, string slang, string tlang, IEnumerable <string> notes)
        {
            var selem = src.Element;
            var telem = tgt.Element;

            var pair = new XliffTransPair()
            {
                Serial     = (selem != null) || (telem != null) ? 1 : -1,
                Id         = (string)selem?.Attribute("mid") ?? (string)telem?.Attribute("mid") ?? "*",
                Source     = GetInline(selem) ?? src.InlineString ?? InlineString.Empty,
                Target     = GetInline(telem) ?? tgt.InlineString ?? InlineString.Empty,
                SourceLang = slang,
                TargetLang = tlang,
            };

            MatchTags(pair.Source, pair.Target);
            pair.AddNotes(notes);
            return(pair);
        }
예제 #28
0
 /// <summary>
 /// 产生读取用的Stream
 /// </summary>
 /// <param name="source">读取来源</param>
 public SegmentStream(IEnumerable<ArraySegment<byte>> source)
 {
     //Contract.Requires(source != null);
     StreamType = StreamType.Read;
     _currentSegIndex = 0;
     _position = 0;
     int length = 0;
     _core =
         source.Select(
             seg =>
             {
                 var rval = new SegmentData { Segment = seg, StartIndexInStream = length };
                 length = length + seg.Count;
                 return rval;
             }
         )
         .ToList();
     _length = length;
 }
예제 #29
0
        // This method will be cast to Comparison{Segment} delegate,
        // but it doesn't perform real comparison.
        // It is actually like EqualityComparer{Segment}.Equals(Segment, Segment).
        // Current Diff.Diff.Compare(IList{Segment}, IList{Segment}, Comparison{Segment}) works fine with it.
        private static int CompareRuns(SegmentData x, SegmentData y)
        {
            var xx = x.Element;
            var yy = y.Element;

            if (xx == null && yy == null)
            {
                return(0);
            }
            if (xx == null || yy == null)
            {
                return(-1);
            }
            if ((string)xx.Attribute("mid") == (string)yy.Attribute("mid"))
            {
                return(0);
            }
            return(-1);
        }
예제 #30
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (_core.Count == 0)
            {
                _core.Add(new SegmentData {
                    Segment = _segmentCreator(count), StartIndexInStream = 0
                });
            }
            var segData       = _core[_currentSegIndex];
            var currentOffset = (int)(_position - segData.StartIndexInStream);
            var copied        = 0;

            for (int left = count; left > 0;)
            {
                var needMoveNext = (segData.Segment.Count < left);
                var currentCount = !needMoveNext ? left : segData.Segment.Count;
                var fromOffset   = offset + copied;
                Buffer.BlockCopy(buffer, fromOffset, segData.Segment.Array, currentOffset, currentCount);
                copied  = copied + currentCount;
                _length = _length + currentCount;
                left    = count - copied;
                if (needMoveNext)
                {
                    _currentSegIndex++;
                    if (_currentSegIndex < _core.Count)
                    {
                        segData = _core[_currentSegIndex];
                    }
                    else
                    {
                        var newseg = new SegmentData
                        {
                            Segment            = _segmentCreator(left),
                            StartIndexInStream = segData.StartIndexInStream + segData.Segment.Count
                        };

                        segData = newseg;
                        _core.Add(newseg);
                    }
                }
            }
            //return copied;
        }
예제 #31
0
        public void SetStreetLightDistance(NetInfo prefab, float val)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            var distanceVector = newSegmentData.RepeatDistances;

            distanceVector.w = Math.Abs(val - GetDefaultStreetLightDistance(prefab)) > .01f ? val : 0f;

            if (distanceVector != Vector4.zero)
            {
                newSegmentData.SetStructFeature(SegmentData.FeatureFlags.RepeatDistances, distanceVector);
            }
            else
            {
                newSegmentData.UnsetFeature(SegmentData.FeatureFlags.RepeatDistances);
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #32
0
        public void SetStreetLight(NetInfo prefab, PropInfo prop)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            if (prop != GetDefaultStreetLight(prefab))
            {
                newSegmentData.SetPrefabFeature(SegmentData.FeatureFlags.StreetLight, prop);
            }
            else
            {
                newSegmentData.UnsetFeature(SegmentData.FeatureFlags.StreetLight);
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #33
0
        public void SetStreetLightDistance(NetInfo prefab, float val)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            var distanceVector = newSegmentData.RepeatDistances;
            distanceVector.w = Math.Abs(val - GetDefaultStreetLightDistance(prefab)) > .01f ? val : 0f;

            if (distanceVector != Vector4.zero)
            {
                newSegmentData.SetStructFeature(SegmentData.FeatureFlags.RepeatDistances, distanceVector);
            }
            else
            {
                newSegmentData.UnsetFeature(SegmentData.FeatureFlags.RepeatDistances);
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #34
0
        public void SetTree(NetInfo prefab, LanePosition position, TreeInfo tree)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            if (tree != GetDefaultTree(prefab, position))
            {
                newSegmentData.SetPrefabFeature(position.ToTreeFeatureFlag(), tree);
            }
            else
            {
                newSegmentData.UnsetFeature(position.ToTreeFeatureFlag());
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #35
0
        private void RebuildBuffer()
        {
            List<SegmentInstance> tempInstances = null;
            lock (m_instances)
            {
                tempInstances = new List<SegmentInstance>(m_instances);
            }

            var length = tempInstances.Count;

            if (length != 0)
            {
                SegmentData[] data = new SegmentData[length * 2];

                for (int i = 0; i < length * 2; i = i + 2)
                {
                    var instance = tempInstances.ElementAt(i / 2);

                    var matrix = Matrix4.Identity;

                    data[i] = new SegmentData()
                    {
                        Color = instance.Color,
                        Position = instance.P1
                    };

                    data[i + 1] = new SegmentData()
                    {
                        Color = instance.Color,
                        Position = instance.P2
                    };
                }

                m_bufferSprite.SetData(data, GL.STREAM_DRAW);

            }

            m_isDirty = false;
        }
예제 #36
0
        /// <summary>
        /// Loads TargetContent Property based on legact widget properties
        /// </summary>
        private void LoadLegacyWidget()
        {
            //this is an upgraded version of the widget.
            //Load New TargetContent data object from legacy properties

            _targetedContent = new TargetedContentData();
            SegmentData p = new SegmentData() { };

            _targetedContent.PageData = new PageData();
            _targetedContent.PageData.Zones = new List<DropZoneData>();
            _targetedContent.PageData.Zones.Add(new DropZoneData());
            _targetedContent.PageData.Zones[0].Columns = new List<ColumnDataSerialize>();
            SynchTargetConfiguration();

            for (int index = 0; index < Rulesets.Count; index++)
            {
                List<Rule> rules = Ektron.Newtonsoft.Json.JsonConvert.DeserializeObject<List<Rule>>(Rulesets[index]);
                if (rules == null)
                {
                    rules = new List<Rule>();
                }

                SegmentData segment = new SegmentData() { Name = RulesetNames[index] };
                segment.Rules = rules;
                _targetedContent.Segments.Add(segment);
            }
        }
예제 #37
0
        /// <summary>
        /// Gets the persona definition for the supplied ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private TargetedContentData GetTargetConfiguration(long targetContentId)
        {
            TargetedContentData tc = null;

            if (targetContentId > 0)
            {
                tc = TargetContentManager.GetItem(targetContentId);
            }
            if (tc == null)
            {
                //New target Content Data
                tc = new TargetedContentData();
                SegmentData p = new SegmentData() { };

                tc.PageData = new PageData();//PageData.Restore(pageXml);
                tc.PageData.Zones = new List<DropZoneData>();
                tc.PageData.Zones.Add(new DropZoneData());
                tc.PageData.Zones[0].Columns = new List<ColumnDataSerialize>();
            }

            return tc;
        }
예제 #38
0
        public void SetTreeDistance(NetInfo prefab, LanePosition position, float val)
        {
            var newSegmentData = new SegmentData(SegmentDataManager.Instance.GetActiveOptions(prefab));

            var distanceVector = newSegmentData.RepeatDistances;
            var value = Mathf.Abs(val - GetDefaultTreeDistance(prefab, position)) > .01f ? val : 0f;

            switch (position)
            {
                case LanePosition.Left:
                    distanceVector.x = value;
                    break;
                case LanePosition.Middle:
                    distanceVector.y = value;
                    break;
                case LanePosition.Right:
                    distanceVector.z = value;
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(position));
            }

            if (distanceVector != Vector4.zero)
            {
                newSegmentData.SetStructFeature(SegmentData.FeatureFlags.RepeatDistances, distanceVector);
            }
            else
            {
                newSegmentData.UnsetFeature(SegmentData.FeatureFlags.RepeatDistances);
            }

            SegmentDataManager.Instance.SetActiveOptions(prefab, newSegmentData);
        }
예제 #39
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (_core.Count == 0)
            {
                _core.Add(new SegmentData { Segment = _segmentCreator(count), StartIndexInStream = 0 });
            }
            var segData = _core[_currentSegIndex];
            var currentOffset = (int)(_position - segData.StartIndexInStream);
            var copied = 0;
            for (int left = count; left > 0; )
            {
                var needMoveNext = (segData.Segment.Count < left);
                var currentCount = !needMoveNext ? left : segData.Segment.Count;
                var fromOffset = offset + copied;
                Buffer.BlockCopy(buffer, fromOffset, segData.Segment.Array, currentOffset, currentCount);
                copied = copied + currentCount;
                _length = _length + currentCount;
                left = count - copied;
                if (needMoveNext)
                {
                    _currentSegIndex++;
                    if (_currentSegIndex < _core.Count)
                    {

                        segData = _core[_currentSegIndex];

                    }
                    else
                    {

                        var newseg = new SegmentData
                        {
                            Segment = _segmentCreator(left),
                            StartIndexInStream = segData.StartIndexInStream + segData.Segment.Count
                        };

                        segData = newseg;
                        _core.Add(newseg);
                    }

                }

            }
            //return copied;
        }
예제 #40
0
            public void Deserialize(DataSerializer s)
            {
                var count = s.ReadInt32();

                #if DEBUG
                Debug.Log($"Deserializing {count} active options");
                #endif

                for (var i = 0; i < count; i++)
                {
                    var prefabName = s.ReadUniqueString();

                    var prefab = PrefabCollection<NetInfo>.FindLoaded(prefabName);
                    if (prefab == null) continue;

                    var options = new SegmentData();
                    options.Deserialize(s);

                #if DEBUG
                    Debug.Log($"{prefabName} --> {options.ToString()}");
                #endif
                    SegmentDataManager.Instance.SetActiveOptions(prefab, options);
                }
            }
예제 #41
0
 private void DeleteIfNotInUse(SegmentData segmentData)
 {
     if (segmentData.UsedCount <= 0)
     {
         _usedSegmentData.Remove(segmentData);
     }
 }
예제 #42
0
 public SegmentDisplayData(SegmentData segment)
 {
     Id = segment.Id;
     Name = segment.Name;
     SegmentType = segment.SegmentType;
 }
예제 #43
0
        private static void SetTreeFeature(SegmentData data, string treeName, SegmentData.FeatureFlags flag)
        {
            if (treeName == null) return;

            TreeInfo tree = null;
            if (treeName != NoneValue) tree = PrefabCollection<TreeInfo>.FindLoaded(treeName);

            data.SetPrefabFeature(flag, tree);
        }
예제 #44
0
        private void Apply(BuildingInfo prefab)
        {
            BuildingNetworkSkinsDef.Building buildingDef;
            if (!_buildingDefsMap.TryGetValue(prefab, out buildingDef)) return;

            foreach (var networkDef in buildingDef.NetworkDefs)
            {
                var netInfo = PrefabCollection<NetInfo>.FindLoaded(networkDef.Name);
                if (netInfo == null) continue;

                var data = new SegmentData();

                if (networkDef.StreetLight != null)
                {
                    PropInfo streetLight = null;
                    if (networkDef.StreetLight != NoneValue)
                        streetLight = PrefabCollection<PropInfo>.FindLoaded(networkDef.StreetLight);
                    data.SetPrefabFeature(SegmentData.FeatureFlags.StreetLight, streetLight);
                }
                SetTreeFeature(data, networkDef.TreeLeft, SegmentData.FeatureFlags.TreeLeft);
                SetTreeFeature(data, networkDef.TreeMiddle, SegmentData.FeatureFlags.TreeMiddle);
                SetTreeFeature(data, networkDef.TreeRight, SegmentData.FeatureFlags.TreeRight);

                SetPillarFeature(netInfo, networkDef.BridgePillar, PillarType.BridgePillar, _userModeBridgePillars);
                SetPillarFeature(netInfo, networkDef.MiddlePillar, PillarType.MiddlePillar, _userModeMiddlePillars);

                SegmentDataManager.Instance.SetActiveOptions(netInfo, data);
            }
        }
예제 #45
0
        public void SetActiveOptions(NetInfo prefab, SegmentData segmentOptions)
        {
            var options = _assetMode ? _assetSegmentOptions : _selectedSegmentOptions;

            // Delete existing data if it is not used anymore
            var activeSegmentData = GetActiveOptions(prefab);
            if (activeSegmentData != null)
            {
                options.Remove(prefab);
                activeSegmentData.UsedCount--;
                DeleteIfNotInUse(activeSegmentData);
            }

            // No new data? Stop here
            if (segmentOptions == null || segmentOptions.Features == SegmentData.FeatureFlags.None) return;

            // Check if there is an equal data object
            var equalSegmentData = _usedSegmentData.FirstOrDefault(segmentOptions.Equals);
            if (equalSegmentData != null)
            {
                // yes? use that, discard the one we created
                options[prefab] = equalSegmentData;
                equalSegmentData.UsedCount++;
            }
            else
            {
                // no? Use the one we got
                _usedSegmentData.Add(segmentOptions);
                options[prefab] = segmentOptions;
                segmentOptions.UsedCount++;
            }
        }
예제 #46
0
    protected void BindItems(List<SegmentData> segments, List<string> selectedItems)
    {
        if (0 == segments.Count)
        {
            litErrorMessage.Text = GetMessage("lbl no segment setup for this provider");
            ErrorPanel.Visible = true;
        }

        List<SegmentDisplayData> defaultSegments = new List<SegmentDisplayData>();
        List<SegmentDisplayData> customSegments = new List<SegmentDisplayData>();
        foreach (SegmentData segment in segments)
        {
            SegmentDisplayData displaySegment = new SegmentDisplayData(segment);
            displaySegment.Selected = (selectedItems.FirstOrDefault(c => c == displaySegment.Id + "|0") != null);
            displaySegment.CmsSegmentValue = string.Empty;
            if (segment.SegmentType == SegmentType.Custom)
                customSegments.Add(displaySegment);
            else
                defaultSegments.Add(displaySegment);
        }

        if (this.CookieSegments.Count > 0)
        {
            int idx = 0;
            foreach (string idPair in this.CookieSegments)
            {
                string sSegProp = idPair.Substring(idPair.IndexOf("|") + 1);
                SegmentProperty segProp = (SegmentProperty)Convert.ToInt32(sSegProp);
                if (segProp != SegmentProperty.Id)
                {
                    string segValue = idPair.Replace("|" + sSegProp, "");
                    string segDisplayName = string.Empty;
                    switch (segProp)
                    {
                        case SegmentProperty.UserId:
                            segDisplayName = _user + " ";
                            break;
                        case SegmentProperty.VisitorId:
                            segDisplayName = _visitor + " ";
                            break;
                    }
                    SegmentData seg = new SegmentData("prop_" + idx.ToString() + "_" + sSegProp, segDisplayName, SegmentType.CMS);
                    SegmentDisplayData customSegment = new SegmentDisplayData(seg);
                    customSegment.Selected = true;
                    customSegment.CmsSegmentValue = segValue;
                    customSegments.Add(customSegment);
                    idx++;
                }
            }
        }
        rpt_Default.DataSource = defaultSegments;
        rpt_Default.DataBind();
        rpt_Custom.DataSource = customSegments;
        rpt_Custom.DataBind();
    }