Пример #1
0
    void AttackTargetPos()
    {
        Vector3 targetPos = targetNextPos;
        Vector3 targetDir = Vector3.zero;
        Vector3 selfPos   = this.transform.position;

        Vector3 selfNewPos;
        Vector3 selfNewDir;
        //根据距离,决定不同的行动方式
        float distance1 = (targetPos - selfPos).magnitude;
        float distance2 = selfAtkRange + selfMoveRange;        //未完成,还要考虑目标的移动

        if (distance1 <= distance2)
        {
            //下回合可能攻击到目标
            GetNewPosition(targetPos, targetDir, selfPos, selfAtkRange, selfMoveRange, out selfNewPos, out selfNewDir);
        }
        else
        {
            //下回合攻击不到目标
            GetNewPosition(targetPos, selfPos, selfMoveRange, out selfNewPos, out selfNewDir);
        }

        MoveTo(selfNewPos);
        unitCtrl.DirectionChange(GetAngle(selfNewPos, targetPos));
    }
Пример #2
0
    //敌人行动
    void EnemyAction()
    {
        //敌人行动一次.
        UnitCtrl selfCtrl     = enemy;
        UnitCtrl targetCtrl   = player;
        Vector3  targetNewPos = GetNewPosition(targetCtrl.transform.position, selfCtrl.transform.position, targetCtrl.atkRange, targetCtrl.moveRange);
        Vector3  selfNewPos   = GetNewPosition(selfCtrl.transform.position, targetNewPos, selfCtrl.atkRange, selfCtrl.moveRange);

        selfCtrl.MoveTo(selfNewPos);
        selfCtrl.DirectionChange(GetAngle(selfNewPos, targetNewPos));
    }
Пример #3
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();
            }
        }
    }