public void UseItem(Item toUse) { partManager = null; GameObject player = GameObject.Find("Character"); if (player != null) { partManager = player.GetComponentInChildren <PartManager> (); } switch (toUse.itemSet) { case 0: if ((headItem != null) && (headItem != toUse)) { SetMaxHealth(maxHealth + toUse.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * toUse.speedChange)); ammoDiff = toUse.ammoChange; reloadDiff = toUse.reloadChange; rangeDiff = toUse.rangeChange; if (toUse.attackType != -1) { equippedAttack = PlayerInfo.Instance.equippedAttack = AttackList.Instance.attackType [toUse.attackType]; } SetMaxHealth(maxHealth - headItem.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * -headItem.speedChange)); headPart = toUse.bodyPart; if (partManager != null) { partManager.ActivateHead(headPart); } headItem = toUse; } break; case 1: if ((bodyItem != null) && (bodyItem != toUse)) { SetMaxHealth(maxHealth + toUse.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * toUse.speedChange)); ammoDiff = toUse.ammoChange; reloadDiff = toUse.reloadChange; rangeDiff = toUse.rangeChange; if (toUse.attackType != -1) { equippedAttack = PlayerInfo.Instance.equippedAttack = AttackList.Instance.attackType [toUse.attackType]; } SetMaxHealth(maxHealth - bodyItem.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * -bodyItem.speedChange)); bodyPart = toUse.bodyPart; if (partManager != null) { partManager.ActivateBody(bodyPart); partManager.ActivateHead(headPart); partManager.ActivateArms(armPart); partManager.ActivateLegs(legPart); } } bodyItem = toUse; break; case 2: if ((armItem != null) && (armItem != toUse)) { SetMaxHealth(maxHealth + toUse.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * toUse.speedChange)); ammoDiff = toUse.ammoChange; reloadDiff = toUse.reloadChange; rangeDiff = toUse.rangeChange; if (toUse.attackType != -1) { equippedAttack = PlayerInfo.Instance.equippedAttack = AttackList.Instance.attackType [toUse.attackType]; } SetMaxHealth(maxHealth - armItem.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * -armItem.speedChange)); armPart = toUse.bodyPart; if (partManager != null) { partManager.ActivateArms(armPart); } } try { equippedAttack = AttackList.Instance.attackType[toUse.attackType]; } catch {} armItem = toUse; break; case 3: if ((legItem != null) && (legItem != toUse)) { SetMaxHealth(maxHealth + toUse.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * toUse.speedChange)); ammoDiff = toUse.ammoChange; reloadDiff = toUse.reloadChange; rangeDiff = toUse.rangeChange; if (toUse.attackType != -1) { equippedAttack = PlayerInfo.Instance.equippedAttack = AttackList.Instance.attackType [toUse.attackType]; } SetMaxHealth(maxHealth - legItem.healthChange); SetMaxSpeed(maxSpeed + (maxSpeed * -legItem.speedChange)); legPart = toUse.bodyPart; if (partManager != null) { partManager.ActivateLegs(legPart); } } legItem = toUse; break; } }