Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        void Refresh()
        {
            // avoid loops
            if (refreshing)
            {
                return;
            }
            refreshing = true;
            int selectedItem = _hitsList.SelectedItem;

            _hitsList.Options = new List <string>();
            Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation();
            if (currentAnim == null || currentAnim.hitBoxes.Count == 0)
            {
                SetPanelActive(false);
                refreshing = false;
                return;
            }
            SetPanelActive(true);
            // populate list of hits
            for (int i = 0; i < currentAnim.hitBoxes.Count; ++i)
            {
                _hitsList.AddOption(boxName + " " + i);
            }
            _hitsList.SelectedItem = selectedItem;
            CharacterEditor.Instance.SelectedHitId = _hitsList.SelectedItem;
            OnFrameChanged();
            refreshing = false;
        }
Exemplo n.º 3
0
 public void OnRemoveButton()
 {
     Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation();
     if (currentAnim == null)
     {
         return;
     }
     currentAnim.hitBoxes.RemoveAt(_hitsList.SelectedItem);
     Refresh();
 }
Exemplo n.º 4
0
 public CollisionBox GetCollisionBox(int collisionId)
 {
     Editor.CharacterAnimation currentAnim = CurrentAnimation();
     if (currentAnim == null || collisionId >= currentAnim.collisionBoxes.Count)
     {
         return(null);
     }
     Editor.CollisionBox currentCollision = currentAnim.collisionBoxes[collisionId];
     currentCollision.EnsureBoxExists(selectedFrame);
     return(currentCollision);
 }
Exemplo n.º 5
0
        public HitBox GetHitBox(int hitId)
        {
            Editor.CharacterAnimation currentAnim = CurrentAnimation();
            if (currentAnim == null || hitId >= currentAnim.hitBoxes.Count)
            {
                return(null);
            }
            HitBox currentHit = currentAnim.hitBoxes[hitId];

            currentHit.EnsureBoxExists(selectedFrame);
            return(currentHit);
        }
Exemplo n.º 6
0
        public void OnAddButton()
        {
            Editor.CharacterAnimation currentAnim = CharacterEditor.Instance.CurrentAnimation();
            if (currentAnim == null)
            {
                return;
            }
            RetroBread.Editor.CollisionBox newBox = new RetroBread.Editor.CollisionBox();
            // populate with whatever is in the editor, cose usually want to copy from other rather than build from scratch
            int frameId = CharacterEditor.Instance.SelectedFrame;

            newBox.EnsureBoxExists(frameId);
            newBox.boxesPerFrame[frameId] = new Editor.Box(_boxPanel.GetPoint1(), _boxPanel.GetPoint2());
            newBox.enabledFrames[frameId] = true;

            currentAnim.collisionBoxes.Add(newBox);
            Refresh();
            // select the recently added item
            _collisionsList.SelectedItem = _collisionsList.OptionsCount - 1;
            CharacterEditor.Instance.RefreshCollisions();
        }
Exemplo n.º 7
0
 private int CurrentAnimationSize()
 {
     Editor.CharacterAnimation anim = CharacterEditor.Instance.CurrentAnimation();
     return(anim != null ? anim.numFrames : 0);
 }