Ejemplo n.º 1
0
    public static void Update(BQE_Attack p_attackEvent, float d)
    {
        Anim_BattleAttack_Distance l_battleAttack = (Anim_BattleAttack_Distance)p_attackEvent.Context_UserObject;

        switch (l_battleAttack.State)
        {
        case Anim_BattleAttack_Distance_State.End:
        {
            if (p_attackEvent.Out_DamageSteps == null)
            {
                p_attackEvent.Out_DamageSteps = new List <BaseDamageStep>();
            }
            p_attackEvent.Out_DamageSteps.Add(BaseDamageStep.build(p_attackEvent.Source, p_attackEvent.Target, p_attackEvent.Attack));
            l_battleAttack.AnimatedTransform.transform.rotation = l_battleAttack.InitalAnimatedTransform_Rotation;

            p_attackEvent.HasEnded = true;
        }
        break;
        }
    }
Ejemplo n.º 2
0
    public void update(float d)
    {
        this.Out_DamageApplied_Events.Clear();
        this.Out_Death_Events.Clear();
        this.Out_CompletedBattlequeue_Events.Clear();

        // Update ATB_Values
        if (!this.ATB_Locked)
        {
            for (int i = 0; i < this.BattleEntities.Count; i++)
            {
                BattleEntity l_entity = this.BattleEntities[i];

                if (!l_entity.IsDead)
                {
                    l_entity.ATB_Value = Math.Min(l_entity.ATB_Value + (l_entity.ATB_Speed * d), 1.0f);
                    if (l_entity.ATB_Value >= 1.0f)
                    {
                        if (!l_entity.IsControlledByPlayer)
                        {
                            this.BattleActionDecision_UserFunction.Invoke(this, l_entity);
                        }
                    }
                }

                this.BattleEntities[i] = l_entity;
            }
        }

        // A step takes the first entry of the BattleQueueEvents and initialize it
step:

        if (this.CurrentExecutingEvent == null)
        {
            if (this.BattleQueueEvents.Count > 0)
            {
                this.CurrentExecutingEvent = this.BattleQueueEvents.Dequeue();
                switch (this.BattleQueueEventInitialize_UserFunction.Invoke(this.CurrentExecutingEvent))
                {
                case Initialize_ReturnCode.NOTHING:
                    // When initialization doesn't require further processing, then we perform another step.
                    this.on_currentActionFinished();
                    goto step;
                }
            }
        }


        if (this.CurrentExecutingEvent != null)
        {
            this.ATB_Locked = true;

            // We perform specific operation every frame for the current executing event
            switch (this.CurrentExecutingEvent.Type)
            {
            case BattleQueueEvent_Type.ATTACK:
            {
                // We consume damage events of the BQE_Attack event and push it to the global queue.
                BQE_Attack l_event = (BQE_Attack)this.CurrentExecutingEvent.Event;
                if (l_event.Out_DamageSteps != null && l_event.Out_DamageSteps.Count > 0)
                {
                    for (int i = 0; i < l_event.Out_DamageSteps.Count; i++)
                    {
                        this.DamageEvents.Add(l_event.Out_DamageSteps[i]);
                    }
                    l_event.Out_DamageSteps.Clear();
                }
                if (l_event.HasEnded)
                {
                    on_currentActionFinished();
                }
            }
            break;
            }
        }
        else
        {
            this.ATB_Locked = false;
        }

        // Effectively apply damage events
        if (this.DamageEvents.Count > 0)
        {
            for (int i = 0; i < this.DamageEvents.Count; i++)
            {
                BaseDamageStep l_damageEvent = this.DamageEvents[i];

                int l_appliedDamage = DamageCalculation_Algorithm.calculate(l_damageEvent);
                if (DamageCalculation_Algorithm.apply_damage_raw(l_appliedDamage, l_damageEvent.Target))
                {
                    l_damageEvent.Target.IsDead = true;
                    push_death_event(l_damageEvent.Target);
                    this.BattleEntities.Remove(l_damageEvent.Target);
                    this.DeadBattleEntities.Add(l_damageEvent.Target);
                }

                this.Out_DamageApplied_Events.Add(BQEOut_FinalDamageApplied.Alloc(l_damageEvent.Target, l_appliedDamage));
            }
            this.DamageEvents.Clear();
        }
    }
