Example #1
0
        protected override void OnLoadContents()
        {
            base.OnLoadContents();

            var game = Game.ToBaseGame();

            _basicEffect = new BasicEffect(game.GraphicsDevice);
            game.EffectManager.RegisterSingleton(_basicEffect);

            // Hack: register note effect list
            NoteEffects.Effects[(int)NoteType.Floor] = _basicEffect;
            NoteEffects.Effects[(int)NoteType.Long]  = _basicEffect;
            NoteEffects.Effects[(int)NoteType.Arc]   = _basicEffect;
            NoteEffects.Effects[(int)NoteType.Sky]   = _basicEffect;

            var beatmap = Game.FindSingleElement <BeatmapLoader>()?.Beatmap;

            if (beatmap != null)
            {
                _beatmap = new VisualBeatmap(game.GraphicsDevice, beatmap, _stageMetrics);
            }

            var config = ConfigurationStore.Get <TrackDisplayConfig>();

            _panelTexture            = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.PanelTexture);
            _trackLaneDividerTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.TrackLaneDividerTexture);
            _skyInputTexture         = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.SkyInputTexture);

            _noteTexture                = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteTexture);
            _noteHoldTexture            = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteHoldTexture);
            _noteHoldHighlightedTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteHoldHighlightedTexture);
            _noteSkyTexture             = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteSkyTexture);

            var metrics = _stageMetrics;

            {
                _trackRectangle = new TexturedRectangle(game.GraphicsDevice);
                _trackRectangle.SetVerticesXY(new Vector2(-metrics.HalfTrackFullWidth, -metrics.TrackLength * 0.1f), new Vector2(metrics.TrackFullWidth, metrics.TrackLength * 1.1f), new Color(Color.White, 0.9f), 0, 0);
            }
            {
                _finishLineRectangle = new TexturedRectangle(game.GraphicsDevice);
                _finishLineRectangle.SetVerticesXY(new Vector2(-metrics.HalfTrackInnerWidth, metrics.FinishLineY - metrics.FinishLineHeight / 2), new Vector2(metrics.TrackInnerWidth, metrics.FinishLineHeight), new Color(Color.MediumPurple, 0.9f), 0.02f);
            }
            {
                _laneDividerRectangles = new TexturedRectangle[3];
                for (var i = 1; i < 4; ++i)
                {
                    _laneDividerRectangles[i - 1] = new TexturedRectangle(game.GraphicsDevice);
                    var left   = i * metrics.TrackInnerWidth / 4 - metrics.LaneDividerWidth / 2 - metrics.HalfTrackInnerWidth;
                    var origin = new Vector2(left, 0);
                    var size   = new Vector2(metrics.LaneDividerWidth, metrics.TrackLength);
                    _laneDividerRectangles[i - 1].SetVerticesXY(origin, size, new Color(Color.Lavender, 0.9f), 0.01f);
                }
            }
            {
                _skyInputRectangle = new TexturedRectangle(game.GraphicsDevice);
                _skyInputRectangle.SetVerticesXZ(new Vector2(-metrics.SkyInputWidth / 2, metrics.SkyInputZ - metrics.SkyInputTallness / 2), new Vector2(metrics.SkyInputWidth, metrics.SkyInputTallness), Color.White, metrics.FinishLineY);
            }
        }
Example #2
0
File: Icon.cs Project: ndech/Alpha
        public override void Initialize()
        {
            IconStyle style = Context.UiManager.StyleManager.GetStyle(this);

            BaseTexture        = Context.TextureManager.Create(style.BaseTexture, "").TextureResource;
            HoveredTexture     = Context.TextureManager.Create(style.HoveredTexture, "").TextureResource;
            _texturedRectangle = new TexturedRectangle(Context, BaseTexture, Size);
        }
Example #3
0
        public FloorVisualNote([NotNull] VisualBeatmap beatmap, [NotNull] FloorNote baseNote, [NotNull] StageMetrics metrics)
            : base(beatmap, baseNote)
        {
            _baseNote       = baseNote;
            _metrics        = metrics;
            _noteRectangle  = new TexturedRectangle(beatmap.GraphicsDevice);
            _linkHexahedron = new ColoredHexahedron(beatmap.GraphicsDevice);

            PreviewY = beatmap.CalculateY(baseNote.Tick, metrics, metrics.FinishLineY);
        }
Example #4
0
        public LongVisualNote([NotNull] VisualBeatmap beatmap, [NotNull] LongNote baseNote, [NotNull] StageMetrics metrics)
            : base(beatmap, baseNote)
        {
            _baseNote      = baseNote;
            _metrics       = metrics;
            _noteRectangle = new TexturedRectangle(beatmap.GraphicsDevice);

            PreviewStartY = beatmap.CalculateY(baseNote.StartTick, metrics, metrics.FinishLineY);
            PreviewEndY   = beatmap.CalculateY(baseNote.EndTick, metrics, metrics.FinishLineY);
        }
