Beispiel #1
0
        public static IEnumerable <Edge <T> > FollowBoundaryEdges(Edge <T> edge)
        {
            Edge <T> currentEdge = edge;
            bool     abort       = false;
            int      startID     = currentEdge.Start.ID;

            do
            {
                CyclicArray <Edge <T> > edges = CycleThroughEdgesAfterEdge(currentEdge);
                for (int i = 0; i < edges.Length; ++i)
                {
                    currentEdge = edges[i];
                    if (currentEdge.IsBoundary)
                    {
                        if (currentEdge.Start.ID != startID)
                        {
                            yield return(currentEdge);
                        }
                        else
                        {
                            abort = true;
                            break;
                        }
                    }
                    else
                    {
                        currentEdge = currentEdge.Twin;
                        break;
                    }
                }
            }while (!abort);
        }
Beispiel #2
0
        public int AccessShouldWork(int i)
        {
            var sut = new CyclicArray <int>(new [] { 0, 2, 4, 6, 8 });

            var result = sut[i];

            return(result);
        }
Beispiel #3
0
        static CyclicArray <Edge <T> > PositiveEdgeRotationOfCellAfter(Edge <T> first, int offset)
        {
            MeshCell <T>            cell            = first.Cell;
            int                     firstEdgeIndice = FindIndiceOfEdgeInItsCell(cell.Edges, first);
            CyclicArray <Edge <T> > edges           = new CyclicArray <Edge <T> >(cell.Edges, firstEdgeIndice + offset);

            return(edges);
        }
Beispiel #4
0
        static CyclicArray <Edge <T> > NegativeEdgeRotationOfCellAfter(Edge <T> first, int offset)
        {
            Edge <T>[] edgesOfCell        = first.Cell.Edges;
            Edge <T>[] reversedEdges      = ArrayMethods.GetReverseOrderArray(edgesOfCell);
            int        firstEdgeIndice    = FindIndiceOfEdgeInItsCell(reversedEdges, first);
            CyclicArray <Edge <T> > edges = new CyclicArray <Edge <T> >(reversedEdges, firstEdgeIndice + offset);

            return(edges);
        }
Beispiel #5
0
 public CyclicArray(CyclicArray other)
 {
     _nextIndex = other._nextIndex;
     _capacity  = other._capacity;
     _data      = new int[_capacity];
     for (int i = 0; i < _capacity; ++i)
     {
         _data[i] = other._data[i];
     }
 }
Beispiel #6
0
        public void Enumerate_0_ShouldReturnEmptyIEnumerable()
        {
            var sut = new CyclicArray <int>(new [] { 1, 2, 3 });

            var result = sut.Enumerate(0).ToArray();

            Assert.Multiple(() =>
            {
                Assert.That(result.Length, Is.EqualTo(0));
            });
        }
Beispiel #7
0
        public void Sequence_ShouldWork()
        {
            var sut = new CyclicArray <int>(new [] { 1, 2, 3 });

            var result = sut.Sequence().Take(10).ToArray();

            Assert.Multiple(() =>
            {
                Assert.That(result.Length, Is.EqualTo(10));
                Assert.That(result, Is.EqualTo(new int[] { 1, 2, 3, 1, 2, 3, 1, 2, 3, 1 }));
            });
        }
Beispiel #8
0
    private void OnGameReady()
    {
        Score.Value = 0;

        _map             = MapManager.Instance.Map;
        _mapView         = MapManager.Instance.View;
        _distToTakeBonus = (_ball.GetSize() + _mapView.GetBonusSizeOnMap()) / 3f;

        _ball.ResetAnimations();
        _ball.transform.position = _mapView.transform.up * _ball.GetSize() / 2f;

        StopCoroutine(nameof(UpdateGame));
        StartCoroutine(nameof(UpdateGame));
    }
Beispiel #9
0
        static CyclicArray <Edge <T> > CycleThroughEdgesAfterEdge(Edge <T> edge)
        {
            Edge <T>[] edges = edge.Cell.Edges;
            CyclicArray <Edge <T> > reorderedEdges = new CyclicArray <Edge <T> >(edges);

            for (int i = 0; i < edges.Length; ++i)
            {
                if (edge.End.ID == edges[i].Start.ID)
                {
                    reorderedEdges.Start = i;
                    return(reorderedEdges);
                }
            }
            throw new Exception("Edge not found in edges.");
        }
Beispiel #10
0
        public void Enumerate_ShouldWork()
        {
            var sut = new CyclicArray <int>(new [] { 1, 2, 3 });

            var result = sut.Enumerate(2).ToArray();

            Assert.Multiple(() =>
            {
                Assert.That(result.Length, Is.EqualTo(6));
                Assert.That(result[0], Is.EqualTo((0, 1)));
                Assert.That(result[1], Is.EqualTo((1, 2)));
                Assert.That(result[2], Is.EqualTo((2, 3)));
                Assert.That(result[3], Is.EqualTo((3, 1)));
                Assert.That(result[4], Is.EqualTo((4, 2)));
                Assert.That(result[5], Is.EqualTo((5, 3)));
            });
        }
Beispiel #11
0
    private void Awake()
    {
        _transform = transform;

        _maxParticles = Mathf.CeilToInt(_startLifetime.y * _frequency + 50);

        _particles     = new CyclicArray <ParticleData>(_maxParticles);
        _matrices      = new Matrix4x4[_maxParticles];
        _colors        = new Vector4[_maxParticles];
        _propertyBlock = new MaterialPropertyBlock();

        _material.enableInstancing = true;
        _startTime = Time.time;

        if (_useNoise)
        {
            _noiseX = AbstractNoise.GetNoise(_noiseSettings, 13);
            _noiseY = AbstractNoise.GetNoise(_noiseSettings, 28);
            _noiseZ = AbstractNoise.GetNoise(_noiseSettings, 43);
        }
    }
Beispiel #12
0
        public void GenerateHandStatus_ShouldWork(int siteswap)
        {
            var sut = new Siteswap(siteswap);

            var result = sut.GenerateHandStatus();

            var expectedValues = new CyclicArray <HandStatus>(new []
            {
                HandStatus.Empty,
                HandStatus.Empty,
                HandStatus.Full,
                HandStatus.Empty,
                HandStatus.Full
            });

            Assert.Multiple(() =>
            {
                for (int i = 0; i < sut.MaxThrow(); i++)
                {
                    Assert.That(result[i], Is.EqualTo(expectedValues[i]), $"Position {i} ist falsch");
                }
            });
        }
Beispiel #13
0
    void InitArrays()
    {
        samplesL  = new float[SAMPLE_SIZE];
        spectrumL = new float[SPECTRUM_SIZE];

        samplesR  = new float[SAMPLE_SIZE];
        spectrumR = new float[SPECTRUM_SIZE];

        visualScale        = new float[numOfBands];
        visualScaleDecayed = new float[numOfBands];

        int midNum = numOfBands % 2 != 0 ? (numOfBands / 2) + 1 : (numOfBands / 2);

        bands = GetHertzBands(startingFrequency, midFrequency, midNum);
        List <float> highBands = GetHertzBands(midFrequency, endingFrequency, numOfBands / 2);

        highBands.RemoveAt(0);
        bands.AddRange(highBands);
        //bands = GetHertzBands(startingFrequency, endingFrequency, numOfVisualCubes);

        waveFormL = new CyclicArray <float>(waveFormResolution);
        waveFormR = new CyclicArray <float>(waveFormResolution);
        waveFormSingleBinInSeconds = waveFormLengthInSeconds / waveFormResolution;
    }