Exemplo n.º 1
0
    void PlayRotateAnim(float angleToTarget, Vector3 targetDir)
    {
        if (Agent.BlackBoard.motionType != MotionType.BLOCK)
        {
            return;
        }
        string animName;

        if (angleToTarget > 0)
        {
            if (Vector3.Dot(targetDir, Agent.Transform.right) > 0)
            {
                animName = Agent.AnimSet.GetRotateAnim(Agent.BlackBoard.motionType, RotationType.RIGHT);
            }
            else
            {
                animName = Agent.AnimSet.GetRotateAnim(Agent.BlackBoard.motionType, RotationType.LEFT);
            }
            AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.01f, QueueMode.CompleteOthers);
        }
        else
        {
            animName = Agent.AnimSet.GetBlockAnim(BlockState.HOLD, Agent.BlackBoard.weaponSelected);
            AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.01f);
        }
    }
Exemplo n.º 2
0
    protected override void Initialize(FSMEvent ev = null)
    {
        _eventRotate = ev as AnimFSMEventMoveRotate;

        _rotationProgress = 0;
        _startRotation    = Agent.Transform.rotation;
        Vector3 finalDir;

        if (_eventRotate.target != null)
        {
            finalDir = (_eventRotate.target.Position + (_eventRotate.target.BlackBoard.moveDir *
                                                        _eventRotate.target.BlackBoard.speed * 0.5f)) - Agent.Transform.position;
            finalDir.Normalize();
        }
        else if (_eventRotate.direction != Vector3.zero)
        {
            finalDir = _eventRotate.direction;
        }
        else
        {
            finalDir = Agent.Transform.forward;
        }

        _animName = Agent.AnimSet.GetMoveAnim(Agent.BlackBoard.motionType, MoveType.FORWARD,
                                              Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState);
        AnimationTools.PlayAnim(Agent.AnimEngine, _animName, 0.2f);

        _finalRotation.SetLookRotation(finalDir);
    }
Exemplo n.º 3
0
 void InitializeRoll()
 {
     _state = AttackRollState.ROLL;
     AnimationTools.PlayAnim(Agent.AnimEngine, "attackRollLoop", 0.1f);
     Agent.BlackBoard.motionType = MotionType.ROLL;
     Agent.MotionTrace.Play();
 }
Exemplo n.º 4
0
    void InitializeAttacking()
    {
        AnimationTools.PlayAnim(Agent.AnimEngine, _eventAttackMelee.animAttackData.animName, 0.2f);
        _hitTime        = Time.timeSinceLevelLoad + _eventAttackMelee.animAttackData.hitTime;
        _startPosition  = Agent.Transform.position;
        _finalPosition  = _startPosition + Agent.Transform.forward * _eventAttackMelee.animAttackData.moveDistance;
        _moveTime       = _eventAttackMelee.animAttackData.attackMoveEndTime - _eventAttackMelee.animAttackData.attackMoveStartTime;
        _endOfStateTime = Time.timeSinceLevelLoad + Agent.AnimEngine[_eventAttackMelee.animAttackData.animName].length * 0.9f;
        _eventAttackMelee.attackPhaseStart = true;

        if (_eventAttackMelee.animAttackData.lastAttackInCombo)
        {
            _attackPhaseTime = _endOfStateTime;
        }
        else
        {
            _attackPhaseTime = Time.timeSinceLevelLoad + _eventAttackMelee.animAttackData.attackEndTime;
        }

        _currentMoveTime = -_eventAttackMelee.animAttackData.attackMoveStartTime;

        if (_eventAttackMelee.target && _eventAttackMelee.target.BlackBoard.IsAlive)
        {
            HandleCamera.SlowMotion(_isCritical, _eventAttackMelee.animAttackData.isFatal);
        }
    }
