|
@@ -17,7 +17,7 @@ namespace Comp
|
|
|
|
|
|
private Vector3 _thrust;
|
|
|
|
|
|
- private Vector3 _rThrust = new Vector3(0, 0, -MoveSpeed);
|
|
|
+ private readonly Vector3 _rThrust = new Vector3(0, 0, -MoveSpeed);
|
|
|
|
|
|
private const float MoveSpeed = 1f;
|
|
|
|
|
@@ -37,7 +37,7 @@ namespace Comp
|
|
|
|
|
|
private Vector3 _liftPos;
|
|
|
|
|
|
- private bool _putdown = false;
|
|
|
+ private bool _isPutDown = false;
|
|
|
|
|
|
public int playerId;
|
|
|
|
|
@@ -57,42 +57,20 @@ namespace Comp
|
|
|
StartCoroutine(CockRayCast());
|
|
|
}
|
|
|
|
|
|
- private IEnumerator CockRayCast()
|
|
|
+ private IEnumerator CockRayCast() // 判断碰撞点,现在不用射线了
|
|
|
{
|
|
|
yield return new WaitForSeconds(1f);
|
|
|
- for (float i = _miniY - 2f; i <= 2f; i += 0.05f) // 多次碰撞寻找自己的cock
|
|
|
+ var actionComp = GameCore.Instance.GetCockActionCompByPlayerId(playerId);
|
|
|
+ var cockObj = actionComp.gameObject;
|
|
|
+ _cock = cockObj;
|
|
|
+ if (playerId == GameCore.Instance.localPlayer.playerId)
|
|
|
+ _collisionX = _cock.transform.position.x - 1f;
|
|
|
+ else
|
|
|
{
|
|
|
- var position = transform.position;
|
|
|
- position.y = _miniY; // 创建射线基础位置,y为脚底
|
|
|
- var ray = new Ray(position, transform.forward); // 创建前进射线
|
|
|
- if (Physics.Raycast(ray, out var hitInfo))
|
|
|
- {
|
|
|
- // 发生碰撞,处理碰撞事件
|
|
|
- Debug.Log("Hit object: " + hitInfo.collider.gameObject.name);
|
|
|
- _collisionX = hitInfo.point.x;
|
|
|
- if (hitInfo.collider.CompareTag("cock"))
|
|
|
- {
|
|
|
- var comp = hitInfo.collider.gameObject.GetComponent<CockActionComp>();
|
|
|
- if (comp.playerId != playerId)
|
|
|
- {
|
|
|
- Debug.Log("不是自己的cock");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _cock = hitInfo.collider.gameObject;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.Log("碰撞单位不是cock");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.LogWarning("无碰撞");
|
|
|
- }
|
|
|
+ _collisionX = _cock.transform.position.x + 1f;
|
|
|
}
|
|
|
+
|
|
|
+ actionComp.willBeLift = true;
|
|
|
}
|
|
|
|
|
|
private void FixedUpdate()
|
|
@@ -141,7 +119,7 @@ namespace Comp
|
|
|
|
|
|
private void OnLowest() // 抱起动画最低点回调
|
|
|
{
|
|
|
- if (!_putdown)
|
|
|
+ if (!_isPutDown)
|
|
|
{
|
|
|
_liftPos = _cock.transform.position;
|
|
|
_cock.transform.parent = transform;
|
|
@@ -158,20 +136,22 @@ namespace Comp
|
|
|
_cock.transform.localPosition = new Vector3(0, 0.9f, 0.3f);
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
StartCoroutine(PutDown());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_cock.transform.parent = GameCore.Instance.parent.transform;
|
|
|
_cock.transform.position = _liftPos;
|
|
|
- _putdown = false;
|
|
|
+ _cock.GetComponent<Rigidbody>().useGravity = true;
|
|
|
+ _isPutDown = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private IEnumerator PutDown()
|
|
|
{
|
|
|
yield return new WaitForSeconds(5f); // 5秒后放下来
|
|
|
- _putdown = true;
|
|
|
+ _isPutDown = true;
|
|
|
_masterController.PutDown();
|
|
|
}
|
|
|
}
|