Exemplo n.º 1
0
 private static void SecondaryPanelControl_MouseLeave(object sender, EventArgs e)
 {
     BattleEventRenderer.IsSecondaryPanelMouseDown = false;
     BattleEventRenderer.IsHoveringSecondaryPanel  = false;
     BattleEventRenderer.DrawSecondaryPanel();
     BattleEventRenderer.DrawField();
 }
Exemplo n.º 2
0
 private static void PatternControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (!BattleEventRenderer.PatternMouseClickPosition.HasValue)
     {
         BattleEventRenderer.PatternMouseClickPosition = e.Location;
         BattleEventRenderer.DrawPatterns();
     }
 }
Exemplo n.º 3
0
 private static void FieldControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (!BattleEventRenderer.FieldMouseDownPosition.HasValue)
     {
         BattleEventRenderer.FieldMouseDownPosition = e.Location;
         BattleEventRenderer.DrawField();
     }
 }
Exemplo n.º 4
0
 private static void PanelSelectionControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (!BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.HasValue)
     {
         BattleEventRenderer.PanelSelectionMouseClickConfirmPosition = e.Location;
         BattleEventRenderer.DrawPanels();
     }
 }
Exemplo n.º 5
0
 public static void UpdateDrawnEnemy()
 {
     BattleEventRenderer.DrawEnemy();
     if (BattleEventRenderer.EnemySelectionWindow != null && BattleEventRenderer.EnemySelectionWindow.IsVisible)
     {
         BattleEventRenderer.DrawEnemies();
     }
 }
Exemplo n.º 6
0
 private static void SecondaryPanelControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (BattleEventRenderer.IsSecondaryPanelMouseDown)
     {
         BattleEventRenderer.ShowPanelSelect(false);
     }
     BattleEventRenderer.IsSecondaryPanelMouseDown = false;
     BattleEventRenderer.DrawSecondaryPanel();
     BattleEventRenderer.DrawPanels();
 }
Exemplo n.º 7
0
 private static void EnemyControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (BattleEventRenderer.IsEnemyMouseDown)
     {
         BattleEventRenderer.ShowEnemySelect();
     }
     BattleEventRenderer.IsEnemyMouseDown = false;
     BattleEventRenderer.DrawEnemy();
     BattleEventRenderer.DrawEnemies();
 }
