2024-11-30 17:43:21 +08:00
using System.Collections ;
using System.Collections.Generic ;
2024-12-24 18:51:35 +08:00
using System.Linq ;
2024-12-01 22:24:03 +08:00
using Unity.VisualScripting ;
2024-11-30 17:43:21 +08:00
using UnityEngine ;
2024-12-24 18:51:35 +08:00
using UnityEngine.Assertions.Must ;
2024-12-11 01:32:11 +08:00
using UnityEngine.Networking.Types ;
2024-11-30 17:43:21 +08:00
using UnityEngine.UI ;
public class JueseChoicePop : MonoBehaviour
{
2024-12-01 19:24:07 +08:00
public ClassMate classMate ;
public ClassItem classItem ;
2024-11-30 17:43:21 +08:00
public Button CloseBtn ;
public Button Surebtn ;
public GameObject classmatePrefab ;
public Transform content ;
2024-12-01 22:24:03 +08:00
public List < ClassMate > classMateList = new List < ClassMate > ( ) ;
2024-12-24 18:51:35 +08:00
// <20> 洢<EFBFBD> <E6B4A2> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> GameObject <20> б <EFBFBD>
private List < GameObject > instantiatedObjects = new List < GameObject > ( ) ;
2024-12-01 22:24:03 +08:00
2024-12-10 18:14:08 +08:00
public string s ;
2024-12-10 23:24:15 +08:00
public JSONReader jsonReader ;
2024-12-11 01:32:11 +08:00
public Panel panel ;
2024-12-10 18:14:08 +08:00
//Start is called before the first frame update
2024-11-30 17:43:21 +08:00
void Start ( )
{
this . gameObject . SetActive ( false ) ;
CloseBtn . onClick . AddListener ( CLosePop ) ;
Surebtn . onClick . AddListener ( CLosePop ) ;
2024-12-11 01:32:11 +08:00
//Surebtn.onClick.AddListener(SetFenguan);
2024-12-10 21:34:19 +08:00
//SetClass();
2024-12-24 18:51:35 +08:00
}
void Update ( )
{
2024-11-30 17:43:21 +08:00
}
void CLosePop ( )
{
this . gameObject . SetActive ( false ) ;
}
public void openPop ( )
{
this . gameObject . SetActive ( true ) ;
}
void SetFenguan ( )
{
//<2F> <> <EFBFBD> ô<EFBFBD> <C3B4> <EFBFBD> <EFBFBD> ֵķֹ<C4B7> <D6B9> <EFBFBD> ԱΪ<D4B1> û<EFBFBD> ѡ <EFBFBD> е Ľ<D0B5> ɫ<EFBFBD> <C9AB> <EFBFBD> <EFBFBD> ˢ<EFBFBD> ½<EFBFBD> <C2BD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
2024-12-01 19:24:07 +08:00
classItem . isSet = true ;
//classItem.setClassItem();
2024-11-30 17:43:21 +08:00
}
2024-12-24 18:51:35 +08:00
//<2F> <> <EFBFBD> طֹ<D8B7> <D6B9> <EFBFBD> Ա
public void SetClass ( int id , string scnenName )
2024-11-30 17:43:21 +08:00
{
2024-12-24 18:51:35 +08:00
Debug . LogError ( ">>>>>>>>>>>>>>>>>>>>>>>>>>" + id ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> Ѿ<EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> id <20> Ķ<EFBFBD> <C4B6> <EFBFBD>
if ( instantiatedObjects . Any ( obj = > obj . GetComponent < ClassMate > ( ) . id = = id ) )
{
Debug . Log ( $"<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> {id} <20> Ѿ<EFBFBD> <D1BE> <EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> ." ) ;
return ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
}
2024-12-11 01:32:11 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD>
foreach ( Transform child in content )
{
Destroy ( child . gameObject ) ;
}
2024-12-10 23:24:15 +08:00
// <20> <> ȡָ<C8A1> <D6B8> ID <20> <> LocationData
LocationData locationData = jsonReader . GetAreaDateById ( id ) ;
2024-12-24 18:51:35 +08:00
2024-12-10 23:24:15 +08:00
// <20> ж<EFBFBD> Oversee <20> ֶ<EFBFBD>
if ( locationData . Oversee = = "-1" )
2024-11-30 17:43:21 +08:00
{
2024-12-10 23:24:15 +08:00
Debug . Log ( $"Skipping ID {id}: Oversee is -1." ) ;
return ; // <20> <> <EFBFBD> <EFBFBD>
}
2024-12-24 18:51:35 +08:00
2024-12-10 23:24:15 +08:00
// <20> ָ<EFBFBD> Oversee <20> ֶ<EFBFBD>
string [ ] overseeParts = locationData . Oversee . Split ( ',' ) ;
2024-12-11 01:32:11 +08:00
string firstElement = overseeParts [ 0 ] ;
string lastElement = overseeParts [ 1 ] ;
2024-12-24 18:51:35 +08:00
2024-12-11 01:32:11 +08:00
if ( overseeParts . Length > 0 )
2024-12-10 23:24:15 +08:00
{
2024-12-11 01:32:11 +08:00
// <20> жϵ<D0B6> һ <EFBFBD> <D2BB> Ԫ<EFBFBD> <D4AA> <EFBFBD> Ƿ<EFBFBD> Ϊ "1"
if ( lastElement = = "1" )
2024-12-10 23:24:15 +08:00
{
2024-12-11 01:32:11 +08:00
foreach ( var pair in panel . sceneDataDictionary )
2024-12-10 23:24:15 +08:00
{
2024-12-11 01:32:11 +08:00
foreach ( var selectedInfo in pair . Value )
{
2024-12-12 15:21:07 +08:00
if ( selectedInfo . dutyId = = firstElement )
2024-12-11 01:32:11 +08:00
{
GameObject item = GameObject . Instantiate ( classmatePrefab , content ) ;
ClassMate classMate = item . GetComponent < ClassMate > ( ) ;
2024-12-24 18:51:35 +08:00
Button button = item . GetComponent < Button > ( ) ;
button . onClick . AddListener ( ( ) = > {
SetClassMate ( classMate , scnenName ) ;
} ) ;
classMate . name = selectedInfo . name ;
classMate . classmatename . text = classMate . name ;
classMate . id = id ;
// <20> <> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӵ<EFBFBD> <D3B5> б <EFBFBD> <D0B1> <EFBFBD>
instantiatedObjects . Add ( item ) ;
2024-12-11 01:32:11 +08:00
}
}
2024-12-10 23:24:15 +08:00
}
2024-12-11 01:32:11 +08:00
Debug . Log ( $"Instantiated ClassMate for ID {id} with name {locationData.Name}" ) ;
2024-12-10 23:24:15 +08:00
}
2024-11-30 17:43:21 +08:00
}
}
2024-12-24 18:51:35 +08:00
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ա<EFBFBD> <D4B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> õķ<C3B5> <C4B7> <EFBFBD>
2024-12-10 18:14:08 +08:00
public void SetClassMate ( ClassMate classMate , string a = "" )
2024-12-01 19:24:07 +08:00
{
this . classMate = classMate ;
2024-12-24 18:51:35 +08:00
this . classMate . classmatename . text = classMate . name + "(" + a + ")" ;
classMate . isBeSet = false ;
}
public void SetClassItem ( ClassItem classItem )
{
this . classItem = classItem ;
2024-12-01 22:24:03 +08:00
}
2024-11-30 17:43:21 +08:00
}