Пример #1
0
        /// <summary>
        /// Creates a new EntityModel.
        /// </summary>
        /// <param name="entity">Entity to attach the graphical representation to.</param>
        /// <param name="model">Graphical representation to use for the entity.</param>
        /// <param name="transform">Base transformation to apply to the model before moving to the entity.</param>
        /// <param name="game">Game to which this component will belong.</param>
        public EntityModel(Entity entity, Model model, Matrix transform, Game game, Player player)
            : base(game)
        {
            this.entity = entity;
            this.model = model;
            Transform = transform;
            Player = player;

            //Collect any bone transformations in the model itself.
            //The default cube model doesn't have any, but this allows the EntityModel to work with more complicated shapes.
            boneTransforms = new Matrix[model.Bones.Count];
            foreach (var effect in model.Meshes.SelectMany(mesh => mesh.Effects).Cast<BasicEffect>())
            {
                effect.EnableDefaultLighting();
            }
        }
Пример #2
0
        public void Initialize(Game game)
        {
            Game = game;
            _assetManager = new ScreenAwareAssetManager(Game, this);
            _spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            var myGame = game as NewHorizonGame;

            GamePlayer = new Player(myGame);

            HUD = new BasicUserHUD(this, new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height))
            {
                DrawOrder = 9999
            };
            Game.Components.Add(HUD);

            myGame.KeyboardListener.KeyReleased += KeyboardListenerOnKeyReleased;
            myGame.KeyboardListener.KeyTyped += KeyboardListenerOnKeyPressed;
            myGame.MouseListener.MouseWheelMoved += MouseListenerOnMouseWheelMoved;
            myGame.MouseListener.MouseUp += MouseListenerOnMouseUp;
        }