Exemplo n.º 8
0
        private static void DrawPanels()
        {
            var cols         = 4;
            var startPoint   = new Point(10, 10);
            var margin       = 5;
            var optionsCount = 10;

            for (int panel = 0; panel < optionsCount; panel++)
            {
                var topLeft = new Point(startPoint.X + (panel % cols) * (40 + margin * 2), startPoint.Y + (panel / cols) * (32 + margin * 2));

                BattleEventRenderer.PanelSelectionRenderer.Draw(new Sprite
                {
                    Position = new Point(topLeft.X, topLeft.Y),
                    TexX     = 0,
                    TexY     = 32 * panel,
                    Width    = 40,
                    Height   = 32,
                    Texture  = $"battleobjects"
                }.WithTopLeftPosition(), 0);
            }

            {
                var selectedPanel = (int)(BattleEventRenderer.IsSettingPrimaryPanel ? BattleEventRenderer.CurrentEncounter.PrimaryPanel : BattleEventRenderer.CurrentEncounter.SecondaryPanel);
                var topLeft       = new Point(startPoint.X - margin + (selectedPanel % cols) * (40 + margin * 2), startPoint.Y - margin + (selectedPanel / cols) * (32 + margin * 2));
                var bottomRight   = new Point(topLeft.X + 40 + margin * 2, topLeft.Y + 32 + margin * 2);
                BattleEventRenderer.PanelSelectionRenderer.DrawQuad(new Quad
                {
                    A     = new Point(bottomRight.X, topLeft.Y),
                    B     = new Point(bottomRight.X, bottomRight.Y),
                    C     = new Point(topLeft.X, bottomRight.Y),
                    D     = new Point(topLeft.X, topLeft.Y),
                    Color = Color.FromArgb(125, Color.Wheat),
                    Type  = DrawType.Outline | DrawType.Fill
                }, 4);
            }

            var selectedPosition = BattleEventRenderer.PanelSelectionMouseClickConfirmPosition ?? BattleEventRenderer.PanelSelectionMouseClickPosition ?? BattleEventRenderer.PanelSelectionMousePosition;

            if (selectedPosition != null)
            {
                var highlightedPanel = (selectedPosition.Value.X / (40 + 2 * margin)) + cols * (selectedPosition.Value.Y / (32 + 2 * margin));
                if (highlightedPanel < optionsCount)
                {
                    var topLeft     = new Point(startPoint.X - margin + (highlightedPanel % cols) * (40 + margin * 2), startPoint.Y - margin + (highlightedPanel / cols) * (32 + margin * 2));
                    var bottomRight = new Point(topLeft.X + 40 + margin * 2, topLeft.Y + 32 + margin * 2);
                    var color       = BattleEventRenderer.PanelSelectionMouseClickPosition.HasValue ? Color.FromArgb(128, Color.DarkBlue) : Color.FromArgb(128, Color.AliceBlue);
                    BattleEventRenderer.PanelSelectionRenderer.DrawQuad(new Quad
                    {
                        A     = new Point(bottomRight.X, topLeft.Y),
                        B     = new Point(bottomRight.X, bottomRight.Y),
                        C     = new Point(topLeft.X, bottomRight.Y),
                        D     = new Point(topLeft.X, topLeft.Y),
                        Color = color,
                        Type  = DrawType.Outline | DrawType.Fill
                    }, 4);
                }
                if (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.HasValue && BattleEventRenderer.PanelSelectionMouseClickPosition.HasValue)
                {
                    var selectedPanel = (BattleEventRenderer.PanelSelectionMouseClickPosition.Value.X / (40 + 2 * margin)) + cols * (BattleEventRenderer.PanelSelectionMouseClickPosition.Value.Y / (32 + 2 * margin));
                    var confirmPanel  = (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.Value.X / (40 + 2 * margin)) + cols * (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.Value.Y / (32 + 2 * margin));
                    if (confirmPanel < optionsCount && confirmPanel == selectedPanel)
                    {
                        if (BattleEventRenderer.IsSettingPrimaryPanel)
                        {
                            BattleEventRenderer.CurrentEncounter.PrimaryPanel = (Panel.PANEL)highlightedPanel;
                        }
                        else
                        {
                            BattleEventRenderer.CurrentEncounter.SecondaryPanel = (Panel.PANEL)highlightedPanel;
                        }
                        BattleEventRenderer.DrawField();
                        BattleEventRenderer.DrawPrimaryPanel();
                        BattleEventRenderer.DrawSecondaryPanel();
                    }
                    BattleEventRenderer.PanelSelectionMouseClickPosition        = null;
                    BattleEventRenderer.PanelSelectionMouseClickConfirmPosition = null;
                }
            }
            BattleEventRenderer.PanelSelectionRenderer.Render();
        }
