Exemple #1
0
    void PlayMoveAnim()
    {
        E_MotionType old = Owner.BlackBoard.MotionType;

        Owner.BlackBoard.MotionType = GetMotionType();
        Owner.BlackBoard.MoveType   = GetMoveType();

        if (Owner.IsOwner)
        {
            float fov = GameCamera.Instance.DefaultFOV;
            if (old != E_MotionType.Sprint && Owner.BlackBoard.MotionType == E_MotionType.Sprint)
            {
                GameCamera.Instance.SetFov(fov * 0.9f, 60);
            }
            else if (old == E_MotionType.Sprint && Owner.BlackBoard.MotionType != E_MotionType.Sprint)
            {
                GameCamera.Instance.SetFov(fov, 60);
            }
        }

        string AnimName = Owner.AnimSet.GetMoveAnim();
        bool   playing  = Animation.IsPlaying(AnimName);

        if (!playing /*|| (!playing && force)*/)
        {
            CrossFade(AnimName, 0.28f, PlayMode.StopSameLayer);
        }
    }
Exemple #2
0
    public override void Update()
    {
        if (Action.IsActive() == false)
        {
            Release();
            return;
        }

        //角色旋转
        RotationProgress += Owner.BlackBoard.RotationSmooth * Time.deltaTime;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.Transform.rotation = q;
        //角色速度
        MaxSpeed = Mathf.Max(Owner.BlackBoard.MaxWalkSpeed, Owner.BlackBoard.MaxRunSpeed * Owner.BlackBoard.MoveSpeedModifier);
        float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime;

        Owner.BlackBoard.Speed   = Mathf.Lerp(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);
        Owner.BlackBoard.MoveDir = Owner.BlackBoard.DesiredDirection;
        //Move
        if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
        {
            Release();
        }
        //Play Animation
        E_MotionType motion = GetMotionType();

        if (Owner.BlackBoard.MotionType != motion)
        {
            PlayAnim(motion);
        }
    }
Exemple #3
0
    public void Reset()
    {
        m_ActiveActions.Clear();

        //  Stop = false;
        MotionType     = E_MotionType.None;
        WeaponState    = E_WeaponState.NotInHands;
        WeaponToSelect = E_WeaponType.None;

        Speed = 0;

        Health = MaxHealth;

        Rage      = RageMin;
        Dodge     = DodgeMin;
        Fear      = FearMin;
        IdleTimer = 0;

        MoveDir = Vector3.zero;

        DesiredPosition  = Vector3.zero;
        DesiredDirection = Vector3.zero;

        InteractionObject = null;
        Interaction       = E_InteractionType.None;

        DesiredAnimation = "";

        DesiredTarget     = null;
        DesiredAttackType = E_AttackType.None;

        DontUpdate = false;
    }
Exemple #4
0
 public override string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState)
 {
     if (weaponState == E_WeaponState.NotInHands)
     {
         return("walk");
     }
     else
     {
         if (move == E_MoveType.Forward)
         {
             return("combatMoveF");
         }
         else if (move == E_MoveType.Backward)
         {
             return("combatMoveB");
         }
         else if (move == E_MoveType.StrafeRight)
         {
             return("combatMoveR");
         }
         else
         {
             return("combatMoveL");
         }
     }
 }
Exemple #5
0
    protected void PlayAnim(E_MotionType motion)
    {
        Owner.BlackBoard.MotionType = motion;

        AnimName = Owner.AnimSet.GetMoveAnim(Owner.BlackBoard.MotionType, E_MoveType.Forward, Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState);

        CrossFade(AnimName, 0.2f);
    }
Exemple #6
0
 public override void Reset()
 {
     base.Reset();
     DistanceToMove      = 0;
     MinDistanceToTarget = 0;
     MoveType            = E_MoveType.Forward;
     MotionType          = E_MotionType.Walk;
 }
Exemple #7
0
    void PlayAnim(E_MotionType motion)
    {
        Owner.BlackBoard.MotionType = motion;
        Owner.BlackBoard.MoveType   = Action.MoveType;

        AnimName = Owner.AnimSet.GetMoveAnim();

        CrossFade(AnimName, 0.2f, PlayMode.StopSameLayer);
    }
 public override void Reset()
 {
     MoveType                = E_MoveType.Forward;
     Motion                  = E_MotionType.Run;
     LookTarget              = null;
     MinDistance             = 0.3f;
     DontChangeParameters    = false;
     UseNavMeshAgentRotation = false;
 }
    public override string GetRotateAnim(E_MotionType motionType, E_RotationType rotationType)
    {
        if (rotationType == E_RotationType.Left)
        {
            return("rotateL");
        }

        return("rotateR");
    }
