123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- using SC.XR.Unity.Module_InputSystem;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GameManager : MonoBehaviour
- {
- // Start is called before the first frame update
- public static GameManager instacne;
- public PosCommunication posCom;
- public GameObject obj_model1;
- // public GameObject obj_model2;
- public GameObject obj_model3;
- public GameObject obj_model4,scence4flooreffict;
- public GameObject obj_model5, DaoHangMap;
- public GameObject makeEneutralPanel;
- public GameObject fooldObj;//地面碰撞体
- private MakeEneutralManager makeEneutralManager;
- public GameObject gameScenes;
- public GameObject uiManager;
- public GameObject changeUIScenes4or5;
- public EnemyMessagerPanelManager enemyMessagerPanelManager_Scenes5;//跟随视野旋转 左右上下
- public EnemyMessagerPanelManager enemyMessagerPanelManager_2D;//固定位置界面
- public EnemyMessagerPanelManager enemyMessagerPanelManager_3D;//跟随视野旋转,左右 不上下
- public string scenesName;
- public GameObject gamescence;
- public GameObject []scence3button;
- public GameObject[] scence4or5button;
-
- Vector3 scence4localposoffset;//scence4与眼镜差值
- public bool scence5Iscollision = false;//false 没有发生碰撞满足生成敌人条件,true为发生碰撞不满足生成敌人条件
- public float gpsPosInitx ; //367183;// 初始限定的位置 用于全局性质的坐标修改 并用于标定 地图的0,0点
- public float gpsPosInitz ;//3457939;
- public GameObject PointToNorth;//指北针
- public GameObject map3D;// 3d地图 总级
- public GameObject map3DParent;//新的 3d地图 父级
- public TextMesh delayText; // 右上角延迟显示(暂时先放这里 D)
- public Manage navManage;
- private void Awake()
- {
- // Debug.Log("位置X" + gpsPosInitx + "原始位置Z++++++++++++++++" +gpsPosInitz);
- instacne = this;
- posCom = this.GetComponent<PosCommunication>();
- makeEneutralManager = makeEneutralPanel.GetComponent<MakeEneutralManager>();
- }
- private void Start()
- {
- gpsPosInitx = 0;
- gpsPosInitz = 0;
- DispatcherBase.KeyDownDelegateRegister(PartAnyKeyEventDelegate);//点击,出现预支体
- //makeEneutralPanel.transform.parent = SvrManager.Instance.head.transform;
- //makeEneutralManager.handRot.transform.parent = SvrManager.Instance.head.transform;
- //makeEneutralPanel.transform.rotation = Quaternion.Euler(0, 0, 0);
- //makeEneutralManager.handRot.transform.rotation = Quaternion.Euler(0, 0, 0);
- //makeEneutralPanel.SetActive(false);
- changeUIScenes4or5.SetActive(false);
-
- scence4localposoffset = SvrManager.Instance.head.transform.position - obj_model4.transform.position;
-
- NorthTheparentPos();
- }
- /// <summary>
- /// 将指北针放入小地图
- /// </summary>
- private void NorthTheparentPos()
- {
- PointToNorth.gameObject.SetActive(true);
- PointToNorth.transform.parent = DaoHangMap.transform.Find("huan").gameObject.transform;
- PointToNorth.transform.localPosition = new Vector3(0, 0, 0);
- PointToNorth.transform.localEulerAngles = new Vector3(0,0,0);
- }
- private void MoveMap3DPos(float moveX,float moveY,float moveZ)//对3D模式地图进行位移
- {
- map3D.transform.localPosition = new Vector3(moveX, moveY, moveZ);
- }
- private void Update()
- {
- //Debug.Log(posCom.dataPlayerAttributesList.Count);
-
- for (int i = 0; i < posCom.dataPlayerAttributesListOne.Count; i++)
- {
- if (posCom.dataPlayerAttributesListOne[i].data.message.data2.id.Contains(posCom.dataPAOne.data.message.data2.id))
- {
- posCom.dataPlayerAttributesListOne[i] = posCom.dataPAOne;
- }
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().action = posCom.dataPlayerAttributesListOne[i].data.message.data2.action;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().id = posCom.dataPlayerAttributesListOne[i].data.message.data2.id;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().des = posCom.dataPlayerAttributesListOne[i].data.message.data2.des;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().pos = posCom.dataPlayerAttributesListOne[i].data.message.data2.pos;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().eul = posCom.dataPlayerAttributesListOne[i].data.message.data2.eul;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().typeOfWork = posCom.dataPlayerAttributesListOne[i].data.message.data2.typeOfWork;
- posCom.playerTypeOfWorksList[i].GetComponent<MiniMapFit>().thisCurrentMinMapFitIndex = PosCommunication.currentMinMapFitIndex;
- }
- // Debug.Log(posCom.dataPlayerAttributesList.Count);
- //for (int i = 0; i < posCom.dataPlayerAttributesList.Count; i++)
- //{
- // Debug.Log(posCom.dataPlayerAttributesList[i].data.message.dataEnemy.Count);
- // Debug.Log(posCom.dataPA.data.message.dataEnemy.Count);
- // if (posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].id.Contains(posCom.dataPA.data.message.dataEnemy[i].id))
- // {
- // posCom.dataPlayerAttributesList[i] = posCom.dataPA;
- // }
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().action = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].action;
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().id = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].id;
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().des = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].des;
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().pos = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].pos;
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().eul = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].eul;
- // posCom.playerMakeTypeOfWorksList[i].GetComponent<MiniMapFit>().typeOfWork = posCom.dataPlayerAttributesList[i].data.message.dataEnemy[i].typeOfWork;
- //}
- }
- private void LateUpdate()
- {
- Vector3 Posrotate = new Vector3(0,0 - SvrManager.Instance.head.localEulerAngles.y, 0);//指北针旋转
-
- PointToNorth.transform.localEulerAngles = Posrotate;
- // Debug.Log("指北针旋转++++++++++++" + Posrotate.y);
- }
- public void UserClick(string ButtonName)
- {
-
- switch (ButtonName)
- {
- case "button_To1":
- obj_model1.transform.GetChild(0).gameObject.GetComponent<Animator>().SetBool("M1", true);
- Invoke("obj_modle2true", 3.5f);
- break;
- case "OpenScence3":
- ButtonBoxManage(0);
-
- if (obj_model5.activeInHierarchy == false && obj_model4.activeInHierarchy == false)
- {
- obj_model3.SetActive(true);
-
- obj_model4.transform.Find("地形_大").gameObject.GetComponent<Animator>().SetBool("M3", true);
- }
- if (obj_model5.activeInHierarchy == false || obj_model4.activeInHierarchy == false)
- {
-
- DaoHangMap.SetActive(false);
- obj_model5.SetActive(false);
- obj_model4.transform.Find("地形_大").gameObject.GetComponent<Animator>().SetBool("M3", true);
- }
- scenesName = "scenes3";
- ScencesIntheGameScence("Scenes3_2D");//将3D场景放入gamescence中
-
- Invoke("obj_model3true", 2f);
- changeUIScenes4or5.SetActive(false);
- enemyMessagerPanelManager_3D.Init();
- enemyMessagerPanelManager_Scenes5.Init();
- break;
- case "OpenScence4":
- scenesName = "scenes4";
- ButtonBoxManage(1);
- if (obj_model5.activeInHierarchy==false&& obj_model3.activeInHierarchy == false)
- {
- obj_model4.SetActive(true);
-
- }
- if (obj_model5.activeInHierarchy == false || obj_model3.activeInHierarchy == false)
- {
- DaoHangMap.SetActive(false);
- obj_model5.SetActive(false);
-
- obj_model3.transform.GetChild(0).gameObject.GetComponent<Animator>().SetBool("M2", true);
- }
- // ScencesIntheGameScence("Scenes4_3D");//将4场景放入gamescence中
-
- Invoke("obj_model4ture", 2.7f);
- enemyMessagerPanelManager_2D.Init();
- enemyMessagerPanelManager_Scenes5.Init();
- navManage.move.CloseAllLine();
- break;
- case "OpenScence5":
- scenesName = "scenes5";
- ButtonBoxManage(2);
- obj_model4.transform.Find("地形_大").gameObject.GetComponent<Animator>().SetBool("M3", true);
- obj_model3.transform.GetChild(0).gameObject.GetComponent<Animator>().SetBool("M2", true);
- Invoke("obj_model5true", 2.7f);
- enemyMessagerPanelManager_2D.Init();
- enemyMessagerPanelManager_3D.Init();
- navManage.move.CloseAllLine();
- break;
- //case "Scence5ToScence3":
- // obj_model5.SetActive(false);
- // obj_model3.SetActive(true);
- // DaoHangMap.SetActive(false);
- // fooldObj.gameObject.SetActive(false);
-
- // break;
- case "ButtonFooldPanle":
- //float handrot = SvrManager.Instance.head.transform.localEulerAngles.y;
- //float gamesScenesRot = uiManager.transform.transform.localEulerAngles.y;
- //float makePanelRot = handrot - gamesScenesRot;
- // makeEneutralPanel.transform.parent = uiManager.transform;
- //makeEneutralPanel.transform.position = new Vector3(makeEneutralPanel.transform.position.x, 0.06f, makeEneutralPanel.transform.position.z);
- //makeEneutralPanel.transform.localRotation = Quaternion.Euler(0, makePanelRot, 0);
- // fooldObj.GetComponent<BoxCollider>().enabled = false;
-
- makeEneutralPanel.gameObject.SetActive(true);
- Vector3 linePosition = SvrManager.Instance.head.transform.position;// inputDevicePartUIBase.modelBase.lineIndicate.StartPoint.transform.position;
- Vector3 lineForward = SvrManager.Instance.head.transform.forward;// part.inputDevicePartUIBase.modelBase.lineIndicate.StartPoint.transform.forward;
- Vector3 worldPosition = linePosition + (lineForward * 0.5f);
- makeEneutralPanel.transform.position = new Vector3(worldPosition.x, worldPosition.y, worldPosition.z);
-
- makeEneutralPanel.transform.rotation = Quaternion.Euler(0, scence3followPos.transform.parent.transform.eulerAngles.y, 0);
- break;
- case "UserEnterFoold":
- fooldObj.GetComponent<MeshRenderer>().material.SetFloat("_Brightness", 0f);
- break;
- case "UserEixtFoold":
- fooldObj.GetComponent<MeshRenderer>().material.SetFloat("_Brightness", 0f);
- break;
- }
- }
- /// <summary>
- /// scence1切换到场景scences3
- /// </summary>
- public void obj_modle2true()
- {
- obj_model1.SetActive(false);
- obj_model3.SetActive(true);
- }
- /// <summary>
- /// 打开Scence4
- /// </summary>
- public void obj_model4ture()
- {
- ScencesIntheGlasse("Scenes3_2D");//场景2放入眼镜下
- obj_model3.SetActive(false);
- scence4flooreffict.SetActive(true);
- obj_model4.SetActive(true);
- changeUIScenes4or5.SetActive(true);
- Invoke("Falsescence4Floor", 2.7f);
- MapDaoHangShowOrHeid(false);
- }
- private void Falsescence4Floor()
- {
- scence4flooreffict.gameObject.SetActive(false);
- }
- /// <summary>
- ///打开Scence3
- /// </summary>
- public void obj_model3true()
- {
- // ScencesIntheGlasse("Scenes4_3D");//场景2放入眼镜下
- // XieTongButton.gameObject.SetActive(true);
- obj_model3.SetActive(true);
-
- obj_model4.SetActive(false);
- obj_model5.SetActive(false);
- MapDaoHangShowOrHeid(false);
- }
- /// <summary>
- /// 打开Scence5
- /// </summary>
- public void obj_model5true()
- {
- ScencesIntheGlasse("Scenes3_2D");//场景2放入眼镜下
- //ScencesIntheGlasse("Scenes4_3D");//场景2放入眼镜下
- obj_model3.SetActive(false);
- obj_model4.SetActive(false);
- obj_model5.SetActive(true);
- MapDaoHangShowOrHeid(true);
- //fooldObj.SetActive(true);
- // fooldObj.GetComponent<MeshRenderer>().material.SetFloat("_Brightness", 0f);
- changeUIScenes4or5.SetActive(true);
- }
- public void MapDaoHangShowOrHeid(bool isB)
- {
- if(isB)
- {
- DaoHangMap.SetActive(true);
-
- }
- else
- {
- DaoHangMap.SetActive(false);
-
-
- }
- }
- /// <summary>
- /// 将地形场景放入眼镜下
- /// </summary>
- public void ScencesIntheGlasse(string Scence)
- {
-
- switch (Scence)
- {
- case "Scenes3_2D":
- obj_model3.transform.parent = SvrManager.Instance.head.transform;
-
- Invoke("objmodle3dely", 2.7f);
- break;
- case "Scenes4_3D":
-
- //obj_model4.transform.parent = SvrManager.Instance.head.transform;
- ////obj_model4.transform.localPosition = new Vector3(0.58f, -1.51f, 0.12f);//赋予差值的位置
- ////obj_model4.transform.localRotation = Quaternion.Euler(90f, 180f, 0f);
- //Invoke("objmodle4dely", 2.7f);
- break;
- }
-
- }
- public void objmodle3dely()
- {
- // obj_model3.transform.localPosition = new Vector3(0.02f, -0.88f, 1.786f);//赋予差值的位置
- obj_model3.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
- }
- public void objmodle4dely()
- {
-
- obj_model4.transform.localPosition = new Vector3(0.58f, -1.51f, 0.12f);//赋予差值的位置
- obj_model4.transform.localRotation = Quaternion.Euler(90f, 180f, 0f);
- }
- public GameObject scence3followPos;
- /// <summary>
- /// 将地形场景放入Gamescence下
- /// </summary>
- public void ScencesIntheGameScence(string Scence)
- {
- switch (Scence)
- {
- case "Scenes3_2D":
- obj_model3.transform.parent = gamescence.transform;
- obj_model3.transform.position = scence3followPos.transform.position;
- // Debug.Log(scence3followPos.transform.localPosition + "旋转度");
- obj_model3.transform.localRotation = Quaternion.Euler(0, obj_model3.transform.localEulerAngles.y, 0);
- break;
- // case "Scenes4_3D":
- //obj_model4.transform.localPosition = new Vector3(obj_model4.transform.localPosition.x, obj_model4.transform.localPosition.y, 0.12f);
- // obj_model4.transform.parent = gamescence.transform;
- //obj_model4.transform.localPosition = new Vector3(obj_model4.transform.position.x, -1.7f, obj_model4.transform.position.z);
- //obj_model4.transform.localRotation = Quaternion.Euler(90, obj_model4.transform.localEulerAngles.y, 0);
- // break;
- }
- }
- public void ButtonBoxManage(int Num)
- {
- for (int i = 0; i < scence3button.Length; i++)
- {
- if (Num==i)
- {
- scence3button[i].gameObject.GetComponent<BoxCollider>().enabled = false;
- }
- else
- {
- scence3button[i].gameObject.GetComponent<BoxCollider>().enabled = true;
- }
- }
- for (int i = 0; i < scence4or5button.Length; i++)
- {
- if (Num == i)
- {
- scence4or5button[i].gameObject.GetComponent<BoxCollider>().enabled = false;
- }
- else
- {
- scence4or5button[i].gameObject.GetComponent<BoxCollider>().enabled = true;
- }
- }
-
- }
- int size = 0;
-
-
- void PartAnyKeyEventDelegate(InputKeyCode keyCode, InputDevicePartBase part)
- {
- // Debug.Log("条件++++++++++++++++++++++++scence5Iscollision=" + scence5Iscollision);
- if (scenesName == "scenes5"&& scence5Iscollision==false)
- {
- Debug.Log("david key down");
- UserClick("ButtonFooldPanle");
- }
- else
- {
- //GameObject go = Resources.Load("Cubess") as GameObject;
- //Instantiate(go, new Vector3(3, 1f, 0), Quaternion.identity);
- }
- }
- void OnDestory()
- {
- DispatcherBase.KeyDownDelegateUnRegister(PartAnyKeyEventDelegate);
- }
- /// <summary>
- /// 满足显示制造敌人面板条件(将方法挂在切换场景按钮上)
- /// </summary>
- public void PremiseconditionEenemy()
- {
- scence5Iscollision = false;
- }
- /// <summary>
- /// 不满足显示创造敌人面板条件
- /// </summary>
- public void UnPremiseconditionEenemy()
- {
- scence5Iscollision = true;
- }
-
- }
|