Exemplo n.º 1
0
    public void ReadyToGo()
    {
        if (data.State == XBeHitState.Hit_Freezed)
        {
            return;
        }
        pos.x   = transform.position.x;
        pos.y   = transform.position.z;
        elapsed = 0;
        Vector3 destination = transform.position + dir * offset;

        des.x   = destination.x;
        des.y   = destination.z;
        phase   = XBeHitPhase.Hit_Present;
        trigger = data.State == XBeHitState.Hit_Freezed ? (data.FreezePresent ? AnimTriger.ToFreezed : null) : AnimTriger.ToBeHit;
        if (bcurve)
        {
            curve_height_time_scale = curve_h == null ? 1 : present_straight / curve_h.GetTime(curve_h.length - 1);
            curve_offset_time_scale = curve_v == null ? 1 : present_straight / curve_v.GetTime(curve_v.length - 1);
            last_offset             = 0;
            last_height             = 0;
        }
        else
        {
            factor  = XCommon.singleton.GetSmoothFactor((pos - des).magnitude, present_straight, 0.01f);
            rticalV = ((!change_to_fly && data.State != XBeHitState.Hit_Fly)) ? 0 : (height * 4.0f) / present_straight;
            gravity = rticalV / present_straight * 2.0f;
        }
    }
Exemplo n.º 2
0
    public bool Update()
    {
        if (hoster == null)
        {
            return(true);
        }

        if (!string.IsNullOrEmpty(trigger) && !ator.IsInTransition(0))
        {
            if (trigger == AnimTriger.ToBeHit)
            {
                ator.Play("Present", 0);
            }
            else
            {
                ator.SetTrigger(trigger);
            }
            trigger = null;
        }
        else
        {
            float last_elapsed = elapsed;
            elapsed += Time.deltaTime;
            if (data.State == XBeHitState.Hit_Freezed)
            {
                float dh = -(deltaH / present_straight) * Time.deltaTime;
                transform.Translate(0, dh, 0, Space.World);
                if (elapsed > time_total)
                {
                    Cancel();
                    return(false);
                }
            }
            else
            {
                switch (phase)
                {
                case XBeHitPhase.Hit_Present:
                    if (elapsed > present_straight)
                    {
                        elapsed    = present_straight;
                        ator.speed = 1;
                        if ((change_to_fly || data.State == XBeHitState.Hit_Fly) && present.HitFly != null && present.HitFly.Length > 0)
                        {
                            ator.SetTrigger(AnimTriger.ToBeHit_Landing);
                            phase = XBeHitPhase.Hit_Landing;
                        }
                        else
                        {
                            ator.SetTrigger(AnimTriger.ToBeHit_Hard);
                            phase = XBeHitPhase.Hit_Hard;
                        }
                    }
                    CalcDeltaPos(transform.position, Time.deltaTime, last_elapsed);
                    if (offset < 0)
                    {
                        float move = Mathf.Sqrt(delta_x * delta_x + delta_z * delta_z);
                        float dis  = (hoster.Transform.position - transform.position).magnitude;
                        if (move < dis - 0.5)
                        {
                            transform.Translate(delta_x, 0, delta_z, Space.World);
                        }
                    }
                    break;

                case XBeHitPhase.Hit_Landing:
                    if (elapsed > present_straight + landing_time)
                    {
                        ator.SetTrigger(AnimTriger.ToBeHit_Hard);
                        phase = XBeHitPhase.Hit_Hard;
                    }
                    break;

                case XBeHitPhase.Hit_Hard:
                    if (elapsed > present_straight + landing_time + hard_straight)
                    {
                        ator.speed = 1;
                        ator.SetTrigger(AnimTriger.ToBeHit_GetUp);
                        phase = XBeHitPhase.Hit_GetUp;
                    }
                    else if (!loop_hard)
                    {
                        ator.speed = hard_straight_time / hard_straight;
                    }
                    break;

                case XBeHitPhase.Hit_GetUp:
                    if (elapsed > time_total)
                    {
                        Cancel();
                        return(false);
                    }
                    break;
                }
            }
        }
        return(true);
    }