Exemplo n.º 5
0
    void PlayIdleAnim()
    {
        //Debug.Log(Owner.AnimSet.GetIdleAnim(Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState).ToString());
        string name = Agent.AnimSet.GetIdleAnim(Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState);

        AnimationTools.PlayAnim(Agent.AnimEngine, name, 0.2f);
    }
Exemplo n.º 6
0
    public override bool OnEvent(FSMEvent ev)
    {
        if (ev is AnimFSMEventIdle)
        {
            (ev as AnimFSMEventIdle).IsFinished = true;
            return(true);
        }

        if (ev is AnimFSMEventShowHideSword)
        {
            if ((ev as AnimFSMEventShowHideSword).show == true)
            {
                string animName = Agent.AnimSet.GetShowWeaponAnim(Agent.BlackBoard.weaponSelected);
                _timeToFinishWeapon = Time.timeSinceLevelLoad + Agent.AnimEngine[animName].length * 0.8f;
                AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.1f);
            }
            else
            {
                string animName = Agent.AnimSet.GetHideWeaponAnim(Agent.BlackBoard.weaponSelected);
                _timeToFinishWeapon = Time.timeSinceLevelLoad + (Agent.AnimEngine[animName].length * 0.9f);
                AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.1f);
            }
            _eventSword = ev as AnimFSMEventShowHideSword;
            return(true);
        }

        return(false);
    }
Exemplo n.º 7
0
        void TransferTo(AnimationFSMState nextState)
        {
            if (_current != null && _current.onExit != null)
            {
                _current.onExit.Invoke();
            }

            _current = nextState;
            if (_current.loop == false)
            {
                _stateTime          = _current.clip.length;
                _stateCompleteTimer = Time.timeSinceLevelLoad + _stateTime;
            }
            else
            {
                _stateTime          = 0;
                _stateCompleteTimer = 0;
            }

            if (_current.onEnter != null)
            {
                _current.onEnter.Invoke();
            }

            AnimationTools.PlayAnim(_anim, _current.clip.name, 0.1f);
        }
Exemplo n.º 8
0
 private void PlayAnim(MotionType motion)
 {
     Agent.BlackBoard.motionType = motion;
     _animName = Agent.AnimSet.GetMoveAnim(Agent.BlackBoard.motionType, MoveType.FORWARD,
                                           Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState);
     AnimationTools.PlayAnim(Agent.AnimEngine, _animName, 0.2f);
 }
Exemplo n.º 9
0
 public override void Play(string clipName, float fadeTime)
 {
     if (animation == null)
     {
         return;
     }
     AnimationTools.PlayAnim(animation, clipName, fadeTime);
 }
Exemplo n.º 10
0
 void UpdateMoveType()
 {
     Agent.BlackBoard.moveType = _eventCombatMove.moveType;
     AnimationTools.PlayAnim(Agent.AnimEngine, Agent.AnimSet.GetMoveAnim(_eventCombatMove.motionType, Agent.BlackBoard.moveType,
                                                                         Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState), 0.2f);
     _maxSpeed = _eventCombatMove.motionType == MotionType.RUN ? Agent.BlackBoard.maxRunSpeed :
                 Agent.BlackBoard.maxCombatMoveSpeed;
 }
Exemplo n.º 11
0
 void InitializeStandUp()
 {
     _state = AttackRollState.STAND_UP;
     AnimationTools.PlayAnim(Agent.AnimEngine, "attackRollEnd", 0.1f);
     Agent.BlackBoard.motionType = MotionType.ROLL;
     _endOfStateTime             = Agent.AnimEngine["attackRollEnd"].length * 0.95f + Time.timeSinceLevelLoad;
     Agent.MotionTrace.Stop();
     //Agent.SoundPlay(Agent.RollSounds[2]);
 }
Exemplo n.º 12
0
    void InitializeNext(FSMEvent ev)
    {
        _eventInjury = ev as AnimFSMEventInjuryBoss;
        string animName = Agent.AnimSet.GetInjuryPhaseAnim(++_curInjuryPhaseIDX);

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.1f);
        _endOfStateTime             = Agent.AnimEngine[animName].length + Time.timeSinceLevelLoad;
        Agent.BlackBoard.motionType = MotionType.NONE;
    }
