diff --git a/Assets/Sences/Main.unity b/Assets/Sences/Main.unity index d9598a6..5d5d330 100644 Binary files a/Assets/Sences/Main.unity and b/Assets/Sences/Main.unity differ diff --git a/Assets/Sprite/Disassemble/SightPlantController.cs b/Assets/Sprite/Disassemble/SightPlantController.cs index f6185f5..2329318 100644 --- a/Assets/Sprite/Disassemble/SightPlantController.cs +++ b/Assets/Sprite/Disassemble/SightPlantController.cs @@ -26,16 +26,20 @@ public class SightPlantController : MonoBehaviour { public static SightPlantController Instace; public OilTankType TankType; - public Transform NFDGpos; - public Transform WFDGpos; - public Transform QGpos; - public Transform GDGpos; - public Transform NFDGCanvasPos; - public Transform WFDGCanvasPos; - public Transform QGCanvasPos; - public Transform GDGCanvasPos; + //public Transform NFDGpos; + //public Transform WFDGpos; + //public Transform QGpos; + //public Transform GDGpos; + //public Transform NFDGCanvasPos; + //public Transform WFDGCanvasPos; + //public Transform QGCanvasPos; + //public Transform GDGCanvasPos; + public Transform PlantPoss; + public Transform PlantCanvasPos; public Transform plant; public Transform plantCanvas; + public Transform TankSightseeing; + public GameObject Player; void Awake() { @@ -51,30 +55,47 @@ public class SightPlantController : MonoBehaviour { } public void SetPlantAndCanvasPos() { - switch (TankType) + + Transform targetPpos = null; + Transform targetCanvasPos = null; + TankType[] posAll = PlantPoss.GetComponentsInChildren(); + for (int i = 0; i < posAll.Length; i++) { - case OilTankType.None: - break; - case OilTankType.NFDG: - plant.position = NFDGpos.position; - plantCanvas.position=NFDGCanvasPos.position; - break; - case OilTankType.WFDG: - plant.position = WFDGpos.position; - plantCanvas.position = WFDGCanvasPos.position; + if (posAll[i].OilTankType==TankType) + { + targetPpos = posAll[i].transform; break; - case OilTankType.QG: - plant.position = QGpos.position; - plantCanvas.position = QGCanvasPos.position; + } + } + TankType[] CanvasposAll = PlantCanvasPos.GetComponentsInChildren(); + for (int i = 0; i < CanvasposAll.Length; i++) + { + if (CanvasposAll[i].OilTankType == TankType) + { + targetCanvasPos = CanvasposAll[i].transform; break; - case OilTankType.GDG: - plant.position = GDGpos.position; - plantCanvas.position = GDGCanvasPos.position; + } + } + plant.position = targetPpos.position; + plantCanvas.position= targetCanvasPos.position; + plantCanvas.rotation = targetCanvasPos.rotation; + + UIShow targetUIShow = null; + UIShow[] all = TankSightseeing.GetComponentsInChildren(); + for (int i = 0; i < all.Length; i++) + { + if (all[i].oilTankType == TankType) + { + targetUIShow = all[i]; + targetUIShow.TransformPlayerShowUI(); break; - default: - break; - } - } + } + } + + Player.transform.eulerAngles = targetPpos.GetComponent().playerRotate; + Player.transform.position = targetUIShow.transform.position + Vector3.up * 0.5f; + plantCanvas.GetComponent().SetOirCanvasPos(); + } // Use this for initialization void Start () { diff --git a/Assets/Sprite/Disassemble/TankPartsInfo.cs b/Assets/Sprite/Disassemble/TankPartsInfo.cs index adaac37..66ac1be 100644 --- a/Assets/Sprite/Disassemble/TankPartsInfo.cs +++ b/Assets/Sprite/Disassemble/TankPartsInfo.cs @@ -16,8 +16,8 @@ public class TankPartsInfo : MonoBehaviour { // Use this for initialization private void Awake() { - P_PartMask mask = GetComponentInParent(); - GetPartName(transform, ""); + // P_PartMask mask = GetComponentInParent(); + // GetPartName(transform, ""); localScale = transform.localScale; disass = GetComponentsInChildren(); diff --git a/Assets/Sprite/Disassemble/TankType.cs b/Assets/Sprite/Disassemble/TankType.cs index 2e044d0..6698a8b 100644 --- a/Assets/Sprite/Disassemble/TankType.cs +++ b/Assets/Sprite/Disassemble/TankType.cs @@ -5,5 +5,8 @@ using UnityEngine; public class TankType : MonoBehaviour { public OilTankType OilTankType; - + /// + /// 传送后玩家的rotate,只有挂在在平台位置点的脚本需要设置 + /// + public Vector3 playerRotate; } diff --git a/Assets/Sprite/TankShow/UIShow.cs b/Assets/Sprite/TankShow/UIShow.cs index 878f80a..d40cf3a 100644 --- a/Assets/Sprite/TankShow/UIShow.cs +++ b/Assets/Sprite/TankShow/UIShow.cs @@ -56,7 +56,16 @@ public class UIShow : MonoBehaviour { IEnumerator waitfornext() { iscanbeenter = false; - yield return new WaitForSeconds(15f); + yield return new WaitForSeconds(10f); iscanbeenter = true; } + /// + /// 瞬移player后,显示拆解面板 + /// + public void TransformPlayerShowUI() + { + MessageDispatcher.SendMessage("InteractUI", true); + BG.gameObject.SetActive(true); + StartCoroutine(waitfornext()); + } } diff --git a/Assets/Sprite/TestSprite/HandController.cs b/Assets/Sprite/TestSprite/HandController.cs index 5998174..b9981ff 100644 --- a/Assets/Sprite/TestSprite/HandController.cs +++ b/Assets/Sprite/TestSprite/HandController.cs @@ -19,6 +19,7 @@ public class HandController : MonoBehaviour public float PlantMoveSpeed = 2; float timer; private Transform SettingPanel; + private Transform OriPlantPos; /// /// 当前交互物体,交互该物体时不可移动,比如水炮 /// @@ -26,6 +27,7 @@ public class HandController : MonoBehaviour // Use this for initialization protected virtual void Awake() { + OriPlantPos = GameObject.Find("OriPlantPos").transform; moveController = GetComponentInParent(); cte = GetComponent(); @@ -59,6 +61,7 @@ public class HandController : MonoBehaviour private void PlantStateChange(IMessage obj) { IsOnPlant = (bool)obj.Data; + OriPlantPos.position = Vector3.zero; } @@ -117,6 +120,11 @@ public class HandController : MonoBehaviour /// private void Cte_ApplicationMenuPressed(object sender, ControllerInteractionEventArgs e) { + //在拆解观测平台上不能打开菜单按钮 + if (IsOnPlant) + { + return; + } if (!SettingPanel.gameObject.activeInHierarchy) { ControllerSetting.Instace.SetMenuPanel(true); @@ -166,18 +174,31 @@ public class HandController : MonoBehaviour if (axis.x > 0) {//右移动 - - if (Plant.transform.localPosition.x > -50) + if (OriPlantPos.position.x < -50) + { + OriPlantPos.position = new Vector3(-50, OriPlantPos.position.y, OriPlantPos.position.z); + return; + } + if (OriPlantPos.position.x > -50) { Plant.transform.Translate(Vector3.left * Time.deltaTime * PlantMoveSpeed); + OriPlantPos.Translate(Vector3.left * Time.deltaTime * PlantMoveSpeed); } + } else { - if (Plant.transform.localPosition.x < 50) + if (OriPlantPos.position.x > 50) + { + OriPlantPos.position = new Vector3(50, OriPlantPos.position.y, OriPlantPos.position.z); + return; + } + if (OriPlantPos.position.x < 50) { Plant.transform.Translate(Vector3.right * Time.deltaTime * PlantMoveSpeed); + OriPlantPos.Translate(Vector3.right * Time.deltaTime * PlantMoveSpeed); } + } } else @@ -186,18 +207,32 @@ public class HandController : MonoBehaviour if (axis.y > 0) {//上移动 - if (Plant.transform.localPosition.y < 120) + if (OriPlantPos.position.y > 100) + { + OriPlantPos.position = new Vector3(OriPlantPos.position.x, 100, OriPlantPos.position.z); + return; + } + if (OriPlantPos.position.y < 100) { Plant.transform.Translate(Vector3.up * Time.deltaTime * PlantMoveSpeed); + OriPlantPos.transform.Translate(Vector3.up * Time.deltaTime * PlantMoveSpeed); } + } else {//下移动 - if (Plant.transform.localPosition.y > 0) + if (OriPlantPos.position.y < 0.5) + { + OriPlantPos.position = new Vector3(OriPlantPos.position.x, 0.5f, OriPlantPos.position.z); + return; + } + if (OriPlantPos.position.y > 0.5) { Plant.transform.Translate(Vector3.down * Time.deltaTime * PlantMoveSpeed); + OriPlantPos.transform.Translate(Vector3.down * Time.deltaTime * PlantMoveSpeed); } + } } } diff --git a/Assets/Sprite/UI/Main/SettingPanel.cs b/Assets/Sprite/UI/Main/SettingPanel.cs index d931bb2..704b73a 100644 --- a/Assets/Sprite/UI/Main/SettingPanel.cs +++ b/Assets/Sprite/UI/Main/SettingPanel.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using AX.MessageSystem; public class SettingPanel : MonoBehaviour { @@ -17,6 +18,19 @@ public class SettingPanel : MonoBehaviour { SureButton.onClick.AddListener(Sure); SpeedSlider.onValueChanged.AddListener(SpeedChange); typetoggles = GetComponentsInChildren(true); + MessageDispatcher.AddListener("GoPlant", Close); + } + + private void Close(IMessage obj) + { + bool isgo = (bool)obj.Data; + if (isgo) + { + if (gameObject.activeInHierarchy) + { + Close(); + } + } } private void Sure() @@ -24,6 +38,7 @@ public class SettingPanel : MonoBehaviour { ControllerSetting.Instace.SetMaxSpeed((int)SpeedSlider.value); ControllerSetting.Instace.SetMenuPanel(false); SetTankPos(); + transform.parent.position += Vector3.up * 50f; } private void SpeedChange(float value) @@ -44,6 +59,7 @@ public class SettingPanel : MonoBehaviour { } private void Close() { + transform.parent.position += Vector3.up * 50f; ControllerSetting.Instace.SetMenuPanel(false); } public void SetSpeedSlider() diff --git a/Assets/Sprite/UI/Main/TankCanvas.cs b/Assets/Sprite/UI/Main/TankCanvas.cs index cddf96f..e863467 100644 --- a/Assets/Sprite/UI/Main/TankCanvas.cs +++ b/Assets/Sprite/UI/Main/TankCanvas.cs @@ -15,6 +15,11 @@ public class TankCanvas : MonoBehaviour { offest = plant.transform.position - transform.position; originalpos = transform.position; } + public void SetOirCanvasPos() + { + offest = plant.transform.position - transform.position; + originalpos = transform.position; + } private void OnDestroy() { MessageDispatcher.RemoveListener("GoPlant", PlantStateChange);