void OnFrameChanged() { Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation(); if (currentAnim == null || currentAnim.hitBoxes.Count == 0) { _boxPanel.SetInteractible(false); _copyButton.interactable = false; _typeDropdown.interactable = false; UpdateParameter(); return; } Editor.HitBox currentHit = currentAnim.hitBoxes[CharacterEditor.Instance.SelectedHitId]; int frameId = CharacterEditor.Instance.SelectedFrame; currentHit.EnsureBoxExists(frameId); Editor.Box currentBox = currentHit.boxesPerFrame[frameId]; _enabledToggle.isOn = currentHit.enabledFrames[frameId]; if (currentBox != null) { if (!(currentBox.pointOne.Equals(FixedVector3.Zero) && currentBox.pointTwo.Equals(FixedVector3.Zero))) { _boxPanel.SetPoints(currentBox.pointOne, currentBox.pointTwo); } else if (_enabledToggle.isOn) { OnBoxChanged(); } } _boxPanel.SetInteractible(_enabledToggle.isOn); _copyButton.interactable = _enabledToggle.isOn; _typeDropdown.interactable = true; UpdateParameter(); }
public void OnFrameEnabled(bool enabled) { Editor.HitBox currentHit = CharacterEditor.Instance.CurrentHit(); currentHit.enabledFrames[CharacterEditor.Instance.SelectedFrame] = enabled; OnFrameChanged(); CharacterEditor.Instance.RefreshHits(); }
public void OnCopyButton() { Editor.HitBox currentHit = CharacterEditor.Instance.GetHitBox(_hitsList.SelectedItem); Editor.Box originalBox = currentHit.boxesPerFrame[CharacterEditor.Instance.SelectedFrame]; copyFramesPanel.GetComponent <CopyFramesPanel>().Setup(originalBox, _hitsList.SelectedItem, true); copyFramesPanel.SetActive(true); }
public void OnCopyButton() { string text = _inputField.text; text = text.Replace(" ", string.Empty); char[] separators = { ',' }; string[] components = text.Split(separators); separators[0] = '-'; string[] subComponents; List <Editor.Box> boxes; List <bool> enablings; if (isHitFrame) { Editor.HitBox hitBox = CharacterEditor.Instance.GetHitBox(listId); hitBox.EnsureBoxExists(CharacterEditor.Instance.CurrentAnimation().numFrames - 1); boxes = hitBox.boxesPerFrame; enablings = hitBox.enabledFrames; } else { Editor.CollisionBox collisionBox = CharacterEditor.Instance.GetCollisionBox(listId); collisionBox.EnsureBoxExists(CharacterEditor.Instance.CurrentAnimation().numFrames - 1); boxes = collisionBox.boxesPerFrame; enablings = collisionBox.enabledFrames; } foreach (string component in components) { subComponents = component.Split(separators); if (subComponents.Length == 2) { int first; int last; if (int.TryParse(subComponents[0], out first) && int.TryParse(subComponents[1], out last)) { first = Mathf.Clamp(first, 1, boxes.Count); last = Mathf.Clamp(last, first, boxes.Count); PopulateList(first - 1, last - 1, boxes, enablings); } } else { int frameId; if (int.TryParse(component, out frameId)) { frameId = Mathf.Clamp(frameId, 1, boxes.Count); SetBox(frameId - 1, boxes, enablings); } } } Close(); }
public void OnTypeSelected(int type) { Editor.HitBox currentHit = CharacterEditor.Instance.GetHitBox(_hitsList.SelectedItem); if (currentHit.param.type != type) { currentHit.param = new RetroBread.Editor.GenericParameter(type); if (!refreshing) { UpdateParameter(); } } }
public static CharacterAnimation LoadFromStorage(Storage.CharacterAnimation storageAnimation, Storage.Character storageCharacter) { // Build collisionboxes, hitboxes and events from storageCharacter // No worries with performance here, get a copy to everything CharacterAnimation anim = new CharacterAnimation(storageAnimation.name, storageAnimation.numFrames); // Populate collision boxes if (storageAnimation.collisionBoxes != null) { anim.collisionBoxes = new List <CollisionBox>(storageAnimation.collisionBoxes.Length); foreach (Storage.CollisionBox box in storageAnimation.collisionBoxes) { anim.collisionBoxes.Add(CollisionBox.LoadFromStorage(box, storageCharacter)); } } else { anim.collisionBoxes = new List <CollisionBox>(); } // Populate hit boxes if (storageAnimation.hitBoxes != null) { anim.hitBoxes = new List <HitBox>(storageAnimation.hitBoxes.Length); foreach (Storage.HitBox box in storageAnimation.hitBoxes) { anim.hitBoxes.Add(HitBox.LoadFromStorage(box, storageCharacter)); } } else { anim.hitBoxes = new List <HitBox>(); } // Populate events if (storageAnimation.events != null) { anim.events = new List <ConditionalEvent>(storageAnimation.events.Length); foreach (Storage.GenericEvent e in storageAnimation.events) { anim.events.Add(ConditionalEvent.LoadFromStorage(e, storageCharacter)); } } else { anim.events = new List <ConditionalEvent>(); } return(anim); }
private void UpdateParameter() { // Cleanup foreach (Transform child in parameterContent.transform) { GameObject.Destroy(child.gameObject); } // Setup if enabled Editor.HitBox currentHit = CharacterEditor.Instance.GetHitBox(_hitsList.SelectedItem); if (currentHit != null && _typeDropdown.interactable) { if (currentHit.param.type >= _typeDropdown.options.Count || currentHit.param.type < 0) { RetroBread.Debug.LogError("Unknown hit type " + currentHit.param.type + ", parameter data removed"); currentHit.param = new RetroBread.Editor.GenericParameter(); } _typeDropdown.value = currentHit.param.type; HitParameterBuilder.Instance.Build(parameterContent, currentHit.param); } }
public void OnBoxChanged() { Editor.HitBox currentHit = CharacterEditor.Instance.GetHitBox(_hitsList.SelectedItem); currentHit.boxesPerFrame[CharacterEditor.Instance.SelectedFrame] = new Editor.Box(_boxPanel.GetPoint1(), _boxPanel.GetPoint2()); CharacterEditor.Instance.RefreshHits(); }