Exemple #10
0
    void PlayMoveAnim(E_MotionType motion)
    {
        Owner.BlackBoard.MotionType = motion;
        Owner.BlackBoard.MoveType   = GetMoveType();

        string anim = Owner.AnimSet.GetMoveAnim();

        CrossFade(anim, 0.2f, PlayMode.StopSameLayer);
        Owner.SetDominantAnimName(anim);
    }
Exemple #11
0
    public override void Update()
    {
        //Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), Action.FinalPosition + new Vector3(0, 1, 0));

        float   dist = (Action.FinalPosition - Transform.position).sqrMagnitude;
        Vector3 dir;

        //if (Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + "Speed " + Owner.BlackBoard.Speed + " Max Speed " + Owner.BlackBoard.MaxWalkSpeed);

        if (dist < 1.5f * 1.5f)
        {
            MaxSpeed = Owner.BlackBoard.RealMaxWalkSpeed;
        }

        RotationProgress += Time.deltaTime * 12;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.Transform.rotation = q;

        /*if (Quaternion.Angle(q, FinalRotation) > 40.0f)
         * return;*/

        // Smooth the speed based on the current target direction
        float curSmooth = Owner.BlackBoard.BaseSetup.SpeedSmooth * Time.deltaTime;

        Owner.BlackBoard.Speed = Mathf.Lerp(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);

        dir   = Action.FinalPosition - Transform.position;
        dir.y = 0;
        dir.Normalize();
        Owner.BlackBoard.MoveDir = dir;

        // MOVE
        if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
        {
            Release();
        }
        else if ((Action.FinalPosition - Transform.position).sqrMagnitude < 0.3f * 0.3f)
        {
            Release();
        }
        else
        {
            E_MotionType motion = GetMotionType();

            if (motion != Owner.BlackBoard.MotionType)
            {
                PlayAnim(motion);
            }
        }
    }
Exemple #12
0
    override public void Update()
    {
        //Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), Action.FinalPosition + new Vector3(0, 1, 0));

        //if (Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + "Speed " + Owner.BlackBoard.Speed + " Max Speed " + Owner.BlackBoard.MaxWalkSpeed);
        if (Action.IsActive() == false)
        {
            Release();
            return;
        }

        RotationProgress += Time.deltaTime * Owner.BlackBoard.RotationSmooth;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.Transform.rotation = q;

        if (Quaternion.Angle(q, FinalRotation) > 40.0f)
        {
            return;
        }

        MaxSpeed = Mathf.Max(Owner.BlackBoard.MaxWalkSpeed, Owner.BlackBoard.MaxRunSpeed * Owner.BlackBoard.MoveSpeedModifier);

        //Debug.Log("Owner.BlackBoard.MaxWalkSpeed" + Owner.BlackBoard.MaxWalkSpeed);
        //Debug.Log("Owner.BlackBoard.MaxRunSpeed =" + Owner.BlackBoard.MaxRunSpeed);
        //Debug.Log("Owner.BlackBoard.MoveSpeedModifier =" + Owner.BlackBoard.MoveSpeedModifier);


        // Smooth the speed based on the current target directions
        float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime;

        Owner.BlackBoard.Speed   = Mathf.Lerp(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);
        Owner.BlackBoard.MoveDir = Owner.BlackBoard.DesiredDirection;

        //Debug.Log("Owner.BlackBoard.Speed ="+ Owner.BlackBoard.Speed);
        // MOVE
        if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
        {
            Debug.Log(Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false);
            Release();
        }

        E_MotionType motion = GetMotionType();

        if (motion != Owner.BlackBoard.MotionType)
        {
            PlayAnim(motion);
        }
    }
Exemple #13
0
    void PlayMoveAnim(bool force)
    {
        E_MotionType old = Owner.BlackBoard.MotionType;

        Owner.BlackBoard.MotionType = GetMotionType();
        Owner.BlackBoard.MoveType   = GetMoveType();

        if (Owner.IsOwner)
        {
            float fov = GameCamera.Instance.DefaultFOV;
            if (old != E_MotionType.Sprint && Owner.BlackBoard.MotionType == E_MotionType.Sprint)
            {
                GameCamera.Instance.SetFov(fov * 0.9f, 60);
            }
            else if (old == E_MotionType.Sprint && Owner.BlackBoard.MotionType != E_MotionType.Sprint)
            {
                GameCamera.Instance.SetFov(fov, 60);
            }
        }

        AnimNameBase = Owner.AnimSet.GetMoveAnim();
        bool playing = Animation.IsPlaying(AnimNameBase);

        //speed up the anim when the movement is faster and vice versa
        float mod = Owner.RunSpeedModifier;

        //clamp the max speed
        if (mod > 1)
        {
            mod = 1 + ((mod - 1) * 0.5f);
        }

        if ((Owner.BlackBoard.MotionType == E_MotionType.Run) && (Mathf.Approximately(Animation[AnimNameBase].speed, mod) == false))
        {
            Animation[AnimNameBase].speed = mod;

            if (Owner.debugAnims)
            {
                Debug.Log("Run speed changed: " + mod + ", anim=" + AnimNameBase + ", time=" + Time.timeSinceLevelLoad);
            }
        }

        //play anim
        if (!playing || (!playing && force))
        {
            CrossFade(AnimNameBase, 0.28f, PlayMode.StopSameLayer);
        }

        Owner.SetDominantAnimName(AnimNameBase);
    }