Example #5
0
 public FleetRenderer(IContext context)
 {
     _context = context;
     _shader = context.Shaders.Get<LightShader>();
     _model = new ObjModel(context.DirectX.Device, "BasicBoat.obj", context.TextureManager.Create("Metal.png"));
     _baseOverlay = new TexturedRectangle(context, context.TextureManager.Create("fleet_overlay.dds", "Data/UI/"));
     _enemySubOverlay = new TexturedRectangle(context, context.TextureManager.Create("fleet_overlay_relation_enemy.dds", "Data/UI/"));
     _allySubOverlay = new TexturedRectangle(context, context.TextureManager.Create("fleet_overlay_relation_ally.dds", "Data/UI/"));
     _neutralSubOverlay = new TexturedRectangle(context, context.TextureManager.Create("fleet_overlay_relation_neutral.dds", "Data/UI/"));
     _mineSubOverlay = new TexturedRectangle(context, context.TextureManager.Create("fleet_overlay_relation_mine.dds", "Data/UI/"));
     foreach (Fleet fleet in context.World.FleetManager.Fleets)
         OnNewFleet(context, fleet);
     context.NotificationResolver.FleetMoved += f => OnFleetUpdate(context, f);
 }
Example #6
0
        public override void Initialize()
        {
            Texture2D minimapTexture = new Texture2D(Context.DirectX.Device, new Texture2DDescription
            {
                Width             = Size.X,
                Height            = Size.Y,
                Format            = Format.R8G8B8A8_UNorm_SRgb,
                BindFlags         = BindFlags.ShaderResource,
                ArraySize         = 1,
                MipLevels         = 1,
                SampleDescription = new SampleDescription(1, 0)
            });

            int rowPitch  = 4 * minimapTexture.Description.Width;
            int byteCount = rowPitch * minimapTexture.Description.Height;
            var byteArray = new byte[byteCount];

            for (int i = 0; i < minimapTexture.Description.Width; i++)
            {
                for (int j = 0; j < minimapTexture.Description.Height; j++)
                {
                    if (ProvincePicker.ClosestProvince(new Vector3D((
                                                                        (float)i * Context.World.Size.X) / Size.X, 0, ((float)(Size.Y - j) * Context.World.Size.Y) / Size.Y)) is LandProvince)
                    {
                        byteArray[4 * (j * minimapTexture.Description.Width + i)]     = 106;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 1] = 98;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 2] = 85;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 3] = 255;
                    }
                    else
                    {
                        byteArray[4 * (j * minimapTexture.Description.Width + i)]     = 197;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 1] = 183;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 2] = 164;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 3] = 255;
                    }
                }
            }
            DataStream dataStream = new DataStream(byteCount, true, true);

            dataStream.Write(byteArray, 0, byteCount);
            DataBox data = new DataBox(dataStream.DataPointer, rowPitch, byteCount);

            Context.DirectX.DeviceContext.UpdateSubresource(data, minimapTexture);
            _minimapTexture = new ShaderResourceView(Context.DirectX.Device, minimapTexture);
            _mapTexture     = new TexturedRectangle(Context, _minimapTexture, Size);
        }
        public ArcVisualNote([NotNull] VisualBeatmap beatmap, [NotNull] ArcNote baseNote, [NotNull] StageMetrics metrics)
            : base(beatmap, baseNote)
        {
            _baseNote = baseNote;
            _metrics  = metrics;

            PreviewStartY = beatmap.CalculateY(baseNote.StartTick, metrics, metrics.FinishLineY);
            PreviewEndY   = beatmap.CalculateY(baseNote.EndTick, metrics, metrics.FinishLineY);

            _arcMesh = new BottomlessColoredTriangularPrism(beatmap.GraphicsDevice);
            _shadow  = new ColoredParallelogram(beatmap.GraphicsDevice);
            _support = new TexturedRectangle(beatmap.GraphicsDevice);
            _header  = new BottomlessColoredTetrahedron(beatmap.GraphicsDevice);

            if (baseNote.SkyNotes != null && baseNote.SkyNotes.Length > 0)
            {
                SkyVisualNotes = baseNote.SkyNotes.Select(n => new SkyVisualNote(beatmap, n, this, metrics)).ToArray();
            }
        }
