コード例 #1
0
ファイル: ArenaScene.cs プロジェクト: darthdeus/HexMage.NET
        public override void Initialize()
        {
            HistoryLog.Initialize(_assetManager.Font, 400, _assetManager);

            HistoryLog.Instance.SortOrder = Camera2D.SortUI + 100;
            HistoryLog.Instance.Hidden    = false;
            AddAndInitializeRootEntity(HistoryLog.Instance, _assetManager);

            var cursorSprite = _assetManager[AssetManager.CrosshairCursor];

            var crosshairCursor = CreateRootEntity(Camera2D.SortUI + 10000);

            crosshairCursor.Renderer = new SpriteRenderer(cursorSprite);
            crosshairCursor.AddComponent(() => {
                crosshairCursor.Position = InputManager.Instance.MousePosition.ToVector2() -
                                           cursorSprite.Bounds.Size.ToVector2() / 2;
            });

            Camera2D.Instance.Translate = new Vector3(600, 400, 0);

            var gameBoardEntity = CreateRootEntity(Camera2D.SortBackground);

            gameBoardEntity.AddComponent(() => {
                if (InputManager.Instance.IsKeyJustPressed(Keys.P))
                {
                    Terminate();
                }
            });

            _gameBoardController = new GameBoardController(_game,
                                                           crosshairCursor,
                                                           this,
                                                           _replay);

            _gameBoardController.GameFinishedCallback = () => GameFinishedCallback?.Invoke();

            gameBoardEntity.AddComponent(_gameBoardController);
            gameBoardEntity.CustomBatch = true;

            BuildUi();

            foreach (var mobId in _game.MobManager.Mobs)
            {
                var mobAnimationController = new MobAnimationController(_game);
                var mobEntity = new MobEntity(mobId, _game)
                {
                    SortOrder = Camera2D.SortMobs,
                    Renderer  = new MobRenderer(_game, mobId, mobAnimationController),
                    Transform = () => Camera2D.Instance.Transform
                };
                mobEntity.AddComponent(mobAnimationController);

                AddAndInitializeRootEntity(mobEntity, _assetManager);
                MobEntities[mobId] = mobEntity;
            }
        }
コード例 #2
0
ファイル: MobRenderer.cs プロジェクト: darthdeus/HexMage.NET
 public MobRenderer(GameInstance game, int mobId, MobAnimationController animationController)
 {
     _game  = game;
     _mobId = mobId;
     _animationController = animationController;
 }