Пример #1
0
    protected override void Initialize(ActionBase action)
    {
        base.Initialize(action);

        MoveOk = true;

        Action = action as ActionAttackWhirl;

        CrossFade(Action.Data.AnimName, 0.2f);

        UpdateFinalRotation();

        Owner.BlackBoard.MotionType = E_MotionType.Walk;

        RotationProgress = 0;

        TimeToEndState = AnimEngine[Action.Data.AnimName].length * 0.9f + Time.timeSinceLevelLoad;
        NoHitTimer     = Time.timeSinceLevelLoad + 0.75f;

        Owner.PlayLoopSound(Owner.BerserkSound, 1, AnimEngine[Action.Data.AnimName].length - 1, 0.5f, 0.9f);

        TimeToStartEffect = Time.timeSinceLevelLoad + 1;
        TimeToEndEffect   = Time.timeSinceLevelLoad + AnimEngine[Action.Data.AnimName].length - 1;

        MaxSpeed = 2;
    }
Пример #2
0
    override public void OnDeactivate()
    {
        if (Action != null)
        {
            Action.SetSuccess();
            Action = null;
        }

        Owner.BlackBoard.Speed = 0;
        if (Effect != null)
        {
            CombatEffectsManager.Instance.ReturnWhirlEffect(Effect);
        }

        Effect = null;

        base.OnDeactivate();

        // Time.timeScale = 1;
    }
Пример #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);
    }
    void Update()
    {
        if (Owner.BlackBoard.Health <= 0)
        {
            if (!isDeath)
            {
                StartCoroutine(PlayTeleport());
                isDeath = true;
            }
            return;
        }
        else
        {
            Owner.CharacterController.SimpleMove(Vector3.zero);
        }

        //  只有当在警觉状态下,才会进行警戒计时
        if (Alert() && Owner.Status == E_CurrentStatus.E_Idle)
        {
            alertStartTime += Time.deltaTime;
            ActionRotate actionRotate = ActionFactory.Create(ActionFactory.E_Type.E_Rotate) as ActionRotate;
            actionRotate.Direction = targetDir;
            animComponent.HandleAction(actionRotate);
            Owner.BlackBoard.WeaponState = E_WeaponState.Ready;
        }
        else
        {
            ActionIdle actionIdle = ActionFactory.Create(ActionFactory.E_Type.E_IDLE) as ActionIdle;
            animComponent.HandleAction(actionIdle);
            alertStartTime = 0;
            Owner.BlackBoard.WeaponState = E_WeaponState.NotInHands;
        }

        //  当超过警觉时间,切换为移动状态
        if (alertStartTime > alertTime)
        {
            Owner.Status   = E_CurrentStatus.E_Move;
            alertStartTime = 0;
        }

        if (Owner.Status == E_CurrentStatus.E_Move)
        {
            //  当进入移动状态时,判断敌人是否在视野范围内,如果是追击敌人,如果不在,返回到Idl状态,接着之前的行为
            if (InView())
            {
                ActionGoTo actionGoto = ActionFactory.Create(ActionFactory.E_Type.E_GOTO) as ActionGoTo;

                Owner.BlackBoard.MoveDir     = targetDir.normalized; //  更新移动方向
                Owner.BlackBoard.WeaponState = E_WeaponState.Ready;

                actionGoto.FinalPosition = targetPos;
                actionGoto.MoveType      = E_MoveType.Forward;
                actionGoto.Motion        = E_MotionType.Sprint;
                animComponent.HandleAction(actionGoto);
            }
            else
            {
                Owner.Status = E_CurrentStatus.E_Idle;
                Owner.BlackBoard.WeaponState = E_WeaponState.NotInHands;
            }
        }

        //  只要在攻击距离内,就直接切换到攻击状态
        if (InAttackView() && Owner.Status == E_CurrentStatus.E_Move)
        {
            //  随机攻击方式
            int random = Random.Range(0, 10);

            if (random < 2)
            {
                ActionAttack actionAttack = ActionFactory.Create(ActionFactory.E_Type.E_ATTACK) as ActionAttack;
                actionAttack.Target    = Player.Instance.Agent;
                actionAttack.AttackDir = Player.Instance.transform.position - transform.position;
                actionAttack.Data      = GetComponent <AnimSetEnemyDoubleSwordsman>().GetFirstAttackAnim(E_WeaponType.Katana, E_AttackType.X);

                animComponent.HandleAction(actionAttack);
            }
            else if (random < 5)
            {
                ActionAttack actionAttack = ActionFactory.Create(ActionFactory.E_Type.E_ATTACK) as ActionAttack;
                actionAttack.Target    = Player.Instance.Agent;
                actionAttack.AttackDir = Player.Instance.transform.position - transform.position;
                actionAttack.Data      = GetComponent <AnimSetEnemyDoubleSwordsman>().GetFirstAttackAnim(E_WeaponType.Katana, E_AttackType.O);

                animComponent.HandleAction(actionAttack);
            }
            else
            {
                ActionAttackWhirl actionAttackWhirl = ActionFactory.Create(ActionFactory.E_Type.E_ATTACK_WHIRL) as ActionAttackWhirl;
                actionAttackWhirl.Data = GetComponent <AnimSetEnemyDoubleSwordsman>().GetWhirlAttackAnim();
                animComponent.HandleAction(actionAttackWhirl);
            }

            Owner.WorldState.SetWSProperty(E_PropKey.E_IDLING, false);
            Owner.Status = E_CurrentStatus.E_Attack;
        }

        if (Owner.Status == E_CurrentStatus.E_Attack && Owner.WorldState.GetWSProperty(E_PropKey.E_IDLING).GetBool())
        {
            Owner.Status = E_CurrentStatus.E_Idle;
        }

        //  如果在受伤或者格挡状态,隔0.3s回Idle
        if (Owner.Status == E_CurrentStatus.E_Injury || Owner.Status == E_CurrentStatus.E_Block)
        {
            injuryStartTime += Time.deltaTime;
        }

        if (injuryStartTime > injuryTime)
        {
            Owner.Status    = E_CurrentStatus.E_Idle;
            injuryStartTime = 0;
        }
    }