Example #1
0
    public void leftClick(Vector2 position)
    {
        if (skill == -1)
        {
            return;
        }
        Ray ray = mainCamera.ScreenPointToRay(position);

        RaycastHit[]     hits   = Physics.RaycastAll(ray, 200);
        List <Transform> list   = new List <Transform>();
        Vector3          tigger = Vector3.zero;

        for (int i = hits.Length - 1; i >= 0; i--)
        {
            RaycastHit item = hits[i];


            if (item.transform.gameObject.layer == LayerMask.NameToLayer("Water"))
            {
                tigger = item.point;
            }
            list.Add(item.transform);
        }

        myHero.baseSkill(skill, list.ToArray(), tigger);
        skill = -1;
    }
Example #2
0
    /// <summary>
    /// 鼠标右键
    /// </summary>
    /// <param name="position"></param>
    public void leftClick(Vector2 position)
    {
        Ray ray = Camera.main.ScreenPointToRay(position);

        RaycastHit[]     hits   = Physics.RaycastAll(ray, 200);
        List <Transform> list   = new List <Transform>();
        Vector3          tigger = Vector3.zero;

        for (int i = hits.Length - 1; i >= 0; i--)
        {
            RaycastHit item = hits[i];
            if (item.transform.gameObject.layer == LayerMask.NameToLayer("enemy"))//点击的是enenmy
            {
                PlayerCon con = item.transform.GetComponent <PlayerCon>();
                if (fight == null)
                {
                    return;
                }
                //CursorManager._instance.setAttack();
                if (Vector3.Distance(myHero.transform.position, item.transform.position) < con.data.aRange)
                {
                    //进行攻击
                    fight.applyAttack(con.data.id);
                }
                else
                {
                }
                tigger = item.point;
            }
            list.Add(item.transform);
            if (skill == -1)
            {
            }
        }
        if (skill != -1)
        {
            //技能攻击
            myHero.baseSkill(skill, list.ToArray(), tigger);
        }
        skill = -1;
    }