_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/Allother.cs

139 lines
4.0 KiB
C#
Raw Normal View History

2024-11-18 16:53:39 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
2024-11-22 09:27:28 +08:00
using static UnityEngine.UIElements.UxmlAttributeDescription;
2024-11-18 16:53:39 +08:00
public class Allother : MonoBehaviour
{
//public List<otherWoniu> otherWonius=new List<otherWoniu>();
2024-11-21 00:04:33 +08:00
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-21 00:04:33 +08:00
public List<GameObject> JiaWoniu;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µļ<C2B5><C4BC><EFBFBD>ţ
2024-11-22 09:27:28 +08:00
public Transform ReTurnPos;//<2F><><EFBFBD>ص<EFBFBD>
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-22 09:27:28 +08:00
public void Reflash()//<2F><><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>
2024-11-21 00:04:33 +08:00
{
foreach (GameObject go in JiaWoniu)
{
go.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-350, 350), Random.Range(-80, 80));
}
}
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
{
foreach (HouseBtn house in allHouseContro.HouseBtnList)
2024-11-21 12:03:01 +08:00
{
if (house.otherWonius != null)
2024-11-21 12:03:01 +08:00
{
for (int i = 0; i < house.otherWonius.Count; i++)
{
Destroy(house.otherWonius[i].gameObject);
2024-11-21 12:03:01 +08:00
}
house.otherWonius.Clear();
2024-11-21 12:03:01 +08:00
}
}
2024-11-21 00:04:33 +08:00
2024-11-18 16:53:39 +08:00
}
2024-11-21 00:04:33 +08:00
2024-11-22 09:27:28 +08:00
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ
public void KilltheWoniu(int killNo)
{
for (int i=0;i<allHouseContro.HouseBtnList.Count;i++)
{
if (allHouseContro.HouseBtnList[i].roomNo==killNo)
{
for (int j = 0; j< allHouseContro.HouseBtnList[i].otherWonius.Count; j++)
{
Destroy(allHouseContro.HouseBtnList[i].otherWonius[i].gameObject);
}
allHouseContro.HouseBtnList[i].otherWonius.Clear();
}
}
}
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
{
for (int i = 0; i < house.roomUserNo-house.otherWonius.Count; 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>Ϊ
house.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-house.otherWonius.Count; i++)
2024-11-21 12:03:01 +08:00
{
GameObject ot = Instantiate(OtherWoniuPre, transform);
ot.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-250, 250), Random.Range(-80, 0));
house.otherWonius.Add(ot.GetComponent<otherWoniu>());
2024-11-21 12:03:01 +08:00
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
}