summaryrefslogtreecommitdiff
path: root/Assets/Scripts/RandomSpawnPosition.cs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
commit74a4f421b436b5950e52660ba7d6ebc53a818fa5 (patch)
tree9841fb6655fee855ba581768872de2deacf57f38 /Assets/Scripts/RandomSpawnPosition.cs
parent38e3e1fa64334f9cfd2f35e21439b93f525bf1b4 (diff)
完成好多HEADmain
Diffstat (limited to 'Assets/Scripts/RandomSpawnPosition.cs')
-rw-r--r--Assets/Scripts/RandomSpawnPosition.cs30
1 files changed, 24 insertions, 6 deletions
diff --git a/Assets/Scripts/RandomSpawnPosition.cs b/Assets/Scripts/RandomSpawnPosition.cs
index cc8b92e..334d72d 100644
--- a/Assets/Scripts/RandomSpawnPosition.cs
+++ b/Assets/Scripts/RandomSpawnPosition.cs
@@ -1,16 +1,34 @@
-using System;
using UnityEngine;
-using Random = UnityEngine.Random;
public class RandomSpawnPosition : MonoBehaviour
{
- public float range = 3;
+ private PlayerMovement _playerMovement;
+
+ private void Awake()
+ {
+ _playerMovement = GetComponent<PlayerMovement>();
+ }
private void Start()
{
- var x = Random.Range(-range, range);
- var z = Random.Range(-range, range);
+ Debug.Log("等待设备输入以加入玩家...");
- transform.position = new Vector3(x,transform.position.y,z);
+ var binder = FindFirstObjectByType<GameProgressManager>();
+ if (binder.player1.bindPlayer == null)
+ {
+ binder.player1.bindPlayer = _playerMovement;
+ var targetPos = binder.player1.transform.position;
+ transform.position = targetPos;
+ Debug.Log("玩家1已加入");
+ binder.Refresh();
+ }
+ else if (binder.player2.bindPlayer == null)
+ {
+ binder.player2.bindPlayer = _playerMovement;
+ var targetPos = binder.player2.transform.position;
+ transform.position = targetPos;
+ Debug.Log("玩家2已加入");
+ binder.Refresh();
+ }
}
}