Пример #1
0
        public void SmallAsteroid_Render_Test()
        {
            var game = new TestGame();
            SmallAsteroid smallAsteroid = null;
            game.Updated += (o, e) =>
            {
                game.DebugText += "\n\nPress key 1~3 to watch each small asteroid";

                Key[] keys = new Key[] { Key.D1, Key.D2, Key.D3 };
                foreach (Key key in keys)
                {
                    if (game.Keyboard.IsKeyDown(key) == false)
                        continue;

                    if (smallAsteroid != null)
                        game.SceneManager.RemoveRenderable(smallAsteroid.MeshNode);

                    int type = key - keys[0];
                    smallAsteroid = new SmallAsteroid(game.Framework, game.SceneManager, type);

                    game.SceneManager.Camera.LookMeshNode(smallAsteroid.MeshNode);
                    game.SceneManager.Light.Position = new Vector3(0.0f, 0.0f, smallAsteroid.MeshNode.BoundingRadius * -5.0f);
                }
            };
            game.Run();
        }
Пример #2
0
        private void GenerateSmallAsteroids(List<SmallAsteroid> smallAsteroids, int numOfAsteroids, int x, int z)
        {
            // Always create at least 1 smaller asteroid instance per sector
            int numOfSmallAsteroids = 2 + RandomHelper.GetRandomInt(4 + numOfAsteroids);

            for (int i = 0; i < numOfSmallAsteroids; ++i)
            {
                int type = RandomHelper.GetRandomInt(SmallAsteroid.NumTypes - 1);
                var smallAsteroid = new SmallAsteroid(this.game.framework, this.game.sceneManager, type);
                smallAsteroid.MeshNode.Position = new Vector3(x * Level.SectorWidth, 0, z * Level.SectorDepth);
                smallAsteroid.MeshNode.Position += new Vector3(RandomHelper.GetRandomFloat(-Level.SectorWidth / 2, +Level.SectorWidth / 2),
                                                               RandomHelper.GetRandomFloat(-Level.SectorWidth * 2.1f, +Level.SectorWidth * 2.1f),
                                                               RandomHelper.GetRandomFloat(-Level.SectorWidth / 2, +Level.SectorWidth / 2));
                smallAsteroids.Add(smallAsteroid);
            }
        }