コード例 #1
0
    public bool Turn(float flAngle, float flSpeed)
    {
        flAngle = GameMath.ClampAngle(flAngle, 0f, 360f);
        float dir = this.GetDir();

        if (Mathf.Abs(dir - flAngle) < 1f)
        {
            return(true);
        }
        float num  = Time.deltaTime * flSpeed;
        float num2 = flAngle - dir;

        if (Mathf.Abs(num2) > 180f)
        {
            if (dir < flAngle)
            {
                num2 = -360f - dir + flAngle;
            }
            else
            {
                num2 = 360f - dir + flAngle;
            }
        }
        if (num > Mathf.Abs(num2))
        {
            num = Mathf.Abs(num2);
        }
        if (num2 < 0f)
        {
            num = -num;
        }
        this.SetDir(GameMath.ClampAngle(360f + dir + num, 0f, 360f));
        return(false);
    }
コード例 #2
0
    public bool SmoothTurn(float flAngle, float flSpeed)
    {
        flAngle = GameMath.ClampAngle(flAngle, 0f, 360f);
        float dir   = this.GetDir();
        float angle = GameMath.LerpAngle(dir, flAngle, Time.deltaTime * flSpeed);

        this.SetDir(GameMath.ClampAngle(angle, 0f, 360f));
        return(Mathf.Abs(dir - flAngle) < 1f);
    }
コード例 #3
0
 public void SetTurn(float flAngle, float flSpeed)
 {
     this.TurnRole    = false;
     this.m_TurnAngle = GameMath.ClampAngle(flAngle, 0f, 360f);
     this.m_TurnSpeed = flSpeed;
     if (0f == this.m_TurnSpeed)
     {
         this.SetDir(this.m_TurnAngle);
     }
     else
     {
         this.TurnRole = true;
     }
     if (this.m_TurnMotion > 0)
     {
         if (this.m_RoleMotion != null)
         {
             this.m_RoleMotion.SetMotion(this.m_TurnMotion);
         }
         this.m_TurnMotion = 0;
     }
 }
コード例 #4
0
    public void SetTurn(Vector3 pos, float flSpeed)
    {
        this.TurnRole = false;
        float angle = GameMath.GetAngle(this.GetPos(), pos);

        this.m_TurnAngle = GameMath.ClampAngle(angle, 0f, 360f);
        this.m_TurnSpeed = flSpeed;
        if (0f == this.m_TurnSpeed)
        {
            this.SetDir(this.m_TurnAngle);
        }
        else
        {
            this.TurnRole = true;
        }
        if (this.m_TurnMotion > 0)
        {
            if (this.m_RoleMotion != null)
            {
                this.m_RoleMotion.SetMotion(this.m_TurnMotion);
            }
            this.m_TurnMotion = 0;
        }
    }