public void SetRun() { Vector2 vector2 = InputManager.GetHV(); float h = vector2.x; float v = vector2.y; if (h != 0) { //x轴方向移动 if (h < 0) { //向左 aiAttribute.SetPlayerDir(PersonDirection.Left); anim.SetInteger("Move", 3); } else {//向右 aiAttribute.SetPlayerDir(PersonDirection.Right); anim.SetInteger("Move", 4); } } else if (v != 0) { //y轴方向移动 if (v < 0) { //向上 aiAttribute.SetPlayerDir(PersonDirection.Down); anim.SetInteger("Move", 1); } else {//向下 aiAttribute.SetPlayerDir(PersonDirection.Up); anim.SetInteger("Move", 2); } } }
public void SetIdle(PersonDirection dir) { switch (dir) { case PersonDirection.Left: image.sprite = IdleLeft; dir = PersonDirection.Left; break; case PersonDirection.Right: image.sprite = IdleRight; dir = PersonDirection.Right; break; case PersonDirection.Up: image.sprite = IdleUp; dir = PersonDirection.Up; break; case PersonDirection.Down: image.sprite = IdleDown; dir = PersonDirection.Down; break; } if (name == "Player") { aiAttribute.SetPlayerDir(dir); } }