Пример #1
0
        private void DistributeOnPath(Vector3[] pos)
        {
            var side = Random.Range(-1, 1);

            if (Mathf.Abs(_lastSide + side) > 3)
            {
                side *= -1;
            }

            for (int i = 0; i < pos.Length; i++)
            {
                var outPos = _trail.TrailMath(pos[i]);
                var split  = Mathf.Abs(outPos[0].z - outPos[1].z) > 3f;

                outPos[0].z  = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith;
                outPos[0].z += (_lastSide + side) * _gridSystem.Widith;
                outPos[0].y  = _infGrid.YGraph(outPos[0]);

                _coins[_currentCoin + i * 2].transform.position = outPos[0];
                _coins[_currentCoin + i * 2].gameObject.SetActive(true);

                if (split)
                {
                    outPos[1].z  = Mathf.Floor(outPos[1].z / _gridSystem.Widith) * _gridSystem.Widith;
                    outPos[1].z += (_lastSide + side) * _gridSystem.Widith;
                    outPos[1].y  = _infGrid.YGraph(outPos[1]);

                    _coins[_currentCoin + i * 2 + 1].transform.position = outPos[1];
                    _coins[_currentCoin + i * 2 + 1].gameObject.SetActive(true);
                }
            }

            _lastSide    = _lastSide + side;
            _currentCoin = (_currentCoin + _mul) % CoinPool * _mul;
        }
Пример #2
0
        void Draw(Vector3 p)
        {
            if (p.x < 500)
            {
                return;
            }

            p.x += Offset;
            var space = GetSpace();

            var pos = new Vector3[]
            {
                new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space),
                new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space + _trail.Step),
                new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space - _trail.Step),
            };

            var offset = Random.Range(-1, 1);

            var rot = Random.Range(0, 360);

            for (int i = 0; i < pos.Length; i++)
            {
                var outPos = _trail.TrailMath(pos[i]);
                var split  = Mathf.Abs(outPos[0].z - outPos[1].z) > 1f;

                outPos[0].z  = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith;
                outPos[0].z += offset * _gridSystem.Widith;
                outPos[0].y  = _infGrid.YGraph(outPos[0]);

                _pool[_currentCoin + i * 2].transform.eulerAngles = new Vector3(0, rot, 0);
                _pool[_currentCoin + i * 2].transform.position    = outPos[0];
                _pool[_currentCoin + i * 2].gameObject.SetActive(true);

                if (split)
                {
                    outPos[1].z  = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith;
                    outPos[1].z += offset * _gridSystem.Widith;
                    outPos[1].y  = _infGrid.YGraph(outPos[1]);
                    _pool[_currentCoin + i * 2 + 1].transform.eulerAngles = new Vector3(0, rot, 0);
                    _pool[_currentCoin + i * 2 + 1].transform.position    = outPos[1];
                    _pool[_currentCoin + i * 2 + 1].gameObject.SetActive(true);
                }
            }
            _currentCoin = (_currentCoin + _mul) % PoolSize * _mul;
        }
Пример #3
0
        private void UpdateProjectilesPosition()
        {
            var delta = _metronome.ElapsedTime - _lastTime;

            for (int i = 0; i < ProjectilesCount; i++)
            {
                if (!_projectiles[i].gameObject.activeSelf)
                {
                    continue;
                }

                _projectiles[i].position = new Vector3(_projectiles[i].position.x - delta * ProjectileSpeed, _infGrid.YGraph(_projectiles[i].position), _projectiles[i].position.z);
            }
            _lastTime = _metronome.ElapsedTime;
        }