public override int GetHashCode() { return(Height.GetHashCode() ^ Weight.GetHashCode() ^ HeadSize.GetHashCode() ^ ClothingSize.GetHashCode() ^ ShoesSize.GetHashCode()); }
public static ClothingManager getInstance(ClothingSize para_size) { if(instance == null) { // Create instance. instance = new ClothingManager(para_size); } return instance; }
public ClothingCatalog loadNGetFullClothingCatalog(ClothingSize para_size) { List<string> clothingCharOrder = new List<string>(); int counter = 1; bool itemFound = true; while(itemFound) { string tmpName = "MainAvatar"; if(counter <= 9) { tmpName += ("0"+counter); } else { tmpName += counter; } Transform tmpTrans = Resources.Load<Transform>("Prefabs/Avatars/"+tmpName); if(tmpTrans == null) { itemFound = false; } else { clothingCharOrder.Add(tmpName); } counter++; } ClothingCatalog clothingCatalog = new ClothingCatalog(); if(clothingCharOrder != null) { for(int i=0; i<clothingCharOrder.Count; i++) { string reqCharName = clothingCharOrder[i]; string charSpritePrefix = ""; if(reqCharName.Contains("MainAvatar")) { charSpritePrefix = "AV"; if(para_size == ClothingSize.BIG) { charSpritePrefix = "Big_AV"; } int tmpNumID = int.Parse(reqCharName.Split(new string[]{"MainAvatar"},System.StringSplitOptions.None)[1]); if(tmpNumID <= 9) { charSpritePrefix += "0"; } charSpritePrefix += tmpNumID; } clothingCatalog.addHeadGear(charSpritePrefix); clothingCatalog.addBodyGear(charSpritePrefix); clothingCatalog.addLegGear(charSpritePrefix); } } return clothingCatalog; }
// Tmp. public void toggleClothingVisibility(string para_modelSpriteName, string para_categoryName, ClothingSize para_size) { List<PCObjSpriteCombo> tmpPieceList = getCategoryPieces(para_categoryName,para_size); if(tmpPieceList != null) { for(int i=0; i<tmpPieceList.Count; i++) { string gObjName = tmpPieceList[i].gObjName; Transform reqChild = deepChildFind(subjectGObj.transform,gObjName); if(reqChild != null) { SpriteRenderer tmpSRend = reqChild.gameObject.GetComponent<SpriteRenderer>(); if(tmpSRend != null) { tmpSRend.enabled = true; } } } } }
public void applyClothingConfig(ClothingConfig para_cConfig, ClothingSize para_size) { if(para_cConfig != null) { ClothingConfigIterator iter = para_cConfig.getIterator(); while(iter.hasNext()) { string[] catNItemPair = iter.getNextClothingInfo(); string tmpCategoryName = catNItemPair[0]; string tmpClothingSelectionPrefix = catNItemPair[1]; if(para_size == ClothingSize.BIG) { tmpClothingSelectionPrefix = "Big_"+tmpClothingSelectionPrefix; } applyClothingByCategory(tmpCategoryName,tmpClothingSelectionPrefix,para_size); } } }
private ClothingManager(ClothingSize para_size) { // Singletons only. loadTables(para_size); loadClothingSprites(para_size); }
private void loadTables(ClothingSize para_size) { // Get APTable Data. string apcsvtableLocation = "APTableFolder/"; string apcatcsvtableLocation = "APTableFolder/"; switch(para_size) { case ClothingSize.BIG: apcsvtableLocation += "BigAvatars/AvatarPieceTree_Big"; apcatcsvtableLocation += "BigAvatars/APCategories_Big"; break; default: apcsvtableLocation += "SmallAvatars/AvatarPieceTree_Small"; apcatcsvtableLocation += "SmallAvatars/APCategories_Small"; break; } CSVTableHelper csvHelper = new CSVTableHelper(); CSVTable extractedAPCSVTable = csvHelper.loadCSVTable("AvatarPieceTree",apcsvtableLocation); CSVTable extractedAPCatCSVTable = csvHelper.loadCSVTable("APCategories",apcatcsvtableLocation); apTable = new APTable(); apCategoryTable = new APCategoryTable(); apTable.buildFromCSVTable(extractedAPCSVTable); apCategoryTable.buildFromCSVTable(extractedAPCatCSVTable); }
private void loadClothingSprites(ClothingSize para_size) { loadedClothingSprites = new Dictionary<string, Sprite>(); //(BIG CLOTHING) Big_AV01, Big_AV02 //(SMALL CLOTHING) AV_Spritesheet_01, AV_Spritesheet_02 if(para_size == ClothingSize.BIG) { for(int i=0; i<10; i++) { int artNum = (i+1); string numSuffix = ""; if(artNum < 10) { numSuffix += "0"; } numSuffix += artNum; Sprite[] tmpSpriteArr = Resources.LoadAll<Sprite>("Prefabs/Avatars/Big_AVs_Sprites/Big_AV"+numSuffix); if(tmpSpriteArr != null) { for(int k=0; k<tmpSpriteArr.Length; k++) { string nxtKey = tmpSpriteArr[k].name; if(loadedClothingSprites.ContainsKey(nxtKey)) { loadedClothingSprites[nxtKey] = tmpSpriteArr[k]; } else { loadedClothingSprites.Add(nxtKey,tmpSpriteArr[k]); } } } } } else { // Default uses Small. for(int i=0; i<5; i++) { int artNum = (i+1); string numSuffix = ""; if(artNum < 10) { numSuffix += "0"; } numSuffix += artNum; Sprite[] tmpSpriteArr = Resources.LoadAll<Sprite>("Prefabs/Avatars/AV_Spritesheet_"+numSuffix); if(tmpSpriteArr != null) { for(int k=0; k<tmpSpriteArr.Length; k++) { loadedClothingSprites.Add(tmpSpriteArr[k].name,tmpSpriteArr[k]); } } } } }
// WARNING: For some reason this method cannot be used outside and must be set to private. // Call applyClothingConfig above from an external script (even if only one clothing category needs to be applied). private void applyClothingByCategory(string para_categoryName, string para_clothingPrefix, ClothingSize para_size) { string spritePrefix = para_clothingPrefix; ClothingManager.getInstance(para_size); // Keep this line in case getInstance was not called previously. Dictionary<string,Sprite> loadedSprites = ClothingManager.loadedClothingSprites; List<PCObjSpriteCombo> reqPieces = getCategoryPieces(para_categoryName,para_size); GameObject mainAvatar = subjectGObj; Animator tmpAni = mainAvatar.gameObject.GetComponent<Animator>(); tmpAni.runtimeAnimatorController = null; if(reqPieces != null) { for(int i=0; i<reqPieces.Count; i++) { PCObjSpriteCombo tmpPieceInfo = reqPieces[i]; Transform tmpChild = deepChildFind(mainAvatar.transform,tmpPieceInfo.gObjName); if(tmpChild != null) { SpriteRenderer tmpSRend = tmpChild.gameObject.GetComponent<SpriteRenderer>(); if(tmpSRend != null) { //if(tmpSRend.sprite != null) //{ //Debug.Log(spritePrefix + tmpPieceInfo.spriteSuffix); Sprite reqNewSprite = null; string reqNewSpriteKey = spritePrefix + tmpPieceInfo.spriteSuffix; if(loadedSprites.ContainsKey(reqNewSpriteKey)) { reqNewSprite = loadedSprites[reqNewSpriteKey]; } else { reqNewSpriteKey = "AV01" + tmpPieceInfo.spriteSuffix; if(para_size == ClothingSize.BIG) { reqNewSpriteKey = "Big_AV01" + tmpPieceInfo.spriteSuffix; } reqNewSprite = loadedSprites[reqNewSpriteKey]; } tmpSRend.sprite = reqNewSprite; //} } } } } tmpAni.runtimeAnimatorController = subjectAniController; }
private List<PCObjSpriteCombo> recursivlyConstructEffectData(int para_pieceID, ClothingSize para_size) { List<PCObjSpriteCombo> retList = new List<PCObjSpriteCombo>(); ClothingManager.getInstance(para_size); APTableRow reqRow = ClothingManager.apTable.findAPTableRow(para_pieceID); if(reqRow == null) { return retList; } else { retList.Add(new PCObjSpriteCombo(reqRow.getGObjName(),reqRow.getSpriteNameSuffix())); int[] childPieceIDs = reqRow.getChildPieces(); if(childPieceIDs != null) { for(int i=0; i<childPieceIDs.Length; i++) { List<PCObjSpriteCombo> listToMerge = recursivlyConstructEffectData(childPieceIDs[i],para_size); retList.AddRange(listToMerge); } } } return retList; }
private List<PCObjSpriteCombo> getCategoryPieces(string para_categoryName, ClothingSize para_size) { ClothingManager.getInstance(para_size); int categoryPKey = ClothingManager.apCategoryTable.getPKeyUsingCategoryName(para_categoryName); int[] topLevelPieces = ClothingManager.apCategoryTable.getTopLevelPieces(categoryPKey); int[] singlePieces = ClothingManager.apCategoryTable.getSinglePieces(categoryPKey); //HashSet<int> seenPieces = new HashSet<int>(); List<PCObjSpriteCombo> tmpPieceList = new List<PCObjSpriteCombo>(); if(topLevelPieces != null) { for(int i=0; i<topLevelPieces.Length; i++) { int currTLPiece = topLevelPieces[i]; List<PCObjSpriteCombo> listToMerge = recursivlyConstructEffectData(currTLPiece,para_size); if(listToMerge != null) { tmpPieceList.AddRange(listToMerge); } } } if(singlePieces != null) { for(int i=0; i<singlePieces.Length; i++) { int currSingPiece = singlePieces[i]; APTableRow reqRow = ClothingManager.apTable.findAPTableRow(currSingPiece); if(reqRow != null) { tmpPieceList.Add(new PCObjSpriteCombo(reqRow.getGObjName(),reqRow.getSpriteNameSuffix())); } } } return tmpPieceList; }