Exemple #14
0
 public override string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState)
 {
     if (E_WeaponState.NotInHands == weaponState)
     {
         if (E_MotionType.Walk == motion)
         {
             return("walk");
         }
         return("run");
     }
     if (E_MotionType.Walk == motion)
     {
         return("walkSword");
     }
     return("runSword");
 }
Exemple #15
0
    private void PlayAnim(E_MotionType motion)
    {
        Owner.BlackBoard.MotionType = motion;

        /*if (AnimName != null)
         *  AnimEngine[AnimName].speed = 1;*/

        AnimName = Owner.AnimSet.GetMoveAnim(Owner.BlackBoard.MotionType, E_MoveType.Forward, Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState);
        CrossFade(AnimName, 0.2f);

        /*
         * if(Owner.BlackBoard.MotionType == E_MotionType.Sprint)
         *  AnimEngine[AnimName].speed = 1.5f;
         * else
         *  AnimEngine[AnimName].speed = 1;*/
    }
    public override string GetRotateAnim(E_MotionType motionType, E_RotationType rotationType)
    {
        if (motionType == E_MotionType.Block)
        {
            if (rotationType == E_RotationType.Left)
            {
                return("blockStepL");
            }

            return("blockStepR");
        }

        if (rotationType == E_RotationType.Left)
        {
            return("rotationL");
        }

        return("rotationR");
    }
Exemple #17
0
    public override string GetRotateAnim(E_MotionType motionType, E_RotationType rotationType)
    {
        if (motionType == E_MotionType.Block)
        {
            if (rotationType == E_RotationType.Left)
            {
                return("rotateBlockLeft");
            }

            return("rotateBlockRight");
        }

        if (rotationType == E_RotationType.Left)
        {
            return("rotateLeft");
        }

        return("rotateRight");
    }
Exemple #18
0
    public override string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState)
    {
        if (weaponState == E_WeaponState.NotInHands)
        {
            if (motion != E_MotionType.Walk)
            {
                return("run");
            }
            else
            {
                return("walk");
            }
        }

        if (motion != E_MotionType.Walk)
        {
            return("runSword");
        }

        return("walkSword");
    }
Exemple #19
0
    public override void Execute()
    {
        if (Cmd.IsActive == false)
        {
            Release();
            return;
        }
        RotationProgress += Time.deltaTime * Owner.BlackBoard.RotationSmooth;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.Transform.rotation = q;

        if (Quaternion.Angle(q, FinalRotation) > 40.0f)
        {
            return;
        }

        MaxSpeed = Mathf.Max(Owner.BlackBoard.MaxWalkSpeed, Owner.BlackBoard.MaxRunSpeed * Owner.BlackBoard.MoveSpeedModifier);
        float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime;

        Owner.BlackBoard.Speed   = Mathf.Lerp(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);
        Owner.BlackBoard.MoveDir = Owner.BlackBoard.DesiredDirection;
        // MOVE
        if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
        {
            Release();
        }

        E_MotionType motion = GetMotionType();

        if (motion != Owner.BlackBoard.MotionType)
        {
            PlayAnim(motion);
        }
    }
Exemple #20
0
 public override string GetRotateAnim(E_MotionType motionType, E_RotationType rotationType)
 {
     return(null);
 }
Exemple #21
0
 /// <summary>
 /// Play the animation.
 /// 根据武器类型,武器状态,移动类型播放动画
 /// </summary>
 /// <param name="_motionType">_motion type.</param>
 private void PlayAnim(E_MotionType _motionType)
 {
     Owner.BlackBoard.MotionType = _motionType;
     CrossFade(Owner.AnimSet.GetMoveAnim(Owner.BlackBoard.MotionType, E_MoveType.Forward, Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState), 0.2f);
 }
Exemple #22
0
 public abstract string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState);
Exemple #23
0
 public override string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState)
 {
     throw new NotImplementedException();
 }
Exemple #24
0
 public abstract string GetRotateAnim(E_MotionType motionType, E_RotationType rotationType);
