int RandomSkin() { List <Cotsume> testAllSkinBuy = new List <Cotsume>(); for (int i = 0; i < skins.cotsume.Length; i++) { testAllSkinBuy.Add(skins.cotsume[i]); } Cotsume skinEnemys = testAllSkinBuy[Random.Range(0, (int)testAllSkinBuy.Count)]; return(skinEnemys.id); }
int RandomSkin() { List <Cotsume> testAllSkinBuy = new List <Cotsume>(); if (packages.Length != 0) { for (int i = 0; i < randomInPackages.cotsume.Length; i++) { testAllSkinBuy.Add(randomInPackages.cotsume[i]); } } else { for (int i = 0; i < controllerSkin.cotsume.Length; i++) { for (int j = 0; j < skinsE.Length; j++) { if (controllerSkin.cotsume[i].id == skinsE[j]) { testAllSkinBuy.Add(controllerSkin.cotsume[i]); } } } } Cotsume skinEnemys = testAllSkinBuy[Random.Range(0, (int)testAllSkinBuy.Count)]; return(skinEnemys.id); /* List<Cotsume> testAllSkinBuy = new List<Cotsume>(); * // * for (int i = 0; i < controllerSkin.cotsume.Length; i++) * { * for (int j = 0; j < skinsE.Length; j++) * { * if (controllerSkin.cotsume[i].id == skinsE[j]) * { * testAllSkinBuy.Add(controllerSkin.cotsume[i]); * } * } * } * * Cotsume skinEnemys = testAllSkinBuy[Random.Range(0, (int)testAllSkinBuy.Count)]; * return skinEnemys.id;*/ }
void actionCotsume() { if (id > 0) { for (int i = 0; i < ControllerSkins.cotsume.Length; i++) { if (ControllerSkins.cotsume[i].id == id) { cotsume = ControllerSkins.cotsume[i]; } } } else { List <Cotsume> testAllSkins = new List <Cotsume>(); testAllSkins.Clear(); for (int i = 0; i < ControllerSkins.cotsume.Length; i++) { if (ControllerSkins.cotsume[i].checkBuy) { testAllSkins.Add(ControllerSkins.cotsume[i]); } } Debug.Log(testAllSkins.Count); if (testAllSkins.Count >= 1) { cotsume = testAllSkins[Random.Range(0, (int)testAllSkins.Count)]; } else { cotsume = ControllerSkins.cotsume[52]; } //cotsume = ControllerSkins.cotsume[0]; } if (cotsume) { gameObject.GetComponent <EnemyManager>().HP = HP; if (gameObject.GetComponent <EnemyManager>().Slider) { gameObject.GetComponent <EnemyManager>().Slider.maxValue = HP; } Head.GetComponent <SpriteRenderer>().sprite = cotsume.Head; Chest.GetComponent <SpriteRenderer>().sprite = cotsume.Chest; Hip.GetComponent <SpriteRenderer>().sprite = cotsume.Hip; UpperArm_R.GetComponent <SpriteRenderer>().sprite = cotsume.UpperArm_R; LowerArm_R.GetComponent <SpriteRenderer>().sprite = cotsume.LowerArm_R; UpperArm_L.GetComponent <SpriteRenderer>().sprite = cotsume.UpperArm_L; LowerArm_L.GetComponent <SpriteRenderer>().sprite = cotsume.LowerArm_L; UpperLeg_R.GetComponent <SpriteRenderer>().sprite = cotsume.UpperLeg_R; lowerLeg_R.GetComponent <SpriteRenderer>().sprite = cotsume.LowerLeg_R; UpperLeg_L.GetComponent <SpriteRenderer>().sprite = cotsume.UpperLeg_L; lowerLeg_L.GetComponent <SpriteRenderer>().sprite = cotsume.LowerLeg_L; } }