private void Awake() { if (platformRigidbody == null) { platformRigidbody = GetComponent <Rigidbody2D>(); } if (collider == null) { collider = GetComponent <Collider2D>(); } parentCatcher = null; Transform currentParent = transform.parent; while (currentParent != null) { PlatformCatcher catcher = currentParent.GetComponent <PlatformCatcher>(); if (catcher != null) { parentCatcher = catcher; } currentParent = currentParent.parent; } if (parentCatcher != null) { parentCatcher.moveDelegate += MoveCaughtObjects; } }
void Awake() { if (platformRigidbody == null) { platformRigidbody = GetComponent <Rigidbody2D>(); } if (m_Collider == null) { m_Collider = GetComponent <Collider2D>(); } m_ParentCatcher = null; Transform currentParent = transform.parent; while (currentParent != null) { PlatformCatcher catcher = currentParent.GetComponent <PlatformCatcher>(); if (catcher != null) { m_ParentCatcher = catcher; } currentParent = currentParent.parent; } //if we have a parent platform catcher, we make it's move "bubble down" to that catcher, so any object caught by that platform catacher will also //be moved by the aprent catacher (e.g. a platform catacher on a pressure plate on top of a moving platform) if (m_ParentCatcher != null) { m_ParentCatcher.m_MoveDelegate += MoveCaughtObjects; } }
private void Start() { rigidbody = GetComponent <Rigidbody2D>(); rigidbody.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } Renderer[] renderers = GetComponentsInChildren <Renderer>(); for (int i = 0; i < renderers.Length; ++i) { var b = renderers[i].gameObject.AddComponent <VisibleBubbleUp>(); b.objectBecameVisible = BecameVisible; } worldNode = new Vector3[localNodes.Length]; for (int i = 0; i < worldNode.Length; ++i) { worldNode[i] = transform.TransformPoint(localNodes[i]); } Init(); }
protected override void Initialise() { container = GetComponentInParent <MovingContainer>(); composite = GetComponent <CompositeCollider2D>(); catcher = GetComponent <PlatformCatcher>(); m_Rigidbody2D = GetComponent <Rigidbody2D>(); }
private void Awake() { if (!_platform) { _platform = GetComponentInChildren <PlatformCatcher>(); } }
protected override void Initialise() { m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } m_WorldNodeDirection = transform.TransformPoint(localNode) - transform.position; m_OriginallyWorldNodeDirection = m_WorldNodeDirection; m_OriginNode = transform.position; if (isMovingAtStart) { m_Started = true; } else { m_Started = false; } m_Returnable = false; }
protected override void Initialise() { m_Box = GetComponent <BoxCollider2D>(); m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.bodyType = RigidbodyType2D.Static; m_GroundRaycastDistance = 0.00001f; m_RaycastDistance = m_Box.size.y * 0.5f + m_GroundRaycastDistance * 2f; m_RaycastSize = new Vector2(m_Box.size.x * 0.9f, m_RaycastDistance); if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } m_PlatformType = PlatformType.FALLING; m_StartingPosition = transform.position; var rootObj = gameObject.scene.GetRootGameObjects(); foreach (var go in rootObj) { if (go.name.Equals("CellController")) { confinerBoundsMinY = go.GetComponent <CellController>().CurrentCell.ConfinerBounds.min.y; break; } } if (confinerBoundsMinY == 0) { Debug.LogError("셀 바운즈 설정 에러"); } }
private void Start() { m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } //Allow to make platform only move when they became visible Renderer[] renderers = GetComponentsInChildren <Renderer>(); for (int i = 0; i < renderers.Length; ++i) { var b = renderers[i].gameObject.AddComponent <VisibleBubbleUp>(); b.objectBecameVisible = BecameVisible; } //we make point in the path being defined in local space so game designer can move the platform & path together //but as the platform will move during gameplay, that would also move the node. So we convert the local nodes // (only used at edit time) to world position (only use at runtime) m_WorldNode = new Vector3[localNodes.Length]; for (int i = 0; i < m_WorldNode.Length; ++i) { m_WorldNode[i] = transform.TransformPoint(localNodes[i]); } Init(); }
protected override void Initialise() { m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } m_WorldNode = new Vector3[localNodes.Length]; for (int i = 0; i < m_WorldNode.Length; i++) { m_WorldNode[i] = transform.TransformPoint(localNodes[i]); } m_WorldNode[0] = transform.position; m_Current = 0; m_Dir = 1; m_Next = localNodes.Length > 1 ? 1 : 0; m_WaitTime = waitTimes[0]; if (isMovingAtStart) { m_Started = true; } else { m_Started = false; } }
public override void OnInspectorGUI() { MovingPlatform _script = (MovingPlatform)target; PlatformCatcher _platform = _script._platform; serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("_platform")); EditorPlatformList.Show(serializedObject.FindProperty("_wayPointList"), EditorListOption.All); EditorGUILayout.PropertyField(serializedObject.FindProperty("_moveMode")); EditorGUILayout.PropertyField(serializedObject.FindProperty("_velocity")); EditorGUILayout.PropertyField(serializedObject.FindProperty("_waitTime")); EditorGUILayout.PropertyField(serializedObject.FindProperty("_timeForStop")); serializedObject.ApplyModifiedProperties(); // MovingPlatform의 _platform이 비어있을 경우 경고문을 띄운다. if (_platform == null) { EditorGUILayout.HelpBox("해당 오브젝트의 자식으로 Platform 오브젝트가 존재하지 않거나, " + "Platform 오브젝트에서 PlatformCatcher 스크립트를 찾을 수 없습니다.", MessageType.Error); } // MovingPlatform의 Layer가 Ground가 권고문을 띄운다. if (_script.gameObject.layer != LayerMask.NameToLayer("Ground")) { EditorGUILayout.HelpBox("Moving Platform의 LayerMask가 Ground가 아닙니다.", MessageType.Warning); } // MovingPlatform의 _wayPoint가 비어있을 경우 권고문을 띄운다. if (_script._wayPointList.Count == 0) { EditorGUILayout.HelpBox("MovingPlatform의 Way Point가 설정되지 않았습니다.\n" + "Way Point List에 새 Way Point를 생성하고 설정해주세요.", MessageType.Warning); } }
protected override void Initialise() { m_Tilemap = GetComponent <Tilemap>(); if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } }
private void Reset() { localNodes[0] = Vector3.zero; waitTimes[0] = 0; rigidbody = GetComponent <Rigidbody2D>(); rigidbody.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } }
private void Reset() { //we always have at least a node which is the local position localNodes[0] = Vector3.zero; waitTimes[0] = 0; m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } }
protected override void Initialise() { if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } if (isMovingAtStart) { m_Started = true; } else { m_Started = false; } }
void Awake() { if (platformRigidbody == null) { platformRigidbody = GetComponent <Rigidbody2D>(); } if (m_Collider == null) { m_Collider = GetComponent <Collider2D>(); if (m_Collider == null) { m_Collider = GetComponentInChildren <Collider2D>(); } } for (int i = 0; i < normalDirection.Length; i++) { normalDirection[i].Normalize(); } m_ParentCatcher = null; Transform currentParent = transform.parent; while (currentParent != null) { PlatformCatcher catcher = currentParent.GetComponent <PlatformCatcher>(); if (catcher != null) { m_ParentCatcher = catcher; } currentParent = currentParent.parent; } //자신과 부모에게 platformCatcher가 있을 때(ex 무빙플랫폼위의 스위치) //MoveCaughtObjects 함수로 찾은 오브젝트를 움직일때 실제 움직이는건 부모에서 합니다 //때문에 만약 자신보다 상위객체의 캐처가 있다면 그 부모객체의 대리자에 자식의 값을 설정합니다 //그렇게 되면 부모의 대리자-> 자식의 함수 호출 if (m_ParentCatcher != null) { m_ParentCatcher.m_MoveDelegate += MoveCaughtObjects; } }
private void Awake() { m_Animator = GetComponentInChildren <Animator>(); m_SpriteRenderer = GetComponentInChildren <SpriteRenderer>(); m_PlatformCatcher = GetComponent <PlatformCatcher>(); }