using System; using System.Collections; using System.Collections.Generic; using GameFramework.Event; using UnityEngine; public class AppTrainStudyCtrl : MonoBehaviour { private Ray _ray; private RaycastHit _raycastHit; public bool _learnTarget = false; private Dictionary _colliderList; private void Awake() { _colliderList = new Dictionary(); for (int i = 1; i < 18; i++) { _colliderList.Add((AppHardWaryType)i,this.transform.Find($"{(AppHardWaryType)i}Collider").GetComponent()); } foreach (var item in _colliderList.Values) { item.SetMeshEnable(false); } } void Start() { _learnTarget = false; GameMain.Event.Subscribe(App_StartLearnTargetInfoEvent.EventId,StartLearn); } // Update is called once per frame void Update() { if (_learnTarget) { foreach (var item in _colliderList.Values) { item.SetMeshEnable(false); } _ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(_ray,out _raycastHit)) { switch (_raycastHit.collider.gameObject.name) { case "GSECollider": _colliderList[AppHardWaryType.GSE].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.GSE)); break; case "CMDBCollider": _colliderList[AppHardWaryType.CMDB].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.CMDB)); break; case "JobCollider": _colliderList[AppHardWaryType.Job].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.Job)); break; case "PaaSCollider": _colliderList[AppHardWaryType.PaaS].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.PaaS)); break; case "BKDataCollider": _colliderList[AppHardWaryType.BKData].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.BKData)); break; case "ApptSaaSCollider": _colliderList[AppHardWaryType.ApptSaaS].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.ApptSaaS)); break; case "AppoSaaSCollider": _colliderList[AppHardWaryType.AppoSaaS].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.AppoSaaS)); break; case "LicenseCollider": _colliderList[AppHardWaryType.License].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.License)); break; case "NginxWebCollider": _colliderList[AppHardWaryType.NginxWeb].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.NginxWeb)); break; case "MySQLCollider": _colliderList[AppHardWaryType.MySQL].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.MySQL)); break; case "RedisCollider": _colliderList[AppHardWaryType.Redis].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.Redis)); break; case "ZookeeperCollider": _colliderList[AppHardWaryType.Zookeeper].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.Zookeeper)); break; case "MongoDBCollider": _colliderList[AppHardWaryType.MongoDB].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.MongoDB)); break; case "RabbitMQCollider": _colliderList[AppHardWaryType.RabbitMQ].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.RabbitMQ)); break; case "InfluxDBCollider": _colliderList[AppHardWaryType.InfluxDB].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.InfluxDB)); break; case "VirtualenvCollider": _colliderList[AppHardWaryType.Virtualenv].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.Virtualenv)); break; case "DockerCollider": _colliderList[AppHardWaryType.Docker].SetMeshEnable(true); GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.Docker)); break; default: GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.none)); break; } } else { GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.none)); } } } private void OnDestroy() { if (GameMain.Event.Check(App_StartLearnTargetInfoEvent.EventId, StartLearn)) { GameMain.Event.Unsubscribe(App_StartLearnTargetInfoEvent.EventId,StartLearn); } } private void StartLearn(object sender,GameEventArgs e) { App_StartLearnTargetInfoEvent args = (App_StartLearnTargetInfoEvent)e; _learnTarget = args.start; } private void ReStartTrain(object sender,GameEventArgs e) { foreach (var item in _colliderList.Values) { item.SetMeshEnable(false); } GameMain.Event.Fire(this, App_TrainStudyShowTargetInfoEvent.Create(AppHardWaryType.none)); } }