Action Bar Weapon Group Binding

Selecting a weapon now displays weapon group toggles
Added global drag and drop handling in game manager
Weapon group toggles can be dragged to action bar to bind them
This commit is contained in:
Reinier Vens 2021-04-19 03:46:35 +01:00
commit 9779afb1bb
24 changed files with 1213 additions and 27 deletions

View file

@ -36,7 +36,10 @@ public class PropertiesPanel : MonoBehaviour
public IncrementField IncrementField;
public StatSheet StatSheet;
public CurveField CurveField;
public WeaponGroupAssignment WeaponGroupAssignment;
public RectTransform Content;
public RectTransform DragParent;
[HideInInspector] public FlatFlatButton SelectedChild;
[HideInInspector] public ActionGameManager GameManager;
@ -45,6 +48,9 @@ public class PropertiesPanel : MonoBehaviour
protected event Action RefreshPropertyValues;
protected bool RadioSelection = false;
private RectTransform _dragObject;
protected event Action<GameObject> OnPropertyAdded;
protected Action OnPropertiesChanged;
@ -462,6 +468,33 @@ public class PropertiesPanel : MonoBehaviour
AddItemProperties(item.EquippableItem);
AddSpacer();
if (item.GetBehavior<Weapon>() != null)
{
var weaponGroups = Instantiate(WeaponGroupAssignment, Content ?? transform);
weaponGroups.Inspect(item);
var dragOffset = Vector2.zero;
Transform dragObject = null;
weaponGroups.OnBeginDragAsObservable().Subscribe(x =>
{
//Debug.Log($"Began dragging weapon group {x.group}");
GameManager.BeginDrag(new WeaponGroupDragAction(x.group));
dragObject = Instantiate(weaponGroups.Groups[x.group], DragParent, true).transform;
dragOffset = (Vector2)dragObject.position - x.pointerEventData.position;
});
weaponGroups.OnDragAsObservable().Subscribe(x =>
{
dragObject.position = x.pointerEventData.position + dragOffset;
});
weaponGroups.OnEndDragAsObservable().Subscribe(x =>
{
//Debug.Log($"Ended dragging weapon group {x.group}");
GameManager.EndDrag();
Destroy(dragObject.gameObject);
});
Properties.Add(weaponGroups.gameObject);
OnPropertyAdded?.Invoke(weaponGroups.gameObject);
}
var gearData = GameManager.ItemManager.GetData(item.EquippableItem);
var statusSheet = AddStatSheet();