Example #8
0
 public override void Initialize()
 {
     _ratioX = Size.X;
     _ratioY = Size.Y;
     _screenX = ConfigurationManager.Config.ScreenSize.X;
     _screenY = ConfigurationManager.Config.ScreenSize.Y;
     _texture = new RenderTexture(Context.DirectX.Device, Size);
     _rectangle = new TexturedRectangle(Context, _texture.ShaderResourceView, Size);
     _camera = new Camera(new Vector3(0,200,0), new Vector3(0, MathUtil.PiOverTwo, 0));
     _terrain = new Terrain(Context, Context.World.ProvinceManager.LandProvinces.ToList());
     _orthoProjectionMatrix = Matrix.OrthoLH(2*_ratioX, 2*_ratioY, ConfigurationManager.Config.NearLimit,
         ConfigurationManager.Config.FarLimit);
     _water = new TexturedRectangle(Context, Context.TextureManager.Create("dark_paper.png", "Data/UI/"), ConfigurationManager.Config.WorldSize * Scaling);
     _water.TextureRepeat(new Vector2I(4,2));
     IconButton centerButton = new IconButton(Context, "province_map_center")
     {
         Coordinates = new UniRectangle(new UniScalar(1.0f, -35), 5, 30, 30)
     };
     centerButton.Clicked += () => MoveCamera((Vector3) _selectedProvince.Center);
     Register(centerButton);
 }
Example #9
0
        public override void Initialize()
        {
            _ratioX                = Size.X;
            _ratioY                = Size.Y;
            _screenX               = ConfigurationManager.Config.ScreenSize.X;
            _screenY               = ConfigurationManager.Config.ScreenSize.Y;
            _texture               = new RenderTexture(Context.DirectX.Device, Size);
            _rectangle             = new TexturedRectangle(Context, _texture.ShaderResourceView, Size);
            _camera                = new Camera(new Vector3(0, 200, 0), new Vector3(0, MathUtil.PiOverTwo, 0));
            _terrain               = new Terrain(Context, Context.World.ProvinceManager.LandProvinces.ToList());
            _orthoProjectionMatrix = Matrix.OrthoLH(2 * _ratioX, 2 * _ratioY, ConfigurationManager.Config.NearLimit,
                                                    ConfigurationManager.Config.FarLimit);
            _water = new TexturedRectangle(Context, Context.TextureManager.Create("dark_paper.png", "Data/UI/"), ConfigurationManager.Config.WorldSize * Scaling);
            _water.TextureRepeat(new Vector2I(4, 2));
            IconButton centerButton = new IconButton(Context, "province_map_center")
            {
                Coordinates = new UniRectangle(new UniScalar(1.0f, -35), 5, 30, 30)
            };

            centerButton.Clicked += () => MoveCamera((Vector3)_selectedProvince.Center);
            Register(centerButton);
        }
Example #10
0
 public void Initialize(IContext context)
 {
     _context = context;
     _default = new TexturedRectangle(context, context.TextureManager.Create("default.png", @"Data/MousePointers/"));
     _drag    = new TexturedRectangle(context, context.TextureManager.Create("move.png", @"Data/MousePointers/"));
 }
Example #11
0
        public override void Initialize()
        {
            Texture2D minimapTexture = new Texture2D(Context.DirectX.Device, new Texture2DDescription
            {
                Width = Size.X,
                Height = Size.Y,
                Format = Format.R8G8B8A8_UNorm_SRgb,
                BindFlags = BindFlags.ShaderResource,
                ArraySize = 1,
                MipLevels = 1,
                SampleDescription = new SampleDescription(1,0)
            });

            int rowPitch = 4 * minimapTexture.Description.Width;
            int byteCount = rowPitch*minimapTexture.Description.Height;
            var byteArray = new byte[byteCount];
            for (int i = 0; i < minimapTexture.Description.Width; i++)
            {
                for (int j = 0; j < minimapTexture.Description.Height; j++)
                {
                    if (ProvincePicker.ClosestProvince(new Vector3D((
                        (float)i * Context.World.Size.X) / Size.X, 0, ((float)(Size.Y-j) * Context.World.Size.Y) / Size.Y)) is LandProvince)
                    {
                        byteArray[4 * (j * minimapTexture.Description.Width + i)] = 106;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 1] = 98;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 2] = 85;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 3] = 255;
                    }
                    else
                    {
                        byteArray[4 * (j * minimapTexture.Description.Width + i)] = 197;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 1] = 183;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 2] = 164;
                        byteArray[4 * (j * minimapTexture.Description.Width + i) + 3] = 255;
                    }
                }
            }
            DataStream dataStream = new DataStream(byteCount, true, true);
            dataStream.Write(byteArray, 0, byteCount);
            DataBox data = new DataBox(dataStream.DataPointer, rowPitch, byteCount);
            Context.DirectX.DeviceContext.UpdateSubresource(data, minimapTexture);
            _minimapTexture = new ShaderResourceView(Context.DirectX.Device, minimapTexture);
            _mapTexture = new TexturedRectangle(Context, _minimapTexture , Size);
        }