2024-12-20 10:10:19 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2024-12-26 03:46:07 +08:00
|
|
|
|
using static UnityEngine.GraphicsBuffer;
|
2024-12-20 10:10:19 +08:00
|
|
|
|
|
|
|
|
|
public class Panel3 : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Button cancel;
|
|
|
|
|
private Button online;//Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
|
|
|
|
private Button follow;//<2F><><EFBFBD><EFBFBD><EFBFBD>鰴ť
|
|
|
|
|
private Dropdown dropdown;
|
|
|
|
|
private int optionCount; // <20><><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>Dropdownѡ<6E><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
2024-12-23 14:46:56 +08:00
|
|
|
|
private GameObject peopleposition;
|
2024-12-25 11:01:30 +08:00
|
|
|
|
private Camera godView;
|
2024-12-26 03:46:07 +08:00
|
|
|
|
public List<GameObject> playertarget; // <20>洢ÿ<E6B4A2><C3BF><EFBFBD><EFBFBD>ɫ
|
2024-12-25 11:01:30 +08:00
|
|
|
|
private int currentCameraIndex = -1;
|
|
|
|
|
private bool isGodView = false; // <20>Ƿ<EFBFBD><C7B7><EFBFBD>ǰΪ<C7B0>ϵ<EFBFBD><CFB5>ӽ<EFBFBD>
|
|
|
|
|
private GameObject[] players;
|
2024-12-26 03:46:07 +08:00
|
|
|
|
private Vector3 startposition = new Vector3(6, 60, -25);
|
|
|
|
|
private Vector3 startrotation = new Vector3(90, 0, -90);
|
2024-12-20 10:10:19 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
cancel=transform.Find("left/btn_enddrill").GetComponent<Button>();
|
|
|
|
|
cancel.onClick.AddListener(OnCancelBtn);
|
|
|
|
|
online=transform.Find("onlineBtn").GetComponent <Button>();
|
|
|
|
|
online.onClick.AddListener(OnClickOnlineBtn);
|
|
|
|
|
dropdown=transform.Find("left/Dropdown").GetComponent<Dropdown>();
|
|
|
|
|
follow = transform.Find("left/Follow").GetComponent<Button>();
|
|
|
|
|
follow.onClick.AddListener(FollowBtn);
|
2024-12-23 14:46:56 +08:00
|
|
|
|
peopleposition = GameObject.Find("peopleposition").gameObject;
|
2024-12-24 20:21:15 +08:00
|
|
|
|
peopleposition.SetActive(false);
|
2024-12-25 11:01:30 +08:00
|
|
|
|
godView=GameObject.Find("TopCamera").GetComponent<Camera>();
|
2024-12-26 03:46:07 +08:00
|
|
|
|
//godView.GetComponent<Camera>().orthographic = false;
|
2024-12-25 11:01:30 +08:00
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>б<EFBFBD>ǩΪ "Player" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-26 03:46:07 +08:00
|
|
|
|
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
|
2024-12-25 11:01:30 +08:00
|
|
|
|
|
|
|
|
|
foreach (GameObject player in players)
|
|
|
|
|
{
|
2024-12-26 03:46:07 +08:00
|
|
|
|
|
|
|
|
|
if (player != null)
|
2024-12-25 11:01:30 +08:00
|
|
|
|
{
|
2024-12-26 03:46:07 +08:00
|
|
|
|
playertarget.Add(player);
|
|
|
|
|
|
2024-12-25 11:01:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-26 03:46:07 +08:00
|
|
|
|
SetOptionCount(playertarget.Count);
|
2024-12-25 11:01:30 +08:00
|
|
|
|
currentCameraIndex = Panel2.instance.currentCameraIndex;
|
2024-12-25 23:37:40 +08:00
|
|
|
|
dropdown.value= currentCameraIndex;
|
2024-12-26 03:46:07 +08:00
|
|
|
|
|
2024-12-25 11:01:30 +08:00
|
|
|
|
}
|
|
|
|
|
// <20>л<EFBFBD><D0BB><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public void SwitchToCamera(int index)
|
|
|
|
|
{
|
2024-12-26 03:46:07 +08:00
|
|
|
|
if (index < 0 || index >= playertarget.Count)
|
2024-12-25 11:01:30 +08:00
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + index);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-26 03:46:07 +08:00
|
|
|
|
isGodView = false;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ target[index] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
godView.transform.SetParent(playertarget[index].transform);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD>ת
|
|
|
|
|
godView.transform.localPosition = Vector3.zero;
|
|
|
|
|
godView.transform.localRotation = Quaternion.identity;
|
2024-12-25 11:01:30 +08:00
|
|
|
|
|
2024-12-26 03:46:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
godView.transform.LookAt(playertarget[index].transform);
|
2024-12-25 11:01:30 +08:00
|
|
|
|
}
|
|
|
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ӽ<EFBFBD>
|
|
|
|
|
public void SwitchToGodView()
|
|
|
|
|
{
|
2024-12-26 03:46:07 +08:00
|
|
|
|
godView.GetComponent<Camera>().orthographic = true;
|
2024-12-25 11:01:30 +08:00
|
|
|
|
isGodView = true;
|
|
|
|
|
currentCameraIndex = -1;
|
2024-12-26 03:46:07 +08:00
|
|
|
|
godView.transform.position = startposition;
|
|
|
|
|
godView.transform.eulerAngles=startrotation;
|
2024-12-20 10:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dropdownѡ<6E><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
public void SetOptionCount(int count)
|
|
|
|
|
{
|
|
|
|
|
optionCount = count;
|
|
|
|
|
dropdown.ClearOptions();
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var options = new System.Collections.Generic.List<string>();
|
|
|
|
|
for (int i = 0; i < optionCount; i++)
|
|
|
|
|
{
|
|
|
|
|
options.Add("<22><>ɫ " + (i + 1)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><>ɫ 1"<22><>"<22><>ɫ 2"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>ɰ<EFBFBD><C9B0><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
dropdown.AddOptions(options);
|
|
|
|
|
}
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void OnCancelBtn()
|
|
|
|
|
{
|
2024-12-23 14:46:56 +08:00
|
|
|
|
peopleposition.gameObject.SetActive(true);
|
2024-12-20 10:10:19 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ӽǽ<D3BD><C7BD><EFBFBD>
|
2024-12-25 11:01:30 +08:00
|
|
|
|
SwitchToGodView();
|
|
|
|
|
// Camera.main.enabled = true;
|
2024-12-20 10:10:19 +08:00
|
|
|
|
Game.uiManager.ShowUI<Image>("Panel1_2");
|
|
|
|
|
Game.uiManager.CloseUI("Panel1_3");
|
|
|
|
|
}
|
|
|
|
|
void OnClickOnlineBtn()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Game.uiManager.ShowUI<Image>("Panel");
|
|
|
|
|
}
|
|
|
|
|
void FollowBtn()
|
|
|
|
|
{
|
2024-12-25 11:01:30 +08:00
|
|
|
|
|
2024-12-20 10:10:19 +08:00
|
|
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ɫ<EFBFBD>ӽ<EFBFBD>
|
|
|
|
|
int selectedIndex = dropdown.value;
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ" + (selectedIndex+1) + "<22>ӽ<EFBFBD>");
|
2024-12-25 11:01:30 +08:00
|
|
|
|
SwitchToCamera(selectedIndex);
|
2024-12-26 03:46:07 +08:00
|
|
|
|
//godView.GetComponent<Camera>().orthographic = false;
|
2024-12-20 10:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|