private Mech loadMechData(MechData mechdata) { Type mechClass = UniTable.GetTypeFromGuid(new Guid(mechdata.mechTypeId)); if (mechClass == null) { Debug.Log("no such class found"); return(null); } //load mech Mech newMech = (Mech)pManager.pDataManager.transform.gameObject.AddComponent(mechClass); newMech.Initialize(); newMech.unitId = new Guid(mechdata.mechUnitId); //load abilities foreach (String g in mechdata.abilityIds) { Guid mechGuid = new Guid(g); ability a = UniTable.abilityDictionary[UniTable.classGuid[UniTable.GetTypeFromGuid(mechGuid)]].clone(); a.parent = newMech; newMech.abilities.Add(a); } Debug.Log(newMech.abilities.Count); //load dynamic attributes newMech.dynamicAttributes.setTo(mechdata.dynamicAtt); //load base attributes newMech.baseAtt.setTo(mechdata.baseAtt); //load mech class info foreach (partOwnership ownedPart in mechdata.parts) { Debug.Log("slot: " + ownedPart.slot + " has item: " + ownedPart.partId); Guid partGuid = new Guid(ownedPart.partId); newMech.addPartAs(masterInventory.getPart(partGuid, ownedPart.slot), ownedPart.slot); } //load unit class info newMech.MovementSpeed = mechdata.movementSpeed; newMech.PlayerNumber = mechdata.playerNumber; newMech.displayName = mechdata.displayName; return(newMech); }
private Part loadPartData(PartData partData) { Type partClass = UniTable.GetTypeFromGuid(new Guid(partData.partTypeId)); Part part = masterInventory.createPart(partClass); part.displayName = partData.displayName; part.partId = new Guid(partData.partId); foreach (Part.slot s in partData.slots) { part.slots.Add(s); } part.baseAtt.setTo(partData.baseAtt); foreach (String g in partData.abilityIds) { Guid abilityGuid = new Guid(g); ability a = UniTable.abilityDictionary[UniTable.classGuid[UniTable.GetTypeFromGuid(abilityGuid)]].clone(); a.parent = part.owner; part.abilities.Add(a); } return(part); }