public static void Init(AttackDefinition attack)
        {
            AttackDefinitionEditorWindow window =
                (AttackDefinitionEditorWindow)EditorWindow.GetWindow(typeof(AttackDefinitionEditorWindow));

            window.attack = attack;
            window.Show();
        }
        public override void OnInterrupted()
        {
            AttackDefinition currentAttack = (TUF.Combat.AttackDefinition)CombatManager.CurrentAttack.attackDefinition;

            if (currentAttack)
            {
                //PhysicsManager.GravityScale += currentAttack.gravityScaleAdded;
            }
        }
 protected virtual bool CheckCancelWindows(AttackDefinition currentAttack)
 {
     if (CheckEnemyStepWindows(currentAttack) ||
         CheckDashCancelWindows(currentAttack) ||
         CheckJumpCancelWindows(currentAttack) ||
         CheckLandCancelWindows(currentAttack) ||
         CheckFloatCancelWindows(currentAttack))
     {
         return(true);
     }
     return(false);
 }
 protected virtual bool CheckFloatCancelWindows(AttackDefinition currentAttack)
 {
     for (int i = 0; i < currentAttack.floatCancelFrames.Count; i++)
     {
         if (StateManager.CurrentStateFrame >= currentAttack.floatCancelFrames[i].x &&
             StateManager.CurrentStateFrame <= currentAttack.floatCancelFrames[i].y)
         {
             if (controller.TryFloat())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 /// <summary>
 /// Check if we should jump cancel on the current frame.
 /// </summary>
 /// <param name="currentAttack">The current attack's information.</param>
 /// <returns>True if we jump canceled</returns>
 protected virtual bool CheckEnemyStepWindows(AttackDefinition currentAttack)
 {
     for (int i = 0; i < currentAttack.enemyStepWindows.Count; i++)
     {
         if (StateManager.CurrentStateFrame >= currentAttack.enemyStepWindows[i].x &&
             StateManager.CurrentStateFrame <= currentAttack.enemyStepWindows[i].y)
         {
             if (controller.TryEnemyStep())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public override void Initialize()
        {
            base.Initialize();
            if (!controller.LockedOn)
            {
                controller.PickSoftlockTarget();
            }
            AttackDefinition currentAttack = (TUF.Combat.AttackDefinition)CombatManager.CurrentAttack.attackDefinition;

            if (currentAttack.stateOverride > -1)
            {
                StateManager.ChangeState(currentAttack.stateOverride);
                return;
            }
            charging = true;
        }
        /// <summary>
        /// Handles processing the charge levels of the current attack.
        /// </summary>
        /// <param name="entityManager">The entity itself.</param>
        /// <param name="currentAttack">The current attack the entity is doing.</param>
        /// <returns>If the frame should be held.</returns>
        private bool HandleChargeLevels(EntityManager entityManager, AttackDefinition currentAttack)
        {
            EntityCombatManager cManager = (EntityCombatManager)entityManager.CombatManager;

            if (!charging)
            {
                return(false);
            }

            if (!entityManager.InputManager.GetButton((int)EntityInputs.Attack).isDown)
            {
                charging = false;
                return(false);
            }

            bool result = false;

            for (int i = 0; i < currentAttack.chargeWindows.Count; i++)
            {
                // Not on the correct frame.
                if (entityManager.StateManager.CurrentStateFrame != currentAttack.chargeWindows[i].frame)
                {
                    continue;
                }

                // Still have charge levels to go through.
                if (entityManager.CombatManager.CurrentChargeLevel < currentAttack.chargeWindows[i].chargeLevels.Count)
                {
                    cManager.IncrementChargeLevelCharge(currentAttack.chargeWindows[i].chargeLevels[cManager.CurrentChargeLevel].maxChargeFrames);
                    // Charge completed, move on to the next level.
                    if (cManager.CurrentChargeLevelCharge == currentAttack.chargeWindows[i].chargeLevels[cManager.CurrentChargeLevel].maxChargeFrames)
                    {
                        cManager.SetChargeLevel(cManager.CurrentChargeLevel + 1);
                        cManager.SetChargeLevelCharge(0);
                    }
                }
                else if (currentAttack.chargeWindows[i].releaseOnCompletion)
                {
                    charging = false;
                }
                result = true;
                // Only one charge level can be handled per frame, ignore everything else.
                break;
            }
            return(result);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="currentAttack"></param>
 /// <returns></returns>
 protected virtual bool TrySpecialCancel(AttackDefinition currentAttack)
 {
     for (int i = 0; i < currentAttack.specialCancelFrames.Count; i++)
     {
         if (StateManager.CurrentStateFrame >= currentAttack.specialCancelFrames[i].x &&
             StateManager.CurrentStateFrame <= currentAttack.specialCancelFrames[i].y)
         {
             MovesetAttackNode man = ((EntityCombatManager)CombatManager).TrySpecial();
             if (man != null)
             {
                 CombatManager.SetAttack(man);
                 StateManager.ChangeState((int)EntityStates.ATTACK);
                 return(true);
             }
         }
     }
     return(false);
 }
 /// <summary>
 /// Check if we should dash cancel on the current frame.
 /// </summary>
 /// <param name="currentAttack">The current attack's information.</param>
 /// <returns>True if we dash canceled.</returns>
 protected virtual bool CheckDashCancelWindows(AttackDefinition currentAttack)
 {
     for (int i = 0; i < currentAttack.dashCancelableFrames.Count; i++)
     {
         if (StateManager.CurrentStateFrame >= currentAttack.dashCancelableFrames[i].x &&
             StateManager.CurrentStateFrame <= currentAttack.dashCancelableFrames[i].y)
         {
             if (InputManager.GetButton((int)EntityInputs.Dash, 0, true).firstPress)
             {
                 if (controller.TryDash())
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
        protected override void DrawWindowsMenu()
        {
            base.DrawWindowsMenu();

            AttackDefinition atk = (AttackDefinition)attack;

            if (cancelWindowsFoldout)
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();

                List <Vector2Int> floatCancelWindows = new List <Vector2Int>(atk.floatCancelFrames);

                DrawCancelWindow("Float Cancel Windows", ref floatCancelWindowsFoldout, ref floatCancelWindows, 180);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(atk, "Changed Cancel Window.");
                    atk.floatCancelFrames = floatCancelWindows;
                }
                EditorGUI.indentLevel--;
            }
        }
        public override void OnUpdate()
        {
            AttackDefinition currentAttack = (TUF.Combat.AttackDefinition)CombatManager.CurrentAttack.attackDefinition;

            // Rotate towards target.
            for (int i = 0; i < currentAttack.faceLockonTargetWindows.Count; i++)
            {
                if (StateManager.CurrentStateFrame >= currentAttack.faceLockonTargetWindows[i].startFrame &&
                    StateManager.CurrentStateFrame <= currentAttack.faceLockonTargetWindows[i].endFrame)
                {
                    Vector3 mov        = controller.InputManager.GetAxis2D((int)EntityInputs.Movement);
                    Vector3 forwardDir = controller.visualTransform.forward;
                    // We're currently locked on to something.
                    if (controller.LockedOn)
                    {
                        forwardDir = controller.LockonForward;
                    }
                    // Movement is neutral, so Soft Target.
                    else if (mov.magnitude < InputConstants.movementMagnitude)
                    {
                        if (controller.LockonTarget)
                        {
                            forwardDir   = (controller.LockonTarget.transform.position - controller.transform.position);
                            forwardDir.y = 0;
                            forwardDir.Normalize();
                        }
                    }
                    // Movement is pointing in a direction, so face that direction.
                    else
                    {
                        forwardDir = controller.GetMovementVector(mov.x, mov.y);
                    }
                    controller.RotateVisual(forwardDir, currentAttack.faceLockonTargetWindows[i].amount);
                }
            }

            // Create hitbox grou ps.
            for (int i = 0; i < currentAttack.boxGroups.Count; i++)
            {
                HandleBoxGroup(i, (BoxGroup)currentAttack.boxGroups[i]);
            }

            // Check if this move was canceled with another action.
            if (CheckCancelWindows(currentAttack))
            {
                CombatManager.Cleanup();
                return;
            }

            // Check if we can special or command attack cancel.
            if (TrySpecialCancel(currentAttack) ||
                TryCommandAttackCancel(currentAttack))
            {
                return;
            }

            // Execute events.
            bool eventCancel = false;

            for (int i = 0; i < currentAttack.events.Count; i++)
            {
                if (HandleEvents(currentAttack.events[i]))
                {
                    eventCancel = true;
                    return;
                }
            }

            // Only increment the frame if the event didn't stop it.
            if (!eventCancel && !HandleChargeLevels((TUF.Entities.EntityManager)Manager, currentAttack))
            {
                controller.StateManager.IncrementFrame();
            }

            CheckInterrupt();
        }