Exemple #1
0
    public void Initialize(BattleEntityComponent p_animatedTransform, BattleEntityComponent p_targetTransform, Anim_BattleAttack_Default_Conf p_animationConfiguration,
                           AttackDefinition p_attack)
    {
        this.AnimatedTransform = p_animatedTransform;
        this.TargetTransform   = p_targetTransform;
        this.Attack            = p_attack;

        this.AnimatedTransform.AnimatorDispatcher.registerListener(this, Anim_BattleAttack_Default.OnAnimatorEvent);

        this.Conf = p_animationConfiguration;

        this.LastFrameDistace = Vector3.Distance(this.AnimatedTransform.transform.position, this.TargetTransform.transform.position);

        this.State = (Anim_BattleAttack_Default_State)1;
        // this.AnimatedTransform.AnimatorDispatcher.Animator.StartPlayback
        this.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_Prepare);

        this.InitalAnimatedTransform_Position = this.AnimatedTransform.transform.position;

        this.TargetPosition_MovingForward = this.AnimatedTransform.transform.position + ((this.LastFrameDistace - this.Conf.DistanceFromTarget) * Vector3.Normalize(this.TargetTransform.transform.position - this.AnimatedTransform.transform.position));

        this.Movement_ForwardDirection = Vector3.Normalize(this.TargetPosition_MovingForward - this.AnimatedTransform.transform.position);

        //Orient to transform to the target
        this.InitalAnimatedTransform_Rotation  = p_animatedTransform.transform.rotation;
        p_animatedTransform.transform.rotation = Quaternion.LookRotation(this.Movement_ForwardDirection, Vector3.up);
    }
Exemple #2
0
    public override void OnAttack(GameObject attacker, GameObject defender, AttackDefinition attackDefinition, Attack attack)
    {
        //var test = Instantiate(burningEfffect, defender.transform);
        // test.initialize();

        Debug.Log("Fire Effect");
    }
Exemple #3
0
    public override void OnAttack(GameObject attacker, GameObject defender, AttackDefinition attackDefinition, Attack attack)
    {
        Rigidbody rb       = defender.GetComponent <Rigidbody>();
        Vector3   forceDir = (defender.transform.position - attacker.transform.position).normalized;

        forceDir.y += 0.5f;
        rb?.AddForce(forceDir * forceAmount);
    }
