/// <summary> /// The velocity of the platform we're on (or zero) /// </summary> /// <returns>The velocity.</returns> Vector2 PlatformVelocity() { if (movingPlatform == null) { return(Vector2.zero); } return(movingPlatform.GetComponent <Rigidbody2D>().velocity); }
public override void UpdateAbility(GameObject player) { base.UpdateAbility(player); if (!abilityInput.IsPressed && abilityActivated) { abilityActivated = false; if (dir.Equals(Vector2.zero)) { return; } Shoot(projectile, projectileSpeed, player); } //UPdate for moving platform if (collidedPlatform != null) { collidedPlatform.GetComponent <MovingPlatform>().Charging = true; } }
static void DrawMovingPlatformGizmo(MovingPlatform movingPlatform, GizmoType gizmoType) { if (movingPlatform.Waypoints == null) { return; } Mesh mesh = null; var meshFilter = movingPlatform.GetComponent <MeshFilter>(); if (meshFilter != null) { mesh = meshFilter.sharedMesh; } for (int i = 0; i < movingPlatform.Waypoints.Length; ++i) { if (movingPlatform.Waypoints[i].Transform == null) { continue; } Gizmos.color = movingPlatform.GizmoColor; // Draw the mesh if it exists. if (mesh != null) { Gizmos.DrawMesh(mesh, movingPlatform.Waypoints[i].Transform.position, movingPlatform.Waypoints[i].Transform.rotation, movingPlatform.transform.localScale); } Gizmos.DrawWireSphere(movingPlatform.Waypoints[i].Transform.position, 0.5f); if (movingPlatform.DrawDebugLabels) { if (s_DebugLabelStyle == null) { s_DebugLabelStyle = new GUIStyle(EditorStyles.label); s_DebugLabelStyle.fontSize = 16; s_DebugLabelStyle.normal.textColor = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor); } // Draw the delay in the center of the platform. Handles.Label(movingPlatform.Waypoints[i].Transform.position, movingPlatform.Waypoints[i].Delay.ToString(), s_DebugLabelStyle); } // Draw a line connecting the platforms. if (i > 0 && movingPlatform.Waypoints[i - 1].Transform != null && movingPlatform.MovementType != MovingPlatform.PathMovementType.Target) { Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor); Gizmos.DrawLine(movingPlatform.Waypoints[i - 1].Transform.position, movingPlatform.Waypoints[i].Transform.position); if (movingPlatform.DrawDebugLabels) { // Draw a distance in the center of the line. var distance = decimal.Round((decimal)Vector3.Distance(movingPlatform.Waypoints[i - 1].Transform.position, movingPlatform.Waypoints[i].Transform.position), 3); Handles.Label((movingPlatform.Waypoints[i - 1].Transform.position + movingPlatform.Waypoints[i].Transform.position) / 2, distance.ToString(), s_DebugLabelStyle); } } } // Complete the path drawing. if (movingPlatform.MovementType == MovingPlatform.PathMovementType.Loop && movingPlatform.Waypoints.Length > 0 && movingPlatform.Waypoints[0].Transform != null && movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform != null) { Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor); Gizmos.DrawLine(movingPlatform.Waypoints[0].Transform.position, movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position); if (movingPlatform.DrawDebugLabels) { // Draw a distance in the center of the line. var distance = decimal.Round((decimal)Vector3.Distance(movingPlatform.Waypoints[0].Transform.position, movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position), 3); Handles.Label((movingPlatform.Waypoints[0].Transform.position + movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position) / 2, distance.ToString(), s_DebugLabelStyle); } } else if (movingPlatform.MovementType == MovingPlatform.PathMovementType.Target && movingPlatform.TargetWaypoint < movingPlatform.Waypoints.Length && movingPlatform.Waypoints[movingPlatform.TargetWaypoint].Transform != null) { Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor); Gizmos.DrawLine(movingPlatform.transform.position, movingPlatform.Waypoints[movingPlatform.TargetWaypoint].Transform.position); } // Draw the current waypoint the platform is moving towards. if (Application.isPlaying && movingPlatform.enabled && movingPlatform.Waypoints.Length > 0) { Gizmos.color = Color.green; Gizmos.DrawLine(movingPlatform.transform.position, movingPlatform.Waypoints[movingPlatform.NextWaypoint].Transform.position); } }