So I’ve been playing around with the new weapon system and I came across some bugs. I don’t know it’s just me or everyone but:
-New Player Inventory system:
Player can have up to 6 weapons and if the number of available weapons (weapon data) are 7 or more, new weapon will show up when player already have 6 weapons in the inventory and it’s unclickable (because i already have 6 wps)
-Random growth is stacking up stats. For example I have knife(max lv8) 1-5 is linear and 5a, 5b, 5c is random growth. Stats from them will stack if upgrades pop up as 5c (stats in 5c will become 5a+5b+5c instead)
My bad on the first one, I set the weapon slots and passive slots to 6 (i don’t remember how), but still, new weapons show up when the weapon slots are full
Hi Kai, below is a quick temporary fix. I will be addressing this issue in Part 18 of the series.
// Finds an empty slot and adds a weapon of a certain type, returns
// the slot number that the item was put in.
public int Add(WeaponData data)
{
int slotNum = -1;
// Try to find an empty slot.
for(int i = 0; i < weaponSlots.Capacity; i++)
{
if (weaponSlots[i].IsEmpty())
{
slotNum = i;
break;
}
}
// If there is no empty slot, exit.
if (slotNum < 0) return slotNum;
else if(slotNum > 5) return -1;
// Otherwise create the weapon in the slot.
// Get the type of the weapon we want to spawn.
Type weaponType = Type.GetType(data.behaviour);
if (weaponType != null)
{
// Spawn the weapon GameObject.
GameObject go = new GameObject(data.baseStats.name + " Controller");
Weapon spawnedWeapon = (Weapon)go.AddComponent(weaponType);
spawnedWeapon.Initialise(data);
spawnedWeapon.transform.SetParent(transform); //Set the weapon to be a child of the player
spawnedWeapon.transform.localPosition = Vector2.zero;
spawnedWeapon.OnEquip();
// Assign the weapon to the slot.
weaponSlots[slotNum].Assign(spawnedWeapon);
// Close the level up UI if it is on.
if (GameManager.instance != null && GameManager.instance.choosingUpgrade)
GameManager.instance.EndLevelUp();
return slotNum;
}
else
{
Debug.LogWarning(string.Format(
"Invalid weapon type specified for {0}.",
data.name
));
}
return -1;
}