示例#1
0
    void RoundPart1()
    {
        /*
         * 显示移动光标.
         * 显示移动范围
         * 隐藏攻击范围
         * 显示完成,技能按钮
         */
        BtnDisable();
        btnSkill.interactable   = true;
        btnConfirm.interactable = true;

        if (roundPart1State == 1)
        {
            //返回之前的位置
            player.transform.position = oldPosition;
            player.DirectionChange(oldDirectionAngle);

            //将移动光标定位在玩家身上
            inputCtrl.TouchSignDisplay(player.transform.position);
            //移动范围参数设置
            moveRange.transform.position = player.transform.position;
            //显示移动范围
            moveRange.SetActive(true);
            //攻击范围隐藏
            player.ATKRangeHidden();
            //开始下一步
            roundPart1State++;
        }
        else if (roundPart1State == 2)
        {
            //开始接收玩家操作
            if (inputCtrl.isTouchSign)
            {
                //开始下一步
                roundPart1State = 3;
            }
        }
        else
        {
            //根据玩家输入,调整目标位置
            if (inputCtrl.isTouchSign)
            {
                //目标位置
                Vector3 targetPos = inputCtrl.touchPosition;
                //起始位置
                Vector3 startPos = moveRange.transform.position;

                //在移动范围内,找到目标位置
                targetPos = InMoveRange(startPos, targetPos, moveDistance);
                //在场地范围内,找到目标位置
                float minX = frame1.position.x;
                float maxX = frame2.position.x;
                float minY = frame1.position.y;
                float maxY = frame2.position.y;
                targetPos.x = GetFInRange(minX, maxX, targetPos.x);
                targetPos.y = GetFInRange(minY, maxY, targetPos.y);

                //将player定位在最终位置
                player.transform.position = targetPos;
            }
            else
            {
                //隐藏移动范围
                moveRange.SetActive(false);
                //开始下一步
                roundPart1State = 1;
                RoundToNext();
            }
        }
    }