finish edit combo

This commit is contained in:
NguyenVanDat
2026-04-14 12:22:02 +07:00
parent e53cd4043f
commit a1c92565dc
5 changed files with 203 additions and 66 deletions
@@ -16,6 +16,7 @@ namespace BrewMonster
[SerializeField] private Image _backgroundImage;
[SerializeField] private Button _button;
[SerializeField] private Sprite[] _slotBackgrounds;
[SerializeField] private GameObject _focusFrame;
private int _skillId;
public int SkillId => _skillId;
@@ -55,5 +56,10 @@ namespace BrewMonster
{
_skillId = skillId;
}
public void SetFocusFrame(bool isFocus)
{
_focusFrame.SetActive(isFocus);
}
}
}
@@ -19,11 +19,10 @@ namespace BrewMonster
private AUIImagePicture _currentSelectSkill;
private SkillSlotWidget _currentSelectComboSlot;
private bool _isInEditComboMode;
private EC_VIDEO_SETTING _currentSetting;
private void Awake()
public override void Awake()
{
base.Awake();
SetUp();
foreach (var skill in ptSkillSlotList)
{
@@ -40,7 +39,6 @@ namespace BrewMonster
_skillSetUpComboWidget.ShowSetUpContent(false);
_skillSetUpComboWidget.OnClickedSkillSlot += OnClickedSkillSlot;
_skillSetUpComboWidget.OnClickedAssignSkill += OnClickedAssignSkill;
_skillSetUpComboWidget.OnClickedEditCombo += OnClickedEditCombo;
_skillSetUpComboWidget.OnClickedConfirmCombo += OnClickedConfirmCombo;
}
@@ -49,7 +47,6 @@ namespace BrewMonster
base.OnDisable();
_skillSetUpComboWidget.OnClickedSkillSlot -= OnClickedSkillSlot;
_skillSetUpComboWidget.OnClickedAssignSkill -= OnClickedAssignSkill;
_skillSetUpComboWidget.OnClickedEditCombo -= OnClickedEditCombo;
_skillSetUpComboWidget.OnClickedConfirmCombo -= OnClickedConfirmCombo;
}
@@ -92,10 +89,7 @@ namespace BrewMonster
CECHostPlayer pHost = GetHostPlayer();
int i = 0;
int activeImgPicIndex = 1;
int passiveImgPicIndex = 1;
int positiveSkillNum = pHost.GetPositiveSkillNum();
int equipSkillNum = pHost.GetEquipSkillNum();
int passiveSkillNum = pHost.GetPassiveSkillNum();
for (i = 0; i < positiveSkillNum; i++)
{
@@ -142,32 +136,26 @@ namespace BrewMonster
_skillSetUpComboWidget.ShowSetUpContent(true);
}
}
private void OnClickedEditCombo()
{
if(_currentSelectComboSlot !=null)
{
_isInEditComboMode = true;
}
}
private void OnClickedConfirmCombo()
{
EC_Game.GetConfigs().SetVideoSettings(_currentSetting);
//Show(false);
if (_currentSelectComboSlot != null &&
_skillSetUpComboWidget.CurrentComboSetting.comboSkill[_currentSelectComboSlot.GetSlotIndex].idSkill == null)
{
BMLogger.LogError("Null to set combo skill");
return;
}
EC_Game.GetConfigs().SetVideoSettings(_skillSetUpComboWidget.CurrentComboSetting);
CECUIManager.Instance.m_pDlgSkillSubOther.UpdateComboSkill();
EC_Game.GetGameRun().SaveConfigsToServer();
//save
_isInEditComboMode = true;
_currentSelectComboSlot = null;
}
//assign skill from list in the left ui
private void OnClickedAssignSkill(SkillSlotWidget slotWidget)
{
if(_isInEditComboMode && _currentSelectSkill != null && _currentSelectSkill is LearnedSkillUI skillUI)
if(_currentSelectSkill != null && _currentSelectSkill is LearnedSkillUI skillUI)
{
if (_skillSetUpComboWidget.SetSkillToCurrentCombo(slotWidget.GetSlotIndex, (short)skillUI.SkillId, out _currentSetting))
{
}
_skillSetUpComboWidget.SetSkillToCurrentCombo(slotWidget.GetSlotIndex, (short)skillUI.SkillId);
}
}
}
@@ -27,15 +27,16 @@ namespace BrewMonster
[SerializeField] private List<SkillSlotWidget> _detailCombosList;
[SerializeField] private Button _btnConfirmCombo;
private SkillSlotWidget _currentSlotWidget;
private SkillSlotWidget _currentSkillToAsign;
private SkillSlotWidget _currentComboSlotWidget;
private SkillSlotWidget _currentSkillToAssign;
private EC_VIDEO_SETTING _currentComboSetting;
private EC_VIDEO_SETTING Setting => EC_Game.GetConfigs().GetVideoSettings();
public EC_VIDEO_SETTING CurrentComboSetting => _currentComboSetting;
public event Action<SkillSlotWidget> OnClickedSkillSlot;
public event Action OnClickedEditCombo;
public event Action<SkillSlotWidget> OnClickedAssignSkill; // click to asign skill to combo
public event Action OnClickedDeleteCombo;
public event Action OnClickedConfirmCombo;
public CECGameUIMan GetGameUIMan()
@@ -44,13 +45,14 @@ namespace BrewMonster
}
private void OnEnable()
{
_currentSkillToAsign = null;
_currentSkillToAssign = null;
ShowCurrentCombos();
for (var index = 0; index < _combosList.Count; index++)
{
var slotWidget = _combosList[index];
slotWidget.SetSlotIndex(index);
slotWidget.OnClickedSkillSlot += OnClickedSkillSlotBtn;
slotWidget.SetFocusFrame(false);
}
for (var index = 0; index < _detailCombosList.Count; index++)
@@ -62,6 +64,10 @@ namespace BrewMonster
_btnEditCombo.onClick.AddListener(OnClickedEditComboBtn);
_btnConfirmCombo.onClick.AddListener(OnClickedConfirmComboBtn);
_btnDeleteCombo.onClick.AddListener(OnClickedDeleteComboBtn);
_btnEditCombo.interactable = false;
_btnDeleteCombo.interactable = false;
GetGameUIMan().SetCover(_btnNormalAttack ,$"{Mathf.Abs(NormalAttackId)}", EC_GAMEUI_ICONS.ICONS_SKILLGRP);
GetGameUIMan().SetCover(_btnLoopAttack ,$"{Mathf.Abs(LoopAttackId)}", EC_GAMEUI_ICONS.ICONS_SKILLGRP);
@@ -83,7 +89,17 @@ namespace BrewMonster
}
_btnEditCombo.onClick.RemoveListener(OnClickedEditComboBtn);
_btnConfirmCombo.onClick.RemoveListener(OnClickedConfirmComboBtn);
_currentSlotWidget = null;
_btnDeleteCombo.onClick.RemoveListener(OnClickedDeleteComboBtn);
if (_currentComboSlotWidget != null)
{
_currentComboSlotWidget.SetFocusFrame(false);
}
_currentComboSlotWidget = null;
if (_currentSkillToAssign != null)
{
_currentSkillToAssign.SetFocusFrame(false);
}
_currentSkillToAssign = null;
_btnNormalAttack.OnClickedSkillSlot -= OnSelectedSkillToAsign;
_btnLoopAttack.OnClickedSkillSlot -= OnSelectedSkillToAsign;
}
@@ -105,6 +121,10 @@ namespace BrewMonster
{
_combosList[i].SetImage(GetGameUIMan().GetIcon(DefaultComboIcon, EC_GAMEUI_ICONS.ICONS_SKILLGRP));
}
else
{
_combosList[i].Clear();
}
}
}
}
@@ -161,22 +181,63 @@ namespace BrewMonster
private void OnClickedSkillSlotBtn(SkillSlotWidget slotWidget)
{
OnClickedSkillSlot?.Invoke(slotWidget);
_currentSlotWidget = slotWidget;
if (_currentComboSlotWidget != null && _currentComboSlotWidget != slotWidget)
{
_currentComboSlotWidget.SetFocusFrame(false);
}
_currentComboSlotWidget = slotWidget;
_currentComboSlotWidget.SetFocusFrame(true);
var isEmptySlot = IsEmptyComboSlot(_currentComboSlotWidget.GetSlotIndex);
ShowSetUpContent(isEmptySlot);
_btnDeleteCombo.interactable = !isEmptySlot;
_btnEditCombo.interactable = !isEmptySlot;
if (IsEmptyComboSlot(slotWidget.GetSlotIndex))
{
ShowComboInDetail(Setting.comboSkill[_currentSlotWidget.GetSlotIndex].idSkill);
ShowComboInDetail(Setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill);
}
}
public void ShowSetUpContent(bool setActive)
{
_contentSetUpCombo.SetActive(setActive);
if (!setActive)
{
if (_currentSkillToAssign != null)
{
_currentSkillToAssign.SetFocusFrame(false);
}
_currentSkillToAssign = null;
}
}
private void OnClickedEditComboBtn()
{
OnClickedEditCombo?.Invoke();
if(_currentSlotWidget == null || Setting.comboSkill == null) return;
if(_currentComboSlotWidget == null || Setting.comboSkill == null) return;
ShowSetUpContent(true);
ShowComboInDetail(Setting.comboSkill[_currentSlotWidget.GetSlotIndex].idSkill);
ShowComboInDetail(Setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill);
}
private void OnClickedDeleteComboBtn()
{
if (_currentComboSlotWidget == null)
{
BMLogger.LogError("_currentComboSlotWidget null");
return;
}
EC_VIDEO_SETTING setting = EC_Game.GetConfigs().GetVideoSettings();
setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].nIcon = 0;
for (var index = 0;
index < setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill.Length;
index++)
{
setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill[index] = 0;
}
_currentComboSetting = setting;
EC_Game.GetConfigs().SetVideoSettings(_currentComboSetting);
//Show(false);
CECUIManager.Instance.m_pDlgSkillSubOther.UpdateComboSkill();
EC_Game.GetGameRun().SaveConfigsToServer();
ShowSetUpContent(false);
ShowCurrentCombos();
}
private void OnClickedConfirmComboBtn()
{
@@ -185,29 +246,34 @@ namespace BrewMonster
private void OnClickedAssignSkillBtn(SkillSlotWidget slotWidget)
{
OnClickedAssignSkill?.Invoke(slotWidget);
if(_currentSkillToAsign!=null)
if(_currentSkillToAssign!=null)
{
SetSkillToCurrentCombo(slotWidget.GetSlotIndex, (short)_currentSkillToAsign.SkillId, out var setting);
EC_Game.GetConfigs().SetVideoSettings(setting);
SetSkillToCurrentCombo(slotWidget.GetSlotIndex, (short)_currentSkillToAssign.SkillId);
EC_Game.GetConfigs().SetVideoSettings(_currentComboSetting);
//Show(false);
CECUIManager.Instance.m_pDlgSkillSubOther.UpdateComboSkill();
EC_Game.GetGameRun().SaveConfigsToServer();
}
}
public bool SetSkillToCurrentCombo(int slotIndex, short skillId, out EC_VIDEO_SETTING result)
public bool SetSkillToCurrentCombo(int slotIndex, short skillId)
{
result = EC_Game.GetConfigs().GetVideoSettings();
if(_currentSlotWidget == null) return false;
if(_currentComboSlotWidget == null) return false;
EC_VIDEO_SETTING setting = EC_Game.GetConfigs().GetVideoSettings();
setting.comboSkill[_currentSlotWidget.GetSlotIndex].idSkill[slotIndex] = skillId;
ShowComboInDetail(setting.comboSkill[_currentSlotWidget.GetSlotIndex].idSkill);
result = setting;
setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].nIcon = 1;
setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill[slotIndex] = skillId;
ShowComboInDetail(setting.comboSkill[_currentComboSlotWidget.GetSlotIndex].idSkill);
_currentComboSetting = setting;
return true;
}
private void OnSelectedSkillToAsign(SkillSlotWidget skillSlotWidget)
{
_currentSkillToAsign = skillSlotWidget;
if (_currentSkillToAssign != null && _currentSkillToAssign != skillSlotWidget)
{
_currentSkillToAssign.SetFocusFrame(false);
}
_currentSkillToAssign = skillSlotWidget;
_currentSkillToAssign.SetFocusFrame(true);
}
}
}
+19 -19
View File
@@ -1542,9 +1542,9 @@ RectTransform:
- {fileID: 4504331075840543341}
m_Father: {fileID: 1361524257611413148}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 108.9562, y: -31.05}
m_SizeDelta: {x: 179.9124, y: 68.0217}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8804506040386004496
@@ -1865,8 +1865,8 @@ MonoBehaviour:
- {fileID: 350743276662082819}
_btnEditCombo: {fileID: 3437965237099525973}
_btnDeleteCombo: {fileID: 3934423158012031278}
_btnNormalAttack: {fileID: 4119795404506360541}
_btnLoopAttack: {fileID: 4493982683425605349}
_btnNormalAttack: {fileID: 4493982683425605349}
_btnLoopAttack: {fileID: 4119795404506360541}
_contentSetUpCombo: {fileID: 1066502479272750133}
_imgCurrentCombo: {fileID: 5232349689356006632}
_detailCombosList:
@@ -4305,9 +4305,9 @@ RectTransform:
- {fileID: 2027606699309904338}
m_Father: {fileID: 1361524257611413148}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 468.781, y: -31.05}
m_SizeDelta: {x: 179.9124, y: 68.0217}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6741821173640675138
@@ -13116,9 +13116,9 @@ RectTransform:
- {fileID: 911293677621153352}
m_Father: {fileID: 1361524257611413148}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 288.8686, y: -31.05}
m_SizeDelta: {x: 179.9124, y: 68.0217}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5623009994815814977
@@ -15755,10 +15755,6 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 7716859618583968298}
m_Modifications:
- target: {fileID: 2767606574811216613, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 450cd00c015f91145b3302f1097984dd, type: 3}
- target: {fileID: 6859972278238108684, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Name
value: SkillSlot
@@ -15843,10 +15839,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8708871892276122358, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: _skillSlotType
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@@ -18246,6 +18238,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 7868147299253831422}
m_Modifications:
- target: {fileID: 2767606574811216613, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 0e66f0ff2fd622d4594eb7f4c68437e4, type: 3}
- target: {fileID: 6859972278238108684, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Name
value: SkillSlot
@@ -18669,6 +18665,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 7868147299253831422}
m_Modifications:
- target: {fileID: 2767606574811216613, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 0e66f0ff2fd622d4594eb7f4c68437e4, type: 3}
- target: {fileID: 6859972278238108684, guid: 8e633e7f512ae4746beccd857a4543d3, type: 3}
propertyPath: m_Name
value: SkillSlot (1)
@@ -1,5 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2318569237748334256
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7667296614254387831}
- component: {fileID: 137337044162810722}
- component: {fileID: 3769169980019734340}
m_Layer: 5
m_Name: FocusFrame
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &7667296614254387831
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2318569237748334256}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7730964945270842893}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.0000017881393, y: 0.0000009536743}
m_SizeDelta: {x: 90.975, y: 90.975}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &137337044162810722
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2318569237748334256}
m_CullTransparentMesh: 1
--- !u!114 &3769169980019734340
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2318569237748334256}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: cc0b56a3332764c4189bd141023055fa, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &6859972278238108684
GameObject:
m_ObjectHideFlags: 0
@@ -27,12 +102,13 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6859972278238108684}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4595083161655252598}
- {fileID: 7667296614254387831}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -68,7 +144,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 0e66f0ff2fd622d4594eb7f4c68437e4, type: 3}
m_Sprite: {fileID: 21300000, guid: 450cd00c015f91145b3302f1097984dd, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@@ -136,12 +212,13 @@ MonoBehaviour:
m_EditorClassIdentifier:
slotIndex: -1
disPlayImage: {fileID: 187270081802886601}
_skillSlotType: 0
_skillSlotType: 1
_backgroundImage: {fileID: 2767606574811216613}
_button: {fileID: 3205796970065559152}
_slotBackgrounds:
- {fileID: 21300000, guid: 0e66f0ff2fd622d4594eb7f4c68437e4, type: 3}
- {fileID: 21300000, guid: 450cd00c015f91145b3302f1097984dd, type: 3}
_focusFrame: {fileID: 2318569237748334256}
--- !u!1 &7245690340817629374
GameObject:
m_ObjectHideFlags: 0