Shitty combat mode & animations. (#367)

* Combat mode UI & targeting zones.

* Fix inventory hud positioning.

* Crappy attack animations.

* Import TG combat sounds

* More work on arcs.

* Implement hit sounds.

* Lunging, hit effects, some more stuff.
This commit is contained in:
Pieter-Jan Briers
2019-09-26 22:32:32 +02:00
committed by GitHub
parent ac55ccf46e
commit 02d509fc5f
47 changed files with 1231 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Content.Client.Utility;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.Input;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Drawing;
@@ -48,6 +49,13 @@ namespace Content.Client.UserInterface
Control HandsContainer { get; }
Control InventoryQuickButtonContainer { get; }
bool CombatPanelVisible { get; set; }
bool CombatModeActive { get; set; }
TargetingZone TargetingZone { get; set; }
Action<bool> OnCombatModeChanged { get; set; }
Action<TargetingZone> OnTargetingZoneChanged { get; set; }
// Init logic.
void Initialize();
}
@@ -62,6 +70,9 @@ namespace Content.Client.UserInterface
private TopButton _buttonCraftingMenu;
private TopButton _buttonSandboxMenu;
private TutorialWindow _tutorialWindow;
private TargetingDoll _targetingDoll;
private Button _combatModeButton;
private VBoxContainer _combatPanelContainer;
#pragma warning disable 649
[Dependency] private readonly IResourceCache _resourceCache;
@@ -71,6 +82,26 @@ namespace Content.Client.UserInterface
public Control HandsContainer { get; private set; }
public Control InventoryQuickButtonContainer { get; private set; }
public bool CombatPanelVisible
{
get => _combatPanelContainer.Visible;
set => _combatPanelContainer.Visible = value;
}
public bool CombatModeActive
{
get => _combatModeButton.Pressed;
set => _combatModeButton.Pressed = value;
}
public TargetingZone TargetingZone
{
get => _targetingDoll.ActiveZone;
set => _targetingDoll.ActiveZone = value;
}
public Action<bool> OnCombatModeChanged { get; set; }
public Action<TargetingZone> OnTargetingZoneChanged { get; set; }
public void Initialize()
{
@@ -179,16 +210,35 @@ namespace Content.Client.UserInterface
{
GrowHorizontal = Control.GrowDirection.Begin,
GrowVertical = Control.GrowDirection.Begin,
SizeFlagsVertical = Control.SizeFlags.ShrinkEnd
};
HandsContainer = new MarginContainer
{
GrowHorizontal = Control.GrowDirection.Both,
GrowVertical = Control.GrowDirection.Begin
GrowVertical = Control.GrowDirection.Begin,
SizeFlagsVertical = Control.SizeFlags.ShrinkEnd
};
_combatPanelContainer = new VBoxContainer
{
Children =
{
(_combatModeButton = new Button
{
Text = _loc.GetString("Combat Mode"),
ToggleMode = true
}),
(_targetingDoll = new TargetingDoll(_resourceCache))
}
};
_combatModeButton.OnToggled += args => OnCombatModeChanged?.Invoke(args.Pressed);
_targetingDoll.OnZoneChanged += args => OnTargetingZoneChanged?.Invoke(args);
inventoryContainer.Children.Add(HandsContainer);
inventoryContainer.Children.Add(InventoryQuickButtonContainer);
inventoryContainer.Children.Add(_combatPanelContainer);
}
private void ButtonTutorialOnOnToggled()

View File

@@ -481,6 +481,23 @@ namespace Content.Client.UserInterface
{
new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
}),
// Targeting doll
new StyleRule(new SelectorElement(typeof(TextureButton), new []{TargetingDoll.StyleClassTargetDollZone}, null, new [] {TextureButton.StylePseudoClassNormal}), new []
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#F00")),
}),
new StyleRule(new SelectorElement(typeof(TextureButton), new []{TargetingDoll.StyleClassTargetDollZone}, null, new [] {TextureButton.StylePseudoClassHover}), new []
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#0F0")),
}),
new StyleRule(new SelectorElement(typeof(TextureButton), new []{TargetingDoll.StyleClassTargetDollZone}, null, new [] {TextureButton.StylePseudoClassPressed}), new []
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#00F")),
}),
});
}
}

View File

@@ -0,0 +1,82 @@
using System;
using Content.Client.Utility;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface
{
public sealed class TargetingDoll : VBoxContainer
{
private TargetingZone _activeZone = TargetingZone.Middle;
public const string StyleClassTargetDollZone = "target-doll-zone";
private const string TextureHigh = "/Textures/UserInterface/target-doll-high.svg.96dpi.png";
private const string TextureMiddle = "/Textures/UserInterface/target-doll-middle.svg.96dpi.png";
private const string TextureLow = "/Textures/UserInterface/target-doll-low.svg.96dpi.png";
private readonly TextureButton _buttonHigh;
private readonly TextureButton _buttonMiddle;
private readonly TextureButton _buttonLow;
public TargetingZone ActiveZone
{
get => _activeZone;
set
{
if (_activeZone == value)
{
return;
}
_activeZone = value;
OnZoneChanged?.Invoke(value);
UpdateButtons();
}
}
public event Action<TargetingZone> OnZoneChanged;
public TargetingDoll(IResourceCache resourceCache)
{
_buttonHigh = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureHigh),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_buttonMiddle = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureMiddle),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_buttonLow = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureLow),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_buttonHigh.OnPressed += _ => ActiveZone = TargetingZone.High;
_buttonMiddle.OnPressed += _ => ActiveZone = TargetingZone.Middle;
_buttonLow.OnPressed += _ => ActiveZone = TargetingZone.Low;
AddChild(_buttonHigh);
AddChild(_buttonMiddle);
AddChild(_buttonLow);
UpdateButtons();
}
private void UpdateButtons()
{
_buttonHigh.Pressed = _activeZone == TargetingZone.High;
_buttonMiddle.Pressed = _activeZone == TargetingZone.Middle;
_buttonLow.Pressed = _activeZone == TargetingZone.Low;
}
}
}