コード例 #1
0
        /// <summary>
        /// Updates each of the game object's models with the time
        /// </summary>
        private void Update()
        {
            // Get the time since the last frame.
            float delta = FrameTimer.ElapsedMilliseconds;

            delta /= 1000.0f;
            delta  = Math.Max(.001f, delta);
            delta  = Math.Min(.01f, delta);
            // Iterate through all networked objects and update them.
            foreach (KeyValuePair <int, NetworkedGameObjectClient> kv in NetworkedGameObjects.AsEnumerable())
            {
                NetworkedGameObjectClient gameObject = kv.Value;

                // Update with delta in seconds
                gameObject.Update(delta);
            }

            // Iterate through all nonnetworked gameobjects and update them.
            foreach (GameObject obj in NonNetworkedGameObjects)
            {
                obj.Update(delta);
            }

            // Tint all of the leaves based on their sections.
            TintLeaves();
            CountLeaves();

            // Update all objects within the player's range with a tint.
            if (ActivePlayer != null)
            {
                ActivePlayer.TintObjectsInRange();
            }

            // Update the graphics manager.
            GraphicsManager.Update(delta);
            AudioManager.Update();
            AnimationManager.Update(delta);

            // Restart the frame ElapsedTime.
            FrameTimer.Restart();

            //AudioManager.UpdateSourceLocation(_audioChirping, Camera.CameraPosition);
        }
コード例 #2
0
        /// <summary>
        /// Loops through the hashtable of gameobjects and draws them
        /// </summary>
        private void Render()
        {
            // Iterate through all networked game objects and draw them.
            foreach (KeyValuePair <int, NetworkedGameObjectClient> kv in
                     NetworkedGameObjects.AsEnumerable())
            {
                NetworkedGameObjectClient gameObject = kv.Value;
                gameObject.Draw();
            }

            // iterate through all the non-networked objects and draw them.
            foreach (
                NonNetworkedGameObjectClient obj in NonNetworkedGameObjects
                )
            {
                obj.Draw();
            }

            GraphicsManager.Draw();
        }
コード例 #3
0
ファイル: GameClient.cs プロジェクト: su636/voxeliq
        /// <summary>
        /// Initializes the game.
        /// </summary>
        protected override void Initialize()
        {
            Logger.Trace("init()");                                                                                             // log the init.
            this.Window.Title = string.Format("Voxeliq [{0}/{1}]", PlatformManager.GameFramework, PlatformManager.GraphicsApi); // set the window title.

            this.IsMouseVisible = false;

            // read settings.
            var audioSettings    = new AudioSettings();
            var graphicsSettings = new GraphicsSettings();

            // create a new engine configuration.
            var config = new EngineConfig
            {
                Chunk =
                {
                    WidthInBlocks  =  16,
                    HeightInBlocks = 128,
                    LengthInBlocks =  16,
                },
                Cache =
                {
                    CacheExtraChunks = true,
                    ViewRange        =   12,
                    CacheRange       =   16,
                },
                Graphics =
                {
                    Width                 = graphicsSettings.Width,
                    Height                = graphicsSettings.Height,
                    FullScreenEnabled     = graphicsSettings.FullScreenEnabled,
                    VerticalSyncEnabled   = graphicsSettings.VerticalSyncEnabled,
                    FixedTimeStepsEnabled = graphicsSettings.FixedTimeStepsEnabled,
                },
                World =
                {
                    IsInfinitive = true,
                },
                Debugging =
                {
                    GraphsEnabled = true,
                },
                Bloom =
                {
                    Enabled = false,
                    State   = BloomState.Saturated,
                },
                Audio =
                {
                    Enabled = audioSettings.Enabled,
                }
            };

            var engine = new Engine.Core.Engine(this, config);

            this.ScreenManager = new GraphicsManager(this._graphicsDeviceManager, this); // start the screen manager.

            engine.EngineStart += OnEngineStart;

            engine.Run();

            base.Initialize();
        }