Example #1
0
    /// <summary>
    /// 瞄准目标
    /// </summary>
    private void AimTarget()
    {
        float angle = ToolsHub.GetAngleBetweenVectors(new Vector2(0, 1), ((Vector3)playerCharacterPos - transform.position).normalized);

        aimLine.transform.RotateAround(gameObject.transform.position, Vector3.forward, angle - tangle);
        tangle = angle;
        aimLine.SetActive(true);
    }
Example #2
0
    /// <summary>
    /// 触发攻击(生成箭矢)
    /// </summary>
    protected void TriggerAttack()
    {
        animator.SetBool("Attack", true);
        GameObject a = Instantiate(attacksPrefabs[0], transform.position, transform.rotation);

        a.transform.Rotate(Vector3.forward, ToolsHub.GetAngleBetweenVectors(Vector2.up, playerCharacterPos));
        a.GetComponent <ArcherArrow>().damage = baseATK;
    }
Example #3
0
    /// <summary>
    /// 触发攻击(生成攻击碰撞检测盒子等)
    /// </summary>
    protected IEnumerator TriggerAttack(float t)
    {
        yield return(new WaitForSeconds(t));

        Debug.Log(actionCastTri);
        if (actionCastTri)
        {
            //GameObject p = ChooseHitBox();
            // GameObject a = Instantiate(attacksPrefabs[0], transform.position, transform.rotation, transform);
            GameObject a     = Instantiate(attacksPrefabs[0], transform);
            float      angle = ToolsHub.GetAngleBetweenVectors(new Vector2(0, 1), Player.MyInstance.transform.position - gameObject.transform.position);
            a.transform.RotateAround(gameObject.transform.position, Vector3.forward, angle);
            //a.transform.Rotate(Vector3.forward, 45f,relativeTo:Space.World);
            a.SetActive(true);
        }
    }
Example #4
0
 private void SetPlayerDirection()
 {
     animator.SetFloat("AttackHorizontal", mouseDir.x);
     animator.SetFloat("AttackVertical", mouseDir.y);
     mouseAngle = ToolsHub.GetAngleBetweenVectors(new Vector2(0, 1), mouseDir);
 }