Hit A Wall of Incomprehension - classes, instances, pass by reference

Lets start with using code tags:

public class gearProperty
{
    public string propertyName;
    public int propertyLevel;

    public gearProperty(string pName, int pLevel)
    {
        propertyName = pName;
        propertyLevel = pLevel;
    }

    public gearProperty()
    {

    }

}

public class battleGear
{
    public string gearName;
    public string gearType;
    public string gearSubType;
    public List<gearProperty> gearProperties;
    public string gearDescription;

    public battleGear(string gName, string gType, string gSType, List<gearProperty> gProperties, string gDescript)
    {
        gearName = gName;
        gearType = gType;
        gearSubType = gSType;
        gearProperties = gProperties;
        gearDescription = gDescript;
    }

    public battleGear()
    {

    }


    public int ReturnPropertyLevel(string input)
    {
        foreach (gearProperty prop in gearProperties)
        {
            if (prop.propertyName == input) return prop.propertyLevel;
        }
        return 0;
    }

    public bool SameGear(battleGear otherGear)
    {
        bool isSame = true;

        if (otherGear.gearName != gearName) isSame = false;
        if (otherGear.gearType != gearType) isSame = false;
        if (otherGear.gearSubType != gearSubType) isSame = false;
        if (otherGear.gearSubType != gearSubType) isSame = false;
        if (otherGear.gearProperties != gearProperties) isSame = false;
        if (otherGear.gearDescription != gearDescription) isSame = false;

        return isSame;

    }
}


public class gearProfile 
{
    public string profileName;
    public battleGear mainWeapon;
    public battleGear offWeapon;
    public battleGear altWeapon;
    public battleGear throwing;
    public battleGear armor;
    public battleGear cloak;
    public battleGear accessory;
    public battleGear useItem;

    public bool ExistsInArmory(battleGear pickedGear, List<battleGear> armory)
    {
        foreach (battleGear gear in armory)
        {
            if (gear.SameGear(pickedGear)) return true;
        }

        return false;
    }

    public int ScanAllGearForHighestProperty(string propName)
    {
        int propLevel = 0;

        if (mainWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel = mainWeapon.ReturnPropertyLevel(propName);
        if (offWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel = offWeapon.ReturnPropertyLevel(propName);
        if (altWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel = altWeapon.ReturnPropertyLevel(propName);
        if (throwing.ReturnPropertyLevel(propName) > propLevel) propLevel = throwing.ReturnPropertyLevel(propName);
        if (cloak.ReturnPropertyLevel(propName) > propLevel) propLevel = cloak.ReturnPropertyLevel(propName);
        if (armor.ReturnPropertyLevel(propName) > propLevel) propLevel = armor.ReturnPropertyLevel(propName);
        if (accessory.ReturnPropertyLevel(propName) > propLevel) propLevel = accessory.ReturnPropertyLevel(propName);
        if (useItem.ReturnPropertyLevel(propName) > propLevel) propLevel = useItem.ReturnPropertyLevel(propName);

        return propLevel;
    }

    public int ScanAllGearForCumulativeProperty(string propName)
    {
        int propLevel = 0;

        if (mainWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel += mainWeapon.ReturnPropertyLevel(propName);
        if (offWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel += offWeapon.ReturnPropertyLevel(propName);
        if (altWeapon.ReturnPropertyLevel(propName) > propLevel) propLevel += altWeapon.ReturnPropertyLevel(propName);
        if (throwing.ReturnPropertyLevel(propName) > propLevel) propLevel += throwing.ReturnPropertyLevel(propName);
        if (cloak.ReturnPropertyLevel(propName) > propLevel) propLevel += cloak.ReturnPropertyLevel(propName);
        if (armor.ReturnPropertyLevel(propName) > propLevel) propLevel += armor.ReturnPropertyLevel(propName);
        if (accessory.ReturnPropertyLevel(propName) > propLevel) propLevel += accessory.ReturnPropertyLevel(propName);
        if (useItem.ReturnPropertyLevel(propName) > propLevel) propLevel += useItem.ReturnPropertyLevel(propName);

        return propLevel;
    }

    public gearProfile(string pName, battleGear mW, battleGear oW, battleGear aW, battleGear tW, battleGear c, battleGear ar, battleGear ac, battleGear uI)
    {
        profileName = pName;
        mainWeapon = mW;
        offWeapon = oW;
        altWeapon = aW;
        throwing = tW;
        armor = ar;
        cloak = c;
        accessory = ac;
        useItem = uI;
    }

    public gearProfile(battleGear mW, battleGear oW, battleGear aW, battleGear tW, battleGear c, battleGear ar, battleGear ac, battleGear uI)
    {
        profileName = "Default";
        mainWeapon = mW;
        offWeapon = oW;
        altWeapon = aW;
        throwing = tW;
        armor = ar;
        cloak = c;
        accessory = ac;
        useItem = uI;
    }

    public gearProfile()
    {

    }

}
1 Like