コード例 #1
0
ファイル: LevelGeometry.cs プロジェクト: zuk2014/CRYENGINE
        public LevelGeometry()
        {
            _tunnelElementsQueue = new Queue <Tunnel>();

            // Get position.
            Vec3 firstTunnelPos = EntitySystem.Entity.ByName("TunnelSpawnPoint").Position;

            _lastTunnel       = Tunnel.Create(firstTunnelPos, 0);
            _lastTunnel.Speed = LevelGeometry.GlobalGeomSpeed;

            _tunnelElementsQueue.Enqueue(_lastTunnel);

            _rotatingRingOne = EntitySystem.Entity.ByName("ring_2");
            _rotatingRingTwo = EntitySystem.Entity.ByName("ring_3");
        }
コード例 #2
0
ファイル: LevelGeometry.cs プロジェクト: carldonitz/CRYENGINE
        /// <summary>
        /// Handles spawning of new tunnel elements and despawning of tunnel elements that are out of view.
        /// </summary>
        public void UpdateGeometry()
        {
            // Get first tunnel in Queue without removing the tunnel from the Queue.
            Tunnel firstTunnel = _tunnelElementsQueue.Peek();

            if (firstTunnel.Position.y < 450)
            {
                // Remove the tunnel from the Queue.
                _tunnelElementsQueue.Dequeue();

                // Purge door with related geometry (Door, Lights, ...).
                firstTunnel.Purge();
            }

            Vector3 lastTunnelPos = _lastTunnel.Position;

            if (lastTunnelPos.y < 700)
            {
                // Spawn new tunnel with door.
                int newTunnelNumber = _lastTunnelNumber;

                // Ensure the next tunnel element is different from the previous one.
                while (newTunnelNumber == _lastTunnelNumber)
                {
                    newTunnelNumber = Random.Next(4);
                }

                _lastTunnelNumber = newTunnelNumber;
                _lastTunnel       = Tunnel.Create(new Vector3(lastTunnelPos.x, (lastTunnelPos.y + 100f), lastTunnelPos.z), newTunnelNumber);
                _lastTunnel.Speed = LevelGeometry.GlobalGeomSpeed;
                _tunnelElementsQueue.Enqueue(_lastTunnel);
            }

            // Update background satelite rings
            RotateSatelliteRings();
        }