2024-11-18 16:53:39 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Allother : MonoBehaviour
|
|
|
|
|
{
|
2024-11-21 00:04:33 +08:00
|
|
|
|
public List<otherWoniu> otherWonius=new List<otherWoniu>();
|
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
// public List<HouseBtn> House;//<2F><>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-21 00:04:33 +08:00
|
|
|
|
public GameObject OtherWoniuPre;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţԤ<C5A3><D4A4><EFBFBD><EFBFBD>
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public AllHouseContro allHouseContro;
|
2024-11-18 16:53:39 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
//ControWoniuToMove();
|
|
|
|
|
//StartCoroutine(WoniuToMove());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//public IEnumerator WoniuToMove()
|
|
|
|
|
//{
|
|
|
|
|
// CreateWoniu();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ
|
2024-11-18 16:53:39 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//}
|
|
|
|
|
//public async void ControWoniuToMove()
|
|
|
|
|
// {
|
|
|
|
|
// foreach (otherWoniu item in otherWonius)
|
|
|
|
|
// {
|
|
|
|
|
// await Task.Delay(1000);
|
|
|
|
|
// item.OtherWoniuMove();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţȫ<C5A3><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public void ClearAllWoniu()
|
2024-11-21 00:04:33 +08:00
|
|
|
|
{
|
2024-11-21 12:03:01 +08:00
|
|
|
|
if (otherWonius != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < otherWonius.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Destroy(otherWonius[i].gameObject);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
otherWonius.Clear();
|
2024-11-18 16:53:39 +08:00
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public void CreateWoniu()
|
2024-11-18 16:53:39 +08:00
|
|
|
|
{
|
2024-11-21 12:03:01 +08:00
|
|
|
|
foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
2024-11-18 16:53:39 +08:00
|
|
|
|
{
|
2024-11-21 12:03:01 +08:00
|
|
|
|
for (int i = 0; i < house.roomUserNo; i++)
|
2024-11-21 00:04:33 +08:00
|
|
|
|
{
|
2024-11-21 12:03:01 +08:00
|
|
|
|
// <20><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
float randomX = Random.Range(-250f, 250f); // X<>᷶Χ
|
|
|
|
|
float randomY = Random.Range(-80f, 80f); // Y<>᷶Χ
|
|
|
|
|
Vector2 randomPosition = new Vector2(randomX, randomY);
|
|
|
|
|
|
|
|
|
|
// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ
|
|
|
|
|
GameObject ot = Instantiate(OtherWoniuPre, transform);
|
|
|
|
|
ot.GetComponent<RectTransform>().anchoredPosition = randomPosition;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ţ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ
|
2024-11-21 00:04:33 +08:00
|
|
|
|
otherWonius.Add(ot.GetComponent<otherWoniu>());
|
2024-11-21 12:03:01 +08:00
|
|
|
|
ot.GetComponent<otherWoniu>().OtherWoniuMove(house); // <20>ƶ<EFBFBD><C6B6><EFBFBD>Ŀ<EFBFBD>귿<EFBFBD><EAB7BF>
|
|
|
|
|
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>" + randomPosition);
|
2024-11-21 00:04:33 +08:00
|
|
|
|
}
|
2024-11-18 16:53:39 +08:00
|
|
|
|
}
|
2024-11-21 12:03:01 +08:00
|
|
|
|
|
2024-11-18 16:53:39 +08:00
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public void startIEmove()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(IECreateWoniu());
|
|
|
|
|
}
|
|
|
|
|
public IEnumerator IECreateWoniu()
|
|
|
|
|
{
|
|
|
|
|
foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < house.roomUserNo; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
GameObject ot = Instantiate(OtherWoniuPre, transform);
|
|
|
|
|
ot.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-250, 250), Random.Range(-80, 80));
|
|
|
|
|
otherWonius.Add(ot.GetComponent<otherWoniu>());
|
|
|
|
|
ot.GetComponent<otherWoniu>().OtherWoniuMove(house);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ");
|
|
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-18 16:53:39 +08:00
|
|
|
|
}
|