Exemplo n.º 9
0
        private static void DrawEnemies()
        {
            var cols         = 10;
            var startPoint   = new Point(10, 10);
            var margin       = 5;
            var optionsCount = LoadingWindowViewModel.Settings.EnemyCount;

            for (int enemyID = 0; enemyID < optionsCount; enemyID++)
            {
                if (enemyID == 0)
                {
                    var offX = 5;
                    var offY = -3;
                    BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad
                    {
                        A     = new Point(70 + offX, 15 + offY),
                        B     = new Point(80 + offX, 25 + offY),
                        C     = new Point(20 + offX, 85 + offY),
                        D     = new Point(10 + offX, 75 + offY),
                        Color = Color.Red,
                        Type  = DrawType.Fill
                    }, 1);

                    continue;
                }

                var x = (enemyID % cols);
                var y = (enemyID / cols);

                var renderPass = y * RenderPassPadding;

                var enemyDef = Constants.BaseEnemyDefinitions[enemyID];

                if (enemyDef == null)
                {
                    continue;
                }

                foreach (var drawCall in enemyDef.DrawCalls)
                {
                    var drawnSprite = new Sprite
                    {
                        Position = new Point(drawCall.Position.X + x * (80 + margin * 2) + 40 - 10, drawCall.Position.Y + y * (80 + margin * 2) - 20),
                        TexX     = drawCall.TexturePosition.X,
                        TexY     = drawCall.TexturePosition.Y,
                        Width    = drawCall.Size.Width,
                        Height   = drawCall.Size.Height,
                        Texture  = drawCall.TextureName,
                        Scale    = new Vector2((float)(drawCall.IsReversed ? -drawCall.Scale : drawCall.Scale), (float)drawCall.Scale),
                        Rotate   = (float)drawCall.Rotate
                    };
                    if (drawCall.IsFromTopLeft)
                    {
                        drawnSprite = drawnSprite.WithTopLeftPosition();
                    }
                    BattleEventRenderer.EnemySelectionRenderer.Draw(drawnSprite, renderPass);
                }
            }

            if (BattleEventRenderer.CurrentEnemy != null)
            {
                var selectedEnemy = BattleEventRenderer.CurrentEnemy.ID;
                var topLeft       = new Point(startPoint.X - margin + (selectedEnemy % cols) * (80 + margin * 2), startPoint.Y - margin + (selectedEnemy / cols) * (80 + margin * 2));
                var bottomRight   = new Point(topLeft.X + 80 + margin * 2, topLeft.Y + 80 + margin * 2);
                BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad
                {
                    A     = new Point(bottomRight.X, topLeft.Y),
                    B     = new Point(bottomRight.X, bottomRight.Y),
                    C     = new Point(topLeft.X, bottomRight.Y),
                    D     = new Point(topLeft.X, topLeft.Y),
                    Color = Color.FromArgb(125, Color.Wheat),
                    Type  = DrawType.Outline | DrawType.Fill
                }, 4);
            }

            var selectedPosition = BattleEventRenderer.EnemySelectionMouseClickConfirmPosition ?? BattleEventRenderer.EnemySelectionMouseClickPosition ?? BattleEventRenderer.EnemySelectionMousePosition;

            if (selectedPosition != null)
            {
                var highlightedEnemy = (selectedPosition.Value.X / (80 + 2 * margin)) + cols * (selectedPosition.Value.Y / (80 + 2 * margin));
                if (highlightedEnemy < optionsCount && (highlightedEnemy == 0 || Constants.BaseEnemyDefinitions[highlightedEnemy] != null))
                {
                    var topLeft     = new Point(startPoint.X - margin + (highlightedEnemy % cols) * (80 + margin * 2), startPoint.Y - margin + (highlightedEnemy / cols) * (80 + margin * 2));
                    var bottomRight = new Point(topLeft.X + 80 + margin * 2, topLeft.Y + 80 + margin * 2);
                    var color       = BattleEventRenderer.EnemySelectionMouseClickPosition.HasValue ? Color.FromArgb(128, Color.DarkBlue) : Color.FromArgb(128, Color.AliceBlue);
                    BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad
                    {
                        A     = new Point(bottomRight.X, topLeft.Y),
                        B     = new Point(bottomRight.X, bottomRight.Y),
                        C     = new Point(topLeft.X, bottomRight.Y),
                        D     = new Point(topLeft.X, topLeft.Y),
                        Color = color,
                        Type  = DrawType.Outline | DrawType.Fill
                    }, 4);
                }
                if (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.HasValue && BattleEventRenderer.EnemySelectionMouseClickPosition.HasValue)
                {
                    var selectedEnemy = (BattleEventRenderer.EnemySelectionMouseClickPosition.Value.X / (80 + 2 * margin)) + cols * (BattleEventRenderer.EnemySelectionMouseClickPosition.Value.Y / (80 + 2 * margin));
                    var confirmEnemy  = (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.Value.X / (80 + 2 * margin)) + cols * (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.Value.Y / (80 + 2 * margin));
                    if (confirmEnemy < optionsCount && confirmEnemy == selectedEnemy && (highlightedEnemy == 0 || Constants.BaseEnemyDefinitions[highlightedEnemy] != null))
                    {
                        BattleEventRenderer.CurrentEnemy.ID = highlightedEnemy;
                        BattleEventRenderer.DrawField();
                        BattleEventRenderer.DrawEnemy();
                    }
                    BattleEventRenderer.EnemySelectionMouseClickPosition        = null;
                    BattleEventRenderer.EnemySelectionMouseClickConfirmPosition = null;
                }
            }
            BattleEventRenderer.EnemySelectionRenderer.Render();
        }
