예제 #1
0
        public Ghost(IIntelligence intelligence, IParlance parlance, IDemeanor demeanor, BaloonWindow baloon, ShellWindow shell)
        {
            _intelligence = intelligence;
            _parlance     = parlance;
            _demeanor     = demeanor;
            _baloon       = baloon;
            _shell        = shell;

            _inputQueue.Dispatched  += InputDispatched;
            _outputQueue.Dispatched += OutputDispatched;
            _intelligence.Output    += IntelligenceOutput;
            _shell.ScreenChanged    += ShellScreenChanged;
            _shell.Rendered         += ShellRendered;

            _demeanor.Loaded(shell);
            _intelligence.Loaded();
        }
예제 #2
0
        /// <summary>
        ///     描画処理
        /// </summary>
        public void Render(IDemeanor demeanor)
        {
            // ワールドを更新
            _renderContext.UpdateWorlds();

            if (IsVisible)
            {
                // 描画前の処理を行います.
                RectangleF regionInWorld;
                demeanor.PreRender(out regionInWorld);
                var workingArea =
                    Screen.FromPoint(new Point((int)(regionInWorld.X * _globalConfig.PixelPerUnitLength), 0)).WorkingArea;
                var regionInScreen = WorldToScreen(regionInWorld, workingArea);
                // ウィンドウの位置
                var windowPos  = new Point((int)regionInScreen.X, (int)regionInScreen.Y);
                var windowSize = new Size(
                    (int)Math.Ceiling(regionInScreen.Right) - windowPos.X,
                    (int)Math.Ceiling(regionInScreen.Bottom) - windowPos.Y);
                if (Size != windowSize)
                {
                    //int deltaWidth = Size.Width - windowSize.Width;
                    //int deltaHeight = Size.Height - windowSize.Height;
                    //if (deltaWidth < -10 || deltaWidth > 0
                    //    || deltaHeight < -10 || deltaHeight > 0)
                    {
                        Size = windowSize;
                        _textureTargetContext.MatrixManager.ProjectionMatrixManager.InitializeProjection(
                            windowSize.Width / _globalConfig.PixelPerUnitLength,
                            windowSize.Height / _globalConfig.PixelPerUnitLength, 1, 2000);
                    }
                    // else
                    // {
                    //     windowSize = Size;
                    // }
                }
                // カメラ位置
                var cameraInScreen = new PointF(
                    windowPos.X + windowSize.Width / 2.0f,
                    windowPos.Y + windowSize.Height / 2.0f);
                var cameraInWorld = ScreenToWorld(cameraInScreen, workingArea);
                // レンダーターゲットサイズ・カメラ位置を設定
                Position = windowPos;
                _textureTargetContext.MatrixManager.ViewMatrixManager.CameraPosition
                    = new Vector3(cameraInWorld.X, cameraInWorld.Y, -1000);
                _textureTargetContext.MatrixManager.ViewMatrixManager.CameraLookAt
                    = new Vector3(cameraInWorld.X, cameraInWorld.Y, 0);

                // 描画
                _textureTargetContext.Render();

                // バルーン基準点(描画した後)
                BaloonReferencePoint = WorldToScreen(demeanor.BaloonReferencePoint, workingArea);

                // 描画内容をGDI互換コンテクストにコピー
                D2D.RenderTarget target = _gdiContext.D2DRenderTarget;
                target.BeginDraw();
                if (_textureTargetContext.SampleDesc.Count > 1)
                {
                    _gdiContext.DeviceManager.Context.ResolveSubresource(
                        _textureTargetContext.RenderTarget, 0,
                        _gdiContext.D3DRenderTarget, 0,
                        _gdiContext.D3DRenderTarget.Description.Format);
                }
                else
                {
                    _gdiContext.DeviceManager.Context.CopyResource(
                        _textureTargetContext.RenderTarget, _gdiContext.D3DRenderTarget);
                }

#if DEBUG
                // Direct2Dの描画
                target.DrawText(string.Format("{0:0.0}FPS", App.Current.Renderer.FpsCounter.FPS), _textFormat,
                                new Rectangle(0, 0, Size.Width, (int)(_textFormat.FontSize + 1)), _textBrush);
#endif

                // ウィンドウに表示
                using (var dc = new RenderTargetDC(_gdiContext.D2DGdiInteropRenderTarget))
                    UpdateLayeredWindow(dc);
                target.EndDraw();
            }

            if (Rendered != null)
            {
                Rendered(this, new EventArgs());
            }
        }
예제 #3
0
        public IEnumerable <FrameworkElement> CreatePrintView(IDemeanor demeanor)
        {
            bool hasModifier    = demeanor.Air != 0 || demeanor.Earth != 0 || demeanor.Fire != 0 || demeanor.Water != 0 || demeanor.Void != 0;
            bool hasUnmasking   = !string.IsNullOrWhiteSpace(demeanor.Unmasking);
            bool hasDescription = !string.IsNullOrWhiteSpace(demeanor.Description);

            var grid = CreateGrid(BoolHelpers.CountTrue(hasModifier, hasUnmasking, hasDescription) + 1);

            int currentRow = 0;
            var name       = CreateObjectName(demeanor.Name.Trim());

            Grid.SetRow(name, currentRow);
            grid.Children.Add(name);
            currentRow++;

            if (hasDescription)
            {
                var description = new TextBlock
                {
                    Text          = demeanor.Description.Trim(),
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 4, 0, 0)
                };
                Grid.SetRow(description, currentRow);
                grid.Children.Add(description);
                currentRow++;
            }

            if (hasModifier)
            {
                var mods = new List <(Ring ring, int mod)>();
                mods.Add((Ring.Air, demeanor.Air));
                mods.Add((Ring.Earth, demeanor.Earth));
                mods.Add((Ring.Fire, demeanor.Fire));
                mods.Add((Ring.Water, demeanor.Water));
                mods.Add((Ring.Void, demeanor.Void));

                mods.Sort((t1, t2) =>
                {
                    int returnValue = t2.mod.CompareTo(t1.mod);
                    if (returnValue == 0)
                    {
                        returnValue = t1.ring.CompareTo(t2.ring);
                    }

                    return(returnValue);
                });

                string modText   = string.Join(", ", mods.Where(t => t.mod != 0).Select(t => GetModifierString(t.ring, t.mod)));
                var    modifiers = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                modifiers.Inlines.Add(new Run("Social Check TN Modifers: ")
                {
                    FontWeight = FontWeights.Bold
                });
                modifiers.Inlines.Add(modText);

                Grid.SetRow(modifiers, currentRow);
                grid.Children.Add(modifiers);
                currentRow++;
            }

            if (hasUnmasking)
            {
                var unmasking = new TextBlock
                {
                    TextWrapping = TextWrapping.Wrap,
                    Margin       = new Thickness(0, 3, 0, 0)
                };
                unmasking.Inlines.Add(new Run("Common Unmasking: ")
                {
                    FontWeight = FontWeights.Bold
                });
                unmasking.Inlines.Add(demeanor.Unmasking);

                Grid.SetRow(unmasking, currentRow);
                grid.Children.Add(unmasking);
            }

            DoMeasure(grid);
            return(new List <FrameworkElement> {
                grid
            });
        }