private void AddStateAnimation(int uniqId, StateStruct state) { var sprite = GetSprite(uniqId); state.StateTransform.localPosition = state.StateTransform.localPosition + new Vector3((-40f * (sprite.Statuses.Count - 1)), 10f, 0); state.StateTransform.DOLocalMoveY(0, 0.4f).Play(); state.StateTransform.GetComponent <CanvasGroup>().alpha = 0; DOTween.To(() => state.StateTransform.GetComponent <CanvasGroup>().alpha, (x) => state.StateTransform.GetComponent <CanvasGroup>().alpha = x, 1f, 0.4f).Play(); }
private void StateIconValueRefresh(StateStruct stateStruct, BattlerSerializableStatus state) { //数値表示させる場合 if (StatusDictionary.IsValueView(state.type)) { var text = stateStruct.StateTransform.Find("Value"); text.GetComponent <TextMeshProUGUI>().text = state.value.ToString(); text.GetComponent <TextMeshProUGUI>().color = StatusDictionary.StatusValueColor(state.type); } //ターン数表示させる場合 if (StatusDictionary.IsTurnStatus(state.type)) { var text = stateStruct.StateTransform.Find("TurnValue"); text.GetComponent <TextMeshProUGUI>().text = state.turn.ToString(); } }
private void AddStatusIcon(int uniqId) { var battler = BattlerDictionary.GetBattlerByUniqId(uniqId); var sprite = GetSprite(uniqId); battler.status.ForEach(state => { //まだ画面にステータスを表示させてない場合 var stateStruct = sprite.Statuses.Find(f => f.Status.type == state.type); if (stateStruct == null) { //ステータス表示させる必要がある時のみ if (StatusDictionary.IsViewStatus(state.type)) { StateStruct addStateStruct = new StateStruct { Status = state, StateTransform = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/StateIcon")) .transform }; var icon = addStateStruct.StateTransform.transform; icon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/Icons/Status/" + StatusDictionary.StatusIconName(state.type)); /*icon.GetComponent<Image>().sprite = * AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Resources/Sprites/Icons/Status/" + * StatusDictionary.StatusIconName(state.type));*/ addStateStruct.StateTransform.transform.SetParent(sprite.StatusTransform, false); sprite.Statuses.Add(addStateStruct); StateIconValueRefresh(addStateStruct, state); AddStateAnimation(uniqId, addStateStruct); } } //すでに画面に表示させている場合は更新する else { StateIconValueRefresh(stateStruct, state); } }); }