private void LoadPlayerParts() { partIndices = new int[types.Count]; for (int i = 0; i < (types.Count); i++) { partIndices[i] = GlobalPlayer.IndexForType(types[i]); } }
public void SetPartForType(PartType type) { Transform partTransform = null; switch (type) { case PartType.Body: partTransform = body; break; case PartType.Eyes: partTransform = eyes; break; case PartType.Hat: partTransform = hat; break; case PartType.Head: partTransform = head; break; case PartType.Mouth: partTransform = mouth; break; case PartType.Mustache: partTransform = mustache; break; case PartType.Weapon: partTransform = weapon; break; default: partTransform = null; break; } if (partTransform == null || GlobalPlayer.IndexForType(type) == -1) { return; } // Destroy children of current part foreach (Transform part in partTransform) { Destroy(part.gameObject); } bool drawPart = true; // Instantiate new children in parent GameObject if the object is not empty (hat, weapon, etc) switch (type) { case PartType.Hat: case PartType.Weapon: case PartType.Mustache: if (GlobalPlayer.IndexForType(type) == 0) { drawPart = false; } break; } if (drawPart) { Instantiate( inventory.partForTypeIndex(type, GlobalPlayer.IndexForType(type)), partTransform, false); } }