2024-11-22 12:15:36 +08:00
|
|
|
|
using DG.Tweening;
|
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
|
|
|
|
|
{
|
2024-11-22 12:15:36 +08:00
|
|
|
|
public List<otherWoniu> otherWonius;
|
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
|
|
|
|
|
2024-11-21 17:27:26 +08:00
|
|
|
|
public List<GameObject> JiaWoniu;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µļ<C2B5><C4BC><EFBFBD>ţ
|
2024-11-22 12:15:36 +08:00
|
|
|
|
private List<GameObject> hiddenSnails = new List<GameObject>(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼δ<C2BC><CEB4>ʾ<EFBFBD><CABE><EFBFBD><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
|
|
|
|
//}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
//public async void ControWoniuToMove()
|
|
|
|
|
// {
|
|
|
|
|
// foreach (otherWoniu item in otherWonius)
|
|
|
|
|
// {
|
|
|
|
|
// await Task.Delay(1000);
|
|
|
|
|
// item.OtherWoniuMove();
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-11-22 09:27:28 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
public void HideJiaWoniu()
|
|
|
|
|
{
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>δ<EFBFBD><CEB4>ʾ<EFBFBD>б<EFBFBD>
|
|
|
|
|
foreach (GameObject go in JiaWoniu)
|
|
|
|
|
{
|
|
|
|
|
go.SetActive(false);
|
|
|
|
|
hiddenSnails.Add(go);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-22 09:27:28 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
public void Reflash() // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ţ
|
2024-11-21 00:04:33 +08:00
|
|
|
|
{
|
2024-11-22 12:15:36 +08:00
|
|
|
|
if (hiddenSnails.Count == 0)
|
2024-11-21 17:27:26 +08:00
|
|
|
|
{
|
2024-11-25 14:37:44 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD>м<EFBFBD><D0BC><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>");
|
2024-11-22 12:15:36 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<CABE><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><> 3 <20><><EFBFBD><EFBFBD>
|
|
|
|
|
int numToShow = Random.Range(1, Mathf.Min(4, hiddenSnails.Count + 1));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numToShow; i++)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB>δ<EFBFBD><CEB4>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ţ
|
|
|
|
|
int randomIndex = Random.Range(0, hiddenSnails.Count);
|
|
|
|
|
GameObject snail = hiddenSnails[randomIndex];
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
snail.GetComponent<RectTransform>().anchoredPosition = new Vector2(
|
|
|
|
|
Random.Range(-350, 550),
|
|
|
|
|
Random.Range(0, 40)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// <20><>ʾ<EFBFBD><CABE>ţ
|
|
|
|
|
snail.SetActive(true);
|
|
|
|
|
|
|
|
|
|
// <20><>δ<EFBFBD><CEB4>ʾ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
hiddenSnails.RemoveAt(randomIndex);
|
2024-11-21 17:27:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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 17:27:26 +08:00
|
|
|
|
foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
2024-11-21 12:03:01 +08:00
|
|
|
|
{
|
2024-11-21 17:27:26 +08:00
|
|
|
|
if (house.otherWonius != null)
|
2024-11-21 12:03:01 +08:00
|
|
|
|
{
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
2024-11-21 17:27:26 +08:00
|
|
|
|
house.otherWonius.Clear();
|
2024-11-21 12:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
|
|
|
|
for (int i=0;i<otherWonius.Count;i++)
|
|
|
|
|
{
|
|
|
|
|
if (otherWonius[i] != null)
|
|
|
|
|
{
|
|
|
|
|
DOTween.Kill(otherWonius[i].gameObject);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Destroy(otherWonius[i].gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
otherWonius.Clear();
|
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++)
|
|
|
|
|
{
|
2024-11-22 12:15:36 +08:00
|
|
|
|
if (allHouseContro.HouseBtnList[i].otherWonius[j].gameObject!=null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Destroy(allHouseContro.HouseBtnList[i].otherWonius[j].gameObject);
|
2024-11-22 09:27:28 +08:00
|
|
|
|
}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
2024-11-22 09:27:28 +08:00
|
|
|
|
allHouseContro.HouseBtnList[i].otherWonius.Clear();
|
|
|
|
|
}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
2024-11-22 09:27:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 09:49:32 +08:00
|
|
|
|
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
2024-11-22 12:15:36 +08:00
|
|
|
|
public IEnumerator ReturnstartPos(int roomNo)
|
2024-11-22 09:49:32 +08:00
|
|
|
|
{
|
2024-11-22 12:15:36 +08:00
|
|
|
|
allHouseContro.ControAllDoorOpen();
|
2024-11-22 09:49:32 +08:00
|
|
|
|
for (int i = 0; i < allHouseContro.HouseBtnList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (allHouseContro.HouseBtnList[i].roomNo == roomNo)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < allHouseContro.HouseBtnList[i].otherWonius.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
allHouseContro.HouseBtnList[i].otherWonius[j].GetComponent<OtherMove>().EndPos = ReTurnPos;
|
2024-11-22 12:15:36 +08:00
|
|
|
|
allHouseContro.HouseBtnList[i].otherWonius[j].GetComponent<OtherMove>().ReTurnStartPosMove();
|
|
|
|
|
yield return new WaitForSeconds(0.3f);
|
2024-11-22 09:49:32 +08:00
|
|
|
|
}
|
|
|
|
|
allHouseContro.HouseBtnList[i].otherWonius.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-11-22 09:27:28 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
//public void CreateWoniu()
|
|
|
|
|
//{
|
|
|
|
|
// foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
|
|
|
|
// {
|
|
|
|
|
// for (int i = 0; i < house.roomUserNo-house.otherWonius.Count; i++)
|
|
|
|
|
// {
|
2024-11-21 17:27:26 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +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);
|
2024-11-21 12:03:01 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ
|
|
|
|
|
// GameObject ot = Instantiate(OtherWoniuPre, transform);
|
|
|
|
|
// ot.GetComponent<RectTransform>().anchoredPosition = randomPosition;
|
2024-11-21 12:03:01 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// // <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ţ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ
|
2024-11-21 17:27:26 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// house.otherWonius.Add(ot.GetComponent<otherWoniu>());
|
|
|
|
|
|
|
|
|
|
// ot.GetComponent<otherWoniu>().OtherWoniuMove(house); // <20>ƶ<EFBFBD><C6B6><EFBFBD>Ŀ<EFBFBD>귿<EFBFBD><EAB7BF>
|
2024-11-21 12:03:01 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>" + randomPosition);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-11-21 12:03:01 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
//}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public void startIEmove()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(IECreateWoniu());
|
2024-11-22 12:15:36 +08:00
|
|
|
|
Reflash();
|
2024-11-21 12:03:01 +08:00
|
|
|
|
}
|
|
|
|
|
public IEnumerator IECreateWoniu()
|
|
|
|
|
{
|
|
|
|
|
foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
|
|
|
|
{
|
2024-11-21 17:27:26 +08:00
|
|
|
|
for (int i = 0; i < house.roomUserNo-house.otherWonius.Count; i++)
|
2024-11-21 12:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
GameObject ot = Instantiate(OtherWoniuPre, transform);
|
2024-11-21 17:27:26 +08:00
|
|
|
|
ot.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-250, 250), Random.Range(-80, 0));
|
|
|
|
|
house.otherWonius.Add(ot.GetComponent<otherWoniu>());
|
2024-11-22 12:15:36 +08:00
|
|
|
|
otherWonius.Add(ot.GetComponent<otherWoniu>());
|
2024-11-21 12:03:01 +08:00
|
|
|
|
ot.GetComponent<otherWoniu>().OtherWoniuMove(house);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
2024-11-25 14:37:44 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ");
|
2024-11-21 12:03:01 +08:00
|
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-18 16:53:39 +08:00
|
|
|
|
}
|