IEnumerator SelectiveEffects(GeneratedBaseCharacter character) { var percent = 0f; var characterTransform = character.transform; var clone = Instantiate <GeneratedBaseCharacter>(character, characterTransform.position, characterTransform.rotation, characterTransform.parent); var cloneTransform = clone.transform.Find("Body"); var characterElements = clone.elements; var characterEyes = characterElements.eye; var characterMouth = characterElements.mouth; var leftWeapon = characterElements.leftWeapon; var rightWeapon = characterElements.rightWeapon; cloneTransform.localScale = Vector3.one; cloneTransform.SetSiblingIndex(character.transform.GetSiblingIndex() - 1); cloneTransform.localScale = characterTransform.localScale; while (percent <= 1f) { percent += Time.deltaTime * 4.5f; cloneTransform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 1.375f, percent); characterElements.rightLeg.color = characterElements.leftLeg.color = characterElements.rightArm.color = characterElements.leftArm.color = characterElements.body.color = characterMouth.color = characterEyes.color = characterElements.head.color = leftWeapon.color = rightWeapon.color = new Color32(255, 255, 255, (byte)Mathf.Lerp(255, 50, percent)); yield return(null); } Destroy(clone.gameObject); }
IEnumerator SelectiveEffect(GeneratedBaseCharacter character) { StartCoroutine(SelectiveEffects(character)); yield return(new WaitForSeconds(.125f)); StartCoroutine(SelectiveEffects(character)); }
public void AddCharacter(GeneratedBaseCharacter character) { if (squadCharacters.Count < squadNumber) { var clone = Instantiate <GeneratedBaseCharacter>(character, Vector3.zero, Quaternion.identity, transform); clone.gameObject.SetActive(false); squadCharacters.Add(clone); } else { if (preparatoryCharacters.Count < preparatoryNumber) { var clone = Instantiate <GeneratedBaseCharacter>(character, Vector3.zero, Quaternion.identity, transform); clone.gameObject.SetActive(false); preparatoryCharacters.Add(clone); } else { // both lists are full Debug.Log("Both lists are full"); var clone = Instantiate <GeneratedBaseCharacter>(character, Vector3.zero, Quaternion.identity, transform); clone.gameObject.SetActive(false); freeCharacters.Add(clone); } } }
public void AddToPreparatory(GeneratedBaseCharacter character, bool justAdd = false) { if (!justAdd) { if (squadCharacters.Any(x => x.id == character.id)) { squadCharacters.RemoveAll(x => x.id == character.id); } if (preparatoryCharacters.Any(x => x.id == character.id)) { return; } } preparatoryCharacters.Add(character); }
IEnumerator SelectCharacter(GeneratedBaseCharacter character) { var percent = 0f; var characterTransform = character.transform; while (percent <= 1f) { percent += Time.deltaTime * 15f; characterTransform.localScale = Vector3.Lerp(Vector3.one * 27, Vector3.one * 38, percent); yield return(null); } percent = 0f; while (percent <= 1f) { percent += Time.deltaTime * 25f; characterTransform.localScale = Vector3.Lerp(Vector3.one * 38, Vector3.one * 27, percent); yield return(null); } }
public void PerformCharacter(GeneratedBaseCharacter character) { // destroy cloned character before an instantiating if (clonedCharacter != null && clonedCharacter is Object && !clonedCharacter.Equals(null)) { DestroyImmediate(clonedCharacter.gameObject); } // Perform on the podium clonedCharacter = Instantiate <GeneratedBaseCharacter>(character, Vector3.zero, Quaternion.identity, characterPerformancePodium); clonedCharacter.transform.localPosition = new Vector3(0f, 80f, 0); clonedCharacter.transform.localScale = Vector3.one * 23f; clonedCharacter.gameObject.SetActive(true); // Display character's informations jobIcon.sprite = GetJobIconSprite(clonedCharacter.baseJob.label); characterName.text = clonedCharacter.characterName; characterClass.text = clonedCharacter.baseClass.label.ToString(); characterLevel.text = clonedCharacter.baseClass.level.ToString(); characterAttackNumber.text = clonedCharacter.stats.damage.GetValue().ToString(); characterSpeedNumber.text = clonedCharacter.stats.speed.GetValue().ToString(); healthbarNumber.text = Mathf.RoundToInt(clonedCharacter.stats.currentHealth) + "/" + Mathf.RoundToInt(clonedCharacter.stats.maxHealth.GetValue()); }
void Start() { _baseCharacter = GetComponent <GeneratedBaseCharacter>(); }
void GenerateSpriteCharacters(GeneratedBaseCharacter character, ClassLabel classLabel) { var pattern = "{0} => {1}"; var generatedAClassLabels = new[] { generatedCommonClassLabel, generatedAClassLabel }; var generatedSClassLabels = new[] { generatedSClassLabel, generatedAClassLabel }; var realHeadSpriteLoc = string.Empty; var realEyeSpriteLoc = string.Empty; var realMouthSpriteLoc = string.Empty; var realBodySpriteLoc = string.Empty; var realArmSpriteLoc = string.Empty; var realLegSpriteLoc = string.Empty; if (classLabel == ClassLabel.B || classLabel == ClassLabel.C) { realHeadSpriteLoc = string.Format(headSpriteLoc, generatedCommonClassLabel); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedCommonClassLabel); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedCommonClassLabel); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedCommonClassLabel); realArmSpriteLoc = string.Format(armSpriteLoc, generatedCommonClassLabel); realLegSpriteLoc = string.Format(legSpriteLoc, generatedCommonClassLabel); } else if (classLabel == ClassLabel.A) { var rIndex = Random.Range(0, generatedAClassLabels.Length); realHeadSpriteLoc = string.Format(headSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedAClassLabels[rIndex]); realArmSpriteLoc = string.Format(armSpriteLoc, generatedAClassLabels[rIndex]); rIndex = Random.Range(0, generatedAClassLabels.Length); realLegSpriteLoc = string.Format(legSpriteLoc, generatedAClassLabels[rIndex]); } else { var rIndex = Random.Range(0, generatedSClassLabels.Length); realHeadSpriteLoc = string.Format(headSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realEyeSpriteLoc = string.Format(eyeSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realMouthSpriteLoc = string.Format(mouthSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realBodySpriteLoc = string.Format(bodySpriteLoc, generatedSClassLabels[rIndex]); realArmSpriteLoc = string.Format(armSpriteLoc, generatedSClassLabels[rIndex]); rIndex = Random.Range(0, generatedSClassLabels.Length); realLegSpriteLoc = string.Format(legSpriteLoc, generatedSClassLabels[rIndex]); } countOfHeadSprite = spriteHelper.Count(realHeadSpriteLoc); countOfEyeSprite = spriteHelper.Count(realEyeSpriteLoc); countOfMouthSprite = spriteHelper.Count(realMouthSpriteLoc); countOfBodySprite = spriteHelper.Count(realBodySpriteLoc); countOfLegSprite = spriteHelper.Count(realLegSpriteLoc) / 2; var headIndex = Random.Range(0, countOfHeadSprite); var eyeIndex = Random.Range(0, countOfEyeSprite); var mouthIndex = Random.Range(0, countOfMouthSprite); var bodyIndex = Random.Range(0, countOfBodySprite); var legIndex = Random.Range(0, countOfLegSprite); var headSprite = spriteHelper.Get(string.Format(pattern, realHeadSpriteLoc, headIndex)); var eyeSprite = spriteHelper.Get(string.Format(pattern, realEyeSpriteLoc, eyeIndex)); var mouthSprite = spriteHelper.Get(string.Format(pattern, realMouthSpriteLoc, mouthIndex)); var bodySprite = spriteHelper.Get(string.Format(pattern, realBodySpriteLoc, bodyIndex)); var leftArmSprite = spriteHelper.Get(string.Format(pattern, realArmSpriteLoc, "l_" + bodyIndex)); var rightArmSprite = spriteHelper.Get(string.Format(pattern, realArmSpriteLoc, "r_" + bodyIndex)); var leftLegSprite = spriteHelper.Get(string.Format(pattern, realLegSpriteLoc, "l_" + legIndex)); var rightLegSprite = spriteHelper.Get(string.Format(pattern, realLegSpriteLoc, "r_" + legIndex)); // var instanceOfBaseCharacter = Instantiate<GeneratedBaseCharacter>(generatedBaseCharacterPrefab, Vector3.zero, Quaternion.identity); // _generatedCharaters.Add(instanceOfBaseCharacter); var characterElements = character.elements; var characterEyes = characterElements.eye; var characterMouth = characterElements.mouth; characterElements.head.sprite = headSprite; characterEyes.sprite = eyeSprite; characterMouth.sprite = mouthSprite; characterElements.body.sprite = bodySprite; characterElements.leftArm.sprite = leftArmSprite; characterElements.rightArm.sprite = rightArmSprite; characterElements.leftLeg.sprite = leftLegSprite; characterElements.rightLeg.sprite = rightLegSprite; // transform eyes and mouth according to pivot of Y // range of mouth var rangeYOfMouth = Random.Range(.2f, .6f); var mouthPosition = characterMouth.transform.localPosition; mouthPosition.y = rangeYOfMouth; characterMouth.transform.localPosition = mouthPosition; // range of eyes var rangeYOfEyes = Random.Range(1f, 1.3f); var eyesPosition = characterEyes.transform.localPosition; eyesPosition.y = rangeYOfEyes; characterEyes.transform.localPosition = eyesPosition; }
void GeneratePostureByJob(GeneratedBaseCharacter character, JobLabel jobLabel) { var idle = string.Format("{0}_Idle", jobLabel); character.animator.Play(idle); }