Exemplo n.º 13
0
    private void InitializeHold()
    {
        string animName = Agent.AnimSet.GetBlockAnim(BlockState.HOLD, Agent.BlackBoard.weaponSelected);

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.05f);
        _endOfStateTime = _blockHoldEndTime;

        _blockState = BlockState.HOLD;
        Agent.BlackBoard.motionType = MotionType.BLOCK;
    }
Exemplo n.º 14
0
    private void InitializeEnd()
    {
        string animName = Agent.AnimSet.GetBlockAnim(global::BlockState.END, Agent.BlackBoard.weaponSelected);

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.05f);

        _endOfStateTime             = Time.timeSinceLevelLoad + Agent.AnimEngine[animName].length * 0.9f;
        Agent.BlackBoard.motionType = MotionType.NONE;

        _blockState = BlockState.END;
    }
Exemplo n.º 15
0
 public void PlayAnim(Animation anim, string mixAnimName, float fadeInTime,
                      QueueMode queueMode = QueueMode.PlayNow)
 {
     foreach (var mixData in mixDatum)
     {
         if (mixData.newAnimationName == mixAnimName)
         {
             AnimationTools.PlayAnim(anim, mixAnimName, fadeInTime, queueMode,
                                     PlayMode.StopSameLayer /*不可以是StopAll*/);
         }
     }
 }
Exemplo n.º 16
0
    protected override void Initialize(FSMEvent ev)
    {
        _eventAttackRoll = ev as AnimFSMEventAttackRoll;

        _state = AttackRollState.PREPARE;
        AnimationTools.PlayAnim(Agent.AnimEngine, "attackRollStart", 0.4f);
        base.Initialize(_eventAttackRoll);
        Agent.BlackBoard.motionType = MotionType.NONE;
        _endOfStateTime             = Agent.AnimEngine["attackRollStart"].length * 0.95f + Time.timeSinceLevelLoad;
        _hitTimer = 0;
        UpdateFinalRotation();
        //Agent.SoundPlay(Agent.RollSounds[0]);
    }
Exemplo n.º 17
0
    protected override void Initialize(FSMEvent ev = null)
    {
        _eventRotate = ev as AnimFSMEventRotate;
        //_currentRotationTime = 0;
        _rotationProgress = 0;
        _startRotation    = Agent.Transform.rotation;
        Vector3 finalDir;

        if (_eventRotate.target != null)
        {
            finalDir = (_eventRotate.target.Position + (_eventRotate.target.BlackBoard.moveDir *
                                                        _eventRotate.target.BlackBoard.speed * 0.5f)) - Agent.Transform.position;
            finalDir.Normalize();
        }
        else if (_eventRotate.direction != Vector3.zero)
        {
            finalDir = _eventRotate.direction;
        }
        else
        {
            finalDir = Agent.Transform.forward;
        }

        if (Vector3.Dot(finalDir, Agent.Transform.right) > 0)
        {
            _animName = Agent.AnimSet.GetRotateAnim(Agent.BlackBoard.motionType, RotationType.RIGHT);
        }
        else
        {
            _animName = Agent.AnimSet.GetRotateAnim(Agent.BlackBoard.motionType, RotationType.LEFT);
        }

        AnimationTools.PlayAnim(Agent.AnimEngine, _animName, 0.01f, QueueMode.CompleteOthers);

        _finalRotation.SetLookRotation(finalDir);

        /*_rotationTime = Vector3.Angle(Agent.Transform.forward, finalDir) / (360 * Agent.BlackBoard.rotationSmooth);
         *
         * if (_rotationTime == 0)
         * {
         *  IsFinished = true;
         *  _eventRotate.IsFinished = true;
         * }
         *
         * float animLen = Agent.AnimEngine[_animName].length;
         * int multi = Mathf.CeilToInt(_rotationTime / animLen);
         *
         * _rotationTime = animLen * multi + Time.timeSinceLevelLoad;*/
    }