Exemplo n.º 10
0
        private static void DrawField()
        {
            var startPoint = new Point(0, 160 - (32 + 24 + 24) - 10);

            for (int y = 0; y < 3; y++)
            {
                var renderPass = y * RenderPassPadding;
                for (int x = 0; x < 6; x++)
                {
                    int panelTexY = 0;
                    switch (BattleEventRenderer.CurrentEncounter.Panels[y, x])
                    {
                    case 0:
                        panelTexY = 32 * (int)BattleEventRenderer.CurrentEncounter.PrimaryPanel;
                        break;

                    case 1:
                        panelTexY = 32 * (int)BattleEventRenderer.CurrentEncounter.SecondaryPanel;
                        break;
                    }

                    var topLeft = new Point(startPoint.X + x * 40, startPoint.Y + y * 24);

                    BattleEventRenderer.FieldRenderer.Draw(new Sprite
                    {
                        Position = topLeft,
                        TexX     = x < 3 ? 0 : 40,
                        TexY     = panelTexY,
                        Width    = 40,
                        Height   = 32,
                        Texture  = $"battleobjects"
                    }.WithTopLeftPosition(), renderPass);

                    if (BattleEventRenderer.CurrentEncounter.Panels[y, x] == 3)
                    {
                        var rockTopLeft = topLeft;
                        rockTopLeft.Offset(0, -18);
                        BattleEventRenderer.FieldRenderer.Draw(new Sprite
                        {
                            Position = rockTopLeft,
                            TexX     = 0,
                            TexY     = 144,
                            Width    = 40,
                            Height   = 40,
                            Texture  = $"objects1"
                        }.WithTopLeftPosition(), renderPass);
                    }

                    if ((BattleEventRenderer.CurrentEncounter.Panels[y, x] == 0 && BattleEventRenderer.IsHoveringPrimaryPanel) || (BattleEventRenderer.CurrentEncounter.Panels[y, x] == 1 && BattleEventRenderer.IsHoveringSecondaryPanel))
                    {
                        var bottomRight = topLeft;
                        bottomRight.Offset(40, 24);
                        BattleEventRenderer.FieldRenderer.DrawQuad(new Quad
                        {
                            A     = new Point(bottomRight.X, topLeft.Y),
                            B     = new Point(bottomRight.X, bottomRight.Y),
                            C     = new Point(topLeft.X, bottomRight.Y),
                            D     = new Point(topLeft.X, topLeft.Y),
                            Color = Color.FromArgb(128, Color.AliceBlue),
                            Type  = DrawType.Outline | DrawType.Fill
                        }, renderPass + 1);
                    }
                }
            }

            for (int i = 0; i < BattleEventRenderer.CurrentEncounter.Enemies.Length; i++)
            {
                var enemy = BattleEventRenderer.CurrentEncounter.Enemies[i];

                var topLeft     = new Point(startPoint.X + enemy.X * 40, startPoint.Y + enemy.Y * 24);
                var bottomRight = topLeft;
                bottomRight.Offset(40, 24);

                var renderPass = enemy.Y * RenderPassPadding;
                BattleEventRenderer.FieldRenderer.DrawQuad(new Quad
                {
                    A     = new Point(bottomRight.X, topLeft.Y),
                    B     = new Point(bottomRight.X, bottomRight.Y),
                    C     = new Point(topLeft.X, bottomRight.Y),
                    D     = new Point(topLeft.X, topLeft.Y),
                    Color = Color.FromArgb(128, Color.MediumVioletRed),
                    Type  = DrawType.Outline | DrawType.Fill
                }, renderPass + 1);

                var enemyDefinition = enemy.EnemyDefinition;
                if (enemyDefinition != null)
                {
                    foreach (var drawCall in enemyDefinition.DrawCalls)
                    {
                        var drawnSprite = new Sprite
                        {
                            Position = drawCall.Position,
                            TexX     = drawCall.TexturePosition.X,
                            TexY     = drawCall.TexturePosition.Y,
                            Width    = drawCall.Size.Width,
                            Height   = drawCall.Size.Height,
                            Texture  = drawCall.TextureName,
                            Scale    = new Vector2((float)(drawCall.IsReversed ? -drawCall.Scale : drawCall.Scale), (float)drawCall.Scale),
                            Rotate   = (float)drawCall.Rotate
                        };
                        if (drawCall.IsFromTopLeft)
                        {
                            drawnSprite = drawnSprite.WithTopLeftPosition();
                        }
                        BattleEventRenderer.FieldRenderer.Draw(drawnSprite, renderPass + RenderPassPadding);
                    }
                }
            }

            if (BattleEventRenderer.FieldMousePosition != null)
            {
                var hoverPanel = new Point((BattleEventRenderer.FieldMousePosition.Value.X - startPoint.X) / 40, (BattleEventRenderer.FieldMousePosition.Value.Y - startPoint.Y) / 24);

                if (hoverPanel.X >= 3 && hoverPanel.X < 6 && hoverPanel.Y >= 0 && hoverPanel.Y < 3)
                {
                    var hoveredEnemy = CurrentEncounter.Enemies.FirstOrDefault(e => e.X == hoverPanel.X && e.Y == hoverPanel.Y);
                    if (hoveredEnemy != null)
                    {
                        var topLeft     = new Point(startPoint.X + hoverPanel.X * 40, startPoint.Y + hoverPanel.Y * 24);
                        var bottomRight = topLeft;
                        bottomRight.Offset(40, 24);

                        var renderPass = startPoint.Y;

                        var color = BattleEventRenderer.FieldMouseDownPosition.HasValue ? Color.FromArgb(128, Color.DarkBlue) : Color.FromArgb(128, Color.White);

                        BattleEventRenderer.FieldRenderer.DrawQuad(new Quad
                        {
                            A     = new Point(bottomRight.X, topLeft.Y),
                            B     = new Point(bottomRight.X, bottomRight.Y),
                            C     = new Point(topLeft.X, bottomRight.Y),
                            D     = new Point(topLeft.X, topLeft.Y),
                            Color = color,
                            Type  = DrawType.Outline | DrawType.Fill
                        }, renderPass + 1);
                    }
                    else if (BattleEventRenderer.FieldMouseDragEnemy != null)
                    {
                        BattleEventRenderer.FieldMouseDragEnemy.X = hoverPanel.X;
                        BattleEventRenderer.FieldMouseDragEnemy.Y = hoverPanel.Y;
                        BattleEventRenderer.FieldMouseDragEnemy.RefreshEnemyDefinition();
                    }
                }
            }

            if (BattleEventRenderer.FieldMouseDownPosition.HasValue && BattleEventRenderer.FieldMouseDragEnemy == null)
            {
                var downPanel = new Point((BattleEventRenderer.FieldMouseDownPosition.Value.X - startPoint.X) / 40, (BattleEventRenderer.FieldMouseDownPosition.Value.Y - startPoint.Y) / 24);
                var downEnemy = CurrentEncounter.Enemies.FirstOrDefault(e => e.X == downPanel.X && e.Y == downPanel.Y);
                BattleEventRenderer.FieldMouseDragEnemy = downEnemy;
            }

            if (BattleEventRenderer.FieldMouseDragReleasePosition.HasValue)
            {
                var dragPanel = new Point((BattleEventRenderer.FieldMouseDragReleasePosition.Value.X - startPoint.X) / 40, (BattleEventRenderer.FieldMouseDragReleasePosition.Value.Y - startPoint.Y) / 24);
                var dragEnemy = CurrentEncounter.Enemies.FirstOrDefault(e => e.X == dragPanel.X && e.Y == dragPanel.Y);
                if (dragEnemy != null)
                {
                    BattleEventRenderer.CurrentEnemy = dragEnemy;
                }
                BattleEventRenderer.FieldMouseDragEnemy           = null;
                BattleEventRenderer.FieldMouseDragReleasePosition = null;
            }

            if (BattleEventRenderer.CurrentEnemy != null)
            {
                var topLeft     = new Point(startPoint.X + BattleEventRenderer.CurrentEnemy.X * 40, startPoint.Y + BattleEventRenderer.CurrentEnemy.Y * 24);
                var bottomRight = topLeft;
                bottomRight.Offset(40, 24);

                var renderPass = startPoint.Y;

                BattleEventRenderer.FieldRenderer.DrawQuad(new Quad
                {
                    A     = new Point(bottomRight.X, topLeft.Y),
                    B     = new Point(bottomRight.X, bottomRight.Y),
                    C     = new Point(topLeft.X, bottomRight.Y),
                    D     = new Point(topLeft.X, topLeft.Y),
                    Color = Color.FromArgb(128, Color.Wheat),
                    Type  = DrawType.Outline | DrawType.Fill
                }, renderPass + 1);
            }

            BattleEventRenderer.FieldRenderer.Render();
            BattleEventRenderer.DrawEnemy();
        }
