override public void OnDeactivate()
    {
        //  Time.timeScale = 1.0f;
        if (ActionDeath != null)
        {
            ActionDeath.SetSuccess();
        }

        ActionDeath = null;

        Action.SetSuccess();
        Action = null;

        Owner.BlackBoard.MotionType = E_MotionType.None;

        base.OnDeactivate();
    }
    protected override void Initialize(ActionBase action)
    {
        base.Initialize(action);

        Action = action as ActionKnockdown;

        string animName = Owner.AnimSet.GetKnockdowAnim(E_KnockdownState.Down, Owner.BlackBoard.WeaponSelected);

        StartRotation = Transform.rotation;
        StartPosition = Transform.position;

        Vector3 dir   = Action.Attacker.Position - Transform.position;
        float   angle = 0;

        if (dir.sqrMagnitude > 0.1f * 0.1f)
        {
            dir.Normalize();
            angle = Vector3.Angle(Transform.forward, dir);
        }
        else
        {
            dir = Transform.forward;
        }


        FinalRotation.SetLookRotation(dir);
        RotationTime  = angle / 500.0f;
        FinalPosition = StartPosition + Action.Impuls;
        MoveTime      = AnimEngine[animName].length * 0.4f;

        RotationOk = RotationTime == 0;
        PositionOK = MoveTime == 0;

        CurrentRotationTime = 0;
        CurrentMoveTime     = 0;

        CrossFade(animName, 0.05f);

        EndOfStateTime   = Time.timeSinceLevelLoad + AnimEngine[animName].length * 0.9f;
        KnockdownEndTime = EndOfStateTime + Action.Time;

        State = E_State.Start;
    }
Beispiel #3
0
    //  生成动作
    static public ActionBase Create(E_Type type)
    {
        int index = (int)type;

        ActionBase a;

        if (m_UnusedActions[index].Count > 0)
        {
            a = m_UnusedActions[index].Dequeue();
        }
        else
        {
            switch (type)
            {
            case E_Type.E_IDLE:
                a = new ActionIdle();
                break;

            case E_Type.E_MOVE:
                a = new ActionMove();
                break;

            case E_Type.E_GOTO:
                a = new ActionGoTo();
                break;

            case E_Type.E_COMBAT_MOVE:
                a = new ActionCombatMove();
                break;

            case E_Type.E_ATTACK:
                a = new ActionAttack();
                break;

            case E_Type.E_ATTACK_ROLL:
                a = new ActionAttackRoll();
                break;

            case E_Type.E_ATTACK_WHIRL:
                a = new ActionAttackWhirl();
                break;

            case E_Type.E_INJURY:
                a = new ActionInjury();
                break;

            case E_Type.E_DAMAGE_BLOCKED:
                a = new ActionDamageBlocked();
                break;

            case E_Type.E_BLOCK:
                a = new ActionBlock();
                break;

            case E_Type.E_ROLL:
                a = new ActionRoll();
                break;

            case E_Type.E_INCOMMING_ATTACK:
                a = new ActionIncommingAttack();
                break;

            case E_Type.E_WEAPON_SHOW:
                a = new ActionWeaponShow();
                break;

            case E_Type.E_Rotate:
                a = new ActionRotate();
                break;

            case E_Type.E_USE_LEVER:
                a = new ActionUseLever();
                break;

            case E_Type.E_PLAY_ANIM:
                a = new ActionPlayAnim();
                break;

            case E_Type.E_PLAY_IDLE_ANIM:
                a = new ActionPlayIdleAnim();
                break;

            case E_Type.E_DEATH:
                a = new ActionDeath();
                break;

            case E_Type.E_KNOCKDOWN:
                a = new ActionKnockdown();
                break;

            case E_Type.E_Teleport:
                a = new ActionTeleport();
                break;

            default:
                Debug.LogError("no Action to create");
                return(null);
            }
        }
        a.Reset();
        a.SetActive();

        m_ActionsInAction.Add(a);
        return(a);
    }