Exemple #4
0
 public override void OnAttack(GameObject attacker, GameObject defender, AttackDefinition attackDefinition, Attack attack)
 {
     if (attack.IsCritical)
     {
         Debug.Log("CRITICAL DAMAGE!");
     }
     Debug.Log($"{attacker.name} attacked {defender.name} for {attackDefinition.name} - {attack.Damage} damage.");
 }
    public override void OnAttack(GameObject attacker, GameObject defender, AttackDefinition attackDefinition, Attack attack)
    {
        var text          = attack.Damage.ToString();
        var scrollingText = Instantiate(TextPrefab, defender.transform.position + Vector3.up * 2f, Quaternion.identity);

        scrollingText.SetText(text);
        scrollingText.SetColor(attack.IsCritical ? Color.red : Color.yellow);
    }
 protected virtual bool CheckCancelWindows(AttackDefinition currentAttack)
 {
     if (CheckEnemyStepWindows(currentAttack) ||
         CheckJumpCancelWindows(currentAttack) ||
         CheckLandCancelWindows(currentAttack))
     {
         return(true);
     }
     return(false);
 }
        public override void Initialize()
        {
            base.Initialize();
            AttackDefinition currentAttack =
                (TDAction.Combat.AttackDefinition)GetEntityManager().CombatManager.CurrentAttack.attackDefinition;

            if (currentAttack.stateOverride > -1)
            {
                GetEntityManager().StateManager.ChangeState(currentAttack.stateOverride);
                return;
            }
            charging = true;
        }
        public override void OnUpdate()
        {
            EntityManager    entityManager = GetEntityManager();
            AttackDefinition currentAttack =
                (TDAction.Combat.AttackDefinition)entityManager.CombatManager.CurrentAttack.attackDefinition;

            // Handle lifetime of box groups.
            for (int i = 0; i < currentAttack.boxGroups.Count; i++)
            {
                HandleBoxGroup(i, currentAttack.boxGroups[i]);
            }

            // Check if we should cancel the attack with something else.
            if (CheckCancelWindows(currentAttack))
            {
                entityManager.CombatManager.Cleanup();
                return;
            }

            if (TryCommandAttackCancel(currentAttack))
            {
                return;
            }

            // Process events.
            bool eventCancel = false;

            for (int i = 0; i < currentAttack.events.Count; i++)
            {
                if (HandleEvents(currentAttack.events[i]))
                {
                    // Event wants us to stall on the current frame.
                    eventCancel = true;
                    return;
                }
            }

            if (CheckInterrupt())
            {
                return;
            }
            if (!eventCancel && !HandleChargeLevels(entityManager, currentAttack))
            {
                entityManager.StateManager.IncrementFrame();
            }
        }
        private bool CheckEnemyStepWindows(AttackDefinition currentAttack)
        {
            EntityManager e = GetEntityManager();

            for (int i = 0; i < currentAttack.enemyStepWindows.Count; i++)
            {
                if (e.StateManager.CurrentStateFrame >= currentAttack.enemyStepWindows[i].x &&
                    e.StateManager.CurrentStateFrame <= currentAttack.enemyStepWindows[i].y)
                {
                    if (e.TryEnemyStep())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        private bool CheckJumpCancelWindows(AttackDefinition currentAttack)
        {
            EntityManager entityManager = GetEntityManager();

            for (int i = 0; i < currentAttack.jumpCancelWindows.Count; i++)
            {
                if (entityManager.StateManager.CurrentStateFrame >= currentAttack.jumpCancelWindows[i].x &&
                    entityManager.StateManager.CurrentStateFrame <= currentAttack.jumpCancelWindows[i].y)
                {
                    if (entityManager.TryJump())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        /// <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();
                    // 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>
        /// Tries to cancel into a command attack.
        /// </summary>
        /// <param name="currentAttack">The current attack's information.</param>
        /// <returns>True if we attack canceled.</returns>
        protected virtual bool TryCommandAttackCancel(AttackDefinition currentAttack)
        {
            EntityManager e = GetEntityManager();

            for (int i = 0; i < currentAttack.commandAttackCancelWindows.Count; i++)
            {
                if (e.StateManager.CurrentStateFrame >= currentAttack.commandAttackCancelWindows[i].x &&
                    e.StateManager.CurrentStateFrame <= currentAttack.commandAttackCancelWindows[i].y)
                {
                    CAF.Combat.MovesetAttackNode man = (CAF.Combat.MovesetAttackNode)e.CombatManager.TryCommandAttack();
                    if (man != null)
                    {
                        e.CombatManager.SetAttack(man);
                        e.StateManager.ChangeState((int)EntityStates.ATTACK);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #13
0
 public void OnHited(BattleUnit attacker, AttackDefinition attackData)
 {
     
 }
Exemple #14
0
    private static void decide_nextAction_default(BattleResolutionStep p_battle, BattleEntity p_actingEntity, AttackDefinition p_attack)
    {
        BattleEntity l_targettedEntity = null;

        switch (p_actingEntity.Team)
        {
        case BattleEntity_Team.PLAYER:
        {
            l_targettedEntity = BattleDecision.Utils.find_battleEntity_ofTeam_random(p_battle, BattleEntity_Team.FOE);
        }
        break;

        case BattleEntity_Team.FOE:
        {
            l_targettedEntity = BattleDecision.Utils.find_battleEntity_ofTeam_random(p_battle, BattleEntity_Team.PLAYER);
        }
        break;
        }

        if (l_targettedEntity != null)
        {
            BQE_Attack l_attackEvent = new BQE_Attack {
                Attack = p_attack, Source = p_actingEntity, Target = l_targettedEntity
            };
            Battle_Singletons._battleResolutionStep.push_attack_event(p_actingEntity, l_attackEvent);
        }
    }
Exemple #15
0
 public abstract void OnAttack(GameObject attacker, GameObject defender, AttackDefinition attackDefinition, Attack attack);
Exemple #16
0
 return(new BaseDamageStep()
 {
     Source = p_source, Target = p_target, BaseAttack = p_baseAttack
 });