2022-10-01 12:18:33 +03:00
|
|
|
using UnityEngine;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine.UI;
|
2022-10-01 15:40:51 +03:00
|
|
|
using UnityEngine.SceneManagement;
|
2022-10-01 12:18:33 +03:00
|
|
|
|
|
|
|
|
public class CharacterEditor : MonoBehaviour
|
|
|
|
|
{
|
2022-10-01 13:43:28 +03:00
|
|
|
[SerializeField] private FrameEditor[] _frames = default;
|
2022-10-01 12:18:33 +03:00
|
|
|
[SerializeField] private TMP_Dropdown _characterDropdown = default;
|
|
|
|
|
[SerializeField] private TMP_Dropdown _spriteDropdown = default;
|
|
|
|
|
[SerializeField] private TMP_Dropdown _skinDropdown = default;
|
2022-10-02 12:58:34 +03:00
|
|
|
[SerializeField] private TMP_Dropdown _boxesDropdown = default;
|
|
|
|
|
[SerializeField] private TMP_Dropdown _typeDropdown = default;
|
2022-10-01 12:18:33 +03:00
|
|
|
[SerializeField] private Toggle _loopToggle = default;
|
2022-10-01 15:40:51 +03:00
|
|
|
[SerializeField] private Toggle _boxesToggle = default;
|
2022-10-02 12:58:34 +03:00
|
|
|
[SerializeField] private TMP_InputField _sizeXInputField = default;
|
|
|
|
|
[SerializeField] private TMP_InputField _sizeYInputField = default;
|
|
|
|
|
[SerializeField] private TMP_InputField _offsetXInputField = default;
|
|
|
|
|
[SerializeField] private TMP_InputField _offsetYInputField = default;
|
2022-10-01 12:18:33 +03:00
|
|
|
[SerializeField] private Button _playButton = default;
|
|
|
|
|
[SerializeField] private SpriteRenderer _characterSpriteRenderer = default;
|
|
|
|
|
private AnimationSO[] _animations;
|
2022-10-02 12:58:34 +03:00
|
|
|
private List<string> _characterDropOptions = new List<string>();
|
|
|
|
|
private List<string> _spriteDropdownOptions = new List<string>();
|
|
|
|
|
private List<string> _skinDropdownOptions = new List<string>();
|
|
|
|
|
private List<string> _boxesDropdownOptions = new List<string>();
|
2022-10-01 12:18:33 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
_animations = Resources.LoadAll<AnimationSO>("");
|
|
|
|
|
_characterDropdown.ClearOptions();
|
|
|
|
|
_spriteDropdown.ClearOptions();
|
2022-10-01 15:40:51 +03:00
|
|
|
_skinDropdown.ClearOptions();
|
2022-10-01 12:18:33 +03:00
|
|
|
for (int i = 0; i < _animations.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_characterDropOptions.Add(_animations[i].name);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < _animations[0].animationCelsGroup.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_spriteDropdownOptions.Add(_animations[0].animationCelsGroup[i].celName);
|
|
|
|
|
}
|
2022-10-01 15:40:51 +03:00
|
|
|
for (int i = 0; i < _animations[0].spriteAtlas.Length; i++)
|
2022-10-01 12:18:33 +03:00
|
|
|
{
|
|
|
|
|
_skinDropdownOptions.Add(i.ToString());
|
|
|
|
|
}
|
2022-10-01 15:40:51 +03:00
|
|
|
_skinDropdown.AddOptions(_skinDropdownOptions);
|
2022-10-01 12:18:33 +03:00
|
|
|
_spriteDropdown.AddOptions(_spriteDropdownOptions);
|
|
|
|
|
_characterDropdown.AddOptions(_characterDropOptions);
|
2022-10-01 13:43:28 +03:00
|
|
|
SetFrames();
|
2022-10-01 12:18:33 +03:00
|
|
|
_characterDropdown.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
2022-10-08 23:00:05 +03:00
|
|
|
_typeDropdown.value = 0;
|
2022-10-01 12:18:33 +03:00
|
|
|
AnimationEnded();
|
2022-10-02 12:58:34 +03:00
|
|
|
UpdateBoxesFields();
|
2022-10-07 17:31:42 +03:00
|
|
|
SetFrames();
|
2022-10-01 12:18:33 +03:00
|
|
|
_characterSpriteRenderer.sprite = _animations[_characterDropdown.value].GetSprite(_skinDropdown.value, _spriteDropdown.value, _cel);
|
2022-10-01 15:40:51 +03:00
|
|
|
_skinDropdown.ClearOptions();
|
2022-10-07 17:31:42 +03:00
|
|
|
_spriteDropdown.ClearOptions();
|
2022-10-01 15:40:51 +03:00
|
|
|
_skinDropdownOptions.Clear();
|
2022-10-07 17:31:42 +03:00
|
|
|
_spriteDropdownOptions.Clear();
|
2022-10-01 15:40:51 +03:00
|
|
|
for (int i = 0; i < _animations[_characterDropdown.value].spriteAtlas.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_skinDropdownOptions.Add(i.ToString());
|
|
|
|
|
}
|
2022-10-07 17:31:42 +03:00
|
|
|
for (int i = 0; i < _animations[_characterDropdown.value].animationCelsGroup.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_spriteDropdownOptions.Add(_animations[_characterDropdown.value].animationCelsGroup[i].celName);
|
|
|
|
|
}
|
|
|
|
|
_spriteDropdown.AddOptions(_spriteDropdownOptions);
|
2022-10-01 15:40:51 +03:00
|
|
|
_skinDropdown.AddOptions(_skinDropdownOptions);
|
2022-10-01 12:18:33 +03:00
|
|
|
});
|
|
|
|
|
_spriteDropdown.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
2022-10-08 23:00:05 +03:00
|
|
|
_typeDropdown.value = 0;
|
2022-10-01 12:18:33 +03:00
|
|
|
AnimationEnded();
|
2022-10-01 13:43:28 +03:00
|
|
|
SetFrames();
|
2022-10-02 12:58:34 +03:00
|
|
|
UpdateBoxesFields();
|
2022-10-01 12:18:33 +03:00
|
|
|
_characterSpriteRenderer.sprite = _animations[_characterDropdown.value].GetSprite(_skinDropdown.value, _spriteDropdown.value, _cel);
|
2022-10-06 17:42:26 +03:00
|
|
|
_frames[_cel].EnableFrameSelected();
|
2022-10-01 12:18:33 +03:00
|
|
|
});
|
2022-10-02 12:58:34 +03:00
|
|
|
_boxesDropdown.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxesFields();
|
|
|
|
|
});
|
2022-10-09 00:06:44 +03:00
|
|
|
_typeDropdown.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxesFields();
|
|
|
|
|
});
|
2022-10-01 12:18:33 +03:00
|
|
|
_loopToggle.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
if (_loopToggle.isOn)
|
|
|
|
|
{
|
|
|
|
|
_isPaused = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-10-02 12:58:34 +03:00
|
|
|
TrainingSettings.ShowHitboxes = _boxesToggle.isOn;
|
2022-10-01 15:40:51 +03:00
|
|
|
_boxesToggle.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
2022-10-02 12:58:34 +03:00
|
|
|
TrainingSettings.ShowHitboxes = _boxesToggle.isOn;
|
2022-10-01 15:40:51 +03:00
|
|
|
});
|
2022-10-01 12:18:33 +03:00
|
|
|
_playButton.onClick.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
_isPlayOn = !_isPlayOn;
|
2022-10-01 15:40:51 +03:00
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
2022-10-01 12:18:33 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-02 12:58:34 +03:00
|
|
|
private AnimationBox _savedBox;
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.C) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
|
|
|
|
_savedBox = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[_boxesDropdown.value];
|
|
|
|
|
}
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.V) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
|
|
|
|
if (_savedBox != null)
|
|
|
|
|
{
|
|
|
|
|
if (_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[_boxesDropdown.value] = new AnimationBox() { size = _savedBox.size, offset = _savedBox.offset };
|
|
|
|
|
UpdateBoxesFields();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.A) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
2022-10-06 17:42:26 +03:00
|
|
|
_isPlayOn = false;
|
|
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
2022-10-02 12:58:34 +03:00
|
|
|
_cel--;
|
|
|
|
|
if (_cel < 0)
|
|
|
|
|
{
|
|
|
|
|
_cel = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
GoToFrame(_cel);
|
|
|
|
|
}
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.D) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
2022-10-06 17:42:26 +03:00
|
|
|
_isPlayOn = false;
|
|
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
2022-10-02 12:58:34 +03:00
|
|
|
_cel++;
|
|
|
|
|
if (_cel > _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
_cel = 0;
|
|
|
|
|
}
|
|
|
|
|
GoToFrame(_cel);
|
|
|
|
|
}
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
2022-10-06 17:42:26 +03:00
|
|
|
_isPlayOn = false;
|
|
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
|
|
|
|
_spriteDropdown.value = _spriteDropdown.value - 1;
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.S) && Input.GetKey(KeyCode.LeftShift))
|
|
|
|
|
{
|
2022-10-06 17:42:26 +03:00
|
|
|
_isPlayOn = false;
|
|
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
|
|
|
|
_spriteDropdown.value = _spriteDropdown.value + 1;
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-01 12:18:33 +03:00
|
|
|
|
|
|
|
|
private int _frame;
|
|
|
|
|
private int _cel;
|
|
|
|
|
private bool _isPaused;
|
|
|
|
|
private bool _isPlayOn = true;
|
|
|
|
|
void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (!_isPaused && _isPlayOn)
|
|
|
|
|
{
|
|
|
|
|
if (_frame == _animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).frames)
|
|
|
|
|
{
|
|
|
|
|
_cel++;
|
2022-10-01 18:02:11 +03:00
|
|
|
if (_cel > _animations[_characterDropdown.value].GetGroup(_spriteDropdown.value).animationCel.Count - 1)
|
2022-10-01 12:18:33 +03:00
|
|
|
{
|
|
|
|
|
AnimationEnded();
|
|
|
|
|
if (!_animations[_characterDropdown.value].GetGroup(_spriteDropdown.value).loop)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_frame = 0;
|
|
|
|
|
}
|
2022-10-07 17:31:42 +03:00
|
|
|
_frames[_cel].EnableFrameSelected();
|
2022-10-01 12:18:33 +03:00
|
|
|
_characterSpriteRenderer.sprite = _animations[_characterDropdown.value].GetSprite(_skinDropdown.value, _spriteDropdown.value, _cel);
|
|
|
|
|
_frame++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void AnimationEnded()
|
|
|
|
|
{
|
|
|
|
|
if (!_loopToggle.isOn)
|
|
|
|
|
{
|
|
|
|
|
_isPaused = true;
|
|
|
|
|
}
|
|
|
|
|
_frame = 0;
|
|
|
|
|
_cel = 0;
|
2022-10-02 12:58:34 +03:00
|
|
|
UpdateBoxesFields();
|
2022-10-01 12:18:33 +03:00
|
|
|
}
|
2022-10-01 13:43:28 +03:00
|
|
|
|
2022-10-02 12:58:34 +03:00
|
|
|
public void UpdateAnimationBoxSizeX(string value)
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
float valueFixed = 0;
|
|
|
|
|
if (float.TryParse(value, out valueFixed))
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_typeDropdown.value == 0)
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hurtboxes[_boxesDropdown.value].size.x = float.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hitboxes.Count > 0)
|
2022-10-08 23:00:05 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hitboxes[_boxesDropdown.value].size.x = float.Parse(value);
|
2022-10-08 23:00:05 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_characterDropdown.value = 0;
|
2022-10-08 23:00:05 +03:00
|
|
|
}
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void UpdateAnimationBoxSizeY(string value)
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
float valueFixed = 0;
|
|
|
|
|
if (float.TryParse(value, out valueFixed))
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_typeDropdown.value == 0)
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hurtboxes[_boxesDropdown.value].size.y = float.Parse(value);
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
2022-10-09 00:06:44 +03:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hitboxes[_boxesDropdown.value].size.y = float.Parse(value);
|
|
|
|
|
}
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void UpdateAnimationBoxOffsetX(string value)
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
float valueFixed = 0;
|
|
|
|
|
if (float.TryParse(value, out valueFixed))
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_typeDropdown.value == 0)
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hurtboxes[_boxesDropdown.value].offset.x = valueFixed;
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
2022-10-09 00:06:44 +03:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hitboxes[_boxesDropdown.value].offset.x = valueFixed;
|
|
|
|
|
}
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void UpdateAnimationBoxOffsetY(string value)
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
float valueFixed = 0;
|
|
|
|
|
if (float.TryParse(value, out valueFixed))
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_typeDropdown.value == 0)
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hurtboxes[_boxesDropdown.value].offset.y = float.Parse(value);
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
2022-10-09 00:06:44 +03:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_animations[_characterDropdown.value].GetCel(_spriteDropdown.value, _cel).hitboxes[_boxesDropdown.value].offset.y = float.Parse(value);
|
|
|
|
|
}
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-01 18:02:11 +03:00
|
|
|
|
2022-10-01 13:43:28 +03:00
|
|
|
private void SetFrames()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _frames.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_frames[i].gameObject.SetActive(false);
|
|
|
|
|
}
|
2022-10-01 18:02:11 +03:00
|
|
|
for (int i = 0; i < _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Count; i++)
|
2022-10-01 13:43:28 +03:00
|
|
|
{
|
|
|
|
|
_frames[i].gameObject.SetActive(true);
|
|
|
|
|
_frames[i].SetDuration(_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[i].frames);
|
2022-10-07 17:31:42 +03:00
|
|
|
if (_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[i].hitboxes?.Count > 0)
|
2022-10-01 13:43:28 +03:00
|
|
|
{
|
|
|
|
|
_frames[i].SetImage(Color.red);
|
2022-10-07 17:31:42 +03:00
|
|
|
|
2022-10-01 13:43:28 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool isPriorFrameActive = false;
|
2022-10-01 18:02:11 +03:00
|
|
|
for (int j = 0; j < _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Count; j++)
|
2022-10-01 13:43:28 +03:00
|
|
|
{
|
2022-10-07 17:31:42 +03:00
|
|
|
if (_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[j].hitboxes?.Count > 0 && j < i)
|
2022-10-01 13:43:28 +03:00
|
|
|
{
|
|
|
|
|
isPriorFrameActive = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPriorFrameActive)
|
|
|
|
|
{
|
|
|
|
|
_frames[i].SetImage(Color.green);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_frames[i].SetImage(Color.blue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-01 15:40:51 +03:00
|
|
|
|
2022-10-02 12:58:34 +03:00
|
|
|
private void UpdateBoxesFields()
|
|
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_typeDropdown.value == 0)
|
2022-10-02 12:58:34 +03:00
|
|
|
{
|
2022-10-09 00:06:44 +03:00
|
|
|
if (_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
_sizeXInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[0].size.x.ToString();
|
|
|
|
|
_sizeYInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[0].size.y.ToString();
|
|
|
|
|
_offsetXInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[0].offset.x.ToString();
|
|
|
|
|
_offsetYInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes[0].offset.y.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
_sizeXInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes[0].size.x.ToString();
|
|
|
|
|
_sizeYInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes[0].size.y.ToString();
|
|
|
|
|
_offsetXInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes[0].offset.x.ToString();
|
|
|
|
|
_offsetYInputField.text = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes[0].offset.y.ToString();
|
|
|
|
|
}
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-01 15:40:51 +03:00
|
|
|
public void SetFrameDuration(int cel, int duration)
|
|
|
|
|
{
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[cel].frames = duration;
|
|
|
|
|
AnimationEnded();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoToFrame(int cel)
|
|
|
|
|
{
|
2022-10-02 12:58:34 +03:00
|
|
|
_cel = cel;
|
|
|
|
|
_characterSpriteRenderer.sprite = _animations[_characterDropdown.value].GetSprite(_skinDropdown.value, _spriteDropdown.value, _cel);
|
2022-10-01 15:40:51 +03:00
|
|
|
_isPlayOn = false;
|
|
|
|
|
_playButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = _isPlayOn ? "Pause" : "Play";
|
2022-10-02 12:58:34 +03:00
|
|
|
_boxesDropdown.ClearOptions();
|
|
|
|
|
_boxesDropdownOptions.Clear();
|
|
|
|
|
for (int i = 0; i < _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
_boxesDropdownOptions.Add(i.ToString());
|
|
|
|
|
}
|
|
|
|
|
_frames[_cel].EnableFrameSelected();
|
|
|
|
|
_boxesDropdown.AddOptions(_boxesDropdownOptions);
|
|
|
|
|
UpdateBoxesFields();
|
2022-10-01 15:40:51 +03:00
|
|
|
}
|
|
|
|
|
|
2022-10-01 18:02:11 +03:00
|
|
|
public void DeleteFrame(int cel)
|
|
|
|
|
{
|
|
|
|
|
AnimationCel animationCel = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[cel];
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Remove(animationCel);
|
|
|
|
|
SetFrames();
|
|
|
|
|
AnimationEnded();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-01 15:40:51 +03:00
|
|
|
public void AddFrame()
|
|
|
|
|
{
|
2022-10-01 18:02:11 +03:00
|
|
|
AnimationCel animationCel = new AnimationCel();
|
|
|
|
|
animationCel.sprite = _animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Count - 1].sprite;
|
|
|
|
|
animationCel.frames = 1;
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel.Add(animationCel);
|
|
|
|
|
SetFrames();
|
2022-10-01 15:40:51 +03:00
|
|
|
}
|
|
|
|
|
|
2022-10-02 12:58:34 +03:00
|
|
|
public void CreateHurtbox()
|
|
|
|
|
{
|
|
|
|
|
AnimationBox hurtbox = new AnimationBox();
|
|
|
|
|
hurtbox.size = new Vector2(1, 1);
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hurtboxes.Add(hurtbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateHitbox()
|
|
|
|
|
{
|
|
|
|
|
AnimationBox hitbox = new AnimationBox();
|
|
|
|
|
hitbox.size = new Vector2(1, 1);
|
|
|
|
|
_animations[_characterDropdown.value].animationCelsGroup[_spriteDropdown.value].animationCel[_cel].hitboxes.Add(hitbox);
|
2022-10-07 17:31:42 +03:00
|
|
|
SetFrames();
|
2022-10-02 12:58:34 +03:00
|
|
|
}
|
|
|
|
|
|
2022-10-01 15:40:51 +03:00
|
|
|
public void LoadFightScene()
|
|
|
|
|
{
|
|
|
|
|
SceneSettings.PlayerOne = 0;
|
2023-07-03 17:57:46 +03:00
|
|
|
SceneManager.LoadScene(2);
|
2022-10-01 15:40:51 +03:00
|
|
|
}
|
2022-10-01 12:18:33 +03:00
|
|
|
}
|