Exemplo n.º 18
0
    protected override void Initialize(FSMEvent ev)
    {
        _eventWhirl = ev as AnimFSMEventAttackWhirl;

        AnimationTools.PlayAnim(Agent.AnimEngine, _eventWhirl.data.animName, 0.2f);
        //UpdateFinalRotation();
        Agent.BlackBoard.motionType = MotionType.ATTACK;// MotionType.WALK;
        _rotationProgress           = 0;
        _timeToEndState             = Agent.AnimEngine[_eventWhirl.data.animName].length * 0.9f + Time.timeSinceLevelLoad;
        _hitTimer = 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 + Agent.AnimEngine[_eventWhirl.data.animName].length - 1;
    }
Exemplo n.º 19
0
    public override void OnUpdate()
    {
        if (_eventSword != null && _timeToFinishWeapon < Time.timeSinceLevelLoad) // 拔刀或者收刀完毕
        {
            Agent.BlackBoard.weaponState = _eventSword.show ? WeaponState.IN_HAND : WeaponState.NOT_IN_HANDS;
            _eventSword.IsFinished       = true;
            _eventSword         = null;
            _timeToFinishWeapon = 0;
            AnimationTools.PlayAnim(Agent.AnimEngine, Agent.AnimSet.GetIdleAnim(
                                        Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState), 0.2f); // 播放待机动作
        }

        if (Agent.IsPlayer == false)
        {
            //Owner.BlackBoard.Vigor = Owner.BlackBoard.Vigor + 0.2f;
        }
    }
Exemplo n.º 20
0
    protected override void Initialize(FSMEvent ev)
    {
        _eventAttack = ev as AnimFSMEventAttackBow;

        _startRotation = Agent.Transform.rotation;
        _eventAttack.attackPhaseDone = false;
        _fireTime = 0;

        float angle = 0;

        if (_eventAttack.target != null)
        {
            Vector3 dir = _eventAttack.target.Position - Agent.Transform.position;
            if (dir.sqrMagnitude > 0.1f * 0.1f)
            {
                dir.Normalize();
                angle = Vector3.Angle(Agent.Transform.forward, dir);
            }
            else
            {
                dir = Agent.Transform.forward;
            }

            _finalRotation.SetLookRotation(dir);
            _rotationTime = angle / 180.0f;
        }
        else
        {
            _finalRotation.SetLookRotation(_eventAttack.attackDir);
            _rotationTime = Vector3.Angle(Agent.Transform.forward, _eventAttack.attackDir) / 1040.0f;
        }

        _rotationOk      = (_rotationTime == 0);
        _curRotationTime = 0;

        _endOfStateTime = Time.timeSinceLevelLoad +
                          Mathf.Max(Agent.AnimEngine[_eventAttack.animAttackData.animName].length / Agent.AnimEngine[_eventAttack.animAttackData.animName].speed,
                                    _eventAttack.animAttackData.attackEndTime);

        _fireTime = Time.timeSinceLevelLoad + _eventAttack.animAttackData.hitTime;
        Agent.BlackBoard.motionType = MotionType.ATTACK;

        AnimationTools.PlayAnim(Agent.AnimEngine, _eventAttack.animAttackData.animName, 0.1f);
    }
