diff --git a/TheStrongestSnail/Assets/Resources/otherWoniu.prefab b/TheStrongestSnail/Assets/Resources/otherWoniu.prefab index 6c19c7b..3904891 100644 --- a/TheStrongestSnail/Assets/Resources/otherWoniu.prefab +++ b/TheStrongestSnail/Assets/Resources/otherWoniu.prefab @@ -12,9 +12,9 @@ GameObject: - component: {fileID: 4217838679404656789} - component: {fileID: 4217838679404656794} - component: {fileID: 4217838679404656795} - - component: {fileID: 4217838679404656792} - component: {fileID: 4217838679404656793} - component: {fileID: 4217838679404656788} + - component: {fileID: -9060203016143469754} m_Layer: 5 m_Name: otherWoniu m_TagString: Untagged @@ -101,60 +101,6 @@ MonoBehaviour: PlayAni: {fileID: 4217838679404656793} IsLeft: 0 HouseId: 0 ---- !u!114 &4217838679404656792 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4217838679404656796} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a691aaaa3074ac4d823aa67ebc1b2b0, type: 3} - m_Name: - m_EditorClassIdentifier: - objectToMove: {fileID: 4217838679404656799} - pathPoints: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - duration: 5 - isLooping: 0 - room_id: - Speed: 5 - EndPos: {fileID: 0} - TypeEndPos0: {fileID: 0} - TypeEndPos1: {fileID: 0} - TypeEndPos2: {fileID: 0} - TypeEndPos3: {fileID: 0} - TypeEndPos4: {fileID: 0} - TypeEndPos5: {fileID: 0} - TypeEndPos6: {fileID: 0} - JumpPos: {fileID: 0} - Pos1Parent: {fileID: 0} - Pos2Parent: {fileID: 0} - Pos3Parent: {fileID: 0} - Pos4Parent: {fileID: 0} - Pos5Parent: {fileID: 0} - Pos6Parent: {fileID: 0} - OutParent: {fileID: 0} - ReturnPos: {fileID: 0} - IsBoos: 0 - allHouseContro: {fileID: 0} - SelfTextTrans: {fileID: 0} - SelfImage: {fileID: 0} - IsOtherWoniu: 1 --- !u!95 &4217838679404656793 Animator: serializedVersion: 5 @@ -188,20 +134,29 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0ab200c063ec6704eaa1b8951e7c8ff9, type: 3} m_Name: m_EditorClassIdentifier: - EndPosList: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - WaitingArea: {fileID: 0} - bossContros: - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} OrPosTrams: {fileID: 0} Panrent: {fileID: 0} allHouseContros: {fileID: 0} +--- !u!114 &-9060203016143469754 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4217838679404656796} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a0e93af545a029e44bc39dff4b909107, type: 3} + m_Name: + m_EditorClassIdentifier: + objectToMove: {fileID: 0} + pathPoints: [] + duration: 5 + isLooping: 0 + room_id: + Speed: 0 + EndPos: {fileID: 0} + posGroup: {fileID: 0} + OutParent: {fileID: 0} + ReturnPos: {fileID: 0} + allHouseContro: {fileID: 0} diff --git a/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity b/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity index 77d0040..9e16243 100644 --- a/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity +++ b/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity @@ -569,8 +569,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 21 + m_Father: {fileID: 728793965} + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -605,8 +605,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 18 + m_Father: {fileID: 728793965} + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1255,8 +1255,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 12 + m_Father: {fileID: 728793965} + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1588,8 +1588,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 14 + m_Father: {fileID: 728793965} + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1920,22 +1920,9 @@ RectTransform: - {fileID: 177818103} - {fileID: 1219510707} - {fileID: 1409653245} - - {fileID: 1300544800} - - {fileID: 1345616811} - - {fileID: 79505380} - - {fileID: 743869541} - - {fileID: 111370691} - - {fileID: 1267988960} - - {fileID: 1269595633} - - {fileID: 1741271745} - - {fileID: 47838340} - - {fileID: 1739383417} - - {fileID: 1952121428} - - {fileID: 44890940} - - {fileID: 1623243285} - - {fileID: 928564782} - {fileID: 1246685950} - {fileID: 716344323} + - {fileID: 728793965} m_Father: {fileID: 1225833476} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -8822,7 +8809,7 @@ RectTransform: - {fileID: 135970890} - {fileID: 74076850} m_Father: {fileID: 142654719} - m_RootOrder: 25 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -8924,6 +8911,56 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 718419355} m_CullTransparentMesh: 1 +--- !u!1 &728793964 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 728793965} + m_Layer: 5 + m_Name: Posgroup + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &728793965 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 728793964} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1300544800} + - {fileID: 1345616811} + - {fileID: 79505380} + - {fileID: 743869541} + - {fileID: 111370691} + - {fileID: 1267988960} + - {fileID: 1269595633} + - {fileID: 1741271745} + - {fileID: 47838340} + - {fileID: 1739383417} + - {fileID: 1952121428} + - {fileID: 44890940} + - {fileID: 1623243285} + - {fileID: 928564782} + m_Father: {fileID: 142654719} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &734040910 GameObject: m_ObjectHideFlags: 0 @@ -9064,8 +9101,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 13 + m_Father: {fileID: 728793965} + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -10874,8 +10911,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 23 + m_Father: {fileID: 728793965} + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -14861,7 +14898,7 @@ RectTransform: - {fileID: 1013127851} - {fileID: 1046374310} m_Father: {fileID: 142654719} - m_RootOrder: 24 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -14934,8 +14971,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 15 + m_Father: {fileID: 728793965} + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -14970,8 +15007,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 16 + m_Father: {fileID: 728793965} + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -15275,8 +15312,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 10 + m_Father: {fileID: 728793965} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -15855,8 +15892,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 11 + m_Father: {fileID: 728793965} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -19041,8 +19078,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 22 + m_Father: {fileID: 728793965} + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -20474,8 +20511,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 19 + m_Father: {fileID: 728793965} + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -20510,8 +20547,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 17 + m_Father: {fileID: 728793965} + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -22718,8 +22755,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 142654719} - m_RootOrder: 20 + m_Father: {fileID: 728793965} + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} diff --git a/TheStrongestSnail/Assets/Scripts/Battle_Royale/AllHouseContro.cs b/TheStrongestSnail/Assets/Scripts/Battle_Royale/AllHouseContro.cs index 4a93948..e0f91a8 100644 --- a/TheStrongestSnail/Assets/Scripts/Battle_Royale/AllHouseContro.cs +++ b/TheStrongestSnail/Assets/Scripts/Battle_Royale/AllHouseContro.cs @@ -169,7 +169,7 @@ public class AllHouseContro : MonoBehaviour Debug.Log("更新房间蜗牛蛋"); if(serverResponse.data.carrySeconds == -1) { - OtherBack(); + //OtherBack(); player.ReturnStartPos(); diff --git a/TheStrongestSnail/Assets/Scripts/Battle_Royale/OtherMove.cs b/TheStrongestSnail/Assets/Scripts/Battle_Royale/OtherMove.cs index 5ddd578..2d20cf0 100644 --- a/TheStrongestSnail/Assets/Scripts/Battle_Royale/OtherMove.cs +++ b/TheStrongestSnail/Assets/Scripts/Battle_Royale/OtherMove.cs @@ -11,36 +11,46 @@ public class OtherMove : MonoBehaviour public bool isLooping = false; // 是否循环路径 int startIndex = 0; int endIndex = 0; - public string room_id; + public float Speed; public Transform EndPos; - + public Transform posGroup; - public Transform Pos1Parent; - public Transform Pos2Parent; - public Transform Pos3Parent; - public Transform Pos4Parent; - public Transform Pos5Parent; - public Transform Pos6Parent; + public Transform OutParent; public Transform ReturnPos;//返回的位置 - public bool IsBoos; + public AllHouseContro allHouseContro; - public Transform SelfTextTrans; - public Transform SelfImage; - public bool IsOtherWoniu; + + + private void Start() { Speed = 2f; + objectToMove = transform; + allHouseContro=GameObject.Find("Canvas/Bg").GetComponent(); + posGroup=GameObject.Find("Canvas/Bg/Posgroup").transform; + if (posGroup != null) + { + // 获取父物体的所有子节点 + pathPoints = posGroup.GetComponentsInChildren(); + // 去掉父物体自身(只要子节点) + pathPoints = System.Array.FindAll(pathPoints, t => t != posGroup); - + Debug.Log("子节点已存入数组"); + } + else + { + Debug.LogError("请分配父物体!"); + } + OutParent= GameObject.Find("Canvas/Bg").transform ; } public void MoveOutParent() { @@ -64,7 +74,13 @@ public class OtherMove : MonoBehaviour public void SetParentToHouse() { - + foreach (HouseBtn house in allHouseContro.HouseBtnList) + { + if (EndPos==house.post.transform) + { + MoveInParent(house.transform); + } + } } @@ -105,14 +121,10 @@ public class OtherMove : MonoBehaviour if (endIndex > startIndex) { - if (IsBoos) - { - duration = 2f; - } - else - { + + duration = (endIndex - startIndex) / Speed; - } + Vector3[] waypoints = new Vector3[endIndex - startIndex + 1]; for (int i = startIndex, j = 0; j < pathPoints.Length && i <= endIndex; i++, j++) @@ -125,14 +137,9 @@ public class OtherMove : MonoBehaviour } else if (endIndex < startIndex) { - if (IsBoos) - { - duration = 3f; - } - else - { + duration = (startIndex - endIndex) / Speed; - } + //duration = (startIndex-endIndex) / Speed; Vector3[] waypoints = new Vector3[startIndex - endIndex + 1]; for (int i = startIndex, j = 0; j < pathPoints.Length && i >= endIndex; i--, j++) @@ -156,7 +163,7 @@ public class OtherMove : MonoBehaviour RectTransform rectTransform = objectToMove.GetComponent(); - + //objectToMove.DOMoveY(objectToMove.position.y + 100, 0.5f).OnComplete(() => { rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y + 80f, 0.5f) .OnComplete(() => { @@ -170,14 +177,10 @@ public class OtherMove : MonoBehaviour objectToMove.GetComponent().PlayAni.SetInteger("State", 0); - if (!IsOtherWoniu) - { - MaskContro.instance.SetMask(false); - } - else - { + + rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + Random.Range(-50, 50), rectTransform.anchoredPosition.y); - } + }); @@ -225,22 +228,7 @@ public class OtherMove : MonoBehaviour { Vector3 currentWaypoint = waypoints[index]; Vector3 nextWaypoint = waypoints[index + 1]; - if (IsBoos) - { - if (nextWaypoint.x < currentWaypoint.x && !GetComponent().IsLeft) - { - GetComponent().IsLeft = true; - // 旋转物体使其面向左侧(绕Y轴旋转180度) - Rotate(); - } - else if (nextWaypoint.x > currentWaypoint.x && GetComponent().IsLeft) - { - GetComponent().IsLeft = false; - Rotate(); - } - } - else - { + // 判断物体是否需要旋转 if (nextWaypoint.x < currentWaypoint.x && !objectToMove.GetComponent().IsLeft) { @@ -255,7 +243,7 @@ public class OtherMove : MonoBehaviour } } - } + }) .OnComplete(AfterMove); } diff --git a/TheStrongestSnail/Assets/Scripts/otherWoniu.cs b/TheStrongestSnail/Assets/Scripts/otherWoniu.cs index e8d52dc..ea9365f 100644 --- a/TheStrongestSnail/Assets/Scripts/otherWoniu.cs +++ b/TheStrongestSnail/Assets/Scripts/otherWoniu.cs @@ -4,9 +4,9 @@ using UnityEngine; public class otherWoniu : MonoBehaviour { - public List EndPosList; - public Transform WaitingArea;//等待区域 - public List bossContros; + + + public Transform OrPosTrams;//出发点 public Transform Panrent;//父亲节点 public AllHouseContro allHouseContros; @@ -14,6 +14,7 @@ public class otherWoniu : MonoBehaviour void Start() { //OtherWoniuMove(); + allHouseContros=GameObject.Find("Canvas/Bg").GetComponent(); } public void OtherWoniuMove(int roomNo) @@ -22,8 +23,8 @@ public class otherWoniu : MonoBehaviour { if (house.roomNo==roomNo) { - transform.GetComponent().EndPos=house.post.transform; - transform.GetComponent().StartMove(); + transform.GetComponent().EndPos=house.post.transform; + transform.GetComponent().StartMove(); } }