Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / weaponRoulette / WeaponSlot.cs
  1. using Godot;
  2.  
  3. namespace UI.WeaponRoulette;
  4.  
  5. public partial class WeaponSlot : Node2D, IUiNodeScript
  6. {
  7. private WeaponRoulette.WeaponSlotNode _node;
  8. private Weapon _weapon;
  9. public void SetUiNode(IUiNode uiNode)
  10. {
  11. _node = (WeaponRoulette.WeaponSlotNode)uiNode;
  12. _node.L_SlotAreaNode.Instance.AreaEntered += OnAreaEntered;
  13. _node.L_SlotAreaNode.Instance.AreaExited += OnAreaExited;
  14. }
  15.  
  16. public void OnDestroy()
  17. {
  18. }
  19.  
  20. public void SetWeapon(Weapon weapon)
  21. {
  22. _weapon = weapon;
  23. }
  24.  
  25. public void ClearWeapon()
  26. {
  27. _weapon = null;
  28. }
  29. private void OnAreaEntered(Area2D other)
  30. {
  31. _node.UiPanel.ActiveWeapon = _weapon;
  32. _node.Instance.Scale = new Vector2(1.1f, 1.1f);
  33. _node.L_SlotUi.L_WeaponUi.L_WeaponIcon.Instance.Material.SetShaderMaterialParameter(ShaderParamNames.OutlineColor, Colors.White);
  34. }
  35. private void OnAreaExited(Area2D other)
  36. {
  37. if (_node.UiPanel.ActiveWeapon == _weapon)
  38. {
  39. _node.UiPanel.ActiveWeapon = null;
  40. }
  41.  
  42. _node.Instance.Scale = Vector2.One;
  43. _node.L_SlotUi.L_WeaponUi.L_WeaponIcon.Instance.Material.SetShaderMaterialParameter(ShaderParamNames.OutlineColor, Colors.Black);
  44. }
  45. }