You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CarMoveOutController : MonoBehaviour
|
||
|
{
|
||
|
public List<Vector3> PosList;//已停车车位数组
|
||
|
public List<GameObject> Cars;
|
||
|
public CloneStayingAreaTool tool;
|
||
|
void Awake()
|
||
|
{
|
||
|
PosList = new List<Vector3>();
|
||
|
Cars = new List<GameObject>();
|
||
|
Debug.Log(transform.position);
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
CheckOut();
|
||
|
//test();
|
||
|
}
|
||
|
public void CheckOut()
|
||
|
{
|
||
|
if (Cars.Count > 0)
|
||
|
{
|
||
|
int index = 0;
|
||
|
|
||
|
for (;;)
|
||
|
{
|
||
|
if (Cars[index].transform.position.x > transform.position.x + 12 ||
|
||
|
Cars[index].transform.position.x < transform.position.x - 12 ||
|
||
|
Cars[index].transform.position.z > transform.position.z + 12 ||
|
||
|
Cars[index].transform.position.z < transform.position.z - 12
|
||
|
)
|
||
|
{
|
||
|
Debug.Log(Cars[index].name + "离开了!");
|
||
|
|
||
|
Cars.RemoveAt(index);
|
||
|
tool.HadPos.Add(PosList[index]);
|
||
|
PosList.RemoveAt(index);
|
||
|
|
||
|
//满车情况
|
||
|
tool.FillCarSpace();
|
||
|
return;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
index++;
|
||
|
}
|
||
|
if (index >= Cars.Count)
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
private void test()
|
||
|
{
|
||
|
if (Input.GetKeyDown(KeyCode.X))
|
||
|
{
|
||
|
foreach (var item in Cars)
|
||
|
{
|
||
|
Debug.Log(item.transform.position);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|