Exemplo n.º 11
0
 private static void PatternControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     BattleEventRenderer.PatternMousePosition = e.Location;
     BattleEventRenderer.DrawPatterns();
 }
Exemplo n.º 12
0
 private static void FieldControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     BattleEventRenderer.FieldMousePosition = e.Location;
     BattleEventRenderer.DrawField();
 }
Exemplo n.º 13
0
 private static void SecondaryPanelControl_MouseEnter(object sender, EventArgs e)
 {
     BattleEventRenderer.IsHoveringSecondaryPanel = true;
     BattleEventRenderer.DrawSecondaryPanel();
     BattleEventRenderer.DrawField();
 }
Exemplo n.º 14
0
 private static void SecondaryPanelControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     BattleEventRenderer.IsSecondaryPanelMouseDown  = true;
     ((System.Windows.Forms.Control)sender).Capture = false;
     BattleEventRenderer.DrawSecondaryPanel();
 }
Exemplo n.º 15
0
 private static void EnemySelectionControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     BattleEventRenderer.EnemySelectionMousePosition = e.Location;
     BattleEventRenderer.DrawEnemies();
 }
Exemplo n.º 16
0
 private static void EnemyControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     BattleEventRenderer.IsEnemyMouseDown           = true;
     ((System.Windows.Forms.Control)sender).Capture = false;
     BattleEventRenderer.DrawEnemy();
 }