private Vector2 UpdateInfo(Vector2 position) { position += AITool.Patrol(body.target, body, this, body.speed); position += AITool.ApproachOrAway(body.target, body, faceDistance, body.speed, 1); body.DetectGround(); position += body.Gravity(Vector2.zero); //因为跳跃是要连续使用的函数,所以放在update中 position += AITool.Jump(body, jumpHeight); if (body.target != null) { AITool.RandomAttack(body, 5); AITool.IfLost(body.target, body, lostDistance); } return(position); }
void Update() { //Debug.Log(anim.GetFloat("Speed")); //Instantiate(bullet) horizontal = Input.GetAxis("Horizontal"); //水平方向运动 vertical = Input.GetAxis("Vertical"); //垂直方向运动 jump = Input.GetAxis("Jump"); attack = Input.GetButton("Fire1"); shieldPressed = Input.GetMouseButton(1); //点击鼠标右键 bool horizontalDown = Input.GetButtonDown("Horizontal"); Vector2 position = transform.position; // Debug.Log(" Master.currentDirection "+Master.currentDirection+" master.status "+Master.status); if (Master.status == 1) { //游戏暂停时按下任意按键后继续, //倒放后松开按键后自动进入暂停状态 if (jump > 0 || horizontalDown == true) { Master.Resume(); } } body.DetectGround(); //body.DetectWall(); Dead(); //Debug.Log(Master.currentDirection); //$$$$#$@#$@!$! //正向 if (body.tenetDirection == 1 && Master.status != 1) { if (Master.currentDirection == 0 || Master.status == 2) { //当为回放状态或者逆转方向时进行查找egg position = mController.FindEgg(body.tenetDirection); } else if (Master.status == 0 && Master.currentDirection == 1) //当全局状态为正常时才进行所有动作 { //每时每刻都有重力 // Debug.Log("还在动"); position += body.Gravity(Vector2.zero); position += UpdateInfo(); } } //$$$$#$@#$@!$! //逆向 if (body.tenetDirection == 0 && Master.status != 1) { //此部分为逆转主角所独有的. if (Master.status == 0) { //盾牌函数 Shield(); //此时表示正常的逆向主角的操作 position += body.Gravity(Vector2.zero); position += UpdateInfo(); //Debug.Log("逆转"); } else if (Master.status == 2) { //表示逆向的方向在回退 position = mController.FindEgg(body.tenetDirection); } } //Debug.Log(mController.eggList.Count); //Debug.Log(body.tenetDirection + " " + Master.currentDirection); // body.AutoStop(mController.eggList,Master.frame); //position = Input.mousePosition; rigidbody.MovePosition(position); body.AutoStop(mController.eggList, Master.frame); //Debug.Log(mController.eggList.Count); }