public void Refresh(BattlerSerializable battler) { monsterName.GetComponent <TextMeshProUGUI>().text = battler.name; var sprite = MonsterDicionary.GetSprite(battler.monsterId); monsterImage.GetComponent <Image>().sprite = sprite; monsterLevel.GetComponent <TextMeshProUGUI>().text = "レベル " + battler.level; CreateStatusContent(battler); }
private SpriteRenderer CreateSprite(GameObject targetObject, string monsterId) { var monsterData = MonsterDicionary.GetMonsterData(monsterId); var spriteRenderer = targetObject.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = MonsterDicionary.GetSprite(monsterId); spriteRenderer.material = Resources.Load("Material/AllinDefaultMaterials", typeof(Material)) as Material; spriteRenderer.sortingOrder = 2; return(spriteRenderer); }
/// <summary> /// 経験値追加 /// TODO 使わないので仕様をfixしたら消す /// </summary> /// <param name="addExp"></param> /// <returns></returns> private AsyncSubject <Unit> AddExp(int addExp) { AsyncSubject <Unit> subject = new AsyncSubject <Unit>(); _itemTransform.GetComponent <CanvasGroup>() .DOFade(0, 0.2f).Play(); _actorTransform.GetComponent <CanvasGroup>().DOFade(1, 0.2f).Play(); var actors = MemberDataModel.Instance.GetActorData(); var maxDuration = 0f; actors.ForEach(actor => { var duration = GetAddExpDuration(actor, addExp); if (duration > maxDuration) { maxDuration = duration; } }); var countUp = 0; DOVirtual.Float(0, 1, maxDuration, value => { countUp++; if (countUp > 10) { countUp = 0; //TODO SEないほうがいいかも //PlaySe.GetInstance().Play("SE/GaugeUp", 0.4f); } }).SetEase(Ease.InQuad).Play(); actors.ForEach(actor => { var actorObject = Object.Instantiate((GameObject)Resources.Load("Prefabs/GUI/ResultActor"), Vector3.zero, Quaternion.identity, _actorTransform); var image = actorObject.transform.Find("Image").GetComponent <Image>(); image.sprite = MonsterDicionary.GetSprite(actor.monsterId); image.GetComponent <RectTransform>().localScale = MonsterDicionary.GetScale(actor.monsterId); image.SetNativeSize(); var bar = actorObject.transform.Find("ExpBar").GetComponent <Slider>(); bar.value = (float)actor.hasExp / actor.needExp; var needExpText = actorObject.transform.Find("ExpBar/ExpText/Exp/NeedExpText") .GetComponent <TextMeshProUGUI>(); needExpText.text = $"/{actor.needExp.ToString()}"; var hasExpText = actorObject.transform.Find("ExpBar/ExpText/Exp/HasExpText") .GetComponent <TextMeshProUGUI>(); hasExpText.text = actor.hasExp.ToString(); var addExpText = actorObject.transform.Find("ExpBar/AddExpText").GetComponent <TextMeshProUGUI>(); addExpText.text = $"+{addExp}"; var levelText = actorObject.transform.Find("ExpBar/LvText/Level").GetComponent <TextMeshProUGUI>(); levelText.text = actor.level.ToString(); // TODO float virtualHasExp = actor.hasExp; float virtualNeedExp = actor.needExp; int virtualLevel = actor.level; var currentValue = 0f; var duration = GetAddExpDuration(actor, addExp); DOVirtual.Float(0, addExp, duration, value => { var addValue = value - currentValue; currentValue = value; virtualHasExp += addValue; if (virtualHasExp >= virtualNeedExp) { virtualHasExp -= virtualNeedExp; virtualLevel++; virtualNeedExp = ActorLogic.CalcNeedExp(actor.monsterId, virtualLevel); needExpText.text = $"/{((int) virtualNeedExp).ToString()}"; levelText.text = virtualLevel.ToString(); LevelUpPopUp(actorObject.transform); PlaySe.GetInstance().Play("SE/LevelUp"); } hasExpText.text = ((int)virtualHasExp).ToString(); bar.value = virtualHasExp / virtualNeedExp; }).SetEase(Ease.InQuad).Play(); }); return(subject); }