private void OnChoosingUnit(SelectedUnitSlot selectedUnit) { ClearAllItemsInUnitInventoryPanel(); _chosenUnitData = selectedUnit.data; if (preBattleUnitInventoryManager.unit == null) { preBattleUnitInventoryManager.unit = _chosenUnitData; // Debug.Log(chosenUnit.unitID); } else { preBattleUnitInventoryManager.unit = _chosenUnitData; } /*preBattleUnitInventoryManager.statPanel.SetStats(chosenUnit.stats[StatString.PHYSICAL_DAMAGE], * chosenUnit.stats[StatString.MAGIC_DAMAGE], * chosenUnit.stats[StatString.HIT_RATE], * chosenUnit.stats[StatString.CRIT_RATE], * chosenUnit.stats[StatString.ATTACK_RANGE]); * preBattleUnitInventoryManager.statPanel.UpdateStatValues();*/ for (int i = 0; i < _chosenUnitData.unitItems.Count; i++) { ItemSlot slot = personalInventory.ItemSlots[i]; if (_chosenUnitData.unitItems[i] != null) { slot.Item = _chosenUnitData.unitItems[i]; } } }
public void CreateSelectedUnitSlot(UnitData unitData) { GameObject slotGO = Instantiate(unitSelectionSlotPrefab, this.transform); SelectedUnitSlot selectedUnitSlot = slotGO.GetComponent <SelectedUnitSlot>(); selectedUnitSlot.data = unitData; selectedUnitSlot.Refresh(); slotGO.transform.SetAsLastSibling(); selectedUnitSlot.OnSlotLeftClickEvent += slot => OnSlotLeftClickEvent(slot); LayoutRebuilder.ForceRebuildLayoutImmediate(this.GetComponent <RectTransform>()); }
private void OnToggleUnitStats(SelectedUnitSlot selectedUnit) { UnitData unitData = selectedUnit.data; majorStatPanel.UpdateStatsUI(unitData.stats, new Level(unitData.unitLevel, unitData.unitExp)); majorStatPanel.ClearAllAbilitiesFromPanel(); foreach (string abilityName in unitData.unitAbilities) { majorStatPanel.AddAbilityToPanel((string)_abilityConfig[abilityName]["name"], (string)_abilityConfig[abilityName]["description"], StaticData.AbilityReference[abilityName].GetManaCost()); } }
private void OnToggleSelectUnit(SelectedUnitSlot selectedUnit) { // toggle style if (!_selectedUnitSlots.Contains(selectedUnit)) { if (_selectedUnitSlots.Count < limit) { _selectedUnitSlots.Add(selectedUnit); ((UnitSelectionSlot)selectedUnit).SetGrayscale(true); } else { Debug.LogError("Trying to select more than limit"); } } else { _selectedUnitSlots.Remove(selectedUnit); ((UnitSelectionSlot)selectedUnit).SetGrayscale(false); } }