public void InitializeSlots(Critter newCritter, Adaptation.BodySlot type) { SlotData[] allSlots = newCritter.GetSlots().ToArray(); currentSlotType = type; slots = new SlotData[3]; foreach (SlotData item in allSlots) { if (item.GetSlotType() == type) { slots[item.GetNumber()] = item; } } }
public void EquipOpenSlot(Critter critter) { bool equipSuccessful = false; List<SlotData> critterSlots = critter.GetSlots(); for(int i = 0; i < critterSlots.Count; i++){ SlotData currentSlot = critterSlots[i]; if(currentSlot.GetSlotType() == slot){ if(currentSlot.GetIsActive() && !currentSlot.GetIsFilled()){ Equip(critter, critterSlots[i]); equipSuccessful = true; break; } } } if (!equipSuccessful) { List<SlotData> availableSlots = DetermineActiveSlots(critterSlots); int index = Random.Range(0, availableSlots.Count); if (critterSlots.Count > index) { Equip(critter, critterSlots[index]); equipSuccessful = true; } } }