Esempio n. 1
0
    private void SetStartingPosition(GameObject platform)
    {
        PlatformMotion motion = platform.GetComponent <PlatformMotion>();

        if (motion != null)
        {
            motion.StartingPosition = platform.transform.position;
        }
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    //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;
        }
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
 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;
         }
     }
 }
Esempio n. 6
0
    private PlatformMotion _parent; //polymorphism

    void Start()
    {
        _parent = GetComponentInParent <PlatformMotion>();
    }