/** * * ステージクリア時、NPCドロップがあれば * CharaDataを生成して返す。 * * dropNpcStrのフォーマット * Rarity:Percentage:Gender (Percentageはfloat型) * */ private CharaData ParseDropNpc(string dropNpcStr) { if (string.IsNullOrEmpty(dropNpcStr)) { return(null); } string[] dropSplited = dropNpcStr.Split(':'); int rarity = Int32.Parse(dropSplited [0]); float ratio = float.Parse(dropSplited [1]); int gender = Int32.Parse(dropSplited [2]); int MAX = 10000; int RATIOLINE = (int)((float)MAX * ratio); int rand = UnityEngine.Random.Range(1, MAX); if (rand <= RATIOLINE) { CharaData genedChar = CharacterLevelSystem.GenerateCharacterData(rarity); genedChar.gender = (CharaData.Gender)Enum.ToObject(typeof(CharaData.Gender), gender); genedChar.ClothDataStr = ClothingSystem.AutoClothGenerator(genedChar.gender); return(genedChar); } return(null); }
/** * * type別にグループIDのリストを選出。 * TODO: スピード * * */ public List <string> GetGroupIdList(CharaData.Gender gender, ClothingSystem.ClothParts type) { string searchGroup = "mc"; if (gender == CharaData.Gender.Female) { searchGroup = "fc"; } List <string> groupList = new List <string> (); foreach (ClothData data in _table.All) { //男女で区別 if (!data.Name.Contains(searchGroup)) { continue; } //探してるtypeかどうかチェック string searchingID = ClothingSystem.GetClothingID(type, data.GroupID); if (data.ID != searchingID) { continue; } groupList.Add(data.GroupID); } return(groupList); }
public GameObject GetCharThumbnail(CharaData charData) { string prefabPath = "Prefabs/Characters/Female1"; if (charData.IsDead) { prefabPath = "Prefabs/Effect/Grave"; } GameObject thumbnailObj = (GameObject)Instantiate((GameObject)Resources.Load(prefabPath)) as GameObject; if (!charData.IsDead) { ClothingSystem.SetCharThumbnail(charData.ClothDataStr, thumbnailObj); } //死んでたらsortingLayerをかえるだけ else { Utils.ChangeSpriteRendererLayer(thumbnailObj, 5, "NpcPos1"); //UI: 5 } return(thumbnailObj); }
void Start() { //データ初期化 SwordDataTableObject.Instance.InitData(); GunDataTableObject.Instance.InitData(); CraftItemDataTableObject.Instance.InitData(); StageDataTableObject.Instance.InitData(); RarityDataTableObject.Instance.InitData(); ExperienceDataTableObject.Instance.InitData(); ClothDataTableObject.Instance.InitData(); ToolItemDataTableObject.Instance.InitData(); FoodDataTableObject.Instance.InitData(); Scene scene = SceneManager.GetActiveScene(); //プレイヤー初期化 if (PlayerData.playerCharData == null) { PlayerData.InitPlayerData(); } GameObject playerObj = GameObject.FindGameObjectWithTag("Player"); if (playerObj != null) { _playerObject = playerObj.GetComponent <PlayerObject> (); _playerObject.transform.localPosition = new Vector3(-4.0f, -0.2f, 0.0f); _playerObject.InitChar(PlayerData.playerCharData); //InitCharで消える可能性があるためnullチェック。 if (_playerObject != null) { _playerObject.InitCharGunObject(PlayerData.playerCharData.GunID); _playerObject.InitCharSwordObject(PlayerData.playerCharData.SwordID); } } //NPC初期化 InitNpcObject(); //ステージ初期化 if (scene.name == "Main") { Debug.LogError("********************: " + PlayerData.crntStageID); InitStage(PlayerData.crntStageID); } //キャラチェック else if (scene.name == "CharacterTest") { GameObject femaleObj = GameObject.Find("Female1"); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.HAIR, "fc1"); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.EYES, "fc1", Color.red); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.ARM_L, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.ARM_R, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.BODY, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.CHEST, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.HIP, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.LEG_UPPER_L, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.LEG_UPPER_R, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.LEG_LOWER_L, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.LEG_LOWER_R, "fc1", Color.black); // femaleObj.GetComponent<ClothingSystem> ().SetClothParts (ClothingSystem.ClothParts.SHOES, "fc1", Color.white); string dataStr = ClothingSystem.AutoClothGenerator(CharaData.Gender.Female); //, femaleObj.GetComponent<ClothingSystem> ()); // string dataStr = "HAIR@[email protected]&0.447556&0.4697548|EYES@[email protected]&0.2206098&0.7012246|CHEST@[email protected]&0.8151758&0.9653349|BODY@[email protected]&0.6312014&0.2544544|ARM_L@[email protected]&0.2703423&0.1016339|ARM_R@[email protected]&0.2703423&0.1016339|HIP@[email protected]&0.9369744&0.877869|LEG_UPPER_L@[email protected]&0.3799738&0.527169|LEG_UPPER_R@[email protected]&0.3799738&0.527169|LEG_LOWER_L@[email protected]&0.3799738&0.527169|LEG_LOWER_R@[email protected]&0.3799738&0.527169"; femaleObj.GetComponent <ClothingSystem> ().SetClothPartsByStringData(dataStr); } }
public static CharaData GenerateCharacterData(int rarity, int gender = -1) { CharaData genCharData = new CharaData(); //ID生成 genCharData.ID = GenerateNpcID(); //RarityData genCharData.Rarity = rarity; //これはSerialize対象。 genCharData.RarityData = RarityDataTableObject.Instance.Table.All.FirstOrDefault(rarityData => rarityData.Rarity == "" + rarity); //こっちはSerializeされない //攻撃力 float minAtk = 1; float maxAtk = 10; switch (rarity) { case 1: case 2: case 3: case 4: minAtk = 1.0f; maxAtk = (float)UnityEngine.Random.Range(10, 65); break; case 5: case 6: case 7: minAtk = (float)UnityEngine.Random.Range(5, 20); maxAtk = (float)UnityEngine.Random.Range(80, 100); break; case 8: minAtk = (float)UnityEngine.Random.Range(70, 80); maxAtk = (float)UnityEngine.Random.Range(100, 150); break; case 9: minAtk = (float)UnityEngine.Random.Range(150, 200); maxAtk = (float)UnityEngine.Random.Range(230, 400); break; case 10: minAtk = (float)UnityEngine.Random.Range(300, 400); maxAtk = (float)UnityEngine.Random.Range(500, 700); break; } genCharData.MinAtk = minAtk; genCharData.MaxAtk = maxAtk; //gender if (gender >= 0) { genCharData.gender = (CharaData.Gender)Enum.ToObject(typeof(CharaData.Gender), gender); } else { genCharData.gender = (CharaData.Gender)Enum.ToObject(typeof(CharaData.Gender), UnityEngine.Random.Range(0, 1)); } genCharData.BodyPrefab = "Female1"; //服を生成 genCharData.ClothDataStr = ClothingSystem.AutoClothGenerator(genCharData.gender); //favorite weapon genCharData.favoriteWpn = (CharaData.WeaponType)Enum.ToObject(typeof(CharaData.WeaponType), UnityEngine.Random.Range(0, 1)); genCharData.Name = ""; return(genCharData); }
/** * * 性別を元に、 * 服の形と色をランダムに決める。 * * キャラオブジェクトが指定されてた場合はオブジェクトに服を着せる。 * そうでない場合は服のstringデータをかえす。 * * 返り値はセーブ用のデータ文字列。 * <箇所>@<服グループID>@<R>&<G>&<B>| * * ex) * hair@GroupID@r&g&b|eye@GroupID@r&g&b|.... * * */ public static string AutoClothGenerator(CharaData.Gender gender = CharaData.Gender.Male, ClothingSystem CharacterObject = null) { string clothDataStr = ""; //髪 Color rndColor = RandomGenColor(); ClothData clothData = RandomGenClothParts(ClothParts.HAIR, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.HAIR, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr = ClothParts.HAIR + "@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } //目 rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.EYES, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.EYES, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += ClothParts.EYES + "@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } //胸 if (gender == CharaData.Gender.Female) { rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.CHEST, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.CHEST, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += ClothParts.CHEST + "@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } } //服 rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.BODY, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.BODY, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += ClothParts.BODY + "@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } //腕 rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.ARM_L, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.ARM_L, clothData.GroupID, rndColor); CharacterObject.SetClothParts(ClothingSystem.ClothParts.ARM_R, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += "ARM_L@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; clothDataStr += "ARM_R@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } //腰 rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.HIP, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.HIP, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += ClothParts.HIP + "@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; } //足 rndColor = RandomGenColor(); clothData = RandomGenClothParts(ClothParts.LEG_UPPER_L, gender); if (CharacterObject != null) { CharacterObject.SetClothParts(ClothingSystem.ClothParts.LEG_UPPER_L, clothData.GroupID, rndColor); CharacterObject.SetClothParts(ClothingSystem.ClothParts.LEG_UPPER_R, clothData.GroupID, rndColor); CharacterObject.SetClothParts(ClothingSystem.ClothParts.LEG_LOWER_L, clothData.GroupID, rndColor); CharacterObject.SetClothParts(ClothingSystem.ClothParts.LEG_LOWER_R, clothData.GroupID, rndColor); } if (clothData != null) { clothDataStr += "LEG_UPPER_L@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; clothDataStr += "LEG_UPPER_R@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; clothDataStr += "LEG_LOWER_L@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b + "|"; clothDataStr += "LEG_LOWER_R@" + clothData.GroupID + "@" + rndColor.r + "&" + rndColor.g + "&" + rndColor.b; } //もしも"|"で終わっていたら削る if (clothDataStr.EndsWith("|")) { clothDataStr = clothDataStr.Substring(0, clothDataStr.Length - 1); } return(clothDataStr); }