Exemplo n.º 21
0
    protected override void Initialize(FSMEvent ev)
    {
        _eventRoll           = ev as AnimFSMEventRoll;
        _currentMoveTime     = 0;
        _currentRotationTime = 0;
        _startRotation       = Agent.Transform.rotation;
        _startPosition       = Agent.Transform.position;

        Vector3 finalDir;

        if (_eventRoll.toTarget != null)
        {
            finalDir = _eventRoll.toTarget.Position - Agent.Transform.position;
            finalDir.Normalize();

            _finalPosition = _eventRoll.toTarget.Position - finalDir * Agent.BlackBoard.weaponRange;
        }
        else
        {
            finalDir       = _eventRoll.direction;
            _finalPosition = _startPosition + _eventRoll.direction * Agent.BlackBoard.rollDistance;
        }

        string animName = Agent.AnimSet.GetRollAnim(Agent.BlackBoard.weaponSelected, Agent.BlackBoard.weaponState);

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.1f);

        _finalRotation.SetLookRotation(finalDir);
        _rotationTime   = Vector3.Angle(Agent.Transform.forward, finalDir) / 1000.0f;
        _moveTime       = Agent.AnimEngine[animName].length * 0.85f;
        _endOfStateTime = Agent.AnimEngine[animName].length * 0.9f + Time.timeSinceLevelLoad;

        _rotationOk = _rotationTime == 0;
        _positionOK = false;

        Agent.BlackBoard.motionType = MotionType.ROLL;

        if (Agent.BlackBoard.showMotionEffect)
        {
            ParticleTools.Instance.Play(Agent.particleSystemRollTust, Agent.gameObject.ForwardRadian(), 0f);
        }
    }
Exemplo n.º 22
0
    private void InitializeBlockFailed()
    {
        string animName = Agent.AnimSet.GetBlockAnim(BlockState.BLOCK_FAIL, Agent.BlackBoard.weaponSelected);

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.05f);

        _startRotation = Agent.Transform.rotation;
        _startPosition = Agent.Transform.position;

        Vector3 dir   = _eventBlock.attacker.Position - Agent.Transform.position;
        float   angle = 0;

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

        _finalRotation.SetLookRotation(dir);
        _finalPosition = _startPosition - dir * 2;

        _rotationTime = angle / 500.0f;
        _moveTime     = Agent.AnimEngine[animName].length * 0.8f;

        _rotationOK = _rotationTime == 0;
        _positionOK = _moveTime == 0;

        _curRotationTime = 0;
        _curMoveTime     = 0;

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.05f);

        _endOfStateTime = Time.timeSinceLevelLoad + Agent.AnimEngine[animName].length * 0.9f;

        _blockState = BlockState.BLOCK_FAIL;
        Agent.BlackBoard.motionType = MotionType.INJURY;
    }
Exemplo n.º 23
0
    protected override void Initialize(FSMEvent ev = null)
    {
        _eventBlock = ev as AnimFSMEventBlock;

        string animName = Agent.AnimSet.GetBlockAnim(BlockState.START, Agent.BlackBoard.weaponSelected);

        _startRotation = Agent.Transform.rotation;
        _startPosition = Agent.Transform.position;

        Vector3 dir   = _eventBlock.attacker.Position - Agent.Transform.position;
        float   angle = 0;

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

        _finalRotation.SetLookRotation(dir);
        _rotationTime = angle / 500.0f;
        _moveTime     = 0;

        _rotationOK = _rotationTime == 0;
        _positionOK = _moveTime == 0;

        _curRotationTime = 0;
        _curMoveTime     = 0;

        AnimationTools.PlayAnim(Agent.AnimEngine, animName, 0.05f);

        _endOfStateTime   = Time.timeSinceLevelLoad + Agent.AnimEngine[animName].length * 0.9f;
        _blockHoldEndTime = Time.timeSinceLevelLoad + _eventBlock.holdTime;
        _blockState       = BlockState.START;
    }
Exemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.A))
        {
            AnimationTools.PlayAnim(_anim, "combatMoveF", 0.2f);
            _firing = false;
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            _mixMgr.PlayAnim(_anim, "mixBowFire", 0.2f);
            _firing = true;
        }
        if (Input.GetKeyUp(KeyCode.B))
        {
            AnimationTools.PlayAnim(_anim, "idle", 2f);
            _firing = false;
        }

        if (_firing && _spine != null)
        {
            _spine.LookAt(_tar);
        }
    }