Exemple #25
0
    public void Reset()
    {
        Desires.Reset();
        ProxyDataForSpawn.Reset();

        for (int i = 0; i < m_ActiveActions.Count; i++)
        {
            ActionDone(m_ActiveActions[i]);
        }

        m_ActiveActions.Clear();

        Stop       = false;
        MotionType = E_MotionType.None;
        MoveType   = E_MoveType.None;

//		Speed = 0;	//ciphered below

        Health = RealMaxHealth;

        IdleTimer     = 0;
        CoverTime     = 0;
        Cover         = null;
        CoverPosition = E_CoverDirection.Unknown;
        CoverFire     = false;

        MoveDir = Vector3.zero;

        FireDir = Owner.Transform.forward;

        Desires.Rotation      = Owner.Transform.rotation;
        Desires.FireDirection = Owner.Transform.forward;

        InteractionObject = null;

        Invulnerable   = false;
        AbsorbedDamage = 0;
        ReactOnHits    = true;
        BusyAction     = false;
        DontUpdate     = false;
        InKnockDown    = false;
        LastInjuryTime = 0;

        KeepMotion = false;
        IsDetected = false;

        AttackersDamageData.Clear();

        //mangle values
//		Debug.Log ("SPEED 3: Reset, m_MaxRunSpeed=" + BaseSetup.m_MaxRunSpeed + ", MaxRunSpeed=" + BaseSetup.MaxRunSpeed + ", Speed=" + Speed + ", CIPHER=0x" + string.Format("{0:X}", BaseSetup.Cipher1) );

        float run_spd  = BaseSetup.MaxRunSpeed;
        float walk_spd = BaseSetup.MaxWalkSpeed;

        BaseSetup.Cipher1      = (uint)(new System.Random(Time.frameCount).Next());
        BaseSetup.MaxRunSpeed  = run_spd;        //re-assign to re-cipher with new Cipher value
        BaseSetup.MaxWalkSpeed = walk_spd;
        Speed = 0;

//		Debug.Log ("SPEED 4: Reset, m_MaxRunSpeed=" + BaseSetup.m_MaxRunSpeed + ", MaxRunSpeed=" + BaseSetup.MaxRunSpeed + ", Speed=" + Speed + ", CIPHER=0x" + string.Format("{0:X}", BaseSetup.Cipher1) );
    }
Exemple #26
0
    override public void Update()
    {
        //Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), Action.FinalPosition + new Vector3(0, 1, 0));

        float   dist = (Action.FinalPosition - Transform.position).sqrMagnitude;
        Vector3 dir;

        //if (Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + "Speed " + Owner.BlackBoard.Speed + " Max Speed " + Owner.BlackBoard.MaxWalkSpeed);

        if (Action.Motion == E_MotionType.Sprint)
        {
            if (dist < 0.5f * 0.5f)
            {
                MaxSpeed = Owner.BlackBoard.MaxWalkSpeed;
            }
        }
        else
        {
            if (dist < 1.5f * 1.5f)
            {
                MaxSpeed = Owner.BlackBoard.MaxWalkSpeed;
            }
        }


        if (Owner.BlackBoard.LookType == E_LookType.TrackTarget && Owner.BlackBoard.DesiredTarget != null)
        {
            //if (Owner.debugAnims) Debug.Log(this.ToString() + " track " + Owner.BlackBoard.LookType.ToString() + " target: " + Owner.BlackBoard.DesiredTarget.ToString());

            dir   = Owner.BlackBoard.DesiredTarget.Position - Owner.Transform.position;
            dir.y = 0;
            dir.Normalize();

            //Debug.DrawLine(OwnerTransform.position + Vector3.up, OwnerTransform.position + Vector3.up + dir * 3);

            FinalRotation.SetLookRotation(dir);
        }


        RotationProgress += Time.deltaTime * Owner.BlackBoard.RotationSmooth;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.transform.rotation = q;

        /*if (Quaternion.Angle(q, FinalRotation) > 40.0f)
         *      return;*/

        // Smooth the speed based on the current target direction

        float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime;

        Owner.BlackBoard.Speed = Mathf.Lerp(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);

        dir   = Action.FinalPosition - Transform.position;
        dir.y = 0;
        dir.Normalize();
        //Owner.BlackBoard.MoveDir = dir;

        // MOVE
        if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
        {
            Release();
        }
        else if ((Action.FinalPosition - Transform.position).sqrMagnitude < 0.3f * 0.3f)
        {
            Release();
        }
        else
        {
            E_MotionType motion = GetMotionType();

            if (motion != Owner.BlackBoard.MotionType)
            {
                PlayAnim(motion);
            }
        }
    }
 public override string GetMoveAnim(E_MotionType motion, E_MoveType move, E_WeaponType weapon, E_WeaponState weaponState)
 {
     return("walk");
 }