Ejemplo n.º 3
0
    public static void Update(BQE_Attack p_attackEvent, float delta)
    {
        Anim_BattleAttack_Default l_battleAttack = (Anim_BattleAttack_Default)p_attackEvent.Context_UserObject;

        switch (l_battleAttack.State)
        {
        case Anim_BattleAttack_Default_State.Preparing:
        {
        }
        break;

        case Anim_BattleAttack_Default_State.MovingForward:
        {
            float l_distance = Vector3.Distance(l_battleAttack.AnimatedTransform.transform.position, l_battleAttack.TargetPosition_MovingForward);

            if ((l_distance > l_battleAttack.LastFrameDistace) || (l_distance <= 0.001f))
            {
                // We terminate the movement
                l_battleAttack.AnimatedTransform.transform.position = l_battleAttack.TargetPosition_MovingForward;
                if (p_attackEvent.Out_DamageSteps == null)
                {
                    p_attackEvent.Out_DamageSteps = new List <BaseDamageStep>();
                }
                p_attackEvent.Out_DamageSteps.Add(BaseDamageStep.build(p_attackEvent.Source, p_attackEvent.Target, p_attackEvent.Attack));

                l_battleAttack.State = Anim_BattleAttack_Default_State.Slashing;

                l_battleAttack.LastFrameDistace = Vector3.Distance(l_battleAttack.InitalAnimatedTransform_Position, l_battleAttack.TargetPosition_MovingForward);
                return;
            }

            float l_distanceRatio = 1.0f - (l_distance / Vector3.Distance(l_battleAttack.TargetPosition_MovingForward, l_battleAttack.InitalAnimatedTransform_Position));

            l_battleAttack.AnimatedTransform.transform.position += l_battleAttack.Movement_ForwardDirection * l_battleAttack.Conf.AnimatedTransform_Speed_V2.Evaluate(l_distanceRatio) * l_battleAttack.Conf.AnimatedTransform_Speed_Forward * delta;
            l_battleAttack.LastFrameDistace = l_distance;

            if (!l_battleAttack.IsSlashAnimationTriggered && l_distanceRatio >= l_battleAttack.Conf.DistanceRatio_MoveForward_StartMovingLegs)
            {
                l_battleAttack.IsSlashAnimationTriggered = true;
                l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_Slash);
            }
        }
        break;

        case Anim_BattleAttack_Default_State.Slashing:
        {
            if (l_battleAttack.IsSlashAnimationOver)
            {
                l_battleAttack.StandingStill_AfterSlash_Timer += delta;
                if (l_battleAttack.StandingStill_AfterSlash_Timer >= l_battleAttack.Conf.TimeStandingStill_AfterSlashing)
                {
                    l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_MoveBackward);
                    l_battleAttack.State = Anim_BattleAttack_Default_State.MovingBackward;
                    Update(p_attackEvent, delta);
                }
            }
        }
        break;

        case Anim_BattleAttack_Default_State.MovingBackward:
        {
            float l_distance = Vector3.Distance(l_battleAttack.AnimatedTransform.transform.position, l_battleAttack.InitalAnimatedTransform_Position);

            if ((l_distance > l_battleAttack.LastFrameDistace) || (l_distance <= 0.001f))
            {
                // We terminate the movement
                l_battleAttack.AnimatedTransform.transform.position = l_battleAttack.InitalAnimatedTransform_Position;
                l_battleAttack.AnimatedTransform.transform.rotation = l_battleAttack.InitalAnimatedTransform_Rotation;
                p_attackEvent.HasEnded = true;
                l_battleAttack.State   = Anim_BattleAttack_Default_State.End;
                l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.CrossFadeInFixedTime(AnimatorStateConstants.Attack_Close_Idle, 0.1f);
                return;
            }

            l_battleAttack.AnimatedTransform.transform.position += (-l_battleAttack.Movement_ForwardDirection) * l_battleAttack.Conf.AnimatedTransform_Speed_Backward * delta;

            l_battleAttack.LastFrameDistace = l_distance;
        }
        break;
        }

        return;
    }