private void SetStartingPosition(GameObject platform) { PlatformMotion motion = platform.GetComponent <PlatformMotion>(); if (motion != null) { motion.StartingPosition = platform.transform.position; } }
private Vector3 GetPlatformExtents(GameObject platform) { Vector3 extents; PlatformMotion motion = platform.GetComponent <PlatformMotion>(); if (motion != null) { extents = motion.GetMotionExtents(); } else { extents = platform.transform.lossyScale; } return(extents); }
//setting inner placeholder private void SetPlaceholderTransform(GameObject platform, GameObject placeholder) { Transform placeholderTransform = placeholder.transform; PlatformMotion motion = platform.GetComponent <PlatformMotion>(); if (motion != null) { placeholderTransform.position = motion.GetMotionCenter(); placeholderTransform.localScale = motion.GetMotionExtents(); } else { placeholderTransform.position = platform.transform.position; placeholderTransform.localScale = platform.transform.localScale; } }
private Vector3 CreateNewPosition(GameObject previousPlatform, Transform currentPlatform) { Transform previousPlatformTransform = previousPlatform.transform; Vector3 newPositionOffset = CreateNewPositionOffset(previousPlatformTransform, currentPlatform); Vector3 previousDestinationPosition; PlatformMotion motion = previousPlatform.GetComponent <PlatformMotion>(); if (motion != null) { previousDestinationPosition = motion.GetDestinationPosition(); } else { previousDestinationPosition = previousPlatformTransform.position; } Vector3 currentPosition = previousDestinationPosition + newPositionOffset; return(currentPosition); }
private IEnumerator ActivatePlatforms(List <GameObject> platforms) { for (int i = 1; i < platforms.Count; i++) { PlatformMotion platformMotion = platforms[i].GetComponent <PlatformMotion>(); if (platformMotion != null) { PlatformMotion previousPlatformMotion = platforms[i - 1].GetComponent <PlatformMotion>(); if (previousPlatformMotion != null) { //wait until previous platform reaches its destination while (true) { if (previousPlatformMotion.DestinationReached) { break; } yield return(null); } } platformMotion.enabled = true; } } }
private PlatformMotion _parent; //polymorphism void Start() { _parent = GetComponentInParent <PlatformMotion>(); }