powerfun-unity/Assets/Scenes/Ride/Scripts/PlayerItemFactory.cs

43 lines
1.5 KiB
C#
Raw Normal View History

2021-03-29 20:32:30 +08:00
using System.Collections;
using System.Collections.Generic;
2021-04-12 17:35:56 +08:00
using System.Linq;
2021-03-29 20:32:30 +08:00
using UnityEngine;
2021-04-12 17:35:56 +08:00
using UnityEngine.Assertions;
2021-03-29 20:32:30 +08:00
namespace Assets.Scenes.Ride.Scripts
{
2021-04-12 17:35:56 +08:00
public class NearByItemFactory : MonoBehaviour
2021-03-29 20:32:30 +08:00
{
2021-04-12 17:35:56 +08:00
private GameObject nearByItem;
2021-03-29 20:32:30 +08:00
// Start is called before the first frame update
void Start()
{
2021-04-12 17:35:56 +08:00
nearByItem = Resources.Load<GameObject>("UI/Prefab/Ride/NearbyItem");
Assert.IsNotNull(nearByItem);
2021-03-29 20:32:30 +08:00
}
2021-04-12 17:35:56 +08:00
float t = 1;
2021-03-29 20:32:30 +08:00
// Update is called once per frame
void Update()
{
2021-04-12 17:35:56 +08:00
t -= Time.deltaTime;
while (t < 0)
2021-03-29 20:32:30 +08:00
{
2021-04-12 17:35:56 +08:00
//var nearList = MapUDPService.GetNearRiderData(1, 20, new double[] { playerController.Nextlatlong.x, playerController.Nextlatlong.y });
//Debug.Log(nearList.Count());
GameObject newObj; // Create GameObject instance
for (int i = 0; i < 5; i++)
{
// Create new instances of our prefab until we've created as many as we specified
newObj = (GameObject)Instantiate(nearByItem, transform);
var nearByItemscript = newObj.GetComponent<NearByItemScript>();
nearByItemscript.setName("");
nearByItemscript.setRatio("");
nearByItemscript.setSpeed("");
nearByItemscript.setHead("");
t = 1;
}
2021-03-29 20:32:30